Spade
Mini Shell
helper.php000064400000004625151165606710006553 0ustar00<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_archive
*
* @copyright (C) 2006 Open Source Matters, Inc.
<https://www.joomla.org>
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Helper for mod_articles_archive
*
* @since 1.5
*/
class ModArchiveHelper
{
/**
* Retrieve list of archived articles
*
* @param \Joomla\Registry\Registry &$params module parameters
*
* @return array
*
* @since 1.5
*/
public static function getList(&$params)
{
// Get database
$db = JFactory::getDbo();
$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('#__content')
->where('state = 2')
->group($query->year($db->quoteName('created')) .
', ' . $query->month($db->quoteName('created')))
->order($query->year($db->quoteName('created')) .
' DESC, ' .
$query->month($db->quoteName('created')) . '
DESC');
// Filter by language
if (JFactory::getApplication()->getLanguageFilter())
{
$query->where('language in (' .
$db->quote(JFactory::getLanguage()->getTag()) . ',' .
$db->quote('*') . ')');
}
$db->setQuery($query, 0, (int) $params->get('count'));
try
{
$rows = (array) $db->loadObjectList();
}
catch (RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'),
'error');
return array();
}
$app = JFactory::getApplication();
$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 = JFactory::getDate($row->created);
$createdMonth = $date->format('n');
$createdYear = $date->format('Y');
$createdYearCal = JHtml::_('date', $row->created,
'Y');
$monthNameCal = JHtml::_('date', $row->created,
'F');
$lists[$i] = new stdClass;
$lists[$i]->link =
JRoute::_('index.php?option=com_content&view=archive&year='
. $createdYear . '&month=' . $createdMonth . $itemid);
$lists[$i]->text =
JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $monthNameCal,
$createdYearCal);
$i++;
}
return $lists;
}
}
mod_articles_archive.php000064400000001210151165606710011425
0ustar00<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_archive
*
* @copyright (C) 2005 Open Source Matters, Inc.
<https://www.joomla.org>
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the archive functions only once
JLoader::register('ModArchiveHelper', __DIR__ .
'/helper.php');
$params->def('count', 10);
$moduleclass_sfx =
htmlspecialchars($params->get('moduleclass_sfx',
''), ENT_COMPAT, 'UTF-8');
$list = ModArchiveHelper::getList($params);
require JModuleHelper::getLayoutPath('mod_articles_archive',
$params->get('layout', 'default'));
mod_articles_archive.xml000064400000004402151165606710011444
0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1"
client="site" method="upgrade">
<name>mod_articles_archive</name>
<author>Joomla! Project</author>
<creationDate>July 2006</creationDate>
<copyright>(C) 2006 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>MOD_ARTICLES_ARCHIVE_XML_DESCRIPTION</description>
<files>
<filename
module="mod_articles_archive">mod_articles_archive.php</filename>
<folder>tmpl</folder>
<filename>helper.php</filename>
</files>
<languages>
<language
tag="en-GB">en-GB.mod_articles_archive.ini</language>
<language
tag="en-GB">en-GB.mod_articles_archive.sys.ini</language>
</languages>
<help key="JHELP_EXTENSIONS_MODULE_MANAGER_ARTICLES_ARCHIVE"
/>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="count"
type="number"
label="MOD_ARTICLES_ARCHIVE_FIELD_COUNT_LABEL"
description="MOD_ARTICLES_ARCHIVE_FIELD_COUNT_DESC"
default="10"
filter="integer"
/>
</fieldset>
<fieldset name="advanced">
<field
name="layout"
type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_MODULE_LAYOUT_DESC"
validate="moduleLayout"
/>
<field
name="moduleclass_sfx"
type="textarea"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC"
rows="3"
/>
<field
name="cache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
description="COM_MODULES_FIELD_CACHING_DESC"
default="1"
filter="integer"
>
<option value="1">JGLOBAL_USE_GLOBAL</option>
<option
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field
name="cache_time"
type="number"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
description="COM_MODULES_FIELD_CACHE_TIME_DESC"
default="900"
filter="integer"
/>
<field
name="cachemode"
type="hidden"
default="static"
>
<option value="static"></option>
</field>
</fieldset>
</fields>
</config>
</extension>
tmpl/default.php000064400000001031151165606710007660 0ustar00<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_archive
*
* @copyright (C) 2006 Open Source Matters, Inc.
<https://www.joomla.org>
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<?php if (!empty($list)) : ?>
<ul class="archive-module<?php echo $moduleclass_sfx; ?>
mod-list">
<?php foreach ($list as $item) : ?>
<li>
<a href="<?php echo $item->link; ?>">
<?php echo $item->text; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>