| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: element.php 17299 2010-05-27 16:06:54Z ian $ 4 * @package Joomla 5 * @subpackage Content 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 to the 9 * GNU General Public License, and as distributed it includes or is derivative 10 * of works licensed under the GNU General Public License or other free or open 11 * source software licenses. See COPYRIGHT.php for copyright notices and 12 * details. 13 */ 14 15 // no direct access 16 defined('_JEXEC') or die('Restricted access'); 17 18 jimport( 'joomla.application.component.helper'); 19 jimport( 'joomla.application.component.model'); 20 21 /** 22 * Content Component Article Model 23 * 24 * @package Joomla 25 * @subpackage Content 26 * @since 1.5 27 */ 28 class ContentModelElement extends JModel 29 { 30 /** 31 * Content data in category array 32 * 33 * @var array 34 */ 35 var $_list = null; 36 37 var $_page = null; 38 39 /** 40 * Method to get content article data for the frontpage 41 * 42 * @since 1.5 43 */ 44 function getList() 45 { 46 global $mainframe; 47 48 if (!empty($this->_list)) { 49 return $this->_list; 50 } 51 52 // Initialize variables 53 $db =& $this->getDBO(); 54 $filter = null; 55 56 // Get some variables from the request 57 $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); 58 $redirect = $sectionid; 59 $option = JRequest::getCmd( 'option' ); 60 $filter_order = $mainframe->getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd'); 61 $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); 62 $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int'); 63 $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int'); 64 $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int'); 65 $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); 66 $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int'); 67 $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string'); 68 if (strpos($search, '"') !== false) { 69 $search = str_replace(array('=', '<'), '', $search); 70 } 71 $search = JString::strtolower($search); 72 73 //$where[] = "c.state >= 0"; 74 $where[] = "c.state != -2"; 75 76 if (!$filter_order) { 77 $filter_order = 'section_name'; 78 } 79 $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', section_name, cc.name, c.ordering'; 80 $all = 1; 81 82 if ($filter_sectionid >= 0) { 83 $filter = ' WHERE cc.section = '.$db->Quote($filter_sectionid); 84 } 85 $section->title = 'All Articles'; 86 $section->id = 0; 87 88 /* 89 * Add the filter specific information to the where clause 90 */ 91 // Section filter 92 if ($filter_sectionid >= 0) { 93 $where[] = 'c.sectionid = '.(int) $filter_sectionid; 94 } 95 // Category filter 96 if ($catid > 0) { 97 $where[] = 'c.catid = '.(int) $catid; 98 } 99 // Author filter 100 if ($filter_authorid > 0) { 101 $where[] = 'c.created_by = '.(int) $filter_authorid; 102 } 103 104 // Only published articles 105 $where[] = 'c.state = 1'; 106 107 // Keyword filter 108 if ($search) { 109 $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); 110 } 111 112 // Build the where clause of the content record query 113 $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 114 115 // Get the total number of records 116 $query = 'SELECT COUNT(*)' . 117 ' FROM #__content AS c' . 118 ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . 119 ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . 120 $where; 121 $db->setQuery($query); 122 $total = $db->loadResult(); 123 124 // Create the pagination object 125 jimport('joomla.html.pagination'); 126 $this->_page = new JPagination($total, $limitstart, $limit); 127 128 // Get the articles 129 $query = 'SELECT c.*, g.name AS groupname, cc.title as cctitle, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . 130 ' FROM #__content AS c' . 131 ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . 132 ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . 133 ' LEFT JOIN #__groups AS g ON g.id = c.access' . 134 ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . 135 ' LEFT JOIN #__users AS v ON v.id = c.created_by' . 136 ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . 137 $where . 138 $order; 139 $db->setQuery($query, $this->_page->limitstart, $this->_page->limit); 140 $this->_list = $db->loadObjectList(); 141 142 // If there is a db query error, throw a HTTP 500 and exit 143 if ($db->getErrorNum()) { 144 JError::raiseError( 500, $db->stderr() ); 145 return false; 146 } 147 148 return $this->_list; 149 } 150 151 function getPagination() 152 { 153 if (is_null($this->_list) || is_null($this->_page)) { 154 $this->getList(); 155 } 156 return $this->_page; 157 } 158 } 159 ?>
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 |