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,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="module" client="site" method="upgrade">
<name>mod_breadcrumbs</name>
<author>Joomla! Project</author>
<creationDate>2006-07</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_BREADCRUMBS_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\Breadcrumbs</namespace>
<files>
<folder module="mod_breadcrumbs">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/mod_breadcrumbs.ini</language>
<language tag="en-GB">language/en-GB/mod_breadcrumbs.sys.ini</language>
</languages>
<help key="Site_Modules:_Breadcrumbs" />
<config>
<fields name="params">
<fieldset name="basic">
<field
name="showHere"
type="radio"
label="MOD_BREADCRUMBS_FIELD_SHOWHERE_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="showHome"
type="radio"
label="MOD_BREADCRUMBS_FIELD_SHOWHOME_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="homeText"
type="text"
label="MOD_BREADCRUMBS_FIELD_HOMETEXT_LABEL"
description="MOD_BREADCRUMBS_FIELD_HOMETEXT_DESC"
showon="showHome:1"
/>
<field
name="showLast"
type="radio"
label="MOD_BREADCRUMBS_FIELD_SHOWLAST_LABEL"
default="1"
layout="joomla.form.field.radio.switcher"
filter="integer"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</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="cache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
default="0"
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="0"
filter="integer"
/>
<field
name="cachemode"
type="hidden"
default="itemid"
>
<option value="itemid"></option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,41 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_breadcrumbs
*
* @copyright (C) 2023 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 breadcrumbs 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): void
{
$container->registerServiceProvider(new ModuleDispatcherFactory('\\Joomla\\Module\\Breadcrumbs'));
$container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\Breadcrumbs\\Site\\Helper'));
$container->registerServiceProvider(new Module());
}
};

View File

@ -0,0 +1,50 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_breadcrumbs
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\Breadcrumbs\Site\Dispatcher;
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
use Joomla\CMS\Helper\HelperFactoryAwareTrait;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Dispatcher class for mod_breadcrumbs
*
* @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();
$data['list'] = $this->getHelperFactory()->getHelper('BreadcrumbsHelper')->getBreadcrumbs($data['params'], $data['app']);
$data['count'] = \count($data['list']);
if (!$data['params']->get('showHome', 1)) {
$data['homeCrumb'] = $this->getHelperFactory()->getHelper('BreadcrumbsHelper')->getHomeItem($data['params'], $data['app']);
}
return $data;
}
}

View File

@ -0,0 +1,162 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_breadcrumbs
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\Breadcrumbs\Site\Helper;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\Registry\Registry;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Helper for mod_breadcrumbs
*
* @since 1.5
*/
class BreadcrumbsHelper
{
/**
* Retrieve breadcrumb items
*
* @param Registry $params The module parameters
* @param SiteApplication $app The application
*
* @return array
*
* @since 4.4.0
*/
public function getBreadcrumbs(Registry $params, SiteApplication $app): array
{
// Get the PathWay object from the application
$pathway = $app->getPathway();
$items = $pathway->getPathway();
$count = \count($items);
// Don't use $items here as it references JPathway properties directly
$crumbs = [];
for ($i = 0; $i < $count; $i++) {
$crumbs[$i] = new \stdClass();
$crumbs[$i]->name = stripslashes(htmlspecialchars($items[$i]->name, ENT_COMPAT, 'UTF-8'));
$crumbs[$i]->link = $items[$i]->link;
}
if ($params->get('showHome', 1)) {
array_unshift($crumbs, $this->getHomeItem($params, $app));
}
return $crumbs;
}
/**
* Retrieve home item (start page)
*
* @param Registry $params The module parameters
* @param SiteApplication $app The application
*
* @return object
*
* @since 4.4.0
*/
public function getHomeItem(Registry $params, SiteApplication $app): object
{
$menu = $app->getMenu();
if (Multilanguage::isEnabled()) {
$home = $menu->getDefault($app->getLanguage()->getTag());
} else {
$home = $menu->getDefault();
}
$item = new \stdClass();
$item->name = htmlspecialchars($params->get('homeText', $app->getLanguage()->_('MOD_BREADCRUMBS_HOME')), ENT_COMPAT, 'UTF-8');
$item->link = 'index.php?Itemid=' . $home->id;
return $item;
}
/**
* Set the breadcrumbs separator for the breadcrumbs display.
*
* @param string $custom Custom xhtml compliant string to separate the items of the breadcrumbs
*
* @return string Separator string
*
* @since 1.5
*
* @deprecated 4.4.0 will be removed in 6.0 as this function is not used anymore
*/
public static function setSeparator($custom = null)
{
$lang = Factory::getApplication()->getLanguage();
// If a custom separator has not been provided we try to load a template
// specific one first, and if that is not present we load the default separator
if ($custom === null) {
if ($lang->isRtl()) {
$_separator = HTMLHelper::_('image', 'system/arrow_rtl.png', null, null, true);
} else {
$_separator = HTMLHelper::_('image', 'system/arrow.png', null, null, true);
}
} else {
$_separator = htmlspecialchars($custom, ENT_COMPAT, 'UTF-8');
}
return $_separator;
}
/**
* Retrieve breadcrumb items
*
* @param Registry $params The module parameters
* @param CMSApplication $app The application
*
* @return array
*
* @since 1.5
*
* @deprecated 4.4.0 will be removed in 6.0
* Use the non-static method getBreadcrumbs
* Example: Factory::getApplication()->bootModule('mod_breadcrumbs', 'site')
* ->getHelper('BreadcrumbsHelper')
* ->getBreadcrumbs($params, Factory::getApplication())
*/
public static function getList(Registry $params, CMSApplication $app)
{
return (new self())->getBreadcrumbs($params, Factory::getApplication());
}
/**
* Retrieve home item (start page)
*
* @param Registry $params The module parameters
* @param CMSApplication $app The application
*
* @return object
*
* @since 4.2.0
*
* @deprecated 4.4.0 will be removed in 6.0
* Use the non-static method getHomeItem
* Example: Factory::getApplication()->bootModule('mod_breadcrumbs', 'site')
* ->getHelper('BreadcrumbsHelper')
* ->getHomeItem($params, Factory::getApplication())
*/
public static function getHome(Registry $params, CMSApplication $app)
{
return (new self())->getHomeItem($params, Factory::getApplication());
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_breadcrumbs
*
* @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;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\WebAsset\WebAssetManager;
?>
<nav class="mod-breadcrumbs__wrapper" aria-label="<?php echo htmlspecialchars($module->title, ENT_QUOTES, 'UTF-8'); ?>">
<ol class="mod-breadcrumbs breadcrumb px-3 py-2">
<?php if ($params->get('showHere', 1)) : ?>
<li class="mod-breadcrumbs__here float-start">
<?php echo Text::_('MOD_BREADCRUMBS_HERE'); ?>&#160;
</li>
<?php else : ?>
<li class="mod-breadcrumbs__divider float-start">
<span class="divider icon-location icon-fw" aria-hidden="true"></span>
</li>
<?php endif; ?>
<?php
// Get rid of duplicated entries on trail including home page when using multilanguage
for ($i = 0; $i < $count; $i++) {
if ($i === 1 && !empty($list[$i]->link) && !empty($list[$i - 1]->link) && $list[$i]->link === $list[$i - 1]->link) {
unset($list[$i]);
}
}
// Find last and penultimate items in breadcrumbs list
end($list);
$last_item_key = key($list);
prev($list);
$penult_item_key = key($list);
// Make a link if not the last item in the breadcrumbs
$show_last = $params->get('showLast', 1);
$class = null;
// Generate the trail
foreach ($list as $key => $item) :
if ($key !== $last_item_key) :
if (!empty($item->link)) :
$breadcrumbItem = HTMLHelper::_('link', Route::_($item->link), '<span>' . $item->name . '</span>', ['class' => 'pathway']);
else :
$breadcrumbItem = '<span>' . $item->name . '</span>';
endif;
echo '<li class="mod-breadcrumbs__item breadcrumb-item' . $class . '">' . $breadcrumbItem . '</li>';
elseif ($show_last) :
// Render last item if required.
$breadcrumbItem = '<span>' . $item->name . '</span>';
$class = ' active';
echo '<li class="mod-breadcrumbs__item breadcrumb-item' . $class . '">' . $breadcrumbItem . '</li>';
endif;
endforeach; ?>
</ol>
<?php
// Structured data as JSON
$data = [
'@context' => 'https://schema.org',
'@type' => 'BreadcrumbList',
'@id' => Uri::root() . '#/schema/BreadcrumbList/' . (int) $module->id,
'itemListElement' => []
];
// Use an independent counter for positions. E.g. if Heading items in pathway.
$itemsCounter = 0;
// If showHome is disabled use the fallback $homeCrumb for startpage at first position.
if (isset($homeCrumb)) {
$data['itemListElement'][] = [
'@type' => 'ListItem',
'position' => ++$itemsCounter,
'item' => [
'@id' => Route::_($homeCrumb->link, true, Route::TLS_IGNORE, true),
'name' => $homeCrumb->name,
],
];
}
foreach ($list as $key => $item) {
// Only add item to JSON if it has a valid link, otherwise skip it.
if (!empty($item->link)) {
$data['itemListElement'][] = [
'@type' => 'ListItem',
'position' => ++$itemsCounter,
'item' => [
'@id' => Route::_($item->link, true, Route::TLS_IGNORE, true),
'name' => $item->name,
],
];
} elseif ($key === $last_item_key) {
// Add the last item (current page) to JSON, but without a link.
// Google accepts items without a URL only as the current page.
$data['itemListElement'][] = [
'@type' => 'ListItem',
'position' => ++$itemsCounter,
'item' => [
'name' => $item->name,
],
];
}
}
if ($itemsCounter) {
/** @var WebAssetManager $wa */
$wa = $app->getDocument()->getWebAssetManager();
$prettyPrint = JDEBUG ? JSON_PRETTY_PRINT : 0;
$wa->addInline('script', json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | $prettyPrint), [], ['type' => 'application/ld+json']);
}
?>
</nav>