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,197 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright (C) 2009 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\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
HTMLHelper::_('behavior.combobox');
$hasContent = isset($this->item->xml->customContent);
$hasContentFieldName = 'content';
// For a later improvement
if ($hasContent) {
$hasContentFieldName = 'content';
}
// Get Params Fieldsets
$this->fieldsets = $this->form->getFieldsets('params');
$this->useCoreUI = true;
Text::script('JYES');
Text::script('JNO');
Text::script('JALL');
Text::script('JTRASHED');
$this->document->addScriptOptions('module-edit', ['itemId' => $this->item->id, 'state' => (int) $this->item->id == 0 ? 'Add' : 'Edit']);
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive')
->useScript('form.validate')
->useScript('com_modules.admin-module-edit');
$input = Factory::getApplication()->getInput();
// In case of modal
$isModal = $input->get('layout') === 'modal';
$layout = $isModal ? 'modal' : 'edit';
$tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
?>
<form action="<?php echo Route::_('index.php?option=com_modules&layout=' . $layout . $tmpl . '&client_id=' . $this->form->getValue('client_id') . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="module-form" aria-label="<?php echo Text::_('COM_MODULES_FORM_TITLE_' . ((int) $this->item->id === 0 ? 'NEW' : 'EDIT'), true); ?>" class="form-validate">
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>
<div class="main-card">
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'general', 'recall' => true, 'breakpoint' => 768]); ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'general', Text::_('COM_MODULES_MODULE')); ?>
<div class="row">
<div class="col-lg-9">
<?php if ($this->item->xml) : ?>
<?php if ($this->item->xml->description) : ?>
<h2>
<?php
if ($this->item->xml) {
echo ($text = (string) $this->item->xml->name) ? Text::_($text) : $this->item->module;
} else {
echo Text::_('COM_MODULES_ERR_XML');
}
?>
</h2>
<div class="info-labels">
<span class="badge bg-secondary">
<?php echo $this->item->client_id == 0 ? Text::_('JSITE') : Text::_('JADMINISTRATOR'); ?>
</span>
</div>
<div>
<?php
$this->fieldset = 'description';
$short_description = Text::_($this->item->xml->description);
$long_description = LayoutHelper::render('joomla.edit.fieldset', $this);
if (!$long_description) {
$truncated = HTMLHelper::_('string.truncate', $short_description, 550, true, false);
if (strlen($truncated) > 500) {
$long_description = $short_description;
$short_description = HTMLHelper::_('string.truncate', $truncated, 250);
if ($short_description == $long_description) {
$long_description = '';
}
}
}
?>
<p><?php echo $short_description; ?></p>
<?php if ($long_description) : ?>
<p class="readmore">
<a href="#" onclick="document.getElementById('myTab').activateTab(document.getElementById('description'));">
<?php echo Text::_('JGLOBAL_SHOW_FULL_DESCRIPTION'); ?>
</a>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
<?php else : ?>
<div class="alert alert-danger">
<span class="icon-exclamation-triangle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('ERROR'); ?></span>
<?php echo Text::_('COM_MODULES_ERR_XML'); ?>
</div>
<?php endif; ?>
<?php
if ($hasContent) {
echo $this->form->getInput($hasContentFieldName);
}
$this->fieldset = 'basic';
$html = LayoutHelper::render('joomla.edit.fieldset', $this);
echo $html ? '<hr>' . $html : '';
?>
</div>
<div class="col-lg-3">
<?php
// Set main fields.
$this->fields = [
'showtitle',
'position',
'published',
'publish_up',
'publish_down',
'access',
'ordering',
'language',
'note'
];
?>
<?php if ($this->item->client_id == 0) : ?>
<?php echo LayoutHelper::render('joomla.edit.global', $this); ?>
<?php else : ?>
<?php echo LayoutHelper::render('joomla.edit.admin_modules', $this); ?>
<?php endif; ?>
</div>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php if (isset($long_description) && $long_description != '') : ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'description', Text::_('JGLOBAL_FIELDSET_DESCRIPTION')); ?>
<div class="card">
<div class="card-body">
<?php echo $long_description; ?>
</div>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php endif; ?>
<?php if ($this->item->client_id == 0) : ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'assignment', Text::_('COM_MODULES_MENU_ASSIGNMENT')); ?>
<fieldset id="fieldset-assignment" class="options-form">
<legend><?php echo Text::_('COM_MODULES_MENU_ASSIGNMENT'); ?></legend>
<div>
<?php echo $this->loadTemplate('assignment'); ?>
</div>
</fieldset>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php endif; ?>
<?php
$this->fieldsets = [];
$this->ignore_fieldsets = ['basic', 'description'];
echo LayoutHelper::render('joomla.edit.params', $this);
?>
<?php if ($this->canDo->get('core.admin')) : ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'permissions', Text::_('COM_MODULES_FIELDSET_RULES')); ?>
<fieldset id="fieldset-permissions" class="options-form">
<legend><?php echo Text::_('COM_MODULES_FIELDSET_RULES'); ?></legend>
<div>
<?php echo $this->form->getInput('rules'); ?>
</div>
</fieldset>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php endif; ?>
<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="return" value="<?php echo $input->get('return', null, 'BASE64'); ?>">
<?php echo HTMLHelper::_('form.token'); ?>
<?php echo $this->form->getInput('module'); ?>
<?php echo $this->form->getInput('client_id'); ?>
</div>
</form>

View File

@ -0,0 +1,151 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright (C) 2009 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\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\Component\Menus\Administrator\Helper\MenusHelper;
use Joomla\Component\Modules\Administrator\Helper\ModulesHelper;
// Initialise related data.
$menuTypes = MenusHelper::getMenuLinks();
$this->document->getWebAssetManager()
->useScript('joomla.treeselectmenu')
->useScript('com_modules.admin-module-edit-assignment');
?>
<div class="control-group">
<label id="jform_menus-lbl" class="control-label" for="jform_assignment"><?php echo Text::_('COM_MODULES_MODULE_ASSIGN'); ?></label>
<div id="jform_menus" class="controls">
<select class="form-select" name="jform[assignment]" id="jform_assignment">
<?php echo HTMLHelper::_('select.options', ModulesHelper::getAssignmentOptions($this->item->client_id), 'value', 'text', $this->item->assignment, true); ?>
</select>
</div>
</div>
<div id="menuselect-group" class="control-group">
<label id="jform_menuselect-lbl" class="control-label" for="jform_menuselect"><?php echo Text::_('JGLOBAL_MENU_SELECTION'); ?></label>
<div id="jform_menuselect" class="controls">
<?php if (!empty($menuTypes)) : ?>
<div class="card-header">
<section class="d-flex align-items-center flex-wrap w-100" aria-label="<?php echo Text::_('COM_MODULES_GLOBAL'); ?>">
<div class="d-flex align-items-center flex-fill mb-1" role="group" aria-label="<?php echo Text::_('COM_MODULES_GLOBAL_ASSIGN'); ?>"><?php echo Text::_('COM_MODULES_GLOBAL_ASSIGN'); ?>
<button id="treeCheckAll" class="btn btn-secondary btn-sm mx-1" type="button">
<?php echo Text::_('JALL'); ?>
</button>
<button id="treeUncheckAll" class="btn btn-secondary btn-sm mx-1" type="button">
<?php echo Text::_('JNONE'); ?>
</button>
</div>
<div class="d-flex align-items-center mb-1 flex-fill" role="group" aria-label="<?php echo Text::_('COM_MODULES_GLOBAL_TREE_EXPAND'); ?>"><?php echo Text::_('COM_MODULES_GLOBAL_TREE_EXPAND'); ?>
<button id="treeExpandAll" class="btn btn-secondary btn-sm mx-1" type="button">
<?php echo Text::_('JALL'); ?>
</button>
<button id="treeCollapseAll" class="btn btn-secondary btn-sm mx-1" type="button">
<?php echo Text::_('JNONE'); ?>
</button>
</div>
<div role="search" class="flex-grow-1">
<label for="treeselectfilter" class="visually-hidden"><?php echo Text::_('COM_MODULES_SEARCH_MENUITEM'); ?></label>
<input type="text" id="treeselectfilter" name="treeselectfilter" class="form-control search-query" autocomplete="off" placeholder="<?php echo Text::_('JSEARCH_FILTER'); ?>">
</div>
</section>
</div>
<div class="card-body">
<ul class="treeselect">
<?php foreach ($menuTypes as &$type) : ?>
<?php if (count($type->links)) : ?>
<?php $prevlevel = 0; ?>
<li>
<div class="treeselect-item treeselect-header">
<label class="nav-header"><?php echo $type->title; ?></label></div>
<?php foreach ($type->links as $i => $link) : ?>
<?php
if ($prevlevel < $link->level) {
echo '<ul class="treeselect-sub">';
} elseif ($prevlevel > $link->level) {
echo str_repeat('</li></ul>', $prevlevel - $link->level);
} else {
echo '</li>';
}
$selected = 0;
if ($this->item->assignment == 0) {
$selected = 1;
} elseif ($this->item->assignment < 0) {
$selected = in_array(-$link->value, $this->item->assigned);
} elseif ($this->item->assignment > 0) {
$selected = in_array($link->value, $this->item->assigned);
}
?>
<li>
<div class="treeselect-item">
<?php
$uselessMenuItem = in_array($link->type, ['separator', 'heading', 'alias', 'url']);
$id = 'jform_menuselect';
?>
<input type="checkbox" class="novalidate form-check-input" name="jform[assigned][]" id="<?php echo $id . $link->value; ?>" value="<?php echo (int) $link->value; ?>"<?php echo $selected ? ' checked="checked"' : '';
echo $uselessMenuItem ? ' disabled="disabled"' : ''; ?>>
<label for="<?php echo $id . $link->value; ?>" class="">
<?php echo $link->text; ?>
<?php if (Multilanguage::isEnabled() && $link->language != '' && $link->language != '*') : ?>
<?php if ($link->language_image) : ?>
<?php echo HTMLHelper::_('image', 'mod_languages/' . $link->language_image . '.gif', $link->language_title, ['title' => $link->language_title], true); ?>
<?php else : ?>
<?php echo '<span class="badge bg-secondary" title="' . $link->language_title . '">' . $link->language_sef . '</span>'; ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($link->published == 0) : ?>
<?php echo ' <span class="badge bg-secondary">' . Text::_('JUNPUBLISHED') . '</span>'; ?>
<?php endif; ?>
<?php if ($uselessMenuItem) : ?>
<?php echo ' <span class="badge bg-secondary">' . Text::_('COM_MODULES_MENU_ITEM_' . strtoupper($link->type)) . '</span>'; ?>
<?php endif; ?>
</label>
</div>
<?php
if (!isset($type->links[$i + 1])) {
echo str_repeat('</li></ul>', $link->level);
}
$prevlevel = $link->level;
?>
<?php endforeach; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<joomla-alert id="noresultsfound" type="warning" style="display:none"><?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?></joomla-alert>
<div class="hidden" id="treeselectmenu">
<div class="nav-hover treeselect-menu">
<div class="dropdown">
<button type="button" data-bs-toggle="dropdown" class="dropdown-toggle btn btn-sm btn-light">
<span class="caret"></span>
<span class="visually-hidden"><?php echo Text::sprintf('JGLOBAL_TOGGLE_DROPDOWN'); ?></span>
</button>
<div class="dropdown-menu">
<h1 class="dropdown-header"><?php echo Text::_('COM_MODULES_SUBITEMS'); ?></h1>
<div class="dropdown-divider"></div>
<a class="dropdown-item checkall" href="javascript://"><span class="icon-check-square" aria-hidden="true"></span> <?php echo Text::_('JSELECT'); ?></a>
<a class="dropdown-item uncheckall" href="javascript://"><span class="icon-square" aria-hidden="true"></span> <?php echo Text::_('COM_MODULES_DESELECT'); ?></a>
<div class="treeselect-menu-expand">
<div class="dropdown-divider"></div>
<a class="dropdown-item expandall" href="javascript://"><span class="icon-plus" aria-hidden="true"></span> <?php echo Text::_('COM_MODULES_EXPAND'); ?></a>
<a class="dropdown-item collapseall" href="javascript://"><span class="icon-minus" aria-hidden="true"></span> <?php echo Text::_('COM_MODULES_COLLAPSE'); ?></a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright (C) 2009 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\Factory;
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->addInlineScript('
document.addEventListener("DOMContentLoaded", function() {
const saveCloseButton = window.parent.document.getElementById("btnModalSaveAndClose");
if (saveCloseButton) {
saveCloseButton.classList.remove("hidden");
}
});
');
?>
<button id="applyBtn" type="button" class="hidden" onclick="Joomla.submitbutton('module.apply');"></button>
<button id="saveBtn" type="button" class="hidden" onclick="Joomla.submitbutton('module.save');"></button>
<button id="closeBtn" type="button" class="hidden" onclick="Joomla.submitbutton('module.cancel');"></button>
<div class="container-popup">
<?php $this->setLayout('edit'); ?>
<?php echo $this->loadTemplate(); ?>
</div>