[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/modules/mod_newsflash/ -> 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 modNewsFlashHelper
  20  {
  21  	function renderItem(&$item, &$params, &$access)
  22      {
  23          global $mainframe;
  24  
  25          $user     =& JFactory::getUser();
  26  
  27          $item->text     = $item->introtext;
  28          $item->groups     = '';
  29          $item->readmore = (trim($item->fulltext) != '');
  30          $item->metadesc = '';
  31          $item->metakey     = '';
  32          $item->created     = '';
  33          $item->modified = '';
  34  
  35          if ($params->get('readmore') || $params->get('link_titles'))
  36          {
  37              if ($params->get('intro_only'))
  38              {
  39                  // Check to see if the user has access to view the full article
  40                  if ($item->access <= $user->get('aid', 0)) {
  41                      $itemparams=new JParameter($item->attribs);
  42                      $readmoretxt=$itemparams->get('readmore',JText::_('Read more text'));
  43  
  44                      $item->linkOn = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
  45                      $item->linkText = $readmoretxt;
  46                  } else {
  47                      $item->linkOn = JRoute::_('index.php?option=com_user&view=login');
  48                      $item->linkText = JText::_('Login To Read More');
  49                  }
  50              }
  51          }
  52  
  53          if (!$params->get('image')) {
  54              $item->text = preg_replace( '/<img[^>]*>/', '', $item->text );
  55          }
  56  
  57          $results = $mainframe->triggerEvent('onAfterDisplayTitle', array (&$item, &$params, 1));
  58          $item->afterDisplayTitle = trim(implode("\n", $results));
  59  
  60          $results = $mainframe->triggerEvent('onBeforeDisplayContent', array (&$item, &$params, 1));
  61          $item->beforeDisplayContent = trim(implode("\n", $results));
  62  
  63          require(JModuleHelper::getLayoutPath('mod_newsflash', '_item'));
  64      }
  65  
  66  	function getList(&$params, &$access)
  67      {
  68          global $mainframe;
  69  
  70          $db     =& JFactory::getDBO();
  71          $user     =& JFactory::getUser();
  72          $aid    = $user->get('aid', 0);
  73  
  74          $catid     = (int) $params->get('catid', 0);
  75          $items     = (int) $params->get('items', 0);
  76  
  77          $contentConfig    = &JComponentHelper::getParams( 'com_content' );
  78          $noauth            = !$contentConfig->get('show_noauth');
  79          $date =& JFactory::getDate();
  80          $now = $date->toMySQL();
  81  
  82          $nullDate = $db->getNullDate();
  83  
  84          // query to determine article count
  85          $query = 'SELECT a.*,' .
  86              ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
  87              ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
  88              ' FROM #__content AS a' .
  89              ' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
  90              ' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
  91              ' WHERE a.state = 1 ' .
  92              ($noauth ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
  93              ' AND (a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' ) ' .
  94              ' AND (a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )' .
  95              ' AND cc.id = '. (int) $catid .
  96              ' AND cc.section = s.id' .
  97              ' AND cc.published = 1' .
  98              ' AND s.published = 1' .
  99              ' ORDER BY a.ordering';
 100          $db->setQuery($query, 0, $items);
 101          $rows = $db->loadObjectList();
 102  
 103          return $rows;
 104      }
 105  }


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