[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_cpanel/src/View/Cpanel/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_cpanel
   6   *
   7   * @copyright   (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Cpanel\Administrator\View\Cpanel;
  12  
  13  use Joomla\CMS\Application\ApplicationHelper;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Helper\ModuleHelper;
  16  use Joomla\CMS\Language\Text;
  17  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  18  use Joomla\CMS\Toolbar\ToolbarHelper;
  19  
  20  // phpcs:disable PSR1.Files.SideEffects
  21  \defined('_JEXEC') or die;
  22  // phpcs:enable PSR1.Files.SideEffects
  23  
  24  /**
  25   * HTML View class for the Cpanel component
  26   *
  27   * @since  1.0
  28   */
  29  class HtmlView extends BaseHtmlView
  30  {
  31      /**
  32       * Array of cpanel modules
  33       *
  34       * @var  array
  35       */
  36      protected $modules = null;
  37  
  38      /**
  39       * Array of cpanel modules
  40       *
  41       * @var  array
  42       */
  43      protected $quickicons = null;
  44  
  45      /**
  46       * Moduleposition to load
  47       *
  48       * @var  string
  49       */
  50      protected $position = null;
  51  
  52      /**
  53       * Execute and display a template script.
  54       *
  55       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  56       *
  57       * @return  void
  58       */
  59      public function display($tpl = null)
  60      {
  61          $app = Factory::getApplication();
  62          $dashboard = $app->input->getCmd('dashboard', '');
  63  
  64          $position = ApplicationHelper::stringURLSafe($dashboard);
  65  
  66          // Generate a title for the view cpanel
  67          if (!empty($dashboard)) {
  68              $parts     = explode('.', $dashboard);
  69              $component = $parts[0];
  70  
  71              if (strpos($component, 'com_') === false) {
  72                  $component = 'com_' . $component;
  73              }
  74  
  75              // Need to load the language file
  76              $lang = Factory::getLanguage();
  77              $lang->load($component, JPATH_BASE)
  78              || $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component);
  79              $lang->load($component);
  80  
  81              // Lookup dashboard attributes from component manifest file
  82              $manifestFile = JPATH_ADMINISTRATOR . '/components/' . $component . '/' . str_replace('com_', '', $component) . '.xml';
  83  
  84              if (is_file($manifestFile)) {
  85                  $manifest = simplexml_load_file($manifestFile);
  86  
  87                  if ($dashboardManifests = $manifest->dashboards) {
  88                      foreach ($dashboardManifests->children() as $dashboardManifest) {
  89                          if ((string) $dashboardManifest === $dashboard) {
  90                              $title = Text::_((string) $dashboardManifest->attributes()->title);
  91                              $icon  = (string) $dashboardManifest->attributes()->icon;
  92  
  93                              break;
  94                          }
  95                      }
  96                  }
  97              }
  98  
  99              if (empty($title)) {
 100                  // Try building a title
 101                  $prefix = strtoupper($component) . '_DASHBOARD';
 102  
 103                  $sectionkey = !empty($parts[1]) ? '_' . strtoupper($parts[1]) : '';
 104                  $key = $prefix . $sectionkey . '_TITLE';
 105                  $keyIcon = $prefix . $sectionkey . '_ICON';
 106  
 107                  // Search for a component title
 108                  if ($lang->hasKey($key)) {
 109                      $title = Text::_($key);
 110                  } else {
 111                      // Try with a string from CPanel
 112                      $key = 'COM_CPANEL_DASHBOARD_' . $parts[0] . '_TITLE';
 113  
 114                      if ($lang->hasKey($key)) {
 115                          $title = Text::_($key);
 116                      } else {
 117                          $title = Text::_('COM_CPANEL_DASHBOARD_BASE_TITLE');
 118                      }
 119                  }
 120  
 121                  // Define the icon
 122                  if (empty($parts[1])) {
 123                      // Default core icons.
 124                      if ($parts[0] === 'components') {
 125                          $icon = 'icon-puzzle-piece';
 126                      } elseif ($parts[0] === 'system') {
 127                          $icon = 'icon-wrench';
 128                      } elseif ($parts[0] === 'help') {
 129                          $icon = 'icon-info-circle';
 130                      } elseif ($lang->hasKey($keyIcon)) {
 131                          $icon = Text::_($keyIcon);
 132                      } else {
 133                          $icon = 'icon-home';
 134                      }
 135                  } elseif ($lang->hasKey($keyIcon)) {
 136                      $icon = Text::_($keyIcon);
 137                  }
 138              }
 139          } else {
 140              // Home Dashboard
 141              $title = Text::_('COM_CPANEL_DASHBOARD_BASE_TITLE');
 142              $icon = 'icon-home';
 143          }
 144  
 145          // Set toolbar items for the page
 146          ToolbarHelper::title($title, $icon . ' cpanel');
 147          ToolbarHelper::help('screen.cpanel');
 148  
 149          // Display the cpanel modules
 150          $this->position = $position ? 'cpanel-' . $position : 'cpanel';
 151          $this->modules = ModuleHelper::getModules($this->position);
 152  
 153          $quickicons = $position ? 'icon-' . $position : 'icon';
 154          $this->quickicons = ModuleHelper::getModules($quickicons);
 155  
 156          parent::display($tpl);
 157      }
 158  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer