Elgg  Version 3.0
livesearch.php
Go to the documentation of this file.
1 <?php
8 /* @var $request \Elgg\Http\Request */
9 $request = elgg_extract('request', $vars);
10 
11 // pass all input params (GET & POST) into $vars
12 $input_params = $request->getParams();
13 $ignored_inputs = ['view', '_route'];
14 foreach ($input_params as $name => $value) {
15  if (in_array($name, $ignored_inputs)) {
16  continue;
17  }
18 
19  // request can contain wrong value
21 
22  // set request param in $vars, but don't overrule already set values
23  // extract with false in order to replace empty value in $vars with request data
25 }
26 
27 $match_on = elgg_extract('match_on', $vars);
28 
29 // livesearch will result in a json response
30 elgg_set_viewtype('json');
31 
32 if (!elgg_view_exists("resources/livesearch/$match_on")) {
33  throw new \Elgg\PageNotFoundException();
34 }
35 
36 echo elgg_view("resources/livesearch/$match_on", $vars);
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:205
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
$request
Page handler for autocomplete endpoint.
Definition: livesearch.php:9
$ignored_inputs
Definition: livesearch.php:13
$input_params
Definition: livesearch.php:12
foreach($input_params as $name=> $value) $match_on
Definition: livesearch.php:27
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$value
Definition: debugging.php:7
$vars['type']
Definition: save.php:11
elgg_set_viewtype($viewtype= '')
Manually set the viewtype.
Definition: views.php:65
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246