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,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="module" client="site" method="upgrade">
<name>mod_articles_categories</name>
<author>Joomla! Project</author>
<creationDate>2010-02</creationDate>
<copyright>(C) 2010 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_CATEGORIES_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\ArticlesCategories</namespace>
<files>
<folder module="mod_articles_categories">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/mod_articles_categories.ini</language>
<language tag="en-GB">language/en-GB/mod_articles_categories.sys.ini</language>
</languages>
<help key="Site_Modules:_Articles_-_Categories" />
<config>
<fields name="params">
<fieldset name="basic" addfieldprefix="Joomla\Component\Categories\Administrator\Field">
<field
name="parent"
type="modal_category"
label="MOD_ARTICLES_CATEGORIES_FIELD_PARENT_LABEL"
extension="com_content"
filter="integer"
published=""
select="true"
new="true"
edit="true"
clear="true"
/>
<field
name="show_description"
type="radio"
layout="joomla.form.field.radio.switcher"
label="MOD_ARTICLES_CATEGORIES_FIELD_SHOW_DESCRIPTION_LABEL"
default="0"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="numitems"
type="radio"
layout="joomla.form.field.radio.switcher"
label="MOD_ARTICLES_CATEGORIES_FIELD_NUMITEMS_LABEL"
default="0"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_children"
type="radio"
layout="joomla.form.field.radio.switcher"
label="MOD_ARTICLES_CATEGORIES_FIELD_SHOW_CHILDREN_LABEL"
default="0"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="count"
type="list"
label="MOD_ARTICLES_CATEGORIES_FIELD_COUNT_LABEL"
description="MOD_ARTICLES_CATEGORIES_FIELD_COUNT_DESC"
default="0"
filter="integer"
validate="options"
>
<option value="0">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
<option value="6">J6</option>
<option value="7">J7</option>
<option value="8">J8</option>
<option value="9">J9</option>
<option value="10">J10</option>
</field>
<field
name="maxlevel"
type="list"
label="MOD_ARTICLES_CATEGORIES_FIELD_MAXLEVEL_LABEL"
default="0"
filter="integer"
validate="options"
>
<option value="0">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
<option value="6">J6</option>
<option value="7">J7</option>
<option value="8">J8</option>
<option value="9">J9</option>
<option value="10">J10</option>
</field>
</fieldset>
<fieldset name="advanced">
<field
name="layout"
type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL"
class="form-select"
validate="moduleLayout"
/>
<field
name="item_heading"
type="list"
label="MOD_ARTICLES_CATEGORIES_TITLE_HEADING_LABEL"
default="4"
filter="integer"
validate="options"
>
<option value="1">JH1</option>
<option value="2">JH2</option>
<option value="3">JH3</option>
<option value="4">JH4</option>
<option value="5">JH5</option>
</field>
<field
name="moduleclass_sfx"
type="textarea"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
rows="3"
validate="CssIdentifier"
/>
<field
name="owncache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
default="1"
filter="integer"
validate="options"
>
<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"
default="900"
filter="integer"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,41 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_categories
*
* @copyright (C) 2022 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\Extension\Service\Provider\HelperFactory;
use Joomla\CMS\Extension\Service\Provider\Module;
use Joomla\CMS\Extension\Service\Provider\ModuleDispatcherFactory;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
* The articles categories module service provider.
*
* @since 4.4.0
*/
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.4.0
*/
public function register(Container $container)
{
$container->registerServiceProvider(new ModuleDispatcherFactory('\\Joomla\\Module\\ArticlesCategories'));
$container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\ArticlesCategories\\Site\\Helper'));
$container->registerServiceProvider(new Module());
}
};

View File

@ -0,0 +1,56 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_categories
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\ArticlesCategories\Site\Dispatcher;
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
use Joomla\CMS\Helper\HelperFactoryAwareTrait;
use Joomla\CMS\Helper\ModuleHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Dispatcher class for mod_articles_categories
*
* @since 4.4.0
*/
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface
{
use HelperFactoryAwareTrait;
/**
* Returns the layout data.
*
* @return array
*
* @since 4.4.0
*/
protected function getLayoutData(): array
{
$data = parent::getLayoutData();
$params = $data['params'];
$cacheParams = new \stdClass();
$cacheParams->cachemode = 'id';
$cacheParams->class = $this->getHelperFactory()->getHelper('ArticlesCategoriesHelper');
$cacheParams->method = 'getChildrenCategories';
$cacheParams->methodparams = [$params, $data['app']];
$cacheParams->modeparams = md5(serialize($this->module->id));
$data['list'] = ModuleHelper::moduleCache($this->module, $params, $cacheParams);
$data['startLevel'] = $data['list'] ? reset($data['list'])->getParent()->level : null;
return $data;
}
}

View File

@ -0,0 +1,96 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_categories
*
* @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\ArticlesCategories\Site\Helper;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Categories\CategoryInterface;
use Joomla\CMS\Categories\CategoryNode;
use Joomla\CMS\Factory;
use Joomla\Database\DatabaseAwareInterface;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Registry\Registry;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Helper for mod_articles_categories
*
* @since 1.5
*/
class ArticlesCategoriesHelper implements DatabaseAwareInterface
{
use DatabaseAwareTrait;
/**
* Given a parent category, return a list of children categories
*
* @param Registry $moduleParams The module parameters.
* @param SiteApplication $app The current application.
*
* @return CategoryNode[]
*
* @since 4.4.0
*/
public function getChildrenCategories(Registry $moduleParams, SiteApplication $app): array
{
// Joomla\CMS\Categories\Categories options to set
$options = [];
// Get the number of items in this category or descendants of this category at the expense of performance.
$options['countItems'] = $moduleParams->get('numitems', 0);
/** @var CategoryInterface $categoryFactory */
$categoryFactory = $app->bootComponent('com_content')->getCategory($options);
/** @var CategoryNode $parentCategory */
$parentCategory = $categoryFactory->get($moduleParams->get('parent', 'root'));
if ($parentCategory === null) {
return [];
}
// Get all the children categories of this node
$childrenCategories = $parentCategory->getChildren(true);
$count = $moduleParams->get('count', 0);
if ($count > 0 && \count($childrenCategories) > $count) {
$childrenCategories = \array_slice($childrenCategories, 0, $count);
}
return $childrenCategories;
}
/**
* Get list of categories
*
* @param Registry $params module parameters
*
* @return array
*
* @since 1.6
*
* @deprecated 4.4.0 will be removed in 6.0
* Use the non-static method getChildrenCategories
* Example: Factory::getApplication()->bootModule('mod_articles_categories', 'site')
* ->getHelper('ArticlesCategoriesHelper')
* ->getChildrenCategories($params, Factory::getApplication())
*/
public static function getList($params)
{
/** @var SiteApplication $app */
$app = Factory::getApplication();
return (new self())->getChildrenCategories($params, $app);
}
}

View File

@ -0,0 +1,22 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_categories
*
* @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\Helper\ModuleHelper;
if (!$list) {
return;
}
?>
<ul class="mod-articlescategories categories-module mod-list">
<?php require ModuleHelper::getLayoutPath('mod_articles_categories', $params->get('layout', 'default') . '_items'); ?>
</ul>

View File

@ -0,0 +1,51 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_articles_categories
*
* @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\Helper\ModuleHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Content\Site\Helper\RouteHelper;
$input = $app->getInput();
$option = $input->getCmd('option');
$view = $input->getCmd('view');
$id = $input->getInt('id');
foreach ($list as $item) : ?>
<li<?php if ($id == $item->id && in_array($view, ['category', 'categories']) && $option == 'com_content') {
echo ' class="active"';
} ?>> <?php $levelup = $item->level - $startLevel - 1; ?>
<a href="<?php echo Route::_(RouteHelper::getCategoryRoute($item->id, $item->language)); ?>">
<?php echo $item->title; ?>
<?php if ($params->get('numitems')) : ?>
(<?php echo $item->numitems; ?>)
<?php endif; ?>
</a>
<?php if ($params->get('show_description', 0)) : ?>
<?php echo HTMLHelper::_('content.prepare', $item->description, $item->getParams(), 'mod_articles_categories.content'); ?>
<?php endif; ?>
<?php
if (
$params->get('show_children', 0) && (($params->get('maxlevel', 0) == 0)
|| ($params->get('maxlevel') >= ($item->level - $startLevel)))
&& count($item->getChildren())
) : ?>
<?php echo '<ul>'; ?>
<?php $temp = $list; ?>
<?php $list = $item->getChildren(); ?>
<?php require ModuleHelper::getLayoutPath('mod_articles_categories', $params->get('layout', 'default') . '_items'); ?>
<?php $list = $temp; ?>
<?php echo '</ul>'; ?>
<?php endif; ?>
</li>
<?php endforeach; ?>