PHP Classes

File: htdocs/class/smarty3_plugins/compiler.xoImgUrl.php

Recommend this page to a friend!
  Packages of Michael Beck   Xoops 2.5   htdocs/class/smarty3_plugins/compiler.xoImgUrl.php   Download  
File: htdocs/class/smarty3_plugins/compiler.xoImgUrl.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Xoops 2.5
Modular content management publication system
Author: By
Last change:
Date: 10 months ago
Size: 1,727 bytes
 

Contents

Class file image Download
<?php
/**
 * xoImgUrl Smarty compiler plug-in
 *
 * See the enclosed file LICENSE for licensing information. If you did not
 * receive this file, get it at http://www.gnu.org/licenses/gpl-2.0.html
 *
 * @copyright   (c) 2000-2025 XOOPS Project (https://xoops.org)
 * @license     GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
 * @author      Skalpa Keo <skalpa@xoops.org>
 * @package     xos_opal
 * @subpackage  xos_opal_Smarty
 * @since       2.0.14
 */

/**
 * Inserts the URL of a file resource customizable by themes
 *
 * This plug-in works like the {@link smarty_compiler_xoAppUrl() xoAppUrl} plug-in,
 * except that it is intended to generate the URL of resource files customizable by
 * themes.
 *
 * Here the current theme is asked to check if a custom version of the requested file exists, and
 * if one is found its URL is returned. Otherwise, the request will be passed to the
 * theme parents one by one. Ultimately, if no custom version has been found, the resource
 * default URL location will be returned.
 *
 * <b>Note:</b> the themes inheritance system can generate many filesystem accesses depending
 * on your themes configuration. Because of this, the use of the dynamic syntax with this plug-in
 * is not possible right now.
 *
 * @param string[] $params
 * @param Smarty   $smarty
 * @return string
 */

function smarty_compiler_xoImgUrl($params, Smarty $smarty)
{
    global $xoops, $xoTheme;
    $arg = reset($params);
    $arg = trim($arg, " '\"\t\n\r\0\x0B");
    $path = (isset($xoTheme) && is_object($xoTheme)) ? $xoTheme->resourcePath($arg) : $arg;
    //$xoops->events()->triggerEvent('debug.log', $path);
    return "<?php echo '" . addslashes($xoops->url($path)) . "'; ?>";
}