primo commit
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
159
administrator/components/com_cpanel/src/View/Cpanel/HtmlView.php
Normal file
159
administrator/components/com_cpanel/src/View/Cpanel/HtmlView.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user