Elgg  Version 1.9
tags.php
Go to the documentation of this file.
1 <?php
16 if (isset($vars['entity'])) {
17  $vars['tags'] = $vars['entity']->tags;
18  unset($vars['entity']);
19 }
20 
21 if (empty($vars['tags']) && (!empty($vars['value']) || $vars['value'] === 0 || $vars['value'] === '0')) {
22  $vars['tags'] = $vars['value'];
23 }
24 
25 if (empty($vars['tags']) && $vars['value'] !== 0 && $vars['value'] !== '0') {
26  return;
27 }
28 
29 if (!is_array($vars['tags'])) {
30  $vars['tags'] = array($vars['tags']);
31 }
32 
33 $list_class = "elgg-tags";
34 if (isset($vars['list_class'])) {
35  $list_class = "$list_class {$vars['list_class']}";
36 }
37 
38 $item_class = "elgg-tag";
39 if (isset($vars['item_class'])) {
40  $item_class = "$item_class {$vars['item_class']}";
41 }
42 
43 $icon_class = elgg_extract('icon_class', $vars);
45 
47 foreach($vars['tags'] as $tag) {
48  if (is_string($tag) && strlen($tag) > 0) {
49  $params['value'] = $tag;
50 
51  $list_items .= "<li class=\"$item_class\">";
52  $list_items .= elgg_view('output/tag', $params);
53  $list_items .= '</li>';
54  }
55 }
56 
57 if (empty($list_items)) {
58  return;
59 }
60 
62 
63 $list = <<<___HTML
64  <div class="clearfix">
65  <ul class="$list_class">
66  <li>$icon</li>
68  </ul>
69  </div>
70 ___HTML;
71 
72 echo $list;
ul
Definition: admin.php:44
elgg_view_icon($name, $class= '')
View one of the elgg sprite icons.
Definition: views.php:1370
if(isset($vars['entity'])) if(empty($vars['tags'])&&(!empty($vars['value'])||$vars['value']===0||$vars['value']=== '0')) if(empty($vars['tags'])&&$vars['value']!==0 &&$vars['value']!== '0') if(!is_array($vars['tags'])) $list_class
Elgg tags Tags can be a single string (for one tag) or an array of strings.
Definition: tags.php:33
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1464
fieldset div
Definition: admin.php:462
if(isset($vars['entity'])) $vars
Definition: tags.php:29
if(isset($vars['list_class'])) $item_class
Definition: tags.php:38
elgg echo
Translates a string.
Definition: languages.js:43
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
foreach($vars['tags'] as $tag) if(empty($list_items)) $icon
Definition: tags.php:61
elgg menu user li
Definition: admin.php:203
$list
Definition: tags.php:63
$list_items
Definition: tags.php:44
if(isset($vars['item_class'])) $icon_class
Definition: tags.php:43
$params
Definition: tags.php:46