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

source: OpenPNE/trunk/webapp/lib/smarty_plugins/modifier.t_url2cmd.php @ 339

Last change on this file since 339 was 339, checked in by ogawa, 17 years ago

URL判定の修正

File size: 967 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_url2cmd($string)
8{
9    // "(&quot;) と '(&#039;) を元に戻す
10    $search = array('&quot;', '&#039;');
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
18function _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<!--
33url2cmd('{$url}');
34//-->
35</script>
36EOD;
37    return $result;
38}
39
40?>
Note: See TracBrowser for help on using the repository browser.