[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_media/src/View/File/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_media
   6   *
   7   * @copyright   (C) 2017 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\Media\Administrator\View\File;
  12  
  13  use Joomla\CMS\Component\ComponentHelper;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Language\Text;
  16  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  17  use Joomla\CMS\Toolbar\ToolbarHelper;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * View to edit a file.
  25   *
  26   * @since  4.0.0
  27   */
  28  class HtmlView extends BaseHtmlView
  29  {
  30      /**
  31       * Execute and display a template script.
  32       *
  33       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  34       *
  35       * @return  void
  36       *
  37       * @since   4.0.0
  38       */
  39      public function display($tpl = null)
  40      {
  41          $input = Factory::getApplication()->input;
  42  
  43          $this->form = $this->get('Form');
  44  
  45          // The component params
  46          $this->params = ComponentHelper::getParams('com_media');
  47  
  48          // The requested file
  49          $this->file = $this->getModel()->getFileInformation($input->getString('path', null));
  50  
  51          if (empty($this->file->content)) {
  52              // @todo error handling controller redirect files
  53              throw new \Exception(Text::_('COM_MEDIA_ERROR_NO_CONTENT_AVAILABLE'));
  54          }
  55  
  56          $this->addToolbar();
  57  
  58          parent::display($tpl);
  59      }
  60  
  61      /**
  62       * Add the toolbar buttons
  63       *
  64       * @return  void
  65       *
  66       * @since   4.0.0
  67       */
  68      protected function addToolbar()
  69      {
  70          ToolbarHelper::title(Text::_('COM_MEDIA_EDIT'), 'images mediamanager');
  71  
  72          ToolbarHelper::apply('apply');
  73          ToolbarHelper::save('save');
  74          ToolbarHelper::custom('reset', 'refresh', '', 'COM_MEDIA_RESET', false);
  75  
  76          ToolbarHelper::cancel('cancel', 'JTOOLBAR_CLOSE');
  77      }
  78  }


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