[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_modules/src/View/Select/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_modules
   6   *
   7   * @copyright   (C) 2009 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\Modules\Administrator\View\Select;
  12  
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\Layout\FileLayout;
  15  use Joomla\CMS\MVC\View\GenericDataException;
  16  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  17  use Joomla\CMS\Toolbar\Toolbar;
  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 Modules component
  26   *
  27   * @since  1.6
  28   */
  29  class HtmlView extends BaseHtmlView
  30  {
  31      /**
  32       * The model state
  33       *
  34       * @var  \Joomla\CMS\Object\CMSObject
  35       */
  36      protected $state;
  37  
  38      /**
  39       * An array of items
  40       *
  41       * @var  array
  42       */
  43      protected $items;
  44  
  45      /**
  46       * A suffix for links for modal use
  47       *
  48       * @var  string
  49       */
  50      protected $modalLink;
  51  
  52      /**
  53       * Display the view
  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          $this->state = $this->get('State');
  62          $this->items = $this->get('Items');
  63          $this->modalLink = '';
  64  
  65          // Check for errors.
  66          if (count($errors = $this->get('Errors'))) {
  67              throw new GenericDataException(implode("\n", $errors), 500);
  68          }
  69  
  70          $this->addToolbar();
  71          parent::display($tpl);
  72      }
  73  
  74      /**
  75       * Add the page title and toolbar.
  76       *
  77       * @return  void
  78       *
  79       * @since   1.6
  80       */
  81      protected function addToolbar()
  82      {
  83          $state    = $this->get('State');
  84          $clientId = (int) $state->get('client_id', 0);
  85  
  86          // Add page title
  87          ToolbarHelper::title(Text::_('COM_MODULES_MANAGER_MODULES_SITE'), 'cube module');
  88  
  89          if ($clientId === 1) {
  90              ToolbarHelper::title(Text::_('COM_MODULES_MANAGER_MODULES_ADMIN'), 'cube module');
  91          }
  92  
  93          // Get the toolbar object instance
  94          $bar = Toolbar::getInstance('toolbar');
  95  
  96          // Instantiate a new FileLayout instance and render the layout
  97          $layout = new FileLayout('toolbar.cancelselect');
  98  
  99          $bar->appendButton('Custom', $layout->render(array('client_id' => $clientId)), 'new');
 100      }
 101  }


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