Elgg  Version 5.1
url.php
Go to the documentation of this file.
1 <?php
8 $item = elgg_extract('item', $vars);
9 if (!$item instanceof \ElggMenuItem) {
10  return;
11 }
12 
13 unset($vars['item']);
14 
15 $vars = array_merge($item->getValues(), $vars);
16 $vars['class'] = elgg_extract_class($vars, ['elgg-menu-content']);
17 
18 if ($item->getLinkClass()) {
19  $vars['class'] = array_merge($vars['class'], explode(' ', $item->getLinkClass()));
20 }
21 
22 if ($item->getHref() === false || $item->getHref() === null) {
23  $vars['class'][] = 'elgg-non-link';
24 }
25 
26 if (!isset($vars['rel']) && !isset($vars['is_trusted'])) {
27  $vars['is_trusted'] = true;
28 }
29 
30 if ($item->getConfirmText()) {
31  $vars['confirm'] = $item->getConfirmText();
32 }
33 
34 if (isset($vars['badge']) && is_numeric($vars['badge'])) {
35  $vars['badge'] = \Elgg\Values::shortFormatOutput($vars['badge'], 1);
36 }
37 
38 echo elgg_view('output/url', $vars);
$item
Output an ElggMenuItem as an url.
Definition: url.php:8
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:276
Elgg Menu Item.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
static shortFormatOutput($n, $precision=0)
Use to convert large positive numbers in to short form like 1K, 1M, 1B or 1T Example: shortFormatOutp...
Definition: Values.php:211
$vars['class']
Definition: url.php:11