[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_media/src/Model/ -> FileModel.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\Model;
  12  
  13  use Joomla\CMS\Form\FormHelper;
  14  use Joomla\CMS\MVC\Model\FormModel;
  15  use Joomla\CMS\Plugin\PluginHelper;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * File Model
  23   *
  24   * @since  4.0.0
  25   */
  26  class FileModel extends FormModel
  27  {
  28      /**
  29       * Method to get the record form.
  30       *
  31       * @param   array    $data      Data for the form.
  32       * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
  33       *
  34       * @return  \Joomla\CMS\Form\Form|boolean  A Form object on success, false on failure
  35       *
  36       * @since   4.0.0
  37       */
  38      public function getForm($data = [], $loadData = true)
  39      {
  40          PluginHelper::importPlugin('media-action');
  41  
  42          // Load backend forms in frontend.
  43          FormHelper::addFormPath(JPATH_ADMINISTRATOR . '/components/com_media/forms');
  44  
  45          // Get the form.
  46          $form = $this->loadForm('com_media.file', 'file', ['control' => 'jform', 'load_data' => $loadData]);
  47  
  48          if (empty($form)) {
  49              return false;
  50          }
  51  
  52          return $form;
  53      }
  54  
  55      /**
  56       * Method to get the file information for the given path. Path must be
  57       * in the format: adapter:path/to/file.extension
  58       *
  59       * @param   string  $path  The path to get the information from.
  60       *
  61       * @return  \stdClass  An object with file information
  62       *
  63       * @since   4.0.0
  64       * @see     ApiModel::getFile()
  65       */
  66      public function getFileInformation($path)
  67      {
  68          list($adapter, $path) = explode(':', $path, 2);
  69  
  70          return $this->bootComponent('com_media')->getMVCFactory()->createModel('Api', 'Administrator')
  71              ->getFile($adapter, $path, ['url' => true, 'content' => true]);
  72      }
  73  }


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