* Name: html_oos_image
* Date: Feb 24, 2003
* Purpose: format HTML tags for the image
* Input:
* - file = file (and path) of image (required)
* - image =image width (optional, default actual width)
* - basedir = base directory for absolute paths, default
* is environment variable DOCUMENT_ROOT
*
* Examples: {html_oos_image file="images/masthead.gif"}
* Output:
* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_oos_image}
* (Smarty online manual)
* @author Monte Ohrt
* @author credits to Duda - wrote first image function
* in repository, helped with lots of functionality
* @version 2.0
* @param array
* @param Smarty
* @return string
* @uses smarty_function_escape_special_chars()
*/
function smarty_function_html_oos_image($params, &$smarty)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$alt = '';
$image = '';
$extra = '';
$basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '';
foreach($params as $_key => $_val) {
switch($_key) {
case 'image':
case 'basedir':
$$_key = $_val;
break;
case 'alt':
if(!is_array($_val)) {
$$_key = smarty_function_escape_special_chars($_val);
} else {
throw new SmartyException("html_oos_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
default:
if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else {
throw new SmartyException("html_oos_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
$image = $basedir . $image;
if (empty($image) || ($image == OOS_IMAGES)) {
return FALSE;
}
if (isset($template->smarty->security_policy)) {
// local file
if (!$template->smarty->security_policy->isTrustedResourceDir($image)) {
return;
}
}
return '
';
}