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 XOOPS Project (http://xoops.org)
9: * @license GNU GPL 2 or later (http://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: * <code>
23: * // Generate an URL using a physical path
24: * {xoAppUrl 'modules/something/yourpage.php'}
25: * </code>
26: *
27: * The path should be in a form understood by Xoops::url()
28: */
29: function smarty_compiler_xoAppUrl($params, Smarty $smarty)
30: {
31: $xoops = Xoops::getInstance();
32: $arg = reset($params);
33: $url = trim($arg, " '\"\t\n\r\0\x0B");
34:
35: if (substr($url, 0, 1) === '/') {
36: $url = 'www' . $url;
37: }
38: return "<?php echo '" . addslashes(htmlspecialchars($xoops->url($url))) . "'; ?>";
39: }
40: