Elgg  Version 2.3
breadcrumbs.php
Go to the documentation of this file.
1 <?php
15 if (isset($vars['breadcrumbs'])) {
16  $breadcrumbs = $vars['breadcrumbs'];
17 } else {
18  $breadcrumbs = elgg_get_breadcrumbs();
19 }
20 
21 if (!is_array($breadcrumbs) || !$breadcrumbs) {
22  return;
23 }
24 
25 $attrs['class'] = elgg_extract_class($vars, ['elgg-menu', 'elgg-breadcrumbs']);
26 $lis = '';
27 
28 foreach ($breadcrumbs as $breadcrumb) {
29  // We have to escape text (without double-encoding). Titles in core plugins are HTML escaped
30  // on input, but we can't guarantee that other users of this view and of elgg_push_breadcrumb()
31  // will do so.
32  if (!empty($breadcrumb['link'])) {
33  $crumb = elgg_view('output/url', array(
34  'href' => $breadcrumb['link'],
35  'text' => $breadcrumb['title'],
36  'encode_text' => true,
37  'is_trusted' => true,
38  ));
39  } else {
40  $crumb = htmlspecialchars($breadcrumb['title'], ENT_QUOTES, 'UTF-8', false);
41  }
42 
43  $lis .= "<li>$crumb</li>";
44 }
45 
elgg_extract_class(array $array, $existing=[])
Extract class names from an array with key "class", optionally merging into a preexisting set...
Definition: elgglib.php:1396
$vars['entity']
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
elgg echo
Translates a string.
Definition: languages.js:48
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336