Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
tags.php
Go to the documentation of this file.
1 <?php
13 if (isset($vars['entity'])) {
14  $vars['tags'] = $vars['entity']->tags;
15  unset($vars['entity']);
16 }
17 
19 unset($vars['value']);
20 if (empty($vars['tags']) && (!empty($value) || $value === 0 || $value === '0')) {
21  $vars['tags'] = $value;
22 }
23 
24 if (empty($vars['tags']) && $value !== 0 && $value !== '0') {
25  return;
26 }
27 
28 $tags = $vars['tags'];
29 unset($vars['tags']);
30 
31 if (!is_array($tags)) {
32  $tags = array($tags);
33 }
34 
35 $list_class = "elgg-tags";
36 if (isset($vars['list_class'])) {
37  $list_class = "$list_class {$vars['list_class']}";
38  unset($vars['list_class']);
39 }
40 
41 $item_class = "elgg-tag";
42 if (isset($vars['item_class'])) {
43  $item_class = "$item_class {$vars['item_class']}";
44  unset($vars['item_class']);
45 }
46 
47 $icon_class = elgg_extract('icon_class', $vars);
48 unset($vars['icon_class']);
49 
51 
53 foreach($tags as $tag) {
54  if (is_string($tag) && strlen($tag) > 0) {
55  $params['value'] = $tag;
56 
57  $list_items .= "<li class=\"$item_class\">";
58  $list_items .= elgg_view('output/tag', $params);
59  $list_items .= '</li>';
60  }
61 }
62 
63 if (empty($list_items)) {
64  return;
65 }
66 
68 
69 $list = <<<___HTML
70  <div class="clearfix">
71  <ul class="$list_class">
72  <li>$icon</li>
74  </ul>
75  </div>
76 ___HTML;
77 
78 echo $list;
elgg_view_icon($name, $vars=array())
View one of the icons.
Definition: views.php:1447
$vars['class']
Elgg tag input Displays a tag input field.
Definition: tags.php:12
foreach($tags as $tag) if(empty($list_items)) $icon
Definition: tags.php:67
if(empty($vars['tags'])&&(!empty($value)||$value===0||$value=== '0')) if(empty($vars['tags'])&&$value!==0 &&$value!== '0') $tags
Definition: tags.php:28
ul
Definition: admin.css.php:44
if(isset($vars['list_class'])) $item_class
Definition: tags.php:41
elgg river comments li
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
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:1310
$list
Definition: tags.php:69
$list_items
Definition: tags.php:50
if(isset($vars['entity'])) $value
Elgg tags Tags can be a single string (for one tag) or an array of strings.
Definition: tags.php:18
if(isset($vars['item_class'])) $icon_class
Definition: tags.php:47
$params
Definition: tags.php:52
if(!is_array($tags)) $list_class
Definition: tags.php:35