ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE/branches/myumyu/prj_openpne2/webapp/lib/smarty_plugins/modifier.t_cmd.php @ 1500

Last change on this file since 1500 was 1500, checked in by miyumiyu, 16 years ago

GoogleMaps追加

File size: 1021 bytes
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
7function smarty_modifier_t_cmd($string, $type = '')
8{
9    if (!OPENPNE_USE_CMD_TAG) {
10        return $string;
11    }
12
13//    $regexp = '/&lt;cmd\s+src="(\w+)"(?:\s+args="([\w-\+%]+(,[\w-\+%]+)*)?")?\s*&gt;/i';
14    $regexp = '/&lt;cmd\s+src="(\w+)"(?:\s+args="([^,&<>]+(,[\w-\+%]+)*)?")?\s*&gt;/i';
15    $GLOBALS['_CMD']['type'] = $type;
16
17    return preg_replace_callback($regexp, '_smarty_modifier_t_cmd_make_js', $string);
18
19}
20
21function _smarty_modifier_t_cmd_make_js($matches)
22{
23    if (!db_is_use_cmd($matches[1], $GLOBALS['_CMD']['type'])) {
24        return $matches[0];
25    }
26
27    $src  = $matches[1];
28    $args = $matches[2];
29
30    $_args = explode(',', $args);
31    $arg_str = "'" . implode("','", $_args) . "'";
32
33    $result = <<<EOD
34<script type="text/javascript" src="cmd/{$src}.js"></script>
35<script type="text/javascript">
36<!--
37main({$arg_str});
38//-->
39</script>
40EOD;
41    return $result;
42}
43
44
45?>
Note: See TracBrowser for help on using the repository browser.