1: <?php
2: /**
3: * xoImgUrl 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: * Inserts the URL of a file resource customizable by themes
18: *
19: * This plug-in works like the {@link smarty_compiler_xoAppUrl() xoAppUrl} plug-in,
20: * except that it is intended to generate the URL of resource files customizable by
21: * themes.
22: *
23: * Here the current theme is asked to check if a custom version of the requested file exists, and
24: * if one is found its URL is returned. Otherwise, the request will be passed to the
25: * theme parents one by one. Ultimately, if no custom version has been found, the resource
26: * default URL location will be returned.
27: *
28: * <b>Note:</b> the themes inheritance system can generate many filesystem accesses depending
29: * on your themes configuration. Because of this, the use of the dynamic syntax with this plug-in
30: * is not possible right now.
31: */
32:
33: function smarty_compiler_xoImgUrl($params, Smarty $smarty)
34: {
35: $xoops = \Xoops::getInstance();
36: $xoTheme = $xoops->theme();
37: $arg = reset($params);
38: $arg = trim($arg, " '\"\t\n\r\0\x0B");
39: $path = (isset($xoTheme) && is_object($xoTheme)) ? $xoTheme->resourcePath($arg) : $arg;
40: //$xoops->events()->triggerEvent('debug.log', $path);
41: return "<?php echo '" . addslashes($xoops->url($path)) . "'; ?>";
42:
43: }
44: