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,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="component" method="upgrade">
<name>com_cpanel</name>
<author>Joomla! Project</author>
<creationDate>2007-06</creationDate>
<copyright>(C) 2007 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>4.0.0</version>
<description>COM_CPANEL_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Component\Cpanel</namespace>
<administration>
<files folder="admin">
<filename>cpanel.xml</filename>
<folder>services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages folder="admin">
<language tag="en-GB">language/en-GB/com_cpanel.ini</language>
<language tag="en-GB">language/en-GB/com_cpanel.sys.ini</language>
</languages>
</administration>
</extension>

View File

@ -0,0 +1,53 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cpanel
*
* @copyright (C) 2018 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\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
* The cpanel service provider.
*
* @since 4.0.0
*/
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Cpanel'));
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Cpanel'));
$container->set(
ComponentInterface::class,
function (Container $container) {
$component = new MVCComponent($container->get(ComponentDispatcherFactoryInterface::class));
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
return $component;
}
);
}
};

View File

@ -0,0 +1,90 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cpanel
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Cpanel\Administrator\Controller;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Router\Route;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Cpanel Controller
*
* @since 1.5
*/
class DisplayController extends BaseController
{
/**
* The default view.
*
* @var string
* @since 1.6
*/
protected $default_view = 'cpanel';
/**
* Typical view method for MVC based architecture
*
* This function is provide as a default implementation, in most cases
* you will need to override it in your own controllers.
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types.
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values.
*
* @return static An instance of the current object to support chaining.
*
* @since 3.0
*/
public function display($cachable = false, $urlparams = [])
{
/*
* Set the template - this will display cpanel.php
* from the selected admin template.
*/
$this->input->set('tmpl', 'cpanel');
return parent::display($cachable, $urlparams);
}
/**
* Method to add a module to a dashboard
*
* @since 4.0.0
*
* @return void
*/
public function addModule()
{
$position = $this->input->get('position', 'cpanel');
$function = $this->input->get('function');
$appendLink = '';
if ($function) {
$appendLink .= '&function=' . $function;
}
if (substr($position, 0, 6) != 'cpanel') {
$position = 'cpanel';
}
// Administrator
$clientId = (\Joomla\CMS\Application\ApplicationHelper::getClientInfo('administrator', true))->id;
$this->app->setUserState('com_modules.modules.' . $clientId . '.filter.position', $position);
$this->app->setUserState('com_modules.modules.client_id', (string) $clientId);
$this->setRedirect(Route::_('index.php?option=com_modules&view=select&tmpl=component&layout=modal' . $appendLink, false));
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cpanel
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Cpanel\Administrator\Dispatcher;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Dispatcher\ComponentDispatcher;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* ComponentDispatcher class for com_cpanel
*
* @since 4.0.0
*/
class Dispatcher extends ComponentDispatcher
{
/**
* Method to check component access permission
*
* @since 4.0.0
*
* @return void
*
* @throws \Exception|NotAllowed
*/
protected function checkAccess()
{
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cpanel
*
* @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\Cpanel\Administrator\View\Cpanel;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Filter\OutputFilter;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* HTML View class for the Cpanel component
*
* @since 1.0
*/
class HtmlView extends BaseHtmlView
{
/**
* Array of cpanel modules
*
* @var array
*/
protected $modules = null;
/**
* Array of cpanel modules
*
* @var array
*/
protected $quickicons = null;
/**
* Moduleposition to load
*
* @var string
*/
protected $position = null;
/**
* 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)
{
$app = Factory::getApplication();
$dashboard = $app->getInput()->getCmd('dashboard', '');
$toolbar = $this->getDocument()->getToolbar();
$position = OutputFilter::stringURLSafe($dashboard);
// Generate a title for the view cpanel
if (!empty($dashboard)) {
$parts = explode('.', $dashboard);
$component = $parts[0];
if (strpos($component, 'com_') === false) {
$component = 'com_' . $component;
}
// Need to load the language file
$lang = $this->getLanguage();
$lang->load($component, JPATH_BASE)
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component);
$lang->load($component);
// Lookup dashboard attributes from component manifest file
$manifestFile = JPATH_ADMINISTRATOR . '/components/' . $component . '/' . str_replace('com_', '', $component) . '.xml';
if (is_file($manifestFile)) {
$manifest = simplexml_load_file($manifestFile);
if ($dashboardManifests = $manifest->dashboards) {
foreach ($dashboardManifests->children() as $dashboardManifest) {
if ((string) $dashboardManifest === $dashboard) {
$title = Text::_((string) $dashboardManifest->attributes()->title);
$icon = (string) $dashboardManifest->attributes()->icon;
break;
}
}
}
}
if (empty($title)) {
// Try building a title
$prefix = strtoupper($component) . '_DASHBOARD';
$sectionkey = !empty($parts[1]) ? '_' . strtoupper($parts[1]) : '';
$key = $prefix . $sectionkey . '_TITLE';
$keyIcon = $prefix . $sectionkey . '_ICON';
// Search for a component title
if ($lang->hasKey($key)) {
$title = Text::_($key);
} else {
// Try with a string from CPanel
$key = 'COM_CPANEL_DASHBOARD_' . $parts[0] . '_TITLE';
if ($lang->hasKey($key)) {
$title = Text::_($key);
} else {
$title = Text::_('COM_CPANEL_DASHBOARD_BASE_TITLE');
}
}
// Define the icon
if (empty($parts[1])) {
// Default core icons.
if ($parts[0] === 'components') {
$icon = 'icon-puzzle-piece';
} elseif ($parts[0] === 'system') {
$icon = 'icon-wrench';
} elseif ($parts[0] === 'help') {
$icon = 'icon-info-circle';
} elseif ($lang->hasKey($keyIcon)) {
$icon = Text::_($keyIcon);
} else {
$icon = 'icon-home';
}
} elseif ($lang->hasKey($keyIcon)) {
$icon = Text::_($keyIcon);
}
}
} else {
// Home Dashboard
$title = Text::_('COM_CPANEL_DASHBOARD_BASE_TITLE');
$icon = 'icon-home';
}
// Set toolbar items for the page
ToolbarHelper::title($title, $icon . ' cpanel');
$toolbar->help('screen.cpanel');
// Display the cpanel modules
$this->position = $position ? 'cpanel-' . $position : 'cpanel';
$this->modules = ModuleHelper::getModules($this->position);
$quickicons = $position ? 'icon-' . $position : 'icon';
$this->quickicons = ModuleHelper::getModules($quickicons);
parent::display($tpl);
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cpanel
*
* @copyright (C) 2008 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\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\Registry\Registry;
/** @var \Joomla\Component\Cpanel\Administrator\View\Cpanel\HtmlView $this */
// Load JavaScript message titles
Text::script('ERROR');
Text::script('WARNING');
Text::script('NOTICE');
Text::script('MESSAGE');
Text::script('COM_CPANEL_UNPUBLISH_MODULE_SUCCESS');
Text::script('COM_CPANEL_UNPUBLISH_MODULE_ERROR');
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->getDocument()->getWebAssetManager();
$wa->useScript('com_cpanel.admin-cpanel')
->useScript('joomla.dialog-autocreate');
$user = $this->getCurrentUser();
// Set up the modal options that will be used for module editor
$popupOptions = [
'popupType' => 'iframe',
'src' => Route::_('index.php?option=com_cpanel&task=addModule&position=' . $this->position, false),
'textHeader' => Text::_('COM_CPANEL_ADD_MODULE_MODAL_TITLE'),
];
?>
<div id="cpanel-modules">
<div class="cpanel-modules <?php echo $this->position; ?>">
<div class="card-columns">
<?php if ($this->quickicons) :
foreach ($this->quickicons as $iconmodule) {
$modParams = new Registry($iconmodule->params);
echo ModuleHelper::renderModule($iconmodule, [
'style' => 'well',
'class' => 'quickicons-for-' . $modParams->get('context', ''),
]);
}
endif;
foreach ($this->modules as $module) {
echo ModuleHelper::renderModule($module, ['style' => 'well']);
}
?>
<?php if ($user->authorise('core.admin', 'com_modules') && $user->authorise('core.create', 'com_modules')) : ?>
<div class="module-wrapper">
<div class="card">
<button type="button" class="cpanel-add-module"
data-joomla-dialog="<?php echo htmlspecialchars(json_encode($popupOptions, JSON_UNESCAPED_SLASHES)) ?>"
data-close-on-message data-reload-on-close>
<div class="cpanel-add-module-icon">
<span class="icon-plus-square" aria-hidden="true"></span>
</div>
<span><?php echo Text::_('COM_CPANEL_ADD_DASHBOARD_MODULE'); ?></span>
</button>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<layout title="COM_CPANEL_CPANEL_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_CPANEL_CPANEL_VIEW_DEFAULT_TITLE_DESC]]>
</message>
</layout>
</metadata>