1 |
<?php |
2 |
/** |
3 |
* Smarty plugin |
4 |
* @package Smarty |
5 |
* @subpackage plugins |
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 |
* @param array |
18 |
* @param Smarty |
19 |
* @return string |
20 |
*/ |
21 |
function smarty_function_popup($params, &$smarty) |
22 |
{ |
23 |
$append = ''; |
24 |
foreach ($params as $_key=>$_value) { |
25 |
switch ($_key) { |
26 |
case 'text': |
27 |
case 'trigger': |
28 |
$$_key = (string)$_value; |
29 |
break; |
30 |
|
31 |
case 'caption': |
32 |
case 'closetext': |
33 |
case 'status': |
34 |
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'"; |
35 |
break; |
36 |
|
37 |
case 'fgcolor': |
38 |
case 'bgcolor': |
39 |
case 'textcolor': |
40 |
case 'capcolor': |
41 |
case 'closecolor': |
42 |
case 'textfont': |
43 |
case 'captionfont': |
44 |
case 'closefont': |
45 |
case 'fgbackground': |
46 |
case 'bgbackground': |
47 |
case 'inarray': |
48 |
case 'caparray': |
49 |
case 'capicon': |
50 |
case 'background': |
51 |
case 'frame': |
52 |
case 'function': |
53 |
$append .= ',' . strtoupper($_key) . ",'$_value'"; |
54 |
break; |
55 |
|
56 |
case 'textsize': |
57 |
case 'captionsize': |
58 |
case 'closesize': |
59 |
case 'width': |
60 |
case 'height': |
61 |
case 'border': |
62 |
case 'offsetx': |
63 |
case 'offsety': |
64 |
case 'snapx': |
65 |
case 'snapy': |
66 |
case 'fixx': |
67 |
case 'fixy': |
68 |
case 'padx': |
69 |
case 'pady': |
70 |
case 'timeout': |
71 |
case 'delay': |
72 |
$append .= ',' . strtoupper($_key) . ",$_value"; |
73 |
break; |
74 |
|
75 |
case 'sticky': |
76 |
case 'left': |
77 |
case 'right': |
78 |
case 'center': |
79 |
case 'above': |
80 |
case 'below': |
81 |
case 'noclose': |
82 |
case 'autostatus': |
83 |
case 'autostatuscap': |
84 |
case 'fullhtml': |
85 |
case 'hauto': |
86 |
case 'vauto': |
87 |
if ($_value) $append .= ',' . strtoupper($_key); |
88 |
break; |
89 |
|
90 |
default: |
91 |
$smarty->trigger_error("[popup] unknown parameter $_key", E_USER_WARNING); |
92 |
} |
93 |
} |
94 |
|
95 |
if (empty($text) && !isset($inarray) && empty($function)) { |
96 |
$smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required"); |
97 |
return false; |
98 |
} |
99 |
|
100 |
if (empty($trigger)) { $trigger = "onmouseover"; } |
101 |
|
102 |
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\''; |
103 |
$retval .= $append . ');" onmouseout="nd();"'; |
104 |
|
105 |
return $retval; |
106 |
} |
107 |
|
108 |
/* vim: set expandtab: */ |
109 |
|
110 |
?> |