first commit

This commit is contained in:
2025-06-17 11:53:18 +02:00
commit 9f0f7ba12b
8804 changed files with 1369176 additions and 0 deletions

View File

@ -0,0 +1,49 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_popular
*
* @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\Popular\Administrator\Helper\PopularHelper;
$model = $app->bootComponent('com_content')->getMVCFactory()->createModel('Articles', 'Administrator', ['ignore_request' => true]);
$list = PopularHelper::getList($params, $model);
// Get module data.
if ($params->get('automatic_title', 0)) {
$module->title = PopularHelper::getTitle($params);
}
// If recording of hits is disabled.
if (!ComponentHelper::getParams('com_content')->get('record_hits', 1)) {
echo LayoutHelper::render('joomla.content.emptystate_module', [
'title' => 'JGLOBAL_RECORD_HITS_DISABLED',
'icon' => 'icon-minus-circle',
]);
return;
}
// If there are some articles to display.
if (\count($list)) {
require ModuleHelper::getLayoutPath('mod_popular', $params->get('layout', 'default'));
return;
}
// If there are no articles to display, show empty state.
$app->getLanguage()->load('com_content');
echo LayoutHelper::render('joomla.content.emptystate_module', [
'textPrefix' => 'COM_CONTENT',
'icon' => 'icon-copy',
]);

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="module" client="administrator" method="upgrade">
<name>mod_popular</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_POPULAR_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\Popular</namespace>
<files>
<filename module="mod_popular">mod_popular.php</filename>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/mod_popular.ini</language>
<language tag="en-GB">language/en-GB/mod_popular.sys.ini</language>
</languages>
<help key="Admin_Modules:_Popular_Articles" />
<config>
<fields name="params">
<fieldset name="basic">
<field
name="count"
type="number"
label="MOD_POPULAR_FIELD_COUNT_LABEL"
default="5"
filter="integer"
min="1"
validate="number"
/>
<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_POPULAR_FIELD_AUTHORS_LABEL"
default="0"
validate="options"
>
<option value="0">MOD_POPULAR_FIELD_VALUE_ANYONE</option>
<option value="by_me">MOD_POPULAR_FIELD_VALUE_ADDED_OR_MODIFIED_BY_ME</option>
<option value="not_me">MOD_POPULAR_FIELD_VALUE_NOT_ADDED_OR_MODIFIED_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>

View File

@ -0,0 +1,127 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_popular
*
* @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\Popular\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_popular
*
* @since 1.6
*/
abstract class PopularHelper
{
/**
* Get a list of the most popular articles.
*
* @param Registry $params The module parameters.
* @param ArticlesModel $model The model.
*
* @return mixed An array of articles, or false on error.
*
* @throws \Exception
*/
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.created_by, a.publish_up, a.hits');
// Set Ordering filter
$model->setState('list.ordering', 'a.hits');
$model->setState('list.direction', 'DESC');
// 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 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);
$title = '';
if ($catid) {
$category = Categories::getInstance('Content')->get($catid);
$title = Text::_('MOD_POPULAR_UNEXISTING');
if ($category) {
$title = $category->title;
}
}
return Text::plural(
'MOD_POPULAR_TITLE' . ($catid ? '_CATEGORY' : '') . ($who != '0' ? "_$who" : ''),
(int) $params->get('count', 5),
$title
);
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_popular
*
* @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 str_replace(' ', '', $module->title) . $module->id; ?>">
<caption class="visually-hidden"><?php echo $module->title; ?></caption>
<thead>
<tr>
<th scope="col" class="w-60"><?php echo Text::_('JGLOBAL_TITLE'); ?></th>
<th scope="col" class="w-20"><?php echo Text::_('JGLOBAL_HITS'); ?></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) : ?>
<?php // Calculate popular items ?>
<?php $hits = (int) $item->hits; ?>
<?php $hits_class = ($hits >= 10000 ? 'danger' : ($hits >= 1000 ? 'warning' : ($hits >= 100 ? 'info' : 'secondary'))); ?>
<tr>
<th scope="row">
<?php if ($item->checked_out) : ?>
<?php echo HTMLHelper::_('jgrid.checkedout', $moduleId . $i, $item->editor, $item->checked_out_time); ?>
<?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>
<td>
<span class="badge bg-<?php echo $hits_class; ?>"><?php echo $item->hits; ?></span>
</td>
<td>
<?php echo HTMLHelper::_('date', $item->publish_up, Text::_('DATE_FORMAT_LC4')); ?>
</td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr>
<td colspan="3">
<?php echo Text::_('MOD_POPULAR_NO_MATCHING_RESULTS'); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>