<?php
/**
* gTemplate Plugins
*
* @package gTemplate
* @subpackage Plugins
*/
/**
* escape_special_chars common function
*
* Function: smarty_function_escape_special_chars<br>
* Purpose: used by other smarty functions to escape
* special chars except for already escaped ones
*
* @version 1.0
* @author Tamas David (G-Lex) <glex at mittudomain.info>
* @link https://github.com/glex86/g-template-php G-Template Engine on Github
*
* @internal Some source codes are taken from Smarty
* @internal author Monte Ohrt <monte at ohrt dot com>
* @internal link http://smarty.net Smarty
*/
function tpl_escape_chars($string)
{
if(!is_array($string))
{
$string = preg_replace('!&(#?\w+);!', '%%%TEMPLATE_START%%%\\1%%%TEMPLATE_END%%%', $string);
$string = htmlspecialchars($string);
$string = str_replace(array('%%%TEMPLATE_START%%%','%%%TEMPLATE_END%%%'), array('&',';'), $string);
}
return $string;
}
|