Хранилища Subversion ant

Редакция

Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
/**
3
 * Smarty plugin
4
 * @package Smarty
5
 * @subpackage PluginsFunction
6
 */
7
 
8
 
9
/**
10
 * Smarty {popup} function plugin
11
 *
12
 * Type:     function<br>
13
 * Name:     popup<br>
14
 * Purpose:  make text pop up in windows via overlib
15
 * @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
16
 *          (Smarty online manual)
17
 * @author   Monte Ohrt <monte at ohrt dot com>
18
 * @param array $params parameters
19
 * @param object $smarty Smarty object
20
 * @param object $template template object
21
 * @return string
22
 */
23
function smarty_function_popup($params, $smarty, $template)
24
{
25
    $append = '';
26
    foreach ($params as $_key=>$_value) {
27
        switch ($_key) {
28
            case 'text':
29
            case 'trigger':
30
            case 'function':
31
            case 'inarray':
32
                $$_key = (string)$_value;
33
                if ($_key == 'function' || $_key == 'inarray')
34
                    $append .= ',' . strtoupper($_key) . ",'$_value'";
35
                break;
36
 
37
            case 'caption':
38
            case 'closetext':
39
            case 'status':
40
                $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
41
                break;
42
 
43
            case 'fgcolor':
44
            case 'bgcolor':
45
            case 'textcolor':
46
            case 'capcolor':
47
            case 'closecolor':
48
            case 'textfont':
49
            case 'captionfont':
50
            case 'closefont':
51
            case 'fgbackground':
52
            case 'bgbackground':
53
            case 'caparray':
54
            case 'capicon':
55
            case 'background':
56
            case 'frame':
57
                $append .= ',' . strtoupper($_key) . ",'$_value'";
58
                break;
59
 
60
            case 'textsize':
61
            case 'captionsize':
62
            case 'closesize':
63
            case 'width':
64
            case 'height':
65
            case 'border':
66
            case 'offsetx':
67
            case 'offsety':
68
            case 'snapx':
69
            case 'snapy':
70
            case 'fixx':
71
            case 'fixy':
72
            case 'padx':
73
            case 'pady':
74
            case 'timeout':
75
            case 'delay':
76
                $append .= ',' . strtoupper($_key) . ",$_value";
77
                break;
78
 
79
            case 'sticky':
80
            case 'left':
81
            case 'right':
82
            case 'center':
83
            case 'above':
84
            case 'below':
85
            case 'noclose':
86
            case 'autostatus':
87
            case 'autostatuscap':
88
            case 'fullhtml':
89
            case 'hauto':
90
            case 'vauto':
91
            case 'mouseoff':
92
            case 'followmouse':
93
            case 'closeclick':
94
            case 'wrap':
95
                if ($_value) $append .= ',' . strtoupper($_key);
96
                break;
97
 
98
            default:
99
                throw new Exception ("[popup] unknown parameter $_key", E_USER_WARNING);
100
        }
101
    }
102
 
103
    if (empty($text) && !isset($inarray) && empty($function)) {
104
        throw new Exception ("overlib: attribute 'text' or 'inarray' or 'function' required");
105
        return false;
106
    }
107
 
108
    if (empty($trigger)) { $trigger = "onmouseover"; }
109
 
110
    $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!",'!"!',"![\r\n]!"),array("\'","\'",'\r'),$text).'\'';
111
    $retval .= $append . ');"';
112
    if ($trigger == 'onmouseover')
113
       $retval .= ' onmouseout="nd();"';
114
 
115
 
116
    return $retval;
117
}
118
?>