PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/mod_articles_archive/helper.php

https://github.com/joebushi/joomla
PHP | 53 lines | 32 code | 8 blank | 13 comment | 0 complexity | 876b576ea85374423e64bc4d30c3f207 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @package Joomla.Site
  5. * @subpackage mod_articles_archive
  6. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. // no direct access
  10. defined('_JEXEC') or die;
  11. class modArchiveHelper
  12. {
  13. function getList(&$params)
  14. {
  15. //get database
  16. $db = &JFactory::getDbo();
  17. $query = new JQuery;
  18. $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year');
  19. $query->from('#__content');
  20. $query->where('state = -1 AND checked_out = 0');
  21. $query->group('created_year DESC, created_month DESC');
  22. // $query = 'SELECT MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year' .
  23. // ' FROM #__content' .
  24. // ' WHERE (state = -1 AND checked_out = 0)' .
  25. // ' GROUP BY created_year DESC, created_month DESC';
  26. $db->setQuery($query, 0, intval($params->get('count')));
  27. $rows = $db->loadObjectList();
  28. $menu = &JSite::getMenu();
  29. $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
  30. $itemid = isset($item) ? '&Itemid='.$item->id : '';
  31. $i = 0;
  32. $lists = array();
  33. foreach ($rows as $row)
  34. {
  35. $date = &JFactory::getDate($row->created);
  36. $created_month = $date->toFormat("%m");
  37. $month_name = $date->toFormat("%B");
  38. $created_year = $date->toFormat("%Y");
  39. $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year='.$created_year.'&month='.$created_month.$itemid);
  40. $lists[$i]->text = $month_name.', '.$created_year;
  41. $i++;
  42. }
  43. return $lists;
  44. }
  45. }