[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_banners/src/Model/ -> DownloadModel.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\Model;
  12  
  13  use Joomla\CMS\Application\ApplicationHelper;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\MVC\Model\FormModel;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Download model.
  23   *
  24   * @since  1.5
  25   */
  26  class DownloadModel extends FormModel
  27  {
  28      /**
  29       * The model context
  30       *
  31       * @var  string
  32       */
  33      protected $_context = 'com_banners.tracks';
  34  
  35      /**
  36       * Auto-populate the model state.
  37       *
  38       * Note. Calling getState in this method will result in recursion.
  39       *
  40       * @return  void
  41       *
  42       * @since   1.6
  43       */
  44      protected function populateState()
  45      {
  46          $input = Factory::getApplication()->input;
  47  
  48          $this->setState('basename', $input->cookie->getString(ApplicationHelper::getHash($this->_context . '.basename'), '__SITE__'));
  49          $this->setState('compressed', $input->cookie->getInt(ApplicationHelper::getHash($this->_context . '.compressed'), 1));
  50      }
  51  
  52      /**
  53       * Method to get the record form.
  54       *
  55       * @param   array    $data      Data for the form.
  56       * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  57       *
  58       * @return  \Joomla\CMS\Form\Form|boolean  A Form object on success, false on failure
  59       *
  60       * @since   1.6
  61       */
  62      public function getForm($data = array(), $loadData = true)
  63      {
  64          // Get the form.
  65          $form = $this->loadForm('com_banners.download', 'download', array('control' => 'jform', 'load_data' => $loadData));
  66  
  67          if (empty($form)) {
  68              return false;
  69          }
  70  
  71          return $form;
  72      }
  73  
  74      /**
  75       * Method to get the data that should be injected in the form.
  76       *
  77       * @return  mixed  The data for the form.
  78       *
  79       * @since   1.6
  80       */
  81      protected function loadFormData()
  82      {
  83          $data = (object) array(
  84              'basename'   => $this->getState('basename'),
  85              'compressed' => $this->getState('compressed'),
  86          );
  87  
  88          $this->preprocessData('com_banners.download', $data);
  89  
  90          return $data;
  91      }
  92  }


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