mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-01 00:02:21 +09:00
add description of function
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10764 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5a510567d1
commit
ebfe89ca32
10 changed files with 243 additions and 120 deletions
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* @class TemplateHandler
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief template compiler
|
||||
* template compiler
|
||||
* @version 0.1
|
||||
* @remarks It compiles template file by using regular expression into php
|
||||
* code, and XE caches compiled code for further uses
|
||||
|
|
@ -22,6 +22,10 @@ class TemplateHandler {
|
|||
|
||||
var $handler_mtime = 0;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @return void
|
||||
**/
|
||||
function TemplateHandler()
|
||||
{
|
||||
// TODO: replace this with static variable in PHP5
|
||||
|
|
@ -33,7 +37,7 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief returns TemplateHandler's singleton object
|
||||
* returns TemplateHandler's singleton object
|
||||
* @return TemplateHandler instance
|
||||
**/
|
||||
function &getInstance()
|
||||
|
|
@ -51,7 +55,11 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief set variables for template compile
|
||||
* set variables for template compile
|
||||
* @param string $tpl_path
|
||||
* @param string $tpl_filename
|
||||
* @param string $tpl_file
|
||||
* @return void
|
||||
**/
|
||||
function init($tpl_path, $tpl_filename, $tpl_file='')
|
||||
{
|
||||
|
|
@ -80,11 +88,11 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief compiles specified tpl file and execution result in Context into resultant content
|
||||
* @param[in] $tpl_path path of the directory containing target template file
|
||||
* @param[in] $tpl_filename target template file's name
|
||||
* @param[in] $tpl_file if specified use it as template file's full path
|
||||
* @return Returns compiled result in case of success, NULL otherwise
|
||||
* compiles specified tpl file and execution result in Context into resultant content
|
||||
* @param string $tpl_path path of the directory containing target template file
|
||||
* @param string $tpl_filename target template file's name
|
||||
* @param string $tpl_file if specified use it as template file's full path
|
||||
* @return string Returns compiled result in case of success, NULL otherwise
|
||||
*/
|
||||
function compile($tpl_path, $tpl_filename, $tpl_file='') {
|
||||
global $__templatehandler_root_tpl;
|
||||
|
|
@ -140,10 +148,10 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief compile specified file and immediately return
|
||||
* @param[in] $tpl_path path of the directory containing target template file
|
||||
* @param[in] $tpl_filename target template file's name
|
||||
* @return Returns compiled content in case of success or NULL in case of failure
|
||||
* compile specified file and immediately return
|
||||
* @param string $tpl_path path of the directory containing target template file
|
||||
* @param string $tpl_filename target template file's name
|
||||
* @return string Returns compiled content in case of success or NULL in case of failure
|
||||
**/
|
||||
function compileDirect($tpl_path, $tpl_filename) {
|
||||
$this->init($tpl_path, $tpl_filename, null);
|
||||
|
|
@ -158,11 +166,9 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief compile a template file specified in $tpl_file and
|
||||
* @pre files specified by $tpl_file exists.
|
||||
* @param[in] $tpl_file path of tpl file
|
||||
* @param[in] $compiled_tpl_file if specified, write compiled result into the file
|
||||
* @return compiled result in case of success or NULL in case of error
|
||||
* parse syntax.
|
||||
* @param string $buff template file
|
||||
* @return string compiled result in case of success or NULL in case of error
|
||||
**/
|
||||
function parse($buff=null) {
|
||||
if(is_null($buff)) {
|
||||
|
|
@ -202,10 +208,13 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief 1. remove ruleset from form tag
|
||||
* preg_replace_callback handler
|
||||
* 1. remove ruleset from form tag
|
||||
* 2. add hidden tag with ruleset value
|
||||
* 3. if empty default hidden tag, generate hidden tag (ex:mid, vid, act...)
|
||||
* 4. generate return url, return url use in server side validator
|
||||
* @param array $matches
|
||||
* @return string
|
||||
**/
|
||||
function _compileFormAuthGeneration($matches)
|
||||
{
|
||||
|
|
@ -272,11 +281,9 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief fetch using ob_* function
|
||||
* @param[in] $compiled_tpl_file path of compiled template file
|
||||
* @param[in] $buff if buff is not null, eval it instead of including compiled template file
|
||||
* @param[in] $tpl_path set context's tpl path
|
||||
* @return result string
|
||||
* fetch using ob_* function
|
||||
* @param string $buff if buff is not null, eval it instead of including compiled template file
|
||||
* @return string
|
||||
**/
|
||||
function _fetch($buff) {
|
||||
if(!$buff) return;
|
||||
|
|
@ -300,10 +307,12 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief change image path
|
||||
* @pre $matches is an array containg three elements
|
||||
* @param[in] $matches match
|
||||
* @return changed result
|
||||
* preg_replace_callback hanlder
|
||||
*
|
||||
* replace image path
|
||||
* @param array $match
|
||||
*
|
||||
* @return string changed result
|
||||
**/
|
||||
function _replacePath($match)
|
||||
{
|
||||
|
|
@ -320,6 +329,11 @@ class TemplateHandler {
|
|||
return substr($match[0],0,-strlen($match[1])-6)."src=\"{$src}\"";
|
||||
}
|
||||
|
||||
/**
|
||||
* replace loop and cond template syntax
|
||||
* @param string $buff
|
||||
* @return string changed result
|
||||
**/
|
||||
function _parseInline($buff)
|
||||
{
|
||||
if(preg_match_all('/<([a-zA-Z]+\d?)(?>(?!<[a-z]+\d?[\s>]).)*?(?:[ \|]cond| loop)="/s', $buff, $match) === false) return $buff;
|
||||
|
|
@ -408,6 +422,12 @@ class TemplateHandler {
|
|||
return $buff;
|
||||
}
|
||||
|
||||
/**
|
||||
* preg_replace_callback hanlder
|
||||
* replace php code.
|
||||
* @param array $m
|
||||
* @return string changed result
|
||||
**/
|
||||
function _parseResource($m)
|
||||
{
|
||||
// {@ ... } or {$var} or {func(...)}
|
||||
|
|
@ -545,6 +565,11 @@ class TemplateHandler {
|
|||
return $m[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* change relative path
|
||||
* @param string $path
|
||||
* @return string
|
||||
**/
|
||||
function _getRelativeDir($path)
|
||||
{
|
||||
$_path = $path;
|
||||
|
|
@ -573,7 +598,9 @@ class TemplateHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief replace PHP variables of $ character
|
||||
* replace PHP variables of $ character
|
||||
* @param string $php
|
||||
* @return string $__Context->varname
|
||||
**/
|
||||
function _replaceVar($php) {
|
||||
if(!strlen($php)) return '';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue