Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
json.php
Aller à la documentation de ce fichier.
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 JSON Class
14  *
15  * This class decodes a JSON string from the raw request data and makes it available via
16  * the standard JInput interface.
17  *
18  * @package Joomla.Platform
19  * @subpackage Input
20  * @since 12.2
21  */
22 class JInputJSON extends JInput
23 {
24  /**
25  * @var string The raw JSON string from the request.
26  * @since 12.2
27  */
28  private $_raw;
29 
30  /**
31  * Constructor.
32  *
33  * @param array $source Source data (Optional, default is the raw HTTP input decoded from JSON)
34  * @param array $options Array of configuration parameters (Optional)
35  *
36  * @since 12.2
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  if (is_null($source))
50  {
51  $this->_raw = file_get_contents('php://input');
52  $this->data = json_decode($this->_raw, true);
53  }
54  else
55  {
56  $this->data = & $source;
57  }
58 
59  // Set the options for the class.
60  $this->options = $options;
61  }
62 
63  /**
64  * Gets the raw JSON string from the request.
65  *
66  * @return string The raw JSON string from the request.
67  *
68  * @since 12.2
69  */
70  public function getRaw()
71  {
72  return $this->_raw;
73  }
74 }