Elgg  Version 3.0
tags.php
Go to the documentation of this file.
1 <?php
2 
16 if (isset($vars['entity'])) {
17  $vars['tags'] = elgg_extract('entity', $vars)->tags;
18  unset($vars['entity']);
19 }
20 
22 unset($vars['value']);
23 if (empty($vars['tags']) && (!empty($value) || $value === 0 || $value === '0')) {
24  $vars['tags'] = $value;
25 }
26 
27 if (empty($vars['tags']) && $value !== 0 && $value !== '0') {
28  return;
29 }
30 
32 unset($vars['tags']);
33 
34 if (!is_array($tags)) {
35  $tags = [$tags];
36 }
37 
38 $list_class = elgg_extract_class($vars, 'elgg-tags', 'list_class');
39 unset($vars['list_class']);
40 
41 $item_class = elgg_extract_class($vars, 'elgg-tag', 'item_class');
42 unset($vars['item_class']);
43 
44 $icon_name = elgg_extract('icon', $vars, 'tag');
45 unset($vars['icon']);
46 
47 $icon_class = elgg_extract_class($vars, [], 'icon_class');
48 unset($vars['icon_class']);
49 
50 if ($icon_name === false) {
51  $icon = '';
52 } else {
53  $icon = elgg_view_icon($icon_name, ['class' => $icon_class]);
54 }
55 
56 $separator = elgg_extract('separator', $vars, ', ');
57 unset($vars['separator']);
58 
60 
62 foreach ($tags as $tag) {
63  if (is_scalar($tag) && strlen($tag) > 0) {
64  $params['value'] = $tag;
65  $tag_view = elgg_view('output/tag', $params);
67  '#tag_name' => 'span',
68  '#text' => $tag_view,
69  'class' => $item_class,
70  ]);
71  }
72 }
73 
74 if (empty($list_items)) {
75  return;
76 }
77 
79  '#tag_name' => 'div',
80  '#text' => $icon . implode($separator, $list_items),
81  'class' => $list_class,
82 ]);
$icon_class
Definition: tags.php:47
$icon_name
Definition: tags.php:44
$vars['class']
Elgg tag input Displays a tag input field.
Definition: tags.php:12
if(!is_string($title)||$title=== '') $tag
Definition: title.php:19
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
$item_class
Definition: tags.php:41
if(!$owner) $icon
Definition: default.php:16
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
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
$separator
Definition: tags.php:56
elgg_view_icon($name, $vars=[])
View an icon glyph.
Definition: views.php:1552
$list_items
Definition: tags.php:59
if(isset($vars['entity'])) $value
Elgg tags Tags can be a single string (for one tag) or an array of strings.
Definition: tags.php:21
$tags
Output object tags.
Definition: tags.php:9
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
$params
Definition: tags.php:61
if(!is_array($tags)) $list_class
Definition: tags.php:38