[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/modules/mod_mostread/ -> helper.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: helper.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   6  * @license        GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // no direct access
  15  defined('_JEXEC') or die('Restricted access');
  16  
  17  require_once  (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
  18  
  19  class modMostReadHelper
  20  {
  21  	function getList(&$params)
  22      {
  23          global $mainframe;
  24  
  25          $db            =& JFactory::getDBO();
  26          $user        =& JFactory::getUser();
  27  
  28          $count        = intval($params->get('count', 5));
  29          $catid        = trim($params->get('catid'));
  30          $secid        = trim($params->get('secid'));
  31          $show_front    = $params->get('show_front', 1);
  32          $aid        = $user->get('aid', 0);
  33  
  34          $contentConfig = &JComponentHelper::getParams( 'com_content' );
  35          $access        = !$contentConfig->get('show_noauth');
  36  
  37          $nullDate    = $db->getNullDate();
  38          $date =& JFactory::getDate();
  39          $now  = $date->toMySQL();
  40  
  41          if ($catid) {
  42              $ids = explode( ',', $catid );
  43              JArrayHelper::toInteger( $ids );
  44              $catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
  45          }
  46          if ($secid) {
  47              $ids = explode( ',', $secid );
  48              JArrayHelper::toInteger( $ids );
  49              $secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
  50          }
  51  
  52          //Content Items only
  53          $query = 'SELECT a.*,' .
  54              ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
  55              ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
  56              ' FROM #__content AS a' .
  57              ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' .
  58              ' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
  59              ' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
  60              ' WHERE ( a.state = 1 AND s.id > 0 )' .
  61              ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )' .
  62              ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'.
  63              ($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
  64              ($catid ? $catCondition : '').
  65              ($secid ? $secCondition : '').
  66              ($show_front == '0' ? ' AND f.content_id IS NULL' : '').
  67              ' AND s.published = 1' .
  68              ' AND cc.published = 1' .
  69              ' ORDER BY a.hits DESC';
  70          $db->setQuery($query, 0, $count);
  71          $rows = $db->loadObjectList();
  72  
  73          $i        = 0;
  74          $lists    = array();
  75          foreach ( $rows as $row )
  76          {
  77              if($row->access <= $aid)
  78              {
  79                  $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
  80              } else {
  81                  $lists[$i]->link = JRoute::_('index.php?option=com_user&view=login');
  82              }
  83              $lists[$i]->text = htmlspecialchars( $row->title );
  84              $i++;
  85          }
  86  
  87          return $lists;
  88      }
  89  }


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