[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/joomla/input/src/ -> Files.php (source)

   1  <?php
   2  /**
   3   * Part of the Joomla Framework Input Package
   4   *
   5   * @copyright  Copyright (C) 2005 - 2022 Open Source Matters, Inc. All rights reserved.
   6   * @license    GNU General Public License version 2 or later; see LICENSE
   7   */
   8  
   9  namespace Joomla\Input;
  10  
  11  /**
  12   * Joomla! Input Files Class
  13   *
  14   * @since  1.0
  15   */
  16  class Files extends Input
  17  {
  18      /**
  19       * The pivoted data from a $_FILES or compatible array.
  20       *
  21       * @var    array
  22       * @since  1.0
  23       */
  24      protected $decodedData = [];
  25  
  26      /**
  27       * The class constructor.
  28       *
  29       * @param   array|null  $source   Source data (Optional, default is $_FILES)
  30       * @param   array       $options  Array of configuration parameters (Optional)
  31       *
  32       * @since   1.0
  33       */
  34  	public function __construct($source = null, array $options = [])
  35      {
  36          $source = $source ?? $_FILES;
  37          parent::__construct($source, $options);
  38      }
  39  
  40      /**
  41       * Gets a value from the input data.
  42       *
  43       * @param   string  $name     The name of the input property (usually the name of the files INPUT tag) to get.
  44       * @param   mixed   $default  The default value to return if the named property does not exist.
  45       * @param   string  $filter   The filter to apply to the value.
  46       *
  47       * @return  mixed  The filtered input value.
  48       *
  49       * @see     \Joomla\Filter\InputFilter::clean()
  50       * @since   1.0
  51       */
  52  	public function get($name, $default = null, $filter = 'cmd')
  53      {
  54          if (isset($this->data[$name]))
  55          {
  56              $results = $this->decodeData(
  57                  [
  58                      $this->data[$name]['name'],
  59                      $this->data[$name]['type'],
  60                      $this->data[$name]['tmp_name'],
  61                      $this->data[$name]['error'],
  62                      $this->data[$name]['size'],
  63                  ]
  64              );
  65  
  66              return $results;
  67          }
  68  
  69          return $default;
  70      }
  71  
  72      /**
  73       * Method to decode a data array.
  74       *
  75       * @param   array  $data  The data array to decode.
  76       *
  77       * @return  array
  78       *
  79       * @since   1.0
  80       */
  81  	protected function decodeData(array $data)
  82      {
  83          $result = [];
  84  
  85          if (\is_array($data[0]))
  86          {
  87              foreach ($data[0] as $k => $v)
  88              {
  89                  $result[$k] = $this->decodeData([$data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]]);
  90              }
  91  
  92              return $result;
  93          }
  94  
  95          return ['name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]];
  96      }
  97  
  98      /**
  99       * Sets a value.
 100       *
 101       * @param   string  $name   The name of the input property to set.
 102       * @param   mixed   $value  The value to assign to the input property.
 103       *
 104       * @return  void
 105       *
 106       * @since   1.0
 107       */
 108  	public function set($name, $value)
 109      {
 110          // Restricts the usage of parent's set method.
 111      }
 112  }


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