代码规范调整

This commit is contained in:
麦当苗儿
2013-04-19 09:31:21 +08:00
parent 19a99463c9
commit e0f90d9386

View File

@@ -33,8 +33,8 @@ class View {
/** /**
* 模板变量赋值 * 模板变量赋值
* @access public * @access public
* @param mixed $name * @param mixed $name 变量名
* @param mixed $value * @param mixed $value 变量值
*/ */
public function assign($name, $value = ''){ public function assign($name, $value = ''){
if(is_array($name)) { if(is_array($name)) {
@@ -66,7 +66,7 @@ class View {
* @param array $config 引擎参数 * @param array $config 引擎参数
* @return View * @return View
*/ */
public function engine($engine,$config=[]){ public function engine($engine, array $config = []){
$class = '\\Think\\View\\Driver\\' . ucwords($engine); $class = '\\Think\\View\\Driver\\' . ucwords($engine);
$this->engine = new $class($config); $this->engine = new $class($config);
return $this; return $this;
@@ -96,13 +96,13 @@ class View {
* @access public * @access public
* @param string $template 模板文件名 * @param string $template 模板文件名
* @param array $vars 模板输出变量 * @param array $vars 模板输出变量
* @param string $cacheId 模板缓存标识 * @param string $cache_id 模板缓存标识
* @return mixed * @return mixed
*/ */
public function display($template='',$vars=[],$cacheId='') { public function display($template = '', $vars = [], $cache_id = '') {
Tag::listen('view_begin', $template); Tag::listen('view_begin', $template);
// 解析并获取模板内容 // 解析并获取模板内容
$content = $this->fetch($template,$vars,$cacheId); $content = $this->fetch($template, $vars, $cache_id);
// 输出内容过滤 // 输出内容过滤
Tag::listen('view_filter', $content); Tag::listen('view_filter', $content);
// 输出模板内容 // 输出模板内容
@@ -118,10 +118,10 @@ class View {
* @access protected * @access protected
* @param string $template 模板文件名或者内容 * @param string $template 模板文件名或者内容
* @param array $vars 模板输出变量 * @param array $vars 模板输出变量
* @param string $cacheId 模板缓存标识 * @param string $cache_id 模板缓存标识
* @return string * @return string
*/ */
protected function fetch($template,$vars=[],$cacheId='') { protected function fetch($template, $vars = [], $cache_id='') {
if(!$this->config['http_render_content']) { if(!$this->config['http_render_content']) {
$template = $this->parseTemplate($template); $template = $this->parseTemplate($template);
// 模板不存在 抛出异常 // 模板不存在 抛出异常
@@ -133,7 +133,7 @@ class View {
ob_start(); ob_start();
ob_implicit_flush(0); ob_implicit_flush(0);
if($this->engine) { // 指定模板引擎 if($this->engine) { // 指定模板引擎
$this->engine->fetch($template,$vars,$cacheId); $this->engine->fetch($template, $vars, $cache_id);
}else{ // 原生PHP解析 }else{ // 原生PHP解析
extract($vars, EXTR_OVERWRITE); extract($vars, EXTR_OVERWRITE);
is_file($template) ? include $template : eval('?>' . $template); is_file($template) ? include $template : eval('?>' . $template);