[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

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

   1  <?php
   2  /**
   3   * @package        Joomla.Site
   4   * @subpackage    mod_articles_archive
   5   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   6   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   7   */
   8  
   9  // no direct access
  10  defined('_JEXEC') or die;
  11  
  12  class modArchiveHelper
  13  {
  14  	static function getList(&$params)
  15      {
  16          //get database
  17          $db        = JFactory::getDbo();
  18          $query    = $db->getQuery(true);
  19          $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year');
  20          $query->from('#__content');
  21          $query->where('state = 2 AND checked_out = 0');
  22          $query->group('created_year DESC, created_month DESC');
  23  
  24          // Filter by language
  25          if (JFactory::getApplication()->getLanguageFilter()) {
  26              $query->where('language in ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')');
  27          }
  28  
  29          $db->setQuery($query, 0, intval($params->get('count')));
  30          $rows = (array) $db->loadObjectList();
  31  
  32          $app    = JFactory::getApplication();
  33          $menu    = $app->getMenu();
  34          $item    = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
  35          $itemid = (isset($item) && !empty($item->id) ) ? '&Itemid='.$item->id : '';
  36  
  37          $i        = 0;
  38          $lists    = array();
  39          foreach ($rows as $row) {
  40              $date = JFactory::getDate($row->created);
  41  
  42              $created_month    = $date->format('n');
  43              $created_year    = $date->format('Y');
  44  
  45              $created_year_cal    = JHTML::_('date', $row->created, 'Y');
  46              $month_name_cal    = JHTML::_('date', $row->created, 'F');
  47  
  48              $lists[$i] = new stdClass;
  49  
  50              $lists[$i]->link    = JRoute::_('index.php?option=com_content&view=archive&year='.$created_year.'&month='.$created_month.$itemid);
  51              $lists[$i]->text    = JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal);
  52  
  53              $i++;
  54          }
  55          return $lists;
  56      }
  57  }


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