first commit
This commit is contained in:
39
administrator/modules/mod_latest/mod_latest.php
Normal file
39
administrator/modules/mod_latest/mod_latest.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_latest
|
||||
*
|
||||
* @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;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Helper\ModuleHelper;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\Module\Latest\Administrator\Helper\LatestHelper;
|
||||
|
||||
$model = $app->bootComponent('com_content')->getMVCFactory()->createModel('Articles', 'Administrator', ['ignore_request' => true]);
|
||||
$list = LatestHelper::getList($params, $model);
|
||||
$workflow_enabled = ComponentHelper::getParams('com_content')->get('workflow_enabled');
|
||||
|
||||
if ($workflow_enabled) {
|
||||
$app->getLanguage()->load('com_workflow');
|
||||
}
|
||||
|
||||
if ($params->get('automatic_title', 0)) {
|
||||
$module->title = LatestHelper::getTitle($params);
|
||||
}
|
||||
|
||||
if (\count($list)) {
|
||||
require ModuleHelper::getLayoutPath('mod_latest', $params->get('layout', 'default'));
|
||||
} else {
|
||||
$app->getLanguage()->load('com_content');
|
||||
|
||||
echo LayoutHelper::render('joomla.content.emptystate_module', [
|
||||
'textPrefix' => 'COM_CONTENT',
|
||||
'icon' => 'icon-copy',
|
||||
]);
|
||||
}
|
||||
101
administrator/modules/mod_latest/mod_latest.xml
Normal file
101
administrator/modules/mod_latest/mod_latest.xml
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="module" client="administrator" method="upgrade">
|
||||
<name>mod_latest</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2004-07</creationDate>
|
||||
<copyright>(C) 2005 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_LATEST_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Module\Latest</namespace>
|
||||
<files>
|
||||
<filename module="mod_latest">mod_latest.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/mod_latest.ini</language>
|
||||
<language tag="en-GB">language/en-GB/mod_latest.sys.ini</language>
|
||||
</languages>
|
||||
<help key="Admin_Modules:_Articles_-_Latest" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="count"
|
||||
type="number"
|
||||
label="MOD_LATEST_FIELD_COUNT_LABEL"
|
||||
default="5"
|
||||
filter="integer"
|
||||
min="1"
|
||||
validate="number"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="list"
|
||||
label="MOD_LATEST_FIELD_ORDERING_LABEL"
|
||||
default="c_dsc"
|
||||
validate="options"
|
||||
>
|
||||
<option value="c_dsc">MOD_LATEST_FIELD_VALUE_ORDERING_ADDED</option>
|
||||
<option value="m_dsc">MOD_LATEST_FIELD_VALUE_ORDERING_MODIFIED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="catid"
|
||||
type="category"
|
||||
label="JCATEGORY"
|
||||
extension="com_content"
|
||||
default=""
|
||||
filter="integer"
|
||||
>
|
||||
<option value="">JOPTION_ANY_CATEGORY</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="user_id"
|
||||
type="list"
|
||||
label="MOD_LATEST_FIELD_AUTHORS_LABEL"
|
||||
default="0"
|
||||
validate="options"
|
||||
>
|
||||
<option value="0">MOD_LATEST_FIELD_VALUE_AUTHORS_ANYONE</option>
|
||||
<option value="by_me">MOD_LATEST_FIELD_VALUE_AUTHORS_BY_ME</option>
|
||||
<option value="not_me">MOD_LATEST_FIELD_VALUE_AUTHORS_NOT_BY_ME</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
validate="moduleLayout"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
rows="3"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="automatic_title"
|
||||
type="radio"
|
||||
label="COM_MODULES_FIELD_AUTOMATIC_TITLE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
136
administrator/modules/mod_latest/src/Helper/LatestHelper.php
Normal file
136
administrator/modules/mod_latest/src/Helper/LatestHelper.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_latest
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Module\Latest\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Categories\Categories;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\Content\Administrator\Model\ArticlesModel;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Helper for mod_latest
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
abstract class LatestHelper
|
||||
{
|
||||
/**
|
||||
* Get a list of articles.
|
||||
*
|
||||
* @param Registry $params The module parameters.
|
||||
* @param ArticlesModel $model The model.
|
||||
*
|
||||
* @return mixed An array of articles, or false on error.
|
||||
*/
|
||||
public static function getList(Registry $params, ArticlesModel $model)
|
||||
{
|
||||
$user = Factory::getUser();
|
||||
|
||||
// Set List SELECT
|
||||
$model->setState('list.select', 'a.id, a.title, a.checked_out, a.checked_out_time, ' .
|
||||
' a.access, a.created, a.created_by, a.created_by_alias, a.featured, a.state, a.publish_up, a.publish_down');
|
||||
|
||||
// Set Ordering filter
|
||||
switch ($params->get('ordering', 'c_dsc')) {
|
||||
case 'm_dsc':
|
||||
$model->setState('list.ordering', 'a.modified DESC, a.created');
|
||||
$model->setState('list.direction', 'DESC');
|
||||
break;
|
||||
|
||||
case 'c_dsc':
|
||||
default:
|
||||
$model->setState('list.ordering', 'a.created');
|
||||
$model->setState('list.direction', 'DESC');
|
||||
break;
|
||||
}
|
||||
|
||||
// Set Category Filter
|
||||
$categoryId = $params->get('catid', null);
|
||||
|
||||
if (is_numeric($categoryId)) {
|
||||
$model->setState('filter.category_id', $categoryId);
|
||||
}
|
||||
|
||||
// Set User Filter.
|
||||
$userId = $user->get('id');
|
||||
|
||||
switch ($params->get('user_id', '0')) {
|
||||
case 'by_me':
|
||||
$model->setState('filter.author_id', $userId);
|
||||
break;
|
||||
|
||||
case 'not_me':
|
||||
$model->setState('filter.author_id', $userId);
|
||||
$model->setState('filter.author_id.include', false);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the Start and Limit
|
||||
$model->setState('list.start', 0);
|
||||
$model->setState('list.limit', $params->get('count', 5));
|
||||
|
||||
$items = $model->getItems();
|
||||
|
||||
if ($error = $model->getError()) {
|
||||
throw new \Exception($error, 500);
|
||||
}
|
||||
|
||||
// Set the links
|
||||
foreach ($items as &$item) {
|
||||
$item->link = '';
|
||||
|
||||
if (
|
||||
$user->authorise('core.edit', 'com_content.article.' . $item->id)
|
||||
|| ($user->authorise('core.edit.own', 'com_content.article.' . $item->id) && ($userId === $item->created_by))
|
||||
) {
|
||||
$item->link = Route::_('index.php?option=com_content&task=article.edit&id=' . $item->id);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alternate title for the module.
|
||||
*
|
||||
* @param \Joomla\Registry\Registry $params The module parameters.
|
||||
*
|
||||
* @return string The alternate title for the module.
|
||||
*/
|
||||
public static function getTitle($params)
|
||||
{
|
||||
$who = $params->get('user_id', 0);
|
||||
$catid = (int) $params->get('catid', null);
|
||||
$type = $params->get('ordering') === 'c_dsc' ? '_CREATED' : '_MODIFIED';
|
||||
$title = '';
|
||||
|
||||
if ($catid) {
|
||||
$category = Categories::getInstance('Content')->get($catid);
|
||||
$title = Text::_('MOD_POPULAR_UNEXISTING');
|
||||
|
||||
if ($category) {
|
||||
$title = $category->title;
|
||||
}
|
||||
}
|
||||
|
||||
return Text::plural(
|
||||
'MOD_LATEST_TITLE' . $type . ($catid ? '_CATEGORY' : '') . ($who != '0' ? "_$who" : ''),
|
||||
(int) $params->get('count', 5),
|
||||
$title
|
||||
);
|
||||
}
|
||||
}
|
||||
68
administrator/modules/mod_latest/tmpl/default.php
Normal file
68
administrator/modules/mod_latest/tmpl/default.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_latest
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
$moduleId = str_replace(' ', '', $module->title) . $module->id;
|
||||
|
||||
?>
|
||||
<table class="table" id="<?php echo $moduleId; ?>">
|
||||
<caption class="visually-hidden"><?php echo $module->title; ?></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><?php echo Text::_('JGLOBAL_TITLE'); ?></th>
|
||||
<?php if ($workflow_enabled) : ?>
|
||||
<th scope="col" class="w-20"><?php echo Text::_('JSTAGE'); ?></th>
|
||||
<?php endif; ?>
|
||||
<th scope="col" class="w-20"><?php echo Text::_('JAUTHOR'); ?></th>
|
||||
<th scope="col" class="w-20"><?php echo Text::_('JDATE'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (count($list)) : ?>
|
||||
<?php foreach ($list as $i => $item) : ?>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php if ($item->checked_out) : ?>
|
||||
<?php echo HTMLHelper::_('jgrid.checkedout', $moduleId . $i, $item->editor, $item->checked_out_time, $module->id); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($item->link) : ?>
|
||||
<a href="<?php echo $item->link; ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?php echo htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<?php echo htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php if ($workflow_enabled) : ?>
|
||||
<td>
|
||||
<?php echo Text::_($item->stage_title); ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<?php echo $item->author_name; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo HTMLHelper::_('date', $item->created, Text::_('DATE_FORMAT_LC4')); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<?php echo Text::_('MOD_LATEST_NO_MATCHING_RESULTS'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
Reference in New Issue
Block a user