Freeder
 All Classes Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
RainTPL Class Reference

Public Member Functions

 assign ($variable, $value=null)
 
 draw ($tpl_name, $return_string=false)
 
 cache ($tpl_name, $expire_time=self::CACHE_EXPIRE_TIME, $cache_id=null)
 
 const_replace ($html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter=null, $php_right_delimiter=null, $loop_level=null, $echo=null)
 
 func_replace ($html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter=null, $php_right_delimiter=null, $loop_level=null, $echo=null)
 
 var_replace ($html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter=null, $php_right_delimiter=null, $loop_level=null, $echo=null)
 

Static Public Member Functions

static configure ($setting, $value=null)
 

Public Attributes

 $var = array()
 
 $cache = false
 
 $cache_id = null
 
const CACHE_EXPIRE_TIME = 3600
 

Static Public Attributes

static $tpl_dir = "tpl/"
 
static $cache_dir = "tmp/"
 
static $base_url = null
 
static $tpl_ext = "html"
 
static $path_replace = true
 
static $path_replace_list = array( 'a', 'img', 'link', 'script', 'input' )
 
static $black_list = array( '\$this', 'raintpl::', 'self::', '_SESSION', '_SERVER', '_ENV', 'eval', 'exec', 'unlink', 'rmdir' )
 
static $check_template_update = true
 
static $php_enabled = false
 
static $debug = false
 

Protected Member Functions

 check_template ($tpl_name)
 
 xml_reSubstitution ($capture)
 
 compileFile ($tpl_basename, $tpl_basedir, $tpl_filename, $cache_dir, $compiled_filename)
 
 compileTemplate ($template_code, $tpl_basedir)
 
 compileCode ($parsed_code)
 
 reduce_path ($path)
 
 path_replace ($html, $tpl_basedir)
 
 function_check ($code)
 
 printDebug (RainTpl_Exception $e)
 

Protected Attributes

 $tpl = array()
 

Static Protected Attributes

static $config_name_sum = array()
 

Member Function Documentation

RainTPL::assign (   $variable,
  $value = null 
)

Assign variable eg. $t->assign('name','mickey');

Parameters
mixed$variable_nameName of template variable or associative array name/value
mixed$valuevalue assigned to this variable. Not set if variable_name is an associative array
RainTPL::cache (   $tpl_name,
  $expire_time = self::CACHE_EXPIRE_TIME,
  $cache_id = null 
)

If exists a valid cache for this template it returns the cache

Parameters
string$tpl_nameName of template (set the same of draw)
int$expiration_timeSet after how many seconds the cache expire and must be regenerated
Returns
string it return the HTML or null if the cache must be recreated
RainTPL::compileCode (   $parsed_code)
protected

Compile the code protected

RainTPL::compileFile (   $tpl_basename,
  $tpl_basedir,
  $tpl_filename,
  $cache_dir,
  $compiled_filename 
)
protected

Compile and write the compiled template file protected

RainTPL::compileTemplate (   $template_code,
  $tpl_basedir 
)
protected

Compile template protected

static RainTPL::configure (   $setting,
  $value = null 
)
static

Configure the settings of RainTPL

RainTPL::draw (   $tpl_name,
  $return_string = false 
)

Draw the template eg. $html = $tpl->draw( 'demo', TRUE ); // return template in string or $tpl->draw( $tpl_name ); // echo the template

Parameters
string$tpl_nametemplate to load
boolean$return_stringtrue=return a string, false=echo the template
Returns
string
RainTPL::function_check (   $code)
protected

Check if function is in black list (sandbox)

Parameters
string$code
string$tag
RainTPL::path_replace (   $html,
  $tpl_basedir 
)
protected

replace the path of image src, link href and a href. url => template_dir/url url# => url http://url => http://url

Parameters
string$html
Returns
string html sostituito
RainTPL::printDebug ( RainTpl_Exception  $e)
protected

Prints debug info about exception or passes it further if debug is disabled.

Parameters
RainTpl_Exception$e
Returns
string
RainTPL::reduce_path (   $path)
protected

Reduce a path, eg. www/library/../filepath//file => www/filepath/file

Parameters
type$path
Returns
type
RainTPL::xml_reSubstitution (   $capture)
protected

execute stripslaches() on the xml block. Invoqued by preg_replace_callback function below protected

Member Data Documentation

RainTPL::$check_template_update = true
static

Check template. true: checks template update time, if changed it compile them false: loads the compiled template. Set false if server doesn't have write permission for cache_directory.


The documentation for this class was generated from the following file: