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_url2cmd($string) |
---|
8 | { |
---|
9 | // "(") と '(') を元に戻す |
---|
10 | $search = array('"', '''); |
---|
11 | $replace = array('"', "'"); |
---|
12 | $string = str_replace($search, $replace, $string); |
---|
13 | |
---|
14 | $url_pattern = "/https?:\/\/([a-zA-Z0-9-.]+)\/?[\w\-.,:;\~\^\/?\@&=+\$%#!()]*/"; |
---|
15 | return preg_replace_callback($url_pattern, '_smarty_modifier_t_cmd_make_url_js', $string); |
---|
16 | } |
---|
17 | |
---|
18 | function _smarty_modifier_t_cmd_make_url_js($matches) |
---|
19 | { |
---|
20 | $url = $matches[0]; |
---|
21 | $file = $matches[1] . '.js'; |
---|
22 | $path = './cmd/' . $file; |
---|
23 | |
---|
24 | if (!OPENPNE_USE_CMD_TAG || !is_readable($path)) { |
---|
25 | // t_url2a |
---|
26 | return pne_url2a($url); |
---|
27 | } |
---|
28 | |
---|
29 | $result = <<<EOD |
---|
30 | <script type="text/javascript" src="cmd/{$file}"></script> |
---|
31 | <script type="text/javascript"> |
---|
32 | <!-- |
---|
33 | url2cmd('{$url}'); |
---|
34 | //--> |
---|
35 | </script> |
---|
36 | EOD; |
---|
37 | return $result; |
---|
38 | } |
---|
39 | |
---|
40 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.