- md5
- 95565620b4d83884f69c49047e191c64
- sha1
- 486d34bd8f872a413abe6902358e09517e63a4d0
- sha256
- 0adec386dae9f7d62dc7293d7240f52dfdc485c73854dd1594d2bbaa0de77d28
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
<?php
/**
* @package Joomla.Administrator
* @subpackage com_cpanel
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Cpanel\Administrator\View\System;
defined('_JEXEC') or die;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
/**
* HTML View class for the Cpanel component
*
* @since 1.0
*/
class HtmlView extends BaseHtmlView
{
/**
* 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.
*/
private static $notEmpty = false;
/**
* 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)
{
// Set toolbar items for the page
ToolbarHelper::title(Text::_('COM_CPANEL_TITLE_SYSTEM_PANEL'), 'cog help_header');
ToolbarHelper::help('screen.cpanel');
$user = Factory::getUser();
$links = [];
$headerIcons = [];
// Build the array of links
// System
if ($user->authorise('core.admin'))
{
$links['COM_CPANEL_SYSTEM_SETUP'] = [
// System configuration
'com_config' => static::arrayBuilder(
'MOD_MENU_CONFIGURATION',
'index.php?option=com_config',
'cog'
),
];
$headerIcons['COM_CPANEL_SYSTEM_SETUP'] = 'cog';
static::$notEmpty = true;
}
// Maintain
if ($user->authorise('core.manage', 'com_cache'))
{
$links['MOD_MENU_MAINTAIN'] = [
'com_cache' => static::arrayBuilder(
'MOD_MENU_CLEAR_CACHE',
'index.php?option=com_cache',
'trash'
),
'com_cache_purge' => static::arrayBuilder(
'MOD_MENU_PURGE_EXPIRED_CACHE',
'index.php?option=com_cache&view=purge',
'trash'
),
];
$headerIcons['MOD_MENU_MAINTAIN'] = 'refresh';
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_checkin'))
{
$new = [
'com_checkin' => static::arrayBuilder(
'MOD_MENU_GLOBAL_CHECKIN',
'index.php?option=com_checkin',
'refresh'
),
];
if (!empty($links['MOD_MENU_MAINTAIN']))
{
$links['MOD_MENU_MAINTAIN'] = array_merge($links['MOD_MENU_MAINTAIN'], $new);
}
else
{
$links['MOD_MENU_MAINTAIN'] = $new;
$headerIcons['MOD_MENU_MAINTAIN'] = 'refresh';
}
static::$notEmpty = true;
}
// Information
if ($user->authorise('core.manage', 'com_installer'))
{
$links['MOD_MENU_INFORMATION'] = [
'com_installer_warnings' => static::arrayBuilder(
'MOD_MENU_INFORMATION_WARNINGS',
'index.php?option=com_installer&view=warnings',
'refresh'
),
];
$headerIcons['MOD_MENU_INFORMATION'] = 'refresh';
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_postinstall'))
{
$new = [
'com_postinstall' => static::arrayBuilder(
'MOD_MENU_INFORMATION_POST_INSTALL_MESSAGES',
'index.php?option=com_postinstall',
'info-circle'
),
];
if (!empty($links['MOD_MENU_INFORMATION']))
{
$links['MOD_MENU_INFORMATION'] = array_merge($links['MOD_MENU_INFORMATION'], $new);
}
else
{
$links['MOD_MENU_INFORMATION'] = $new;
$headerIcons['MOD_MENU_INFORMATION'] = 'refresh';
}
static::$notEmpty = true;
}
if ($user->authorise('core.admin'))
{
$new = [
'com_admin_sysinfo' => static::arrayBuilder(
'MOD_MENU_SYSTEM_INFORMATION_SYSINFO',
'index.php?option=com_admin&view=sysinfo',
'info'
),
];
if (!empty($links['MOD_MENU_INFORMATION']))
{
$links['MOD_MENU_INFORMATION'] = array_merge($links['MOD_MENU_INFORMATION'], $new);
}
else
{
$links['MOD_MENU_INFORMATION'] = $new;
$headerIcons['MOD_MENU_INFORMATION'] = 'refresh';
}
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_installer'))
{
$new = [
'com_installer_database' => static::arrayBuilder(
'MOD_MENU_SYSTEM_INFORMATION_DATABASE',
'index.php?option=com_installer&view=database',
'refresh'
),
];
if (!empty($links['MOD_MENU_INFORMATION']))
{
$links['MOD_MENU_INFORMATION'] = array_merge($links['MOD_MENU_INFORMATION'], $new);
}
else
{
$links['MOD_MENU_INFORMATION'] = $new;
$headerIcons['MOD_MENU_INFORMATION'] = 'refresh';
}
static::$notEmpty = true;
}
// Install
if ($user->authorise('core.manage', 'com_installer'))
{
// Install
$links['MOD_MENU_INSTALL'] = [
'com_installer_install' => static::arrayBuilder(
'MOD_MENU_INSTALL_EXTENSIONS',
'index.php?option=com_installer&view=install',
'cog'
),
'com_installer_discover' => static::arrayBuilder(
'MOD_MENU_INSTALL_DISCOVER',
'index.php?option=com_installer&view=discover',
'cog'
),
'com_languages_install' => static::arrayBuilder(
'MOD_MENU_INSTALL_LANGUAGES',
'index.php?option=com_installer&view=languages',
'cog'
),
];
$headerIcons['MOD_MENU_INSTALL'] = 'download';
static::$notEmpty = true;
}
// Manage
if ($user->authorise('core.manage', 'com_installer'))
{
$links['MOD_MENU_MANAGE'] = [
'com_installer_manage' => static::arrayBuilder(
'MOD_MENU_MANAGE_EXTENSIONS',
'index.php?option=com_installer&view=manage',
'cog'
),
];
$headerIcons['MOD_MENU_MANAGE'] = 'refresh';
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_languages'))
{
$new = [
'com_languages_installed' => static::arrayBuilder(
'MOD_MENU_MANAGE_LANGUAGES',
'index.php?option=com_languages&view=installed',
'cog'
),
'com_languages_content' => static::arrayBuilder(
'MOD_MENU_MANAGE_LANGUAGES_CONTENT',
'index.php?option=com_languages&view=languages',
'cog'
),
'com_languages_overrides' => static::arrayBuilder(
'MOD_MENU_MANAGE_LANGUAGES_OVERRIDES',
'index.php?option=com_languages&view=overrides',
'cog'
),
];
if (!empty($links['MOD_MENU_MANAGE']))
{
$links['MOD_MENU_MANAGE'] = array_merge($links['MOD_MENU_MANAGE'], $new);
}
else
{
$links['MOD_MENU_MANAGE'] = $new;
$headerIcons['MOD_MENU_MANAGE'] = 'refresh';
}
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_csp'))
{
$new = [
'com_csp_main' => static::arrayBuilder(
'MOD_MENU_MANAGE_CSP',
'index.php?option=com_csp',
'cog'
),
];
if (!empty($links['MOD_MENU_MANAGE']))
{
$links['MOD_MENU_MANAGE'] = array_merge($links['MOD_MENU_MANAGE'], $new);
}
else
{
$links['MOD_MENU_MANAGE'] = $new;
$headerIcons['MOD_MENU_MANAGE'] = 'refresh';
}
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_plugins'))
{
$new = [
'com_plugins' => static::arrayBuilder(
'MOD_MENU_MANAGE_PLUGINS',
'index.php?option=com_plugins',
'cog'
),
];
if (!empty($links['MOD_MENU_MANAGE']))
{
$links['MOD_MENU_MANAGE'] = array_merge($links['MOD_MENU_MANAGE'], $new);
}
else
{
$links['MOD_MENU_MANAGE'] = $new;
$headerIcons['MOD_MENU_MANAGE'] = 'refresh';
}
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_redirect'))
{
$new = [
'com_redirect' => static::arrayBuilder(
'MOD_MENU_MANAGE_REDIRECTS',
'index.php?option=com_redirect',
'cog'
),
];
if (!empty($links['MOD_MENU_MANAGE']))
{
$links['MOD_MENU_MANAGE'] = array_merge($links['MOD_MENU_MANAGE'], $new);
}
else
{
$links['MOD_MENU_MANAGE'] = $new;
$headerIcons['MOD_MENU_MANAGE'] = 'refresh';
}
static::$notEmpty = true;
}
// Update
if ($user->authorise('core.manage', 'com_joomlaupdate'))
{
$links['MOD_MENU_UPDATE'] = [
'com_joomlaupdate' => static::arrayBuilder(
'MOD_MENU_UPDATE_JOOMLA',
'index.php?option=com_joomlaupdate',
'upload'
),
];
$headerIcons['MOD_MENU_UPDATE'] = 'upload';
static::$notEmpty = true;
}
if ($user->authorise('core.manage', 'com_installer'))
{
$new = [
'com_installer_extensions_update' => static::arrayBuilder(
'MOD_MENU_UPDATE_EXTENSIONS',
'index.php?option=com_installer&view=update',
'upload'
),
'com_installer_update_sites' => static::arrayBuilder(
'MOD_MENU_UPDATE_SOURCES',
'index.php?option=com_installer&view=updatesites',
'edit'
),
];
if (!empty($links['MOD_MENU_UPDATE']))
{
$links['MOD_MENU_UPDATE'] = array_merge($links['MOD_MENU_UPDATE'], $new);
}
else
{
$links['MOD_MENU_UPDATE'] = $new;
$headerIcons['MOD_MENU_UPDATE'] = 'upload';
}
static::$notEmpty = true;
}
// Templates
if ($user->authorise('core.manage', 'com_templates'))
{
// Site
$links['MOD_MENU_TEMPLATES'] = [
'com_templates' => static::arrayBuilder(
'MOD_MENU_TEMPLATE_SITE_TEMPLATES',
'index.php?option=com_templates&view=templates&client_id=0',
'edit'
),
'com_templates_site_styles' => static::arrayBuilder(
'MOD_MENU_TEMPLATE_SITE_STYLES',
'index.php?option=com_templates&view=styles&client_id=0',
'image'
),
// Admin
'com_templates_edit' => static::arrayBuilder(
'MOD_MENU_TEMPLATE_ADMIN_TEMPLATES',
'index.php?option=com_templates&view=templates&client_id=1',
'edit'
),
'com_templates_admin_styles' => static::arrayBuilder(
'MOD_MENU_TEMPLATE_ADMIN_STYLES',
'index.php?option=com_templates&view=styles&client_id=1',
'image'
),
];
$headerIcons['MOD_MENU_TEMPLATES'] = 'image';
static::$notEmpty = true;
}
// Access
if ($user->authorise('core.manage', 'com_users'))
{
// Site
$links['MOD_MENU_ACCESS'] = [
'com_users_groups' => static::arrayBuilder(
'MOD_MENU_ACCESS_GROUPS',
'index.php?option=com_users&view=groups',
'image'
),
'com_users_levels' => static::arrayBuilder(
'MOD_MENU_ACCESS_LEVELS',
'index.php?option=com_users&view=levels',
'image'
),
];
$headerIcons['MOD_MENU_ACCESS'] = 'lock';
static::$notEmpty = true;
}
// Global Configuration - Permissions and Filters
if ($user->authorise('core.admin'))
{
$new = [
'com_config_permissions' => static::arrayBuilder(
'MOD_MENU_ACCESS_SETTINGS',
'index.php?option=com_config#page-permissions',
'refresh'
),
'com_config_filters' => static::arrayBuilder(
'MOD_MENU_ACCESS_TEXT_FILTERS',
'index.php?option=com_config#page-filters',
'refresh'
),
];
if (!empty($links['MOD_MENU_ACCESS']))
{
$links['MOD_MENU_ACCESS'] = array_merge($links['MOD_MENU_ACCESS'], $new);
}
else
{
$links['MOD_MENU_ACCESS'] = $new;
$headerIcons['MOD_MENU_ACCESS'] = 'lock';
}
static::$notEmpty = true;
}
if (static::$notEmpty)
{
$this->links = $links;
$this->headerIcons = $headerIcons;
}
else
{
throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
Factory::getLanguage()->load(
'mod_menu',
JPATH_ADMINISTRATOR,
Factory::getLanguage()->getTag(),
true
);
return parent::display($tpl);
}
/**
* Helper function to build an array for each link
*
* @param string $name the name of the link
* @param string $link the url of the link
* @param string $icon the name of the icon
*
* @return array
*
* @since 4.0.0
*/
private static function arrayBuilder($name, $link, $icon): array
{
return [
'link' => $link,
'title' => $name,
'label' => $name . '_LBL',
'desc' => $name . '_DESC',
'icon' => $icon
];
}
}
No other release has this exact content. See every version of this file.