[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_content/models/ -> featured.php (source)

   1  <?php
   2  /**
   3   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   4   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   5   */
   6  
   7  // no direct access
   8  defined('_JEXEC') or die;
   9  
  10  require_once dirname(__FILE__) . '/articles.php';
  11  
  12  /**
  13   * About Page Model
  14   *
  15   * @package        Joomla.Administrator
  16   * @subpackage    com_content
  17   */
  18  class ContentModelFeatured extends ContentModelArticles
  19  {
  20      /**
  21       * Constructor.
  22       *
  23       * @param    array    An optional associative array of configuration settings.
  24       * @see        JController
  25       * @since    1.6
  26       */
  27  	public function __construct($config = array())
  28      {
  29          if (empty($config['filter_fields'])) {
  30              $config['filter_fields'] = array(
  31                  'id', 'a.id',
  32                  'title', 'a.title',
  33                  'alias', 'a.alias',
  34                  'checked_out', 'a.checked_out',
  35                  'checked_out_time', 'a.checked_out_time',
  36                  'catid', 'a.catid', 'category_title',
  37                  'state', 'a.state',
  38                  'access', 'a.access', 'access_level',
  39                  'created', 'a.created',
  40                  'created_by', 'a.created_by',
  41                  'ordering', 'a.ordering',
  42                  'featured', 'a.featured',
  43                  'language', 'a.language',
  44                  'hits', 'a.hits',
  45                  'publish_up', 'a.publish_up',
  46                  'publish_down', 'a.publish_down',
  47                  'fp.ordering',
  48              );
  49          }
  50  
  51          parent::__construct($config);
  52      }
  53  
  54      /**
  55       * @param    boolean    True to join selected foreign information
  56       *
  57       * @return    string
  58       */
  59  	function getListQuery($resolveFKs = true)
  60      {
  61          // Create a new query object.
  62          $db = $this->getDbo();
  63          $query = $db->getQuery(true);
  64  
  65          // Select the required fields from the table.
  66          $query->select(
  67              $this->getState(
  68                  'list.select',
  69                  'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits,' .
  70                  'a.language, a.publish_up, a.publish_down'
  71              )
  72          );
  73          $query->from('#__content AS a');
  74  
  75          // Join over the language
  76          $query->select('l.title AS language_title');
  77          $query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language');
  78  
  79          // Join over the content table.
  80          $query->select('fp.ordering');
  81          $query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id');
  82  
  83          // Join over the users for the checked out user.
  84          $query->select('uc.name AS editor');
  85          $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
  86  
  87          // Join over the asset groups.
  88          $query->select('ag.title AS access_level');
  89          $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
  90  
  91          // Join over the categories.
  92          $query->select('c.title AS category_title');
  93          $query->join('LEFT', '#__categories AS c ON c.id = a.catid');
  94  
  95          // Join over the users for the author.
  96          $query->select('ua.name AS author_name');
  97          $query->join('LEFT', '#__users AS ua ON ua.id = a.created_by');
  98  
  99          // Filter by access level.
 100          if ($access = $this->getState('filter.access')) {
 101              $query->where('a.access = ' . (int) $access);
 102          }
 103  
 104          // Filter by published state
 105          $published = $this->getState('filter.published');
 106          if (is_numeric($published)) {
 107              $query->where('a.state = ' . (int) $published);
 108          } elseif ($published === '') {
 109              $query->where('(a.state = 0 OR a.state = 1)');
 110          }
 111  
 112          // Filter by search in title
 113          $search = $this->getState('filter.search');
 114          if (!empty($search)) {
 115              if (stripos($search, 'id:') === 0) {
 116                  $query->where('a.id = '.(int) substr($search, 3));
 117              } else {
 118                  $search = $db->Quote('%'.$db->escape($search, true).'%');
 119                  $query->where('a.title LIKE '.$search.' OR a.alias LIKE '.$search);
 120              }
 121          }
 122  
 123          // Filter on the language.
 124          if ($language = $this->getState('filter.language')) {
 125              $query->where('a.language = '.$db->quote($language));
 126          }
 127  
 128          // Add the list ordering clause.
 129          $query->order($db->escape($this->getState('list.ordering', 'a.title')).' '.$db->escape($this->getState('list.direction', 'ASC')));
 130  
 131          //echo nl2br(str_replace('#__','jos_',(string)$query));
 132          return $query;
 133      }
 134  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1