Esempio n. 1
0
 /**
  * 实例化调用方法,传递需要的数据到模板
  */
 protected function run()
 {
     $_function_get = 'get_' . $this->class_key;
     #$_class_key = $this->object_code.'_'.$this->class_key;
     #$this->add_data($_class_key,$this->$_function_get());
     #DebugTools::print_r($this->$_function_get());
     if ($this->output == 'html') {
         $dir = Yaf_Registry::get('config')->application->directory . '/widgets/views/';
         $widget_view = new Yaf_View_Simple($dir);
         $widget_view->assign('data', $this->{$_function_get}());
         $widget_view->assign('assist_data', $this->assist_data);
         echo $widget_view->render($this->class_key . '.phtml');
         #DebugTools::print_r($res);
         #Yaf_Loader::getInstance()->import($dir.'/item_condition.phtml');
         #DebugTools::print_r($widget_view);
         /*if (empty($this->view)){$this->view = $this->class_key;}
           $this->render($this->view,array(
               'data'=>$this->$_function_get(),
               'assist_data'=>$this->assist_data
           ));*/
     } else {
         if ($this->output == 'json') {
             $this->output_json($this->{$_function_get}());
         } else {
             if ($this->output == 'array') {
                 $this->output_array($this->{$_function_get}());
             }
         }
     }
 }
Esempio n. 2
0
 public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     # 得到 body 代码
     $body = $response->getBody();
     # 清理 body
     $response->clearBody();
     # 使用 布局
     $layout = new Yaf_View_Simple($this->_layoutDir);
     $layout->content = $body;
     /*
     		if(false !== strpos(REDIRECT_URL, '/loan_')){
        $loan   = LoanModel::getInfoByUid($_SESSION['user']['uid']);
        if(empty($loan)){
            $loan   = array(
                'loan_total'  => 0,
                'deposit_total'  => 0,
                'loan_over'=> 0,
                'ybc_over' => 0,
                'loan_lock'=> 0,
                'ybc_lock' => 0
            );
        }
        $layout->assign('loan', $loan);
             }
     */
     $layout->assign('layout', $this->_layoutVars);
     $response->setBody($layout->render($this->_layoutFile));
 }
Esempio n. 3
0
 public function testCase034()
 {
     $tpl = '<?php
     echo $name, "\\n";
     foreach($entry as $list) {
        echo "1. ", $list, "\\n";
     }
     ?><?=$name?>';
     $this->view->assign("entry", array('a', 'b', 'c'));
     if (!defined('YAF_MODE')) {
         $res = $this->view->evaluate($tpl, array('name' => 'template'));
     } else {
         $res = $this->view->eval($tpl, array('name' => 'template'));
     }
     $this->assertEquals('template' . PHP_EOL . '1. a' . PHP_EOL . '1. b' . PHP_EOL . '1. c' . PHP_EOL . 'template', $res);
 }
Esempio n. 4
0
 public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     /* get the body of the response */
     $body = $response->getBody();
     /*clear existing response*/
     $response->clearBody();
     /* wrap it in the layout */
     $layout = new Yaf_View_Simple($this->_layoutDir);
     $layout->content = $body;
     $layout->assign('layout', $this->_layoutVars);
     /* set the response to use the wrapped version of the content */
     $response->setBody($layout->render($this->_layoutFile));
 }
Esempio n. 5
0
 /**
  * method to render component page
  * 
  * @param string $viewName the view name to render
  * @return type
  */
 protected function renderView($viewName, array $params = array())
 {
     $path = Billrun_Factory::config()->getConfigValue('application.directory');
     $view_path = $path . '/views/' . strtolower($this->getRequest()->getControllerName());
     $view = new Yaf_View_Simple($view_path);
     foreach ($params as $key => $val) {
         $view->assign($key, $val);
     }
     return $view->render($viewName . '.phtml', $params);
 }