| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: view.html.php 19343 2010-11-03 18:12:02Z ian $ 4 * @package Joomla 5 * @subpackage Config 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // no direct access 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 jimport( 'joomla.application.component.view'); 19 20 /** 21 * HTML View class for the Poll component 22 * 23 * @static 24 * @package Joomla 25 * @subpackage Poll 26 * @since 1.0 27 */ 28 class PollViewPolls extends JView 29 { 30 function display( $tpl = null ) 31 { 32 global $mainframe, $option; 33 34 $db =& JFactory::getDBO(); 35 $filter_order = $mainframe->getUserStateFromRequest( "$option.filter_order", 'filter_order', 'm.id', 'cmd' ); 36 $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); 37 $filter_state = $mainframe->getUserStateFromRequest( "$option.filter_state", 'filter_state', '', 'word' ); 38 $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); 39 if (strpos($search, '"') !== false) { 40 $search = str_replace(array('=', '<'), '', $search); 41 } 42 $search = JString::strtolower($search); 43 44 $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); 45 $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); 46 47 $where = array(); 48 49 if ( $filter_state ) 50 { 51 if ( $filter_state == 'P' ) 52 { 53 $where[] = 'm.published = 1'; 54 } 55 else if ($filter_state == 'U' ) 56 { 57 $where[] = 'm.published = 0'; 58 } 59 } 60 if ($search) 61 { 62 $where[] = 'LOWER(m.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); 63 } 64 65 $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); 66 67 // sanitize $filter_order 68 if (!in_array($filter_order, array('m.title', 'm.published', 'a.ordering', 'catname', 'm.voters', 'numoptions', 'm.lag', 'm.id'))) { 69 $filter_order = 'm.id'; 70 } 71 72 if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) { 73 $filter_order_Dir = ''; 74 } 75 76 $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir; 77 78 $query = 'SELECT COUNT(m.id)' 79 . ' FROM #__polls AS m' 80 . $where 81 ; 82 $db->setQuery( $query ); 83 $total = $db->loadResult(); 84 85 jimport('joomla.html.pagination'); 86 $pagination = new JPagination( $total, $limitstart, $limit ); 87 88 $query = 'SELECT m.*, u.name AS editor, COUNT(d.id) AS numoptions' 89 . ' FROM #__polls AS m' 90 . ' LEFT JOIN #__users AS u ON u.id = m.checked_out' 91 . ' LEFT JOIN #__poll_data AS d ON d.pollid = m.id AND d.text <> ""' 92 . $where 93 . ' GROUP BY m.id' 94 . $orderby 95 ; 96 $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); 97 $rows = $db->loadObjectList(); 98 99 if ($db->getErrorNum()) 100 { 101 echo $db->stderr(); 102 return false; 103 } 104 105 // state filter 106 $lists['state'] = JHTML::_('grid.state', $filter_state ); 107 108 // table ordering 109 $lists['order_Dir'] = $filter_order_Dir; 110 $lists['order'] = $filter_order; 111 112 // search filter 113 $lists['search']= $search; 114 115 $this->assignRef('user', JFactory::getUser()); 116 $this->assignRef('lists', $lists); 117 $this->assignRef('items', $rows); 118 $this->assignRef('pagination', $pagination); 119 120 parent::display($tpl); 121 } 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |