You've already forked joomla_test
first commit
This commit is contained in:
120
modules/mod_articles_latest/helper.php
Normal file
120
modules/mod_articles_latest/helper.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_articles_latest
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
|
||||
|
||||
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel');
|
||||
|
||||
/**
|
||||
* Helper for mod_articles_latest
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_articles_latest
|
||||
*/
|
||||
abstract class ModArticlesLatestHelper
|
||||
{
|
||||
public static function getList(&$params)
|
||||
{
|
||||
// Get the dbo
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Get an instance of the generic articles model
|
||||
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
|
||||
|
||||
// Set application parameters in model
|
||||
$app = JFactory::getApplication();
|
||||
$appParams = $app->getParams();
|
||||
$model->setState('params', $appParams);
|
||||
|
||||
// Set the filters based on the module params
|
||||
$model->setState('list.start', 0);
|
||||
$model->setState('list.limit', (int) $params->get('count', 5));
|
||||
$model->setState('filter.published', 1);
|
||||
|
||||
// Access filter
|
||||
$access = !JComponentHelper::getParams('com_content')->get('show_noauth');
|
||||
$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
|
||||
$model->setState('filter.access', $access);
|
||||
|
||||
// Category filter
|
||||
$model->setState('filter.category_id', $params->get('catid', array()));
|
||||
|
||||
// User filter
|
||||
$userId = JFactory::getUser()->get('id');
|
||||
switch ($params->get('user_id'))
|
||||
{
|
||||
case 'by_me':
|
||||
$model->setState('filter.author_id', (int) $userId);
|
||||
break;
|
||||
case 'not_me':
|
||||
$model->setState('filter.author_id', $userId);
|
||||
$model->setState('filter.author_id.include', false);
|
||||
break;
|
||||
|
||||
case '0':
|
||||
break;
|
||||
|
||||
default:
|
||||
$model->setState('filter.author_id', (int) $params->get('user_id'));
|
||||
break;
|
||||
}
|
||||
|
||||
// Filter by language
|
||||
$model->setState('filter.language', $app->getLanguageFilter());
|
||||
|
||||
// Featured switch
|
||||
switch ($params->get('show_featured'))
|
||||
{
|
||||
case '1':
|
||||
$model->setState('filter.featured', 'only');
|
||||
break;
|
||||
case '0':
|
||||
$model->setState('filter.featured', 'hide');
|
||||
break;
|
||||
default:
|
||||
$model->setState('filter.featured', 'show');
|
||||
break;
|
||||
}
|
||||
|
||||
// Set ordering
|
||||
$order_map = array(
|
||||
'm_dsc' => 'a.modified DESC, a.created',
|
||||
'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END',
|
||||
'c_dsc' => 'a.created',
|
||||
'p_dsc' => 'a.publish_up',
|
||||
);
|
||||
$ordering = JArrayHelper::getValue($order_map, $params->get('ordering'), 'a.publish_up');
|
||||
$dir = 'DESC';
|
||||
|
||||
$model->setState('list.ordering', $ordering);
|
||||
$model->setState('list.direction', $dir);
|
||||
|
||||
$items = $model->getItems();
|
||||
|
||||
foreach ($items as &$item)
|
||||
{
|
||||
$item->slug = $item->id . ':' . $item->alias;
|
||||
$item->catslug = $item->catid . ':' . $item->category_alias;
|
||||
|
||||
if ($access || in_array($item->access, $authorised))
|
||||
{
|
||||
// We know that user has the privilege to view the article
|
||||
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
|
||||
}
|
||||
else
|
||||
{
|
||||
$item->link = JRoute::_('index.php?option=com_users&view=login');
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
1
modules/mod_articles_latest/index.html
Normal file
1
modules/mod_articles_latest/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
18
modules/mod_articles_latest/mod_articles_latest.php
Normal file
18
modules/mod_articles_latest/mod_articles_latest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_articles_latest
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Include the syndicate functions only once
|
||||
require_once __DIR__ . '/helper.php';
|
||||
|
||||
$list = ModArticlesLatestHelper::getList($params);
|
||||
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
|
||||
|
||||
require JModuleHelper::getLayoutPath('mod_articles_latest', $params->get('layout', 'default'));
|
138
modules/mod_articles_latest/mod_articles_latest.xml
Normal file
138
modules/mod_articles_latest/mod_articles_latest.xml
Normal file
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension
|
||||
type="module"
|
||||
version="3.1"
|
||||
client="site"
|
||||
method="upgrade">
|
||||
<name>mod_articles_latest</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>July 2004</creationDate>
|
||||
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</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_LATEST_NEWS_XML_DESCRIPTION</description>
|
||||
<files>
|
||||
<filename module="mod_articles_latest">mod_articles_latest.php</filename>
|
||||
<folder>tmpl</folder>
|
||||
<filename>helper.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<filename>mod_articles_latest.xml</filename>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">en-GB.mod_articles_latest.ini</language>
|
||||
<language tag="en-GB">en-GB.mod_articles_latest.sys.ini</language>
|
||||
</languages>
|
||||
<help key="JHELP_EXTENSIONS_MODULE_MANAGER_LATEST_NEWS" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="catid"
|
||||
type="category"
|
||||
extension="com_content"
|
||||
multiple="true"
|
||||
size="10"
|
||||
default=""
|
||||
label="JCATEGORY"
|
||||
description="MOD_LATEST_NEWS_FIELD_CATEGORY_DESC" >
|
||||
<option value="">JOPTION_ALL_CATEGORIES</option>
|
||||
</field>
|
||||
<field
|
||||
name="count"
|
||||
type="text"
|
||||
default="5"
|
||||
label="MOD_LATEST_NEWS_FIELD_COUNT_LABEL"
|
||||
description="MOD_LATEST_NEWS_FIELD_COUNT_DESC" />
|
||||
|
||||
<field
|
||||
name="show_featured"
|
||||
type="list"
|
||||
default=""
|
||||
label="MOD_LATEST_NEWS_FIELD_FEATURED_LABEL"
|
||||
description="MOD_LATEST_NEWS_FIELD_FEATURED_DESC">
|
||||
<option
|
||||
value="">JSHOW</option>
|
||||
<option
|
||||
value="0">JHIDE</option>
|
||||
<option
|
||||
value="1">MOD_LATEST_NEWS_VALUE_ONLY_SHOW_FEATURED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="list"
|
||||
default="published"
|
||||
label="MOD_LATEST_NEWS_FIELD_ORDERING_LABEL"
|
||||
description="MOD_LATEST_NEWS_FIELD_ORDERING_DESC">
|
||||
<option
|
||||
value="c_dsc">MOD_LATEST_NEWS_VALUE_RECENT_ADDED</option>
|
||||
<option
|
||||
value="m_dsc">MOD_LATEST_NEWS_VALUE_RECENT_MODIFIED</option>
|
||||
<option
|
||||
value="p_dsc">MOD_LATEST_NEWS_VALUE_RECENT_PUBLISHED</option>
|
||||
<option
|
||||
value="mc_dsc">MOD_LATEST_NEWS_VALUE_RECENT_TOUCHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="user_id"
|
||||
type="list"
|
||||
default="0"
|
||||
label="MOD_LATEST_NEWS_FIELD_USER_LABEL"
|
||||
description="MOD_LATEST_NEWS_FIELD_USER_DESC">
|
||||
<option
|
||||
value="0">MOD_LATEST_NEWS_VALUE_ANYONE</option>
|
||||
<option
|
||||
value="by_me">MOD_LATEST_NEWS_VALUE_ADDED_BY_ME</option>
|
||||
<option
|
||||
value="not_me">MOD_LATEST_NEWS_VALUE_NOTADDED_BY_ME</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="advanced">
|
||||
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
description="JFIELD_ALT_MODULE_LAYOUT_DESC" />
|
||||
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea" rows="3"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
|
||||
|
||||
<field
|
||||
name="cache"
|
||||
type="list"
|
||||
default="1"
|
||||
label="COM_MODULES_FIELD_CACHING_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHING_DESC">
|
||||
<option
|
||||
value="1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option
|
||||
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="cache_time"
|
||||
type="text"
|
||||
default="900"
|
||||
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHE_TIME_DESC" />
|
||||
<field
|
||||
name="cachemode"
|
||||
type="hidden"
|
||||
default="static">
|
||||
<option
|
||||
value="static"></option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
19
modules/mod_articles_latest/tmpl/default.php
Normal file
19
modules/mod_articles_latest/tmpl/default.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_articles_latest
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
?>
|
||||
<ul class="latestnews<?php echo $moduleclass_sfx; ?>">
|
||||
<?php foreach ($list as $item) : ?>
|
||||
<li>
|
||||
<a href="<?php echo $item->link; ?>">
|
||||
<?php echo $item->title; ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
1
modules/mod_articles_latest/tmpl/index.html
Normal file
1
modules/mod_articles_latest/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
Reference in New Issue
Block a user