[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_config/src/View/Component/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_config
   6   *
   7   * @copyright   (C) 2013 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\Config\Administrator\View\Component;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  16  use Joomla\CMS\Toolbar\ToolbarHelper;
  17  use Joomla\Component\Config\Administrator\Helper\ConfigHelper;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * View for the component configuration
  25   *
  26   * @since  3.2
  27   */
  28  class HtmlView extends BaseHtmlView
  29  {
  30      /**
  31       * The model state
  32       *
  33       * @var    \Joomla\CMS\Object\CMSObject
  34       * @since  3.2
  35       */
  36      public $state;
  37  
  38      /**
  39       * The form object
  40       *
  41       * @var    \Joomla\CMS\Form\Form
  42       * @since  3.2
  43       */
  44      public $form;
  45  
  46      /**
  47       * An object with the information for the component
  48       *
  49       * @var    \Joomla\CMS\Component\ComponentRecord
  50       * @since  3.2
  51       */
  52      public $component;
  53  
  54      /**
  55       * Execute and display a template script.
  56       *
  57       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  58       *
  59       * @return  void
  60       *
  61       * @see     \JViewLegacy::loadTemplate()
  62       * @since   3.2
  63       */
  64      public function display($tpl = null)
  65      {
  66          try {
  67              $component = $this->get('component');
  68  
  69              if (!$component->enabled) {
  70                  return;
  71              }
  72  
  73              $form = $this->get('form');
  74              $user = $this->getCurrentUser();
  75          } catch (\Exception $e) {
  76              Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
  77  
  78              return;
  79          }
  80  
  81          $this->fieldsets   = $form ? $form->getFieldsets() : null;
  82          $this->formControl = $form ? $form->getFormControl() : null;
  83  
  84          // Don't show permissions fieldset if not authorised.
  85          if (!$user->authorise('core.admin', $component->option) && isset($this->fieldsets['permissions'])) {
  86              unset($this->fieldsets['permissions']);
  87          }
  88  
  89          $this->form = &$form;
  90          $this->component = &$component;
  91  
  92          $this->components = ConfigHelper::getComponentsWithConfig();
  93  
  94          $this->userIsSuperAdmin = $user->authorise('core.admin');
  95          $this->currentComponent = Factory::getApplication()->input->get('component');
  96          $this->return = Factory::getApplication()->input->get('return', '', 'base64');
  97  
  98          $this->addToolbar();
  99  
 100          parent::display($tpl);
 101      }
 102  
 103      /**
 104       * Add the page title and toolbar.
 105       *
 106       * @return  void
 107       *
 108       * @since   3.2
 109       */
 110      protected function addToolbar()
 111      {
 112          ToolbarHelper::title(Text::_($this->component->option . '_configuration'), 'cog config');
 113          ToolbarHelper::apply('component.apply');
 114          ToolbarHelper::divider();
 115          ToolbarHelper::save('component.save');
 116          ToolbarHelper::divider();
 117          ToolbarHelper::cancel('component.cancel', 'JTOOLBAR_CLOSE');
 118          ToolbarHelper::divider();
 119  
 120          $inlinehelp  = (string) $this->form->getXml()->config->inlinehelp['button'] == 'show' ?: false;
 121          $targetClass = (string) $this->form->getXml()->config->inlinehelp['targetclass'] ?: 'hide-aware-inline-help';
 122  
 123          if ($inlinehelp) {
 124              ToolbarHelper::inlinehelp($targetClass);
 125          }
 126  
 127          $helpUrl = $this->form->getData()->get('helpURL');
 128          $helpKey = (string) $this->form->getXml()->config->help['key'];
 129  
 130          // Try with legacy language key
 131          if (!$helpKey) {
 132              $language    = Factory::getApplication()->getLanguage();
 133              $languageKey = 'JHELP_COMPONENTS_' . strtoupper($this->currentComponent) . '_OPTIONS';
 134  
 135              if ($language->hasKey($languageKey)) {
 136                  $helpKey = $languageKey;
 137              }
 138          }
 139  
 140          ToolbarHelper::help($helpKey, (bool) $helpUrl, null, $this->currentComponent);
 141      }
 142  }


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