[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_newsfeeds/models/ -> categories.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: categories.php 14401 2010-01-26 14:10:00Z louis $
   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  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  jimport('joomla.application.component.model');
  19  
  20  /**
  21   * Newsfeeds Component Categories Model
  22   *
  23   * @package        Joomla
  24   * @subpackage    Newsfeeds
  25   * @since 1.5
  26   */
  27  class NewsfeedsModelCategories extends JModel
  28  {
  29      /**
  30       * Frontpage data array
  31       *
  32       * @var array
  33       */
  34      var $_data = null;
  35  
  36      /**
  37       * Frontpage total
  38       *
  39       * @var integer
  40       */
  41      var $_total = null;
  42  
  43  
  44      /**
  45       * Constructor
  46       *
  47       * @since 1.5
  48       */
  49  	function __construct()
  50      {
  51          parent::__construct();
  52  
  53      }
  54  
  55      /**
  56       * Method to get newsfeed item data for the categories
  57       *
  58       * @access public
  59       * @return array
  60       */
  61  	function getData()
  62      {
  63          // Lets load the content if it doesn't already exist
  64          if (empty($this->_data))
  65          {
  66              $query = $this->_buildQuery();
  67              $this->_data = $this->_getList($query);
  68          }
  69  
  70          return $this->_data;
  71      }
  72  
  73      /**
  74       * Method to get the total number of newsfeed items for the categories
  75       *
  76       * @access public
  77       * @return integer
  78       */
  79  	function getTotal()
  80      {
  81          // Lets load the content if it doesn't already exist
  82          if (empty($this->_total))
  83          {
  84              $query = $this->_buildQuery();
  85              $this->_total = $this->_getListCount($query);
  86          }
  87  
  88          return $this->_total;
  89      }
  90  
  91  	function _buildQuery()
  92      {
  93          $user =& JFactory::getUser();
  94          $gid = $user->get('aid', 0);
  95  
  96          /* Query to retrieve all categories that belong under the newsfeeds section and that are published. */
  97          $query = 'SELECT cc.*, a.catid, COUNT(a.id) AS numlinks,'
  98              . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END as slug'
  99              . ' FROM #__categories AS cc'
 100              . ' LEFT JOIN #__newsfeeds AS a ON a.catid = cc.id'
 101              . ' WHERE a.published = 1'
 102              . ' AND cc.section = \'com_newsfeeds\''
 103              . ' AND cc.published = 1'
 104              . ' AND cc.access <= '.(int) $gid
 105              . ' GROUP BY cc.id'
 106              . ' ORDER BY cc.ordering'
 107          ;
 108  
 109          return $query;
 110      }
 111  }
 112  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1