예제 #1
0
파일: Response.php 프로젝트: imdaqian/zphp
 public static function display($model)
 {
     if (null === $model || false === $model) {
         return $model;
     }
     if (is_array($model) && !empty($model['_view_mode'])) {
         $viewMode = $model['_view_mode'];
         unset($model['_view_mode']);
     } else {
         $viewMode = Request::getViewMode();
         if (empty($viewMode)) {
             if (Request::isAjax()) {
                 $viewMode = 'Json';
             } else {
                 $viewMode = 'Php';
             }
         }
     }
     $view = ZView::getInstance($viewMode);
     if ('Php' === $viewMode) {
         $_tpl_file = Request::getTplFile();
         if (is_array($model) && !empty($model['_tpl_file'])) {
             $_tpl_file = $model['_tpl_file'];
             unset($model['_tpl_file']);
         }
         if (empty($_tpl_file)) {
             throw new \Exception("tpl file empty");
         }
         $view->setTpl($_tpl_file);
     }
     $view->setModel($model);
     return $view->display();
 }