📄 simpletags.php
字号:
function methods($input) { /* no vars */ $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(\)".$this->stop."/ie", "'<?=htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'())?>'", $input); $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(\):h".$this->stop."/ie", "'<?=".$this->error."$'.str_replace('.','->','\\1').'()?>'", $input); /* single vars */ $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+)\)".$this->stop."/ie", "'<?=htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . '))?>'", $input); $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+)\):h".$this->stop."/ie", "'<?=".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . ')?>'", $input); $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+)\):s".$this->stop."/ie", "'<?php highlight_string($'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . '));?>'", $input); /* double vars */ $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+),([a-z0-9_.]+)\)".$this->stop."/ie", "'<?=htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . ',$' . str_replace('.','->','\\3') . '))?>'", $input); /* double vars:: # #'d ,var */ $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(\#([^\#]+)\#,([a-z0-9_.]+)\)".$this->stop."/ie", "'<?=htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'(\''. str_replace(\"'\",\"\\\'\",'\\2') . '\',$' . str_replace('.','->','\\3') . '))?>'", $input); /* double vars:: var , # #'d */ $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(([a-z0-9_.]+),\#([^\#]+)\#\)".$this->stop."/ie", "'<?=htmlspecialchars(".$this->error."$'.str_replace('.','->','\\1').'($' . str_replace('.','->','\\2') . ',\''. str_replace(\"'\",\"\\\'\",'\\3') . '\'))?>'", $input); /*strings or integers */ $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(\#([^\#]+)\#\)".$this->stop."/ie", "'<?=htmlspecialchars(\$'.str_replace('.','->','\\1') . '(\''. str_replace(\"'\",\"\\\'\",'\\2') . '\'))?>'", $input); $input = preg_replace( "/".$this->start."([a-z0-9_.]+)\(\#([^\#]+)\#\):h".$this->stop."/ie", "'<?=".$this->error."$'.str_replace('.','->','\\1').'(\"' . str_replace(\"'\",\"\\\'\",'\\2') . '\")?>'", $input); return $input; } /** * Looping * * This allows you to do loops on variables (eg. nested/ repeated blocks!) * * Maps Methods * {foreach:t.xyz,zzz} maps to <?php if ($i->xyz) foreach ($t->xyz as $zzz) { ?> * {foreach:t.xyz,xxx,zzz} maps to <?php if ($i->xyz) foreach ($t->xyz as $xxx=>$zzz) { ?> * {end:} maps to <?php }?> * {else:} maps to <?php }else{?> * * * * @param string $input the template * @return string the result of the filtering * @access public */ function looping($input) { $input = preg_replace( "/".$this->start."foreach:([a-z0-9_.]+),([a-z0-9_.]+)".$this->stop."/ie", "'<?php if (".$this->error."$' . str_replace('.','->','\\1') . ') foreach( $' . str_replace('.','->','\\1') . ' as $' . str_replace('.','->','\\2') . ') { ?>'", $input); $input = preg_replace( "/".$this->start."foreach:([a-z0-9_.]+),([a-z0-9_.]+),([a-z0-9_.]+)".$this->stop."/ie", "'<?php if (".$this->error."$' . str_replace('.','->','\\1') . ') foreach( $' . str_replace('.','->','\\1') . ' as $' . str_replace('.','->','\\2') . '=>$' . str_replace('.','->','\\3') .') { ?>'", $input); $input = str_replace(stripslashes($this->start)."else:".stripslashes($this->stop),'<?php }else{?>', $input); $input = str_replace(stripslashes($this->start)."end:".stripslashes($this->stop),'<?php }?>', $input); return $input; } /** * Conditional inclusion * * This allows you to do conditional inclusion (eg. blocks!) * * Maps conditions * * {if:t.xxxx} => <?php if ($t->xxxx) { ?> * {if:t.x_xxx()} => <?php if ($t->x_xxx()) { ?> * * @param string $input the template * @return string the result of the filtering * @access public */ function conditionals($input) { $input = preg_replace( "/".$this->start."if:([a-z0-9_.]+)".$this->stop."/ie", "'<?php if (".$this->error."$' . str_replace('.','->','\\1') . ') { ?>'", $input); $input = preg_replace( "/".$this->start."if:([a-z0-9_.]+)\(\)".$this->stop."/ie", "'<?php if (".$this->error."$' . str_replace('.','->','\\1') . '()) { ?>'", $input); return $input; } /** * sub template inclusion * * This allows you to do include other files (either flat or generated templates.). * * {include:t.abcdef} maps to <?php * if($t->abcdef && file_exists($compileDir . "/". $t->abcdef . "en.php")) * include($compileDir . "/". $t->abcdef . ".en.php"); * ?> * * include abcdef.en.php (Eg. hard coded compiled template * {include:#abcdef#} => <?php * if(file_exists($compileDir . "/abcdef.en.php")) * include($compileDir . "/abcdef.en.php"); * ?> * * include raw * {t_include:#abcdef.html#} => <?php * if(file_exists($templateDir . "/abcdef.html")) * include($compileDir . "/abcdef.html"); * ?> * Compile and include * {q_include:#abcdef.html#} => <?php * HTML_Template_Flexy::staticQuickTemplate('abcedef.html',$t); * ?> * * * @param string $input the template * @return string the result of the filtering * @access public */ function include_template($input) { $input = preg_replace( "/".$this->start."include:([a-z0-9_.]+)".$this->stop."/ie", "'<?php if ((".$this->error."$' . str_replace('.','->','\\1') . ') && file_exists(\"" . $this->engine->options['compileDir'] . "/\{$' . str_replace('.','->','\\1') . '}.en.php\")) include(\"" . $this->engine->options['compileDir'] . "/\{$' . str_replace('.','->','\\1') . '}.en.php\");?>'", $input); $input = preg_replace( "/".$this->start."include:#([a-z0-9_.]+)#".$this->stop."/ie", "'<?php if (file_exists(\"" . $this->engine->options['compileDir'] . "/\\1.en.php\")) include(\"" . $this->engine->options['compileDir'] . "/\\1.en.php\");?>'", $input); $input = preg_replace( "/".$this->start."t_include:#([a-z0-9_.]+)#".$this->stop."/ie", "'<?php if (file_exists(\"" . $this->engine->options['templateDir'] . "/\\1\")) include(\"" . $this->engine->options['templateDir'] . "/\\1\");?>'", $input); $input = preg_replace( "/".$this->start."q_include:#([a-z0-9_.]+)#".$this->stop."/ie", "'<?php HTML_Template_Flexy::staticQuickTemplate(\"\\1\",\$t); ?>'", $input); return $input; }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -