[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_languages/src/View/Language/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_languages
   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\Languages\Administrator\View\Language;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Helper\ContentHelper;
  15  use Joomla\CMS\Language\Text;
  16  use Joomla\CMS\MVC\View\GenericDataException;
  17  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  18  use Joomla\CMS\Object\CMSObject;
  19  use Joomla\CMS\Toolbar\ToolbarHelper;
  20  
  21  // phpcs:disable PSR1.Files.SideEffects
  22  \defined('_JEXEC') or die;
  23  // phpcs:enable PSR1.Files.SideEffects
  24  
  25  /**
  26   * HTML View class for the Languages component.
  27   *
  28   * @since  1.5
  29   */
  30  class HtmlView extends BaseHtmlView
  31  {
  32      /**
  33       * The active item
  34       *
  35       * @var  object
  36       */
  37      public $item;
  38  
  39      /**
  40       * The Form object
  41       *
  42       * @var  \Joomla\CMS\Form\Form
  43       */
  44      public $form;
  45  
  46      /**
  47       * The model state
  48       *
  49       * @var  CMSObject
  50       */
  51      public $state;
  52  
  53      /**
  54       * The actions the user is authorised to perform
  55       *
  56       * @var    CMSObject
  57       *
  58       * @since  4.0.0
  59       */
  60      protected $canDo;
  61  
  62      /**
  63       * Display the view.
  64       *
  65       * @param   string  $tpl  The name of the template file to parse.
  66       *
  67       * @return  void
  68       */
  69      public function display($tpl = null)
  70      {
  71          $this->item  = $this->get('Item');
  72          $this->form  = $this->get('Form');
  73          $this->state = $this->get('State');
  74          $this->canDo = ContentHelper::getActions('com_languages');
  75  
  76          // Check for errors.
  77          if (count($errors = $this->get('Errors'))) {
  78              throw new GenericDataException(implode("\n", $errors), 500);
  79          }
  80  
  81          $this->addToolbar();
  82          parent::display($tpl);
  83      }
  84  
  85      /**
  86       * Add the page title and toolbar.
  87       *
  88       * @return  void
  89       *
  90       * @since   1.6
  91       */
  92      protected function addToolbar()
  93      {
  94          Factory::getApplication()->input->set('hidemainmenu', 1);
  95          $isNew = empty($this->item->lang_id);
  96          $canDo = $this->canDo;
  97  
  98          ToolbarHelper::title(
  99              Text::_($isNew ? 'COM_LANGUAGES_VIEW_LANGUAGE_EDIT_NEW_TITLE' : 'COM_LANGUAGES_VIEW_LANGUAGE_EDIT_EDIT_TITLE'),
 100              'comments-2 langmanager'
 101          );
 102  
 103          $toolbarButtons = [];
 104  
 105          if (($isNew && $canDo->get('core.create')) || (!$isNew && $canDo->get('core.edit'))) {
 106              ToolbarHelper::apply('language.apply');
 107  
 108              $toolbarButtons[] = ['save', 'language.save'];
 109          }
 110  
 111          // If an existing item, can save to a copy only if we have create rights.
 112          if ($canDo->get('core.create')) {
 113              $toolbarButtons[] = ['save2new', 'language.save2new'];
 114          }
 115  
 116          ToolbarHelper::saveGroup(
 117              $toolbarButtons,
 118              'btn-success'
 119          );
 120  
 121          if ($isNew) {
 122              ToolbarHelper::cancel('language.cancel');
 123          } else {
 124              ToolbarHelper::cancel('language.cancel', 'JTOOLBAR_CLOSE');
 125          }
 126  
 127          ToolbarHelper::divider();
 128          ToolbarHelper::help('Languages:_Edit_Content_Language');
 129      }
 130  }


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