class Ext_View extends Yaf_View_Simple { |
private $tmpPath ; |
private $tmpData = array (); |
private $include ; |
//用于保存模板内容的静态变量 |
protected static $_fileArr = array (); |
public function display( $tplFile , $data = array ()) { |
$this ->tmpPath = $this ->getScriptPath() . '/' . $tplFile ; |
if ( is_array ( $data )) { |
$this ->tmpData = array_merge ( $this ->tmpData, $data ); |
} |
unset( $tplFile ); |
unset( $data ); |
extract( $this ->tmpData, EXTR_OVERWRITE); |
//判断模板文件是否已经在变量中,不存在就读取 |
if (!isset(self:: $_fileArr [ $this ->tmpPath])) { |
self:: $_fileArr [ $this ->tmpPath] = file_get_contents ( $this ->tmpPath); |
} |
eval ( '?>' .self:: $_fileArr [ $this ->tmpPath]); |
} |
//其他代码略 |
} |