1: | <?php |
2: | /** |
3: | * xoAppUrl Smarty compiler plug-in |
4: | * |
5: | * See the enclosed file LICENSE for licensing information. If you did not |
6: | * receive this file, get it at http://www.gnu.org/licenses/gpl-2.0.html |
7: | * |
8: | * @copyright (c) 2000-2022 XOOPS Project (https://xoops.org) |
9: | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
10: | * @author Skalpa Keo <skalpa@xoops.org> |
11: | * @package xos_opal |
12: | * @subpackage xos_opal_Smarty |
13: | * @since 2.0.14 |
14: | */ |
15: | |
16: | /** |
17: | * Build application relative URL |
18: | * |
19: | * This plug-in allows you to generate a module location URL. It uses any URL rewriting |
20: | * mechanism and rules you'll have configured for the system. |
21: | * |
22: | * // Generate a URL using a physical path |
23: | * <{xoAppUrl 'modules/something/yourpage.php'}> |
24: | * |
25: | * The path should be in a form understood by Xoops::url() |
26: | * |
27: | * @param string[] $params |
28: | * @param Smarty $smarty |
29: | * @return string |
30: | */ |
31: | function smarty_compiler_xoAppUrl($params, Smarty $smarty) |
32: | { |
33: | global $xoops; |
34: | $arg = reset($params); |
35: | $url = trim($arg, " '\"\t\n\r\0\x0B"); |
36: | |
37: | if (strpos($url, '/') === 0) { |
38: | $url = 'www' . $url; |
39: | } |
40: | return "<?php echo '" . addslashes(htmlspecialchars($xoops->url($url), ENT_QUOTES)) . "'; ?>"; |
41: | } |
42: |