<?php<liu21st@gmail.com>
defined('THINK_PATH') or exit();
/**
* 系统行为扩展:模板内容输出替换
* @category Think
* @package Think
* @subpackage Behavior
* @author liu21st <liu21st@gmail.com>
*/
class ContentReplaceBehavior extends Behavior {
protected $options = array(
'TMPL_PARSE_STRING' => array(),
);
public function run(&$content){
$content = $this->templateContentReplace($content);
}
protected function templateContentReplace($content) {
$replace = array(
'__TMPL__' => APP_TMPL_PATH, '__ROOT__' => __ROOT__, '__APP__' => __APP__, '__GROUP__' => defined('GROUP_NAME')?__GROUP__:__APP__,
'__ACTION__' => __ACTION__, '__SELF__' => __SELF__, '__URL__' => __URL__,
'../Public' => APP_TMPL_PATH.'Public' '__PUBLIC__' => __ROOT__.'/Public' );
if(is_array(C('TMPL_PARSE_STRING')) )
$replace = array_merge($replace,C('TMPL_PARSE_STRING'));
$content = str_replace(array_keys($replace),array_values($replace),$content);
return $content;
}
}