[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_banners/src/View/Tracks/ -> RawView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_banners
   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\Banners\Administrator\View\Tracks;
  12  
  13  use Exception;
  14  use Joomla\CMS\Application\CMSApplication;
  15  use Joomla\CMS\Factory;
  16  use Joomla\CMS\MVC\View\GenericDataException;
  17  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  18  use Joomla\Component\Banners\Administrator\Model\TracksModel;
  19  
  20  // phpcs:disable PSR1.Files.SideEffects
  21  \defined('_JEXEC') or die;
  22  // phpcs:enable PSR1.Files.SideEffects
  23  
  24  /**
  25   * View class for a list of tracks.
  26   *
  27   * @since  1.6
  28   */
  29  class RawView extends BaseHtmlView
  30  {
  31      /**
  32       * Display the view
  33       *
  34       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  35       *
  36       * @return  void
  37       *
  38       * @since   1.6
  39       *
  40       * @throws  Exception
  41       */
  42      public function display($tpl = null): void
  43      {
  44          /** @var TracksModel $model */
  45          $model    = $this->getModel();
  46          $basename = $model->getBaseName();
  47          $fileType = $model->getFileType();
  48          $mimeType = $model->getMimeType();
  49          $content  = $model->getContent();
  50  
  51          // Check for errors.
  52          if (\count($errors = $this->get('Errors'))) {
  53              throw new GenericDataException(implode("\n", $errors), 500);
  54          }
  55  
  56          $this->document->setMimeEncoding($mimeType);
  57  
  58          /** @var CMSApplication $app */
  59          $app = Factory::getApplication();
  60          $app->setHeader(
  61              'Content-disposition',
  62              'attachment; filename="' . $basename . '.' . $fileType . '"; creation-date="' . Factory::getDate()->toRFC822() . '"',
  63              true
  64          );
  65          echo $content;
  66      }
  67  }


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