PluginListTags.php 1.89 KB
Newer Older
Penny Leach's avatar
Penny Leach committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {list_tags} function plugin
 *
 * Type:     function<br>
 * Name:     str<br>
 * Date:     June 22, 2006<br>
 * Purpose:  Render a list of tags
 * @author   Richard Mansfield <richard.mansfield@catalyst.net.nz>
 * @author   Penny Leach <penny@mjollnir.org>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return Internationalized string
 */
23
24
25
use Dwoo\Core;

function PluginListTags(Core $core, $tags, $owner, $view = null) {
Penny Leach's avatar
Penny Leach committed
26
27
28
29
    global $USER;
    if (!is_array($tags)) {
        return '';
    }
30
31
32
    if ($view) {
        $viewobj= new View($view);
    }
Penny Leach's avatar
Penny Leach committed
33
    foreach ($tags as &$t) {
34
35
36
37
        if ($view && !$viewobj->get('owner')) {
            $t = (is_array($t) ? hsc(str_shorten_text($t['tag'], 50)) : hsc(str_shorten_text($t, 50)));
        }
        else if ($owner != $USER->get('id')) {
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
            if (is_array($t)) {
                $t = '<a class="tag" href="' . get_config('wwwroot') . 'relatedtags.php?tag=' . urlencode($t['tag']) . '&view=' . $t['view'] . '">' . hsc(str_shorten_text($t['tag'], 50)) . '</a>';
            }
            else if ($view) {
                $t = '<a class="tag" href="' . get_config('wwwroot') . 'relatedtags.php?tag=' . urlencode($t) . '&view=' . $view . '">' . hsc(str_shorten_text($t, 50)) . '</a>';
            }
            else {
                $t = hsc(str_shorten_text($t, 50));
            }
        }
        else {
            if (is_array($t)) {
                $t = '<a class="tag" href="' . get_config('wwwroot') . 'tags.php?tag=' . urlencode($t['tag']) . '&view=' . $t['view'] . '">' . hsc(str_shorten_text($t['tag'], 50)) . '</a>';
            }
            else {
                $t = '<a class="tag" href="' . get_config('wwwroot') . 'tags.php?tag=' . urlencode($t) . '">' . hsc(str_shorten_text($t, 50)) . '</a>';
            }
        }
Penny Leach's avatar
Penny Leach committed
56
    }
57

Penny Leach's avatar
Penny Leach committed
58
59
60
61
    return join(', ', $tags);
}

?>