添加到 trunk

+YUCHENG HU+

git-svn-id: https://svn.code.sf.net/p/hawebs/svn@322 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-06-13 23:15:17 +00:00
parent d583ea1eda
commit 2d244a4990
18 changed files with 931 additions and 0 deletions
@@ -0,0 +1,223 @@
<?php
/**
* @version $Id: controller.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Config
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport( 'joomla.application.component.controller' );
/**
* @package Joomla
* @subpackage Config
*/
class PollController extends JController
{
/**
* Custom Constructor
*/
function __construct( $default = array())
{
parent::__construct( $default );
$this->registerTask( 'apply', 'save');
$this->registerTask( 'unpublish', 'publish');
$this->registerTask( 'preview', 'display');
$this->registerTask( 'edit', 'display');
$this->registerTask( 'add' , 'display' );
}
function display( )
{
switch($this->getTask())
{
case 'add' :
{
JRequest::setVar( 'hidemainmenu', 1 );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar( 'view', 'poll' );
JRequest::setVar( 'edit', false );
} break;
case 'edit' :
{
JRequest::setVar( 'hidemainmenu', 1 );
JRequest::setVar( 'layout', 'form' );
JRequest::setVar( 'view', 'poll' );
JRequest::setVar( 'edit', true );
} break;
case 'preview' :
{
JRequest::setVar( 'tmpl', 'component' );
JRequest::setVar( 'view', 'poll' );
} break;
}
//Set the default view, just in case
$view = JRequest::getCmd('view');
if(empty($view)) {
JRequest::setVar('view', 'polls');
};
parent::display();
}
function save()
{
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$db =& JFactory::getDBO();
// save the poll parent information
$row =& JTable::getInstance('poll', 'Table');
$post = JRequest::get( 'post' );
if (!$row->bind( $post ))
{
JError::raiseError(500, $row->getError() );
}
$isNew = ($row->id == 0);
if (!$row->check())
{
JError::raiseError(500, $row->getError() );
}
if (!$row->store())
{
JError::raiseError(500, $row->getError() );
}
$row->checkin();
// save the poll options
$options = JArrayHelper::getValue( $post, 'polloption', array(), 'array' );
foreach ($options as $i=>$text)
{
$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
if ($isNew)
{
$obj = new stdClass();
$obj->pollid = (int)$row->id;
$obj->text = $text;
$db->insertObject('#__poll_data', $obj);
}
else
{
$obj = new stdClass();
$obj->id = (int)$i;
$obj->text = $text;
$db->updateObject('#__poll_data', $obj, 'id');
}
}
switch ($this->_task)
{
case 'apply':
$msg = JText::_( 'Changes to Poll saved' );
$link = 'index.php?option=com_poll&view=poll&task=edit&cid[]='. $row->id .'';
break;
case 'save':
default:
$msg = JText::_( 'Poll saved' );
$link = 'index.php?option=com_poll';
break;
}
$this->setRedirect($link);
}
function remove()
{
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$db =& JFactory::getDBO();
$cid = JRequest::getVar( 'cid', array(), '', 'array' );
JArrayHelper::toInteger($cid);
$msg = '';
for ($i=0, $n=count($cid); $i < $n; $i++)
{
$poll =& JTable::getInstance('poll', 'Table');
if (!$poll->delete( $cid[$i] ))
{
$msg .= $poll->getError();
}
}
$this->setRedirect( 'index.php?option=com_poll', $msg );
}
/**
* Publishes or Unpublishes one or more records
* @param array An array of unique category id numbers
* @param integer 0 if unpublishing, 1 if publishing
* @param string The current url option
*/
function publish()
{
global $mainframe;
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$cid = JRequest::getVar( 'cid', array(), '', 'array' );
$publish = ( $this->getTask() == 'publish' ? 1 : 0 );
JArrayHelper::toInteger($cid);
if (count( $cid ) < 1)
{
$action = $publish ? 'publish' : 'unpublish';
JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) );
}
$cids = implode( ',', $cid );
$query = 'UPDATE #__polls'
. ' SET published = ' . (int) $publish
. ' WHERE id IN ( '. $cids .' )'
. ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )'
;
$db->setQuery( $query );
if (!$db->query())
{
JError::raiseError(500, $db->getErrorMsg() );
}
if (count( $cid ) == 1)
{
$row =& JTable::getInstance('poll', 'Table');
$row->checkin( $cid[0] );
}
$mainframe->redirect( 'index.php?option=com_poll' );
}
function cancel()
{
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$id = JRequest::getVar( 'id', 0, '', 'int' );
$db =& JFactory::getDBO();
$row =& JTable::getInstance('poll', 'Table');
$row->checkin( $id );
$this->setRedirect( 'index.php?option=com_poll' );
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,43 @@
<?php
/**
* @version $Id: poll.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
class JElementPoll extends JElement
{
/**
* Element name
*
* @access protected
* @var string
*/
var $_name = 'Poll';
function fetchElement($name, $value, &$node, $control_name)
{
$db =& JFactory::getDBO();
$query = 'SELECT a.id, a.title'
. ' FROM #__polls AS a'
. ' WHERE a.published = 1'
. ' ORDER BY a.title'
;
$db->setQuery( $query );
$options = $db->loadObjectList();
array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Poll').' -', 'id', 'title'));
return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'title', $value, $control_name.$name );
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,33 @@
<?php
/**
* @version $Id: poll.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Polls
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
// Make sure the user is authorized to view this page
$user = & JFactory::getUser();
if (!$user->authorize( 'com_poll', 'manage' )) {
$mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') );
}
require_once( JPATH_COMPONENT.DS.'controller.php' );
// Set the table directory
JTable::addIncludePath( JPATH_COMPONENT.DS.'tables' );
// Create the controller
$controller = new PollController( );
$controller->execute( JRequest::getCmd( 'task' ) );
$controller->redirect();
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<install type="component" version="1.0.0">
<name>Polls</name>
<author>Joomla! Project</author>
<creationDate>July 2004</creationDate>
<copyright>Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>1.5.0</version>
<description>This component manages polls</description>
</install>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,138 @@
<?php
/**
* @version $Id: poll.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Polls
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
/**
* @package Joomla
* @subpackage Polls
*/
class TablePoll extends JTable
{
/** @var int Primary key */
var $id = 0;
/** @var string */
var $title = '';
/** @var string */
var $alias = '';
/** @var string */
var $checked_out = 0;
/** @var time */
var $checked_out_time = 0;
/** @var boolean */
var $published = 0;
/** @var int */
var $access = 0;
/** @var int */
var $lag = 0;
/**
* @param database A database connector object
*/
function __construct( &$db )
{
parent::__construct( '#__polls', 'id', $db );
}
/**
* Binds an array to the object
* @param array Named array
* @param string Space separated list of fields not to bind
* @return boolean
*/
function bind( $array, $ignore='' )
{
$result = parent::bind( $array );
// cast properties
$this->id = (int) $this->id;
return $result;
}
/**
* Overloaded check function
*
* @access public
* @return boolean
* @see JTable::check
* @since 1.5
*/
function check()
{
// check for valid name
if (trim( $this->title ) == '')
{
$this->setError(JText::_( 'Your Poll must contain a title.' ));
return false;
}
// check for valid lag
$this->lag = intval( $this->lag );
if ($this->lag == 0) {
$this->setError(JText::_( 'Your Poll must have a non-zero lag time.' ));
return false;
}
if(empty($this->alias)) {
$this->alias = $this->title;
}
$this->alias = JFilterOutput::stringURLSafe($this->alias);
if(trim(str_replace('-','',$this->alias)) == '') {
$datenow =& JFactory::getDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
return true;
}
// overloaded delete function
function delete( $oid=null )
{
$k = $this->_tbl_key;
if ( $oid ) {
$this->$k = intval( $oid );
}
if ( parent::delete( $oid ))
{
$query = 'DELETE FROM #__poll_data'
. ' WHERE pollid = '.(int) $this->$k
;
$this->_db->setQuery( $query );
if ( !$this->_db->query() ) {
$this->_error .= $this->_db->getErrorMsg() . "\n";
}
$query = 'DELETE FROM #__poll_date'
. ' WHERE poll_id = '.(int) $this->$k
;
$this->_db->setQuery( $query );
if ( !$this->_db->query() ) {
$this->_error .= $this->_db->getErrorMsg() . "\n";
}
$query = 'DELETE from #__poll_menu'
. ' WHERE pollid = '.(int) $this->$k
;
$this->_db->setQuery( $query );
if ( !$this->_db->query() ) {
$this->_error .= $this->_db->getErrorMsg() . "\n";
}
return true;
}
return false;
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,22 @@
<?php defined('_JEXEC') or die('Restricted access'); ?>
<form>
<table align="center" width="90%" cellspacing="2" cellpadding="2" border="0" >
<tr>
<td class="moduleheading" colspan="2"><?php echo $this->poll->title; ?></td>
</tr>
<?php foreach ($this->options as $option)
{
if ($option->text <> "")
{?>
<tr>
<td valign="top" height="30"><input type="radio" name="poll" value="<?php echo $option->text; ?>"></td>
<td class="poll" width="100%" valign="top"><?php echo $option->text; ?></td>
</tr>
<?php }
} ?>
<tr>
<td valign="middle" height="50" colspan="2" align="center"><input type="button" name="submit" value="<?php echo JText::_( 'Vote' ); ?>">&nbsp;&nbsp;<input type="button" name="result" value="<?php echo JText::_( 'Results' ); ?>"></td>
</tr>
</table>
</form>
@@ -0,0 +1,133 @@
<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php
$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
$edit=JRequest::getVar( 'edit', true );
JArrayHelper::toInteger($cid, array(0));
$text = ( $edit ? JText::_( 'Edit' ) : JText::_( 'New' ) );
JToolBarHelper::title( JText::_( 'Poll' ).': <small><small>[ ' . $text.' ]</small></small>' );
JToolBarHelper::Preview('index.php?option=com_poll&controller=poll&cid[]='.$cid[0]);
JToolBarHelper::save();
JToolBarHelper::apply();
if ($edit) {
// for existing items the button is renamed `close`
JToolBarHelper::cancel( 'cancel', 'Close' );
} else {
JToolBarHelper::cancel();
}
JToolBarHelper::help( 'screen.polls.edit' );
?>
<?php
JFilterOutput::objectHTMLSafe( $this->poll, ENT_QUOTES );
?>
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
var form = document.adminForm;
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}
// do field validation
if (form.title.value == "") {
alert( "<?php echo JText::_( 'Poll must have a title', true ); ?>" );
} else if (isNaN(parseInt( form.lag.value ) ) || parseInt(form.lag.value) < 1) {
alert( "<?php echo JText::_( 'Poll must have a non-zero lag time', true ); ?>" );
//} else if (form.menu.options.value == ""){
// alert( "Poll must have pages." );
//} else if (form.adminForm.textfieldcheck.value == 0){
// alert( "Poll must have options." );
} else {
submitform( pressbutton );
}
}
</script>
<form action="index.php" method="post" name="adminForm">
<div class="col width-45">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>
<table class="admintable">
<tr>
<td width="110" class="key">
<label for="title">
<?php echo JText::_( 'Title' ); ?>:
</label>
</td>
<td>
<input class="inputbox" type="text" name="title" id="title" size="60" value="<?php echo $this->poll->title; ?>" />
</td>
</tr>
<tr>
<td width="110" class="key">
<label for="alias">
<?php echo JText::_( 'Alias' ); ?>:
</label>
</td>
<td>
<input class="inputbox" type="text" name="alias" id="alias" size="60" value="<?php echo $this->poll->alias; ?>" />
</td>
</tr>
<tr>
<td class="key">
<label for="lag">
<?php echo JText::_( 'Lag' ); ?>:
</label>
</td>
<td>
<input class="inputbox" type="text" name="lag" id="lag" size="10" value="<?php echo $this->poll->lag; ?>" />
<?php echo JText::_( '(seconds between votes)' ); ?>
</td>
</tr>
<tr>
<td width="120" class="key">
<?php echo JText::_( 'Published' ); ?>:
</td>
<td>
<?php echo JHTML::_( 'select.booleanlist', 'published', 'class="inputbox"', $this->poll->published ); ?>
</td>
</tr>
</table>
</fieldset>
</div>
<div class="col width-45">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Options' ); ?></legend>
<table class="admintable">
<?php for ($i=0, $n=count( $this->options ); $i < $n; $i++ ) { ?>
<tr>
<td class="key">
<label for="polloption<?php echo $this->options[$i]->id; ?>">
<?php echo JText::_( 'Option' ); ?> <?php echo ($i+1); ?>
</label>
</td>
<td>
<input class="inputbox" type="text" name="polloption[<?php echo $this->options[$i]->id; ?>]" id="polloption<?php echo $this->options[$i]->id; ?>" value="<?php echo $this->options[$i]->text; ?>" size="60" />
</td>
</tr>
<?php } for (; $i < 12; $i++) { ?>
<tr>
<td class="key">
<label for="polloption<?php echo $i + 1; ?>">
<?php echo JText::_( 'Option' ); ?> <?php echo $i + 1; ?>
</label>
</td>
<td>
<input class="inputbox" type="text" name="polloption[]" id="polloption<?php echo $i + 1; ?>" value="" size="60" />
</td>
</tr>
<?php } ?>
</table>
</fieldset>
</div>
<div class="clr"></div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="option" value="com_poll" />
<input type="hidden" name="id" value="<?php echo $this->poll->id; ?>" />
<input type="hidden" name="cid[]" value="<?php echo $this->poll->id; ?>" />
<input type="hidden" name="textfieldcheck" value="<?php echo $n; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,83 @@
<?php
/**
* @version $Id: view.html.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Config
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the Poll component
*
* @static
* @package Joomla
* @subpackage Poll
* @since 1.0
*/
class PollViewPoll extends JView
{
function display($tpl = null)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
$option = JRequest::getCmd( 'option');
$uid = (int) @$cid[0];
$edit=JRequest::getVar( 'edit', true );
$poll =& JTable::getInstance('poll', 'Table');
// load the row from the db table
if($edit)
$poll->load( $uid );
// fail if checked out not by 'me'
if ($poll->isCheckedOut( $user->get('id') )) {
$msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The poll' ), $poll->title );
$this->setRedirect( 'index.php?option='. $option, $msg );
}
if ($poll->id == 0)
{
// defaults
$row->published = 1;
}
$options = array();
if ($edit)
{
$poll->checkout( $user->get('id') );
$query = 'SELECT id, text'
. ' FROM #__poll_data'
. ' WHERE pollid = '.(int) $uid
. ' ORDER BY id'
;
$db->setQuery($query);
$options = $db->loadObjectList();
}
else
{
$poll->lag = 3600*24;
}
$this->assignRef('poll', $poll);
$this->assignRef('options', $options);
parent::display($tpl);
}
}
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,127 @@
<?php defined('_JEXEC') or die('Restricted access'); ?>
<?php JHTML::_('behavior.tooltip'); ?>
<?php
JToolBarHelper::title( JText::_( 'Poll Manager' ) );
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();
JToolBarHelper::help( 'screen.polls' );
?>
<form action="index.php?option=com_poll" method="post" name="adminForm">
<table>
<tr>
<td align="left" width="100%">
<?php echo JText::_( 'Filter' ); ?>:
<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
</td>
<td nowrap="nowrap">
<?php echo $this->lists['state']; ?>
</td>
</tr>
</table>
<div id="tablecell">
<table class="adminlist">
<thead>
<tr>
<th width="5">
<?php echo JText::_( 'NUM' ); ?>
</th>
<th width="20">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
</th>
<th class="title">
<?php echo JHTML::_('grid.sort', 'Poll Title', 'm.title', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="5%" align="center">
<?php echo JHTML::_('grid.sort', 'Published', 'm.published', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="5%" align="center">
<?php echo JHTML::_('grid.sort', 'Votes', 'm.voters', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="5%" align="center">
<?php echo JHTML::_('grid.sort', 'Options', 'numoptions', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="5%" align="center">
<?php echo JHTML::_('grid.sort', 'Lag', 'm.lag', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th width="1%" nowrap="nowrap">
<?php echo JHTML::_('grid.sort', 'ID', 'm.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="9">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$k = 0;
for ($i=0, $n=count( $this->items ); $i < $n; $i++)
{
$row = &$this->items[$i];
$link = JRoute::_( 'index.php?option=com_poll&view=poll&task=edit&cid[]='. $row->id );
$checked = JHTML::_('grid.checkedout', $row, $i );
$published = JHTML::_('grid.published', $row, $i );
?>
<tr class="<?php echo "row$k"; ?>">
<td>
<?php echo $this->pagination->getRowOffset( $i ); ?>
</td>
<td>
<?php echo $checked; ?>
</td>
<td>
<?php if ( JTable::isCheckedOut($this->user->get ('id'), $row->checked_out ) ) {
echo $row->title;
} else {
?>
<span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Poll' );?>::<?php echo $row->title; ?>">
<a href="<?php echo $link ?>">
<?php echo $row->title; ?></a></span>
<?php
}
?>
</td>
<td align="center">
<?php echo $published;?>
</td>
<td align="center">
<?php echo $row->voters; ?>
</td>
<td align="center">
<?php echo $row->numoptions; ?>
</td>
<td align="center">
<?php echo $row->lag; ?>
</td>
<td align="center">
<?php echo $row->id; ?>
</td>
</tr>
<?php
$k = 1 - $k;
}
?>
</tbody>
</table>
</div>
<input type="hidden" name="option" value="com_poll" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,109 @@
<?php
/**
* @version $Id: view.html.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Config
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view');
/**
* HTML View class for the Poll component
*
* @static
* @package Joomla
* @subpackage Poll
* @since 1.0
*/
class PollViewPolls extends JView
{
function display( $tpl = null )
{
global $mainframe, $option;
$db =& JFactory::getDBO();
$filter_order = $mainframe->getUserStateFromRequest( "$option.filter_order", 'filter_order', 'm.id', 'cmd' );
$filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' );
$filter_state = $mainframe->getUserStateFromRequest( "$option.filter_state", 'filter_state', '', 'word' );
$search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' );
$search = JString::strtolower( $search );
$limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
$where = array();
if ( $filter_state )
{
if ( $filter_state == 'P' )
{
$where[] = 'm.published = 1';
}
else if ($filter_state == 'U' )
{
$where[] = 'm.published = 0';
}
}
if ($search)
{
$where[] = 'LOWER(m.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
}
$where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' );
$orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir;
$query = 'SELECT COUNT(m.id)'
. ' FROM #__polls AS m'
. $where
;
$db->setQuery( $query );
$total = $db->loadResult();
jimport('joomla.html.pagination');
$pagination = new JPagination( $total, $limitstart, $limit );
$query = 'SELECT m.*, u.name AS editor, COUNT(d.id) AS numoptions'
. ' FROM #__polls AS m'
. ' LEFT JOIN #__users AS u ON u.id = m.checked_out'
. ' LEFT JOIN #__poll_data AS d ON d.pollid = m.id AND d.text <> ""'
. $where
. ' GROUP BY m.id'
. $orderby
;
$db->setQuery( $query, $pagination->limitstart, $pagination->limit );
$rows = $db->loadObjectList();
if ($db->getErrorNum())
{
echo $db->stderr();
return false;
}
// state filter
$lists['state'] = JHTML::_('grid.state', $filter_state );
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
// search filter
$lists['search']= $search;
$this->assignRef('user', JFactory::getUser());
$this->assignRef('lists', $lists);
$this->assignRef('items', $rows);
$this->assignRef('pagination', $pagination);
parent::display($tpl);
}
}