Elgg  Version 4.3
livesearch.php
Go to the documentation of this file.
1 <?php
9 
10 /* @var $request \Elgg\Http\Request */
11 $request = elgg_extract('request', $vars);
12 
13 // pass all input params (GET & POST) into $vars
14 $input_params = $request->getParams();
15 $ignored_inputs = ['view', '_route'];
16 foreach ($input_params as $name => $value) {
17  if (in_array($name, $ignored_inputs)) {
18  continue;
19  }
20 
21  // request can contain wrong value
23 
24  // set request param in $vars, but don't overrule already set values
25  // extract with false in order to replace empty value in $vars with request data
27 }
28 
29 $match_on = elgg_extract('match_on', $vars);
30 
31 // livesearch will result in a json response
32 elgg_set_viewtype('json');
33 
34 if (!elgg_view_exists("resources/livesearch/$match_on")) {
35  throw new PageNotFoundException();
36 }
37 
38 echo elgg_view("resources/livesearch/$match_on", $vars);
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:152
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
$request
Definition: livesearch.php:11
$ignored_inputs
Definition: livesearch.php:15
$input_params
Definition: livesearch.php:14
foreach($input_params as $name=> $value) $match_on
Definition: livesearch.php:29
$value
Definition: generic.php:51
Thrown when page is not accessible.
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
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:547
elgg echo
Translates a string.
Definition: deprecated.js:530
elgg_set_viewtype($viewtype= '')
Manually set the viewtype.
Definition: views.php:63
$vars['head']
Definition: html.php:24
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179