Source for file files.php

Documentation is available at files.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Input
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM') or die;
  11.  
  12. /**
  13.  * Joomla! Input Files Class
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Input
  17.  * @since       11.1
  18.  */
  19. class JInputFiles extends JInput
  20. {
  21.     /**
  22.      * The pivoted data from a $_FILES or compatible array.
  23.      *
  24.      * @var    array 
  25.      * @since  11.1
  26.      */
  27.     protected $decodedData = array();
  28.  
  29.     /**
  30.      * The class constructor.
  31.      *
  32.      * @param   array  $source   The source argument is ignored. $_FILES is always used.
  33.      * @param   array  $options  An optional array of configuration options:
  34.      *                            filter : a custom JFilterInput object.
  35.      *
  36.      * @since   12.1
  37.      */
  38.     public function __construct(array $source = null, array $options = array())
  39.     {
  40.         if (isset($options['filter']))
  41.         {
  42.             $this->filter = $options['filter'];
  43.         }
  44.         else
  45.         {
  46.             $this->filter = JFilterInput::getInstance();
  47.         }
  48.  
  49.         // Set the data source.
  50.         $this->data = & $_FILES;
  51.  
  52.         // Set the options for the class.
  53.         $this->options = $options;
  54.     }
  55.  
  56.     /**
  57.      * Gets a value from the input data.
  58.      *
  59.      * @param   string  $name     The name of the input property (usually the name of the files INPUT tag) to get.
  60.      * @param   mixed   $default  The default value to return if the named property does not exist.
  61.      * @param   string  $filter   The filter to apply to the value.
  62.      *
  63.      * @return  mixed  The filtered input value.
  64.      *
  65.      * @see     JFilterInput::clean()
  66.      * @since   11.1
  67.      */
  68.     public function get($name, $default = null, $filter = 'cmd')
  69.     {
  70.         if (isset($this->data[$name]))
  71.         {
  72.             $results = $this->decodeData(
  73.                 array(
  74.                     $this->data[$name]['name'],
  75.                     $this->data[$name]['type'],
  76.                     $this->data[$name]['tmp_name'],
  77.                     $this->data[$name]['error'],
  78.                     $this->data[$name]['size']
  79.                 )
  80.             );
  81.  
  82.             return $results;
  83.         }
  84.  
  85.         return $default;
  86.  
  87.     }
  88.  
  89.     /**
  90.      * Method to decode a data array.
  91.      *
  92.      * @param   array  $data  The data array to decode.
  93.      *
  94.      * @return  array 
  95.      *
  96.      * @since   11.1
  97.      */
  98.     protected function decodeData(array $data)
  99.     {
  100.         $result = array();
  101.  
  102.         if (is_array($data[0]))
  103.         {
  104.             foreach ($data[0] as $k => $v)
  105.             {
  106.                 $result[$k] = $this->decodeData(array($data[0][$k], $data[1][$k], $data[2][$k], $data[3][$k], $data[4][$k]));
  107.             }
  108.             return $result;
  109.         }
  110.  
  111.         return array('name' => $data[0], 'type' => $data[1], 'tmp_name' => $data[2], 'error' => $data[3], 'size' => $data[4]);
  112.     }
  113.  
  114.     /**
  115.      * Sets a value.
  116.      *
  117.      * @param   string  $name   The name of the input property to set.
  118.      * @param   mixed   $value  The value to assign to the input property.
  119.      *
  120.      * @return  void 
  121.      *
  122.      * @since   11.1
  123.      */
  124.     public function set($name, $value)
  125.     {
  126.     }
  127. }

Documentation generated on Tue, 19 Nov 2013 15:03:13 +0100 by phpDocumentor 1.4.3