PHP Classes

File: lib/plugins/shared.escape_chars.php

Recommend this page to a friend!
  Classes of David Tamas   g-template-php   lib/plugins/shared.escape_chars.php   Download  
File: lib/plugins/shared.escape_chars.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: g-template-php
Process and render templates generating PHP code
Author: By
Last change:
Date: 5 years ago
Size: 968 bytes
 

Contents

Class file image Download
<?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;
}