Elgg  Version 4.3
input.php
Go to the documentation of this file.
1 <?php
20 function get_input($variable, $default = null, $filter_result = true) {
21  return _elgg_services()->request->getParam($variable, $default, $filter_result);
22 }
23 
34 function set_input($variable, $value) {
35  _elgg_services()->request->setParam($variable, $value, true);
36 }
37 
51 function elgg_get_request_data($filter_result = true) {
52  return _elgg_services()->request->getParams($filter_result);
53 }
54 
64 function elgg_get_title_input($variable = 'title', $default = '') {
65  $raw_input = get_input($variable, $default, false);
66  return htmlspecialchars($raw_input ?? '', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
67 }
68 
79  $input = elgg_trigger_deprecated_plugin_hook('validate', 'input', null, $input, "Use the 'sanitize', 'input' hook.", '4.3');
80  return elgg_trigger_plugin_hook('sanitize', 'input', null, $input);
81 }
82 
91 function elgg_is_valid_email(string $address): bool {
92  return _elgg_services()->accounts->isValidEmail($address);
93 }
94 
107 function elgg_make_sticky_form($form_name, array $ignored_field_names = []): void {
108  _elgg_services()->stickyForms->makeStickyForm((string) $form_name, $ignored_field_names);
109 }
110 
123 function elgg_clear_sticky_form($form_name): void {
124  _elgg_services()->stickyForms->clearStickyForm((string) $form_name);
125 }
126 
135 function elgg_is_sticky_form($form_name): bool {
136  return _elgg_services()->stickyForms->isStickyForm((string) $form_name);
137 }
138 
151 function elgg_get_sticky_value($form_name, $variable = '', $default = null, $filter_result = true) {
152  return _elgg_services()->stickyForms->getStickyValue((string) $form_name, (string) $variable, $default, (bool) $filter_result);
153 }
154 
164 function elgg_get_sticky_values($form_name, $filter_result = true): array {
165  return _elgg_services()->stickyForms->getStickyValues((string) $form_name, (bool) $filter_result);
166 }
167 
181 }
182 
197 function _elgg_htmlawed_tag_post_processor($element, $attributes = false) {
198  if ($attributes === false) {
199  // This is a closing tag. Prevent further processing to avoid inserting a duplicate tag
200  return "</${element}>";
201  }
202 
203  // this list should be coordinated with the WYSIWYG editor used (tinymce, ckeditor, etc.)
204  $allowed_styles = [
205  'color', 'cursor', 'text-align', 'vertical-align', 'font-size',
206  'font-weight', 'font-style', 'border', 'border-top', 'background-color',
207  'border-bottom', 'border-left', 'border-right',
208  'margin', 'margin-top', 'margin-bottom', 'margin-left',
209  'margin-right', 'padding', 'float', 'text-decoration'
210  ];
211 
212  $params = ['tag' => $element];
213  $allowed_styles = elgg_trigger_plugin_hook('allowed_styles', 'htmlawed', $params, $allowed_styles);
214 
215  // must return something.
216  $string = '';
217 
218  foreach ($attributes as $attr => $value) {
219  if ($attr == 'style') {
220  $styles = explode(';', $value);
221 
222  $style_str = '';
223  foreach ($styles as $style) {
224  if (!trim($style)) {
225  continue;
226  }
227  list($style_attr, $style_value) = explode(':', trim($style));
228  $style_attr = trim($style_attr);
229  $style_value = trim($style_value);
230 
231  if (in_array($style_attr, $allowed_styles)) {
232  $style_str .= "$style_attr: $style_value; ";
233  }
234  }
235 
236  if ($style_str) {
237  $style_str = trim($style_str);
238  $string .= " style=\"$style_str\"";
239  }
240  } else {
241  $string .= " $attr=\"$value\"";
242  }
243  }
244 
245  // Some WYSIWYG editors do not like tags like <p > so only add a space if needed.
246  if ($string = trim($string)) {
247  $string = " $string";
248  }
249 
250  $r = "<$element$string>";
251  return $r;
252 }
253 
262 function elgg_string_to_array(string $string): array {
263  $ar = explode(',', $string);
264  $ar = array_map('trim', $ar);
265  $ar = array_map('strip_tags', $ar);
266 
267  $ar = array_filter($ar, function($string) {
268  return !elgg_is_empty($string);
269  });
270 
271  $ar = array_unique($ar);
272 
273  // reset keys
274  return array_values($ar);
275 }
$default
Definition: checkbox.php:31
elgg_get_title_input($variable= 'title', $default= '')
Get an HTML-escaped title from input.
Definition: input.php:64
$params
Saves global plugin settings.
Definition: save.php:13
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
elgg_sanitize_input($input)
Filter input from a given string based on registered hooks.
Definition: input.php:78
elgg_string_to_array(string $string)
Takes in a comma-separated string and returns an array of uniquely trimmed and stripped strings...
Definition: input.php:262
static isEmpty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: Values.php:191
$value
Definition: generic.php:51
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:179
set_input($variable, $value)
Sets an input value that may later be retrieved by get_input.
Definition: input.php:34
elgg_make_sticky_form($form_name, array $ignored_field_names=[])
Save form submission data (all GET and POST vars) into a session cache.
Definition: input.php:107
elgg_get_sticky_value($form_name, $variable= '', $default=null, $filter_result=true)
Get a specific value from cached form submission data.
Definition: input.php:151
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
$input
Definition: input.php:9
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:380
_elgg_htmlawed_tag_post_processor($element, $attributes=false)
Post processor for tags in htmlawed.
Definition: input.php:197
elgg_trigger_deprecated_plugin_hook($hook, $type, $params=null, $returnvalue=null, $message=null, $version=null)
Trigger an plugin hook normally, but send a notice about deprecated use if any handlers are registere...
Definition: deprecation.php:39
elgg_is_valid_email(string $address)
Validates an email address.
Definition: input.php:91
$style
Definition: full.php:94
elgg_get_request_data($filter_result=true)
Returns all values parsed from the current request, including $_GET and $_POST values, as well as any values set with set_input()
Definition: input.php:51
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
elgg_is_sticky_form($form_name)
Does form submission data exist for this form?
Definition: input.php:135
elgg_clear_sticky_form($form_name)
Remove form submission data from the session.
Definition: input.php:123
$attributes
Elgg AJAX loader.
Definition: ajax_loader.php:10
elgg_get_sticky_values($form_name, $filter_result=true)
Get all submission data cached for a form.
Definition: input.php:164