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

source: OpenPNE/trunk/webapp/lib/smarty_plugins/modifier.t_cmd.php @ 1472

Last change on this file since 1472 was 1472, checked in by takanashi, 14 years ago

r1458 so-net cmd scripts追加

File size: 931 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    $GLOBALS['_CMD']['type'] = $type;
15
16    return preg_replace_callback($regexp, '_smarty_modifier_t_cmd_make_js', $string);
17
18}
19
20function _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<!--
36main({$arg_str});
37//-->
38</script>
39EOD;
40    return $result;
41}
42
43
44?>
Note: See TracBrowser for help on using the repository browser.