Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
Input.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Http;
3 
14 class Input {
20  private $CONFIG;
21 
25  public function __construct() {
26  global $CONFIG;
27  $this->CONFIG = $CONFIG;
28  }
29 
40  public function set($variable, $value) {
41 
42  if (!isset($this->CONFIG->input)) {
43  $this->CONFIG->input = array();
44  }
45 
46  if (is_array($value)) {
47  array_walk_recursive($value, create_function('&$v, $k', '$v = trim($v);'));
48  $this->CONFIG->input[trim($variable)] = $value;
49  } else {
50  $this->CONFIG->input[trim($variable)] = trim($value);
51  }
52  }
53 
54 
72  function get($variable, $default = null, $filter_result = true) {
73 
74 
75 
76  $result = $default;
77 
78  elgg_push_context('input');
79 
80  if (isset($this->CONFIG->input[$variable])) {
81  // a plugin has already set this variable
82  $result = $this->CONFIG->input[$variable];
83  if ($filter_result) {
85  }
86  } else {
87  $request = _elgg_services()->request;
88  $value = $request->get($variable);
89  if ($value !== null) {
90  $result = $value;
91  if (is_string($result)) {
92  // @todo why trim
93  $result = trim($result);
94  }
95 
96  if ($filter_result) {
98  }
99  }
100  }
101 
103 
104  return $result;
105 
106  }
107 }
__construct()
Constructor.
Definition: Input.php:25
$value
Definition: longtext.php:26
$default
Definition: checkbox.php:35
filter_tags($var)
Filter tags from a given string based on registered hooks.
Definition: input.php:53
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: pageowner.php:225
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
set($variable, $value)
Sets an input value that may later be retrieved by get_input.
Definition: Input.php:40
elgg_push_context($context)
Push a context onto the top of the stack.
Definition: pageowner.php:215