primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,161 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Templates\Administrator\View\Style;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* View to edit a template style.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The item
*
* @var \stdClass
*/
protected $item;
/**
* The form object
*
* @var \Joomla\CMS\Form\Form
*/
protected $form;
/**
* The model state
*
* @var \Joomla\Registry\Registry
*/
protected $state;
/**
* The actions the user is authorised to perform
*
* @var \Joomla\Registry\Registry
*
* @since 4.0.0
*/
protected $canDo;
/**
* Array of fieldsets not to display
*
* @var string[]
*
* @since 5.2.0
*/
public $ignore_fieldsets = [];
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->form = $this->get('Form');
$this->canDo = ContentHelper::getActions('com_templates');
// Check for errors.
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
Factory::getApplication()->getInput()->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
$canDo = $this->canDo;
$toolbar = $this->getDocument()->getToolbar();
ToolbarHelper::title(
$isNew ? Text::_('COM_TEMPLATES_MANAGER_ADD_STYLE')
: Text::_('COM_TEMPLATES_MANAGER_EDIT_STYLE'),
'paint-brush thememanager'
);
// If not checked out, can save the item.
if ($canDo->get('core.edit')) {
$toolbar->apply('style.apply');
}
$saveGroup = $toolbar->dropdownButton('save-group');
$saveGroup->configure(
function (Toolbar $childBar) use ($canDo, $isNew) {
// If not checked out, can save the item.
if ($canDo->get('core.edit')) {
$childBar->save('style.save');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create')) {
$childBar->save2copy('style.save2copy');
}
}
);
if (empty($this->item->id)) {
$toolbar->cancel('style.cancel', 'JTOOLBAR_CANCEL');
} else {
$toolbar->cancel('style.cancel');
}
$toolbar->divider();
// Get the help information for the template item.
$lang = $this->getLanguage();
$help = $this->get('Help');
if ($lang->hasKey($help->url)) {
$debug = $lang->setDebug(false);
$url = Text::_($help->url);
$lang->setDebug($debug);
} else {
$url = null;
}
$toolbar->help($help->key, false, $url);
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Templates\Administrator\View\Style;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* View to edit a template style.
*
* @since 1.6
*/
class JsonView extends BaseHtmlView
{
/**
* The item
*
* @var \stdClass
*/
protected $item;
/**
* The form object
*
* @var \Joomla\CMS\Form\Form
*/
protected $form;
/**
* The model state
*
* @var \Joomla\Registry\Registry
*/
protected $state;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
try {
$this->item = $this->get('Item');
} catch (\Exception $e) {
$app = Factory::getApplication();
$app->enqueueMessage($e->getMessage(), 'error');
return false;
}
$paramsList = $this->item->getProperties();
unset($paramsList['xml']);
$paramsList = json_encode($paramsList);
return $paramsList;
}
}

View File

@ -0,0 +1,161 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Templates\Administrator\View\Styles;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* View class for a list of template styles.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* An array of items
*
* @var array
*/
protected $items;
/**
* The pagination object
*
* @var \Joomla\CMS\Pagination\Pagination
*/
protected $pagination;
/**
* The model state
*
* @var \Joomla\Registry\Registry
*/
protected $state;
/**
* Form object for search filters
*
* @var \Joomla\CMS\Form\Form
*
* @since 4.0.0
*/
public $filterForm;
/**
* The active search filters
*
* @var array
* @since 4.0.0
*/
public $activeFilters;
/**
* Is the parameter enabled to show template positions in the frontend?
*
* @var boolean
* @since 4.0.0
*/
public $preview;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->total = $this->get('Total');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->preview = ComponentHelper::getParams('com_templates')->get('template_positions_display');
// Remove the menu item filter for administrator styles.
if ((int) $this->state->get('client_id') !== 0) {
unset($this->activeFilters['menuitem']);
$this->filterForm->removeField('menuitem', 'filter');
}
// Check for errors.
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = ContentHelper::getActions('com_templates');
$clientId = (int) $this->get('State')->get('client_id');
$toolbar = $this->getDocument()->getToolbar();
// Add a shortcut to the templates list view.
$toolbar->linkButton('templates', 'COM_TEMPLATES_MANAGER_TEMPLATES')
->url('index.php?option=com_templates&view=templates&client_id=' . $clientId)
->icon('icon-code thememanager');
// Set the title.
if ($clientId === 1) {
ToolbarHelper::title(Text::_('COM_TEMPLATES_MANAGER_STYLES_ADMIN'), 'paint-brush thememanager');
} else {
ToolbarHelper::title(Text::_('COM_TEMPLATES_MANAGER_STYLES_SITE'), 'paint-brush thememanager');
}
if ($canDo->get('core.edit.state')) {
$toolbar->makeDefault('styles.setDefault', 'COM_TEMPLATES_TOOLBAR_SET_HOME');
$toolbar->divider();
}
if ($canDo->get('core.create')) {
$toolbar->standardButton('duplicate', 'JTOOLBAR_DUPLICATE', 'styles.duplicate')
->listCheck(true)
->icon('icon-copy');
$toolbar->divider();
}
if ($canDo->get('core.delete')) {
$toolbar->delete('styles.delete')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
$toolbar->divider();
}
if ($canDo->get('core.admin') || $canDo->get('core.options')) {
$toolbar->preferences('com_templates');
$toolbar->divider();
}
$toolbar->help('Templates:_Styles');
}
}

View File

@ -0,0 +1,418 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Templates\Administrator\View\Template;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Toolbar\Button\DropdownButton;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Uri\Uri;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* View to edit a template.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The Model state
*
* @var \Joomla\Registry\Registry
*/
protected $state;
/**
* The template details
*
* @var \stdClass|false
*/
protected $template;
/**
* For loading the source form
*
* @var Form
*/
protected $form;
/**
* For loading source file contents
*
* @var array
*/
protected $source;
/**
* Extension id
*
* @var integer
*/
protected $id;
/**
* Encrypted file path
*
* @var string
*/
protected $file;
/**
* List of available overrides
*
* @var array
*/
protected $overridesList;
/**
* Name of the present file
*
* @var string
*/
protected $fileName;
/**
* Type of the file - image, source, font
*
* @var string
*/
protected $type;
/**
* For loading image information
*
* @var array
*/
protected $image;
/**
* Template id for showing preview button
*
* @var \stdClass
*/
protected $preview;
/**
* For loading font information
*
* @var array
*/
protected $font;
/**
* A nested array containing list of files and folders
*
* @var array
*/
protected $files;
/**
* An array containing a list of compressed files
*
* @var array
*/
protected $archive;
/**
* The state of installer override plugin.
*
* @var array
*
* @since 4.0.0
*/
protected $pluginState;
/**
* A nested array containing list of files and folders in the media folder
*
* @var array
*
* @since 4.1.0
*/
protected $mediaFiles;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void|boolean
*/
public function display($tpl = null)
{
$app = Factory::getApplication();
$this->file = $app->getInput()->get('file', '');
$this->fileName = InputFilter::getInstance()->clean(base64_decode($this->file), 'string');
$explodeArray = explode('.', $this->fileName);
$ext = end($explodeArray);
$this->files = $this->get('Files');
$this->mediaFiles = $this->get('MediaFiles');
$this->state = $this->get('State');
$this->template = $this->get('Template');
$this->preview = $this->get('Preview');
$this->pluginState = PluginHelper::isEnabled('installer', 'override');
$this->updatedList = $this->get('UpdatedList');
$this->styles = $this->get('AllTemplateStyles');
$this->stylesHTML = '';
$params = ComponentHelper::getParams('com_templates');
$imageTypes = explode(',', $params->get('image_formats', 'gif,bmp,jpg,jpeg,png,webp'));
$sourceTypes = explode(',', $params->get('source_formats', 'txt,less,ini,xml,js,php,css,scss,sass,json'));
$fontTypes = explode(',', $params->get('font_formats', 'woff,woff2,ttf,otf'));
$archiveTypes = explode(',', $params->get('compressed_formats', 'zip'));
if (\in_array($ext, $sourceTypes)) {
$this->form = $this->get('Form');
$this->form->setFieldAttribute('source', 'syntax', $ext);
$this->source = $this->get('Source');
$this->type = 'file';
} elseif (\in_array($ext, $imageTypes)) {
try {
$this->image = $this->get('Image');
$this->type = 'image';
} catch (\RuntimeException $exception) {
$app->enqueueMessage(Text::_('COM_TEMPLATES_GD_EXTENSION_NOT_AVAILABLE'));
$this->type = 'home';
}
} elseif (\in_array($ext, $fontTypes)) {
$this->font = $this->get('Font');
$this->type = 'font';
} elseif (\in_array($ext, $archiveTypes)) {
$this->archive = $this->get('Archive');
$this->type = 'archive';
} else {
$this->type = 'home';
}
$this->overridesList = $this->get('OverridesList');
$this->id = $this->state->get('extension.id');
// Check for errors.
if (\count($errors = $this->get('Errors'))) {
$app->enqueueMessage(implode("\n", $errors));
return false;
}
$this->addToolbar();
if (!$this->getCurrentUser()->authorise('core.admin')) {
$this->setLayout('readonly');
}
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*
* @return void
*/
protected function addToolbar()
{
$app = Factory::getApplication();
$user = $this->getCurrentUser();
$toolbar = $this->getDocument()->getToolbar();
$app->getInput()->set('hidemainmenu', true);
// User is global SuperUser
$isSuperUser = $user->authorise('core.admin');
ToolbarHelper::title(Text::sprintf('COM_TEMPLATES_MANAGER_VIEW_TEMPLATE', ucfirst($this->template->name)), 'icon-code thememanager');
// Add a Template preview button
if ($this->type === 'home') {
$client = (int) $this->preview->client_id === 1 ? 'administrator/' : '';
$toolbar->linkButton('preview', 'COM_TEMPLATES_BUTTON_PREVIEW')
->url(Uri::root() . $client . 'index.php?tp=1&templateStyle=' . $this->preview->id)
->icon('icon-image')
->attributes(['target' => '_new']);
}
// Only show file edit buttons for global SuperUser
if ($isSuperUser) {
switch ($this->type) {
case 'file':
$toolbar->apply('template.apply');
$toolbar->save('template.save');
$toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
break;
case 'image':
// Add a Crop and Resize button
$toolbar->standardButton('crop', 'COM_TEMPLATES_BUTTON_CROP', 'template.cropImage')
->listCheck(false)
->icon('icon-crop');
ToolbarHelper::modal('resizeModal', 'icon-expand', 'COM_TEMPLATES_BUTTON_RESIZE');
$toolbar->cancel('template.close', 'COM_TEMPLATES_BUTTON_CLOSE_FILE');
break;
case 'archive':
// Add an extract button
$toolbar->standardButton('extract', 'COM_TEMPLATES_BUTTON_EXTRACT_ARCHIVE', 'template.extractArchive')
->listCheck(false)
->icon('icon-chevron-down');
break;
case 'home':
// Add a copy/child template button
if (isset($this->template->xmldata->inheritable) && (string) $this->template->xmldata->inheritable === '1') {
ToolbarHelper::modal('childModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_TEMPLATE_CHILD');
} elseif (empty($this->template->xmldata->parent) && empty($this->template->xmldata->namespace)) {
// We can't copy parent templates nor namespaced templates
ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
}
break;
}
}
// Only show file manage buttons for global SuperUser
if ($isSuperUser) {
if ($this->type === 'home') {
// Add Manage folders button
ToolbarHelper::modal('folderModal', 'icon-folder icon white', 'COM_TEMPLATES_BUTTON_FOLDERS');
// Add a new file button
ToolbarHelper::modal('fileModal', 'icon-file', 'COM_TEMPLATES_BUTTON_FILE');
} else {
// Add a Rename file Button
ToolbarHelper::modal('renameModal', 'icon-sync', 'COM_TEMPLATES_BUTTON_RENAME_FILE');
// Add a Delete file Button
ToolbarHelper::modal('deleteModal', 'icon-trash', 'COM_TEMPLATES_BUTTON_DELETE_FILE', 'btn-danger');
}
}
if (\count($this->updatedList) !== 0 && $this->pluginState && $this->type === 'home') {
/** @var DropdownButton $dropdown */
$dropdown = $toolbar->dropdownButton('override-group', 'COM_TEMPLATES_BUTTON_CHECK')
->toggleSplit(false)
->icon('icon-ellipsis-h')
->buttonClass('btn btn-action')
->form('updateForm')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
$childBar->publish('template.publish')
->text('COM_TEMPLATES_BUTTON_CHECK_LIST_ENTRY')
->form('updateForm')
->listCheck(true);
$childBar->unpublish('template.unpublish')
->text('COM_TEMPLATES_BUTTON_UNCHECK_LIST_ENTRY')
->form('updateForm')
->listCheck(true);
$childBar->unpublish('template.deleteOverrideHistory')
->text('COM_TEMPLATES_BUTTON_DELETE_LIST_ENTRY')
->form('updateForm')
->listCheck(true);
}
if (!\in_array($this->type, ['image', 'file'])) {
$toolbar->cancel('template.cancel');
}
$toolbar->divider();
$toolbar->help('Templates:_Customise');
}
/**
* Method for creating the collapsible tree.
*
* @param array $array The value of the present node for recursion
*
* @return string
*
* @note Uses recursion
* @since 3.2
*/
protected function directoryTree($array)
{
$temp = $this->files;
$this->files = $array;
$txt = $this->loadTemplate('tree');
$this->files = $temp;
return $txt;
}
/**
* Method for listing the folder tree in modals.
*
* @param array $array The value of the present node for recursion
*
* @return string
*
* @note Uses recursion
* @since 3.2
*/
protected function folderTree($array)
{
$temp = $this->files;
$this->files = $array;
$txt = $this->loadTemplate('folders');
$this->files = $temp;
return $txt;
}
/**
* Method for creating the collapsible tree.
*
* @param array $array The value of the present node for recursion
*
* @return string
*
* @note Uses recursion
* @since 4.1.0
*/
protected function mediaTree($array)
{
$temp = $this->mediaFiles;
$this->mediaFiles = $array;
$txt = $this->loadTemplate('tree_media');
$this->mediaFiles = $temp;
return $txt;
}
/**
* Method for listing the folder tree in modals.
*
* @param array $array The value of the present node for recursion
*
* @return string
*
* @note Uses recursion
* @since 4.1.0
*/
protected function mediaFolderTree($array)
{
$temp = $this->mediaFiles;
$this->mediaFiles = $array;
$txt = $this->loadTemplate('media_folders');
$this->mediaFiles = $temp;
return $txt;
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Templates\Administrator\View\Templates;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* View class for a list of templates.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The list of templates
*
* @var array
* @since 1.6
*/
protected $items;
/**
* The pagination object
*
* @var object
* @since 1.6
*/
protected $pagination;
/**
* The model state
*
* @var object
* @since 1.6
*/
protected $state;
/**
* @var string
* @since 3.2
*/
protected $file;
/**
* Form object for search filters
*
* @var \Joomla\CMS\Form\Form
*
* @since 4.0.0
*/
public $filterForm;
/**
* The active search filters
*
* @var array
* @since 4.0.0
*/
public $activeFilters;
/**
* Is the parameter enabled to show template positions in the frontend?
*
* @var boolean
* @since 4.0.0
*/
public $preview;
/**
* The state of installer override plugin.
*
* @var array
*
* @since 4.0.0
*/
protected $pluginState;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->total = $this->get('Total');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->preview = ComponentHelper::getParams('com_templates')->get('template_positions_display');
$this->file = base64_encode('home');
$this->pluginState = PluginHelper::isEnabled('installer', 'override');
// Check for errors.
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = ContentHelper::getActions('com_templates');
$clientId = (int) $this->get('State')->get('client_id');
$toolbar = $this->getDocument()->getToolbar();
// Add a shortcut to the styles list view.
$toolbar->linkButton('', 'COM_TEMPLATES_MANAGER_STYLES_BUTTON')
->url('index.php?option=com_templates&view=styles&client_id=' . $clientId)
->icon('icon-brush thememanager');
// Set the title.
if ($clientId === 1) {
ToolbarHelper::title(Text::_('COM_TEMPLATES_MANAGER_TEMPLATES_ADMIN'), 'icon-code thememanager');
} else {
ToolbarHelper::title(Text::_('COM_TEMPLATES_MANAGER_TEMPLATES_SITE'), 'icon-code thememanager');
}
if ($canDo->get('core.admin') || $canDo->get('core.options')) {
$toolbar->preferences('com_templates');
$toolbar->divider();
}
$toolbar->help('Templates:_Templates');
}
}