- md5
- 576483586606b2d0add10c4cca25e97b
- sha1
- 57da16c54c06ea184a59dc56648b4f3eda09d6b5
- sha256
- 5ee33ffc7d826d8d9c40b544c488ed0f15c81626c20daf0a57a374d40dc259c2
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_archive
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\ArticlesArchive\Site\Helper;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\Component\Content\Administrator\Extension\ContentComponent;
use Joomla\Database\ParameterType;
/**
* Helper for mod_articles_archive
*
* @since 1.5
*/
class ArticlesArchiveHelper
{
/**
* Retrieve list of archived articles
*
* @param \Joomla\Registry\Registry &$params module parameters
*
* @return array
*
* @since 1.5
*/
public static function getList(&$params)
{
$app = Factory::getApplication();
$db = Factory::getDbo();
$condition = ContentComponent::CONDITION_ARCHIVED;
$query = $db->getQuery(true);
$query->select($query->month($db->quoteName('created')) . ' AS created_month')
->select('MIN(' . $db->quoteName('created') . ') AS created')
->select($query->year($db->quoteName('created')) . ' AS created_year')
->from($db->quoteName('#__content', 'c'))
->innerJoin($db->quoteName('#__workflow_associations', 'wa'), $db->quoteName('wa.item_id') . ' = ' . $db->quoteName('c.id'))
->innerJoin($db->quoteName('#__workflow_stages', 'ws'), $db->quoteName('wa.stage_id') . ' = ' . $db->quoteName('ws.id'))
->where($db->quoteName('ws.condition') . ' = :condition')
->group($query->year($db->quoteName('c.created')) . ', ' . $query->month($db->quoteName('c.created')))
->order($query->year($db->quoteName('c.created')) . ' DESC, ' . $query->month($db->quoteName('c.created')) . ' DESC')
->bind(':condition', $condition, ParameterType::INTEGER);
// Filter by language
if ($app->getLanguageFilter())
{
$query->whereIn($db->quoteName('language'), [Factory::getLanguage()->getTag(), '*'], ParameterType::STRING);
}
$query->setLimit((int) $params->get('count'));
$db->setQuery($query);
try
{
$rows = (array) $db->loadObjectList();
}
catch (\RuntimeException $e)
{
$app->enqueueMessage(Text::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
return [];
}
$menu = $app->getMenu();
$item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
$itemid = (isset($item) && !empty($item->id)) ? '&Itemid=' . $item->id : '';
$i = 0;
$lists = array();
foreach ($rows as $row)
{
$date = Factory::getDate($row->created);
$createdMonth = $date->format('n');
$createdYear = $date->format('Y');
$createdYearCal = HTMLHelper::_('date', $row->created, 'Y');
$monthNameCal = HTMLHelper::_('date', $row->created, 'F');
$lists[$i] = new \stdClass;
$lists[$i]->link = Route::_('index.php?option=com_content&view=archive&year=' . $createdYear . '&month=' . $createdMonth . $itemid);
$lists[$i]->text = Text::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $monthNameCal, $createdYearCal);
$i++;
}
return $lists;
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha10 to 4.0.0-alpha11. See them all, or every version of this file.