Elgg  Version 4.x
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 
77 function filter_tags($var) {
78  return elgg_trigger_plugin_hook('validate', 'input', null, $var);
79 }
80 
89 function current_page_url() {
90  return _elgg_services()->request->getCurrentURL();
91 }
92 
100 function is_email_address($address) {
101  return _elgg_services()->accounts->isValidEmail($address);
102 }
103 
116 function elgg_make_sticky_form($form_name, array $ignored_field_names = []): void {
117  _elgg_services()->stickyForms->makeStickyForm((string) $form_name, $ignored_field_names);
118 }
119 
132 function elgg_clear_sticky_form($form_name): void {
133  _elgg_services()->stickyForms->clearStickyForm((string) $form_name);
134 }
135 
144 function elgg_is_sticky_form($form_name): bool {
145  return _elgg_services()->stickyForms->isStickyForm((string) $form_name);
146 }
147 
160 function elgg_get_sticky_value($form_name, $variable = '', $default = null, $filter_result = true) {
161  return _elgg_services()->stickyForms->getStickyValue((string) $form_name, (string) $variable, $default, (bool) $filter_result);
162 }
163 
173 function elgg_get_sticky_values($form_name, $filter_result = true): array {
174  return _elgg_services()->stickyForms->getStickyValues((string) $form_name, (bool) $filter_result);
175 }
176 
186 function elgg_clear_sticky_value($form_name, $variable): void {
187  _elgg_services()->stickyForms->clearStickyValue((string) $form_name, (string) $variable);
188 }
189 
203 }
204 
219 function _elgg_htmlawed_tag_post_processor($element, $attributes = false) {
220  if ($attributes === false) {
221  // This is a closing tag. Prevent further processing to avoid inserting a duplicate tag
222  return "</${element}>";
223  }
224 
225  // this list should be coordinated with the WYSIWYG editor used (tinymce, ckeditor, etc.)
226  $allowed_styles = [
227  'color', 'cursor', 'text-align', 'vertical-align', 'font-size',
228  'font-weight', 'font-style', 'border', 'border-top', 'background-color',
229  'border-bottom', 'border-left', 'border-right',
230  'margin', 'margin-top', 'margin-bottom', 'margin-left',
231  'margin-right', 'padding', 'float', 'text-decoration'
232  ];
233 
234  $params = ['tag' => $element];
235  $allowed_styles = elgg_trigger_plugin_hook('allowed_styles', 'htmlawed', $params, $allowed_styles);
236 
237  // must return something.
238  $string = '';
239 
240  foreach ($attributes as $attr => $value) {
241  if ($attr == 'style') {
242  $styles = explode(';', $value);
243 
244  $style_str = '';
245  foreach ($styles as $style) {
246  if (!trim($style)) {
247  continue;
248  }
249  list($style_attr, $style_value) = explode(':', trim($style));
250  $style_attr = trim($style_attr);
251  $style_value = trim($style_value);
252 
253  if (in_array($style_attr, $allowed_styles)) {
254  $style_str .= "$style_attr: $style_value; ";
255  }
256  }
257 
258  if ($style_str) {
259  $style_str = trim($style_str);
260  $string .= " style=\"$style_str\"";
261  }
262  } else {
263  $string .= " $attr=\"$value\"";
264  }
265  }
266 
267  // Some WYSIWYG editors do not like tags like <p > so only add a space if needed.
268  if ($string = trim($string)) {
269  $string = " $string";
270  }
271 
272  $r = "<$element$string>";
273  return $r;
274 }
275 
284 function string_to_tag_array($string) {
285  if (!is_string($string)) {
286  return $string;
287  }
288 
289  $ar = explode(',', $string);
290  $ar = array_map('trim', $ar);
291 
292  $ar = array_filter($ar, function($string) {
293  if (($string === '') || ($string === false) || ($string === null)) {
294  return false;
295  }
296 
297  return true;
298  });
299 
300  $ar = array_map('strip_tags', $ar);
301  $ar = array_unique($ar);
302  return $ar;
303 }
$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
current_page_url()
Returns the current page&#39;s complete URL.
Definition: input.php:89
filter_tags($var)
Filter tags from a given string based on registered hooks.
Definition: input.php:77
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:201
is_email_address($address)
Validates an email address.
Definition: input.php:100
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:116
elgg_get_sticky_value($form_name, $variable= '', $default=null, $filter_result=true)
Get a specific value from cached form submission data.
Definition: input.php:160
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
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:219
$style
Definition: full.php:94
elgg_clear_sticky_value($form_name, $variable)
Remove one value of form submission data from the session.
Definition: input.php:186
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:777
elgg_is_sticky_form($form_name)
Does form submission data exist for this form?
Definition: input.php:144
elgg_clear_sticky_form($form_name)
Remove form submission data from the session.
Definition: input.php:132
$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:173
string_to_tag_array($string)
Takes in a comma-separated string and returns an array of tags which have been trimmed.
Definition: input.php:284