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