Source for file featured.php

Documentation is available at featured.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_content
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. require_once __DIR__ . '/articles.php';
  13.  
  14. /**
  15.  * About Page Model
  16.  *
  17.  * @package     Joomla.Administrator
  18.  * @subpackage  com_content
  19.  *
  20.  * @since       1.6
  21.  */
  22. {
  23.     /**
  24.      * Constructor.
  25.      *
  26.      * @param   array  $config  An optional associative array of configuration settings.
  27.      *
  28.      * @see     JController
  29.      * @since   1.6
  30.      */
  31.     public function __construct($config array())
  32.     {
  33.         if (empty($config['filter_fields']))
  34.         {
  35.             $config['filter_fields'array(
  36.                 'id''a.id',
  37.                 'title''a.title',
  38.                 'alias''a.alias',
  39.                 'checked_out''a.checked_out',
  40.                 'checked_out_time''a.checked_out_time',
  41.                 'catid''a.catid''category_title',
  42.                 'state''a.state',
  43.                 'access''a.access''access_level',
  44.                 'created''a.created',
  45.                 'created_by''a.created_by',
  46.                 'created_by_alias''a.created_by_alias',
  47.                 'ordering''a.ordering',
  48.                 'featured''a.featured',
  49.                 'language''a.language',
  50.                 'hits''a.hits',
  51.                 'publish_up''a.publish_up',
  52.                 'publish_down''a.publish_down',
  53.                 'fp.ordering',
  54.                 'published''a.published',
  55.                 'author_id',
  56.                 'category_id',
  57.                 'level',
  58.                 'tag'
  59.             );
  60.         }
  61.  
  62.         parent::__construct($config);
  63.     }
  64.  
  65.     /**
  66.      * Build an SQL query to load the list data.
  67.      *
  68.      * @param   boolean  $resolveFKs  True to join selected foreign information
  69.      *
  70.      * @return  string 
  71.      *
  72.      * @since   1.6
  73.      */
  74.     protected function getListQuery($resolveFKs true)
  75.     {
  76.         // Create a new query object.
  77.         $db $this->getDbo();
  78.         $query $db->getQuery(true);
  79.  
  80.         // Select the required fields from the table.
  81.         $query->select(
  82.             $this->getState(
  83.                 'list.select',
  84.                 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits,' .
  85.                     'a.featured, a.language, a.created_by_alias, a.publish_up, a.publish_down'
  86.             )
  87.         );
  88.         $query->from('#__content AS a');
  89.  
  90.         // Join over the language
  91.         $query->select('l.title AS language_title')
  92.             ->join('LEFT'$db->quoteName('#__languages'' AS l ON l.lang_code = a.language');
  93.  
  94.         // Join over the content table.
  95.         $query->select('fp.ordering')
  96.             ->join('INNER''#__content_frontpage AS fp ON fp.content_id = a.id');
  97.  
  98.         // Join over the users for the checked out user.
  99.         $query->select('uc.name AS editor')
  100.             ->join('LEFT''#__users AS uc ON uc.id=a.checked_out');
  101.  
  102.         // Join over the asset groups.
  103.         $query->select('ag.title AS access_level')
  104.             ->join('LEFT''#__viewlevels AS ag ON ag.id = a.access');
  105.  
  106.         // Join over the categories.
  107.         $query->select('c.title AS category_title')
  108.             ->join('LEFT''#__categories AS c ON c.id = a.catid');
  109.  
  110.         // Join over the users for the author.
  111.         $query->select('ua.name AS author_name')
  112.             ->join('LEFT''#__users AS ua ON ua.id = a.created_by');
  113.  
  114.         // Filter by access level.
  115.         if ($access $this->getState('filter.access'))
  116.         {
  117.             $query->where('a.access = ' . (int) $access);
  118.         }
  119.  
  120.         // Filter by published state
  121.         $published $this->getState('filter.published');
  122.  
  123.         if (is_numeric($published))
  124.         {
  125.             $query->where('a.state = ' . (int) $published);
  126.         }
  127.         elseif ($published === '')
  128.         {
  129.             $query->where('(a.state = 0 OR a.state = 1)');
  130.         }
  131.  
  132.         // Filter by a single or group of categories.
  133.         $baselevel 1;
  134.         $categoryId $this->getState('filter.category_id');
  135.  
  136.         if (is_numeric($categoryId))
  137.         {
  138.             $cat_tbl JTable::getInstance('Category''JTable');
  139.             $cat_tbl->load($categoryId);
  140.             $rgt $cat_tbl->rgt;
  141.             $lft $cat_tbl->lft;
  142.             $baselevel = (int) $cat_tbl->level;
  143.             $query->where('c.lft >= ' . (int) $lft)
  144.                 ->where('c.rgt <= ' . (int) $rgt);
  145.         }
  146.         elseif (is_array($categoryId))
  147.         {
  148.             JArrayHelper::toInteger($categoryId);
  149.             $categoryId implode(','$categoryId);
  150.             $query->where('a.catid IN (' $categoryId ')');
  151.         }
  152.  
  153.         // Filter on the level.
  154.         if ($level $this->getState('filter.level'))
  155.         {
  156.             $query->where('c.level <= ' ((int) $level + (int) $baselevel 1));
  157.         }
  158.  
  159.         // Filter by author
  160.         $authorId $this->getState('filter.author_id');
  161.         if (is_numeric($authorId))
  162.         {
  163.             $type $this->getState('filter.author_id.include'true'= ' '<>';
  164.             $query->where('a.created_by ' $type . (int) $authorId);
  165.         }
  166.  
  167.         // Filter by search in title.
  168.         $search $this->getState('filter.search');
  169.  
  170.         if (!empty($search))
  171.         {
  172.             if (stripos($search'id:'=== 0)
  173.             {
  174.                 $query->where('a.id = ' . (int) substr($search3));
  175.             }
  176.             else
  177.             {
  178.                 $search $db->quote('%' $db->escape($searchtrue'%');
  179.                 $query->where('a.title LIKE ' $search ' OR a.alias LIKE ' $search);
  180.             }
  181.         }
  182.  
  183.         // Filter on the language.
  184.         if ($language $this->getState('filter.language'))
  185.         {
  186.             $query->where('a.language = ' $db->quote($language));
  187.         }
  188.  
  189.         // Filter by a single tag.
  190.         $tagId $this->getState('filter.tag');
  191.  
  192.         if (is_numeric($tagId))
  193.         {
  194.             $query->where($db->quoteName('tagmap.tag_id'' = ' . (int) $tagId)
  195.                 ->join(
  196.                     'LEFT'$db->quoteName('#__contentitem_tag_map''tagmap')
  197.                     . ' ON ' $db->quoteName('tagmap.content_item_id'' = ' $db->quoteName('a.id')
  198.                     . ' AND ' $db->quoteName('tagmap.type_alias'' = ' $db->quote('com_content.article')
  199.                 );
  200.         }
  201.  
  202.         // Add the list ordering clause.
  203.         $query->order($db->escape($this->getState('list.ordering''a.title')) ' ' $db->escape($this->getState('list.direction''ASC')));
  204.  
  205.         return $query;
  206.     }
  207. }

Documentation generated on Tue, 19 Nov 2013 15:02:52 +0100 by phpDocumentor 1.4.3