Line | |
---|
1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2006 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | function smarty_modifier_t_cmd($string, $type = '') |
---|
8 | { |
---|
9 | if (!OPENPNE_USE_CMD_TAG) { |
---|
10 | return $string; |
---|
11 | } |
---|
12 | |
---|
13 | $regexp = '/<cmd\s+src="(\w+)"(?:\s+args="([\w-\+%]+(,[\w-\+%]+)*)?")?\s*>/i'; |
---|
14 | $GLOBALS['_CMD']['type'] = $type; |
---|
15 | |
---|
16 | return preg_replace_callback($regexp, '_smarty_modifier_t_cmd_make_js', $string); |
---|
17 | |
---|
18 | } |
---|
19 | |
---|
20 | function _smarty_modifier_t_cmd_make_js($matches) |
---|
21 | { |
---|
22 | if (!db_is_use_cmd($matches[1], $GLOBALS['_CMD']['type'])) { |
---|
23 | return $matches[0]; |
---|
24 | } |
---|
25 | |
---|
26 | $src = $matches[1]; |
---|
27 | $args = $matches[2]; |
---|
28 | |
---|
29 | $_args = explode(',', $args); |
---|
30 | $arg_str = "'" . implode("','", $_args) . "'"; |
---|
31 | |
---|
32 | $result = <<<EOD |
---|
33 | <script type="text/javascript" src="cmd/{$src}.js"></script> |
---|
34 | <script type="text/javascript"> |
---|
35 | <!-- |
---|
36 | main({$arg_str}); |
---|
37 | //--> |
---|
38 | </script> |
---|
39 | EOD; |
---|
40 | return $result; |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.