예제 #1
0
 /**
  * Called before the controller is deleted.
  *
  * The view's render method is called for each view registered.
  *
  * @throws ViewException
  */
 public function __destruct()
 {
     $this->_output->outputHeader();
     if (!$this->_isRenderAction) {
         if (isset($this->_view)) {
             if (is_array($this->_view)) {
                 $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                 foreach ($this->_view as $view) {
                     $view->render();
                 }
                 $this->_app->getHookManager()->runAfterView();
             } elseif (is_a($this->_view, '\\pff\\AView')) {
                 $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                 $this->_view->render();
                 $this->_app->getHookManager()->runAfterView();
             } else {
                 throw new ViewException("The specified View is not valid.");
             }
         }
     } else {
         if (isset($this->_view)) {
             if (is_array($this->_view)) {
                 foreach ($this->_view as $view) {
                     $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                     $view->render();
                 }
             } elseif (is_a($this->_view, '\\pff\\AView')) {
                 $this->_app->getHookManager()->runBeforeView(array('controller' => $this));
                 $this->_view->render();
             } else {
                 throw new ViewException("The specified View is not valid.");
             }
         }
     }
 }
예제 #2
0
파일: ViewPHP.php 프로젝트: stonedz/pff2
 public function __construct($templateName)
 {
     if (substr($templateName, 0, 1) != '/') {
         $templatePath = ROOT . DS . 'app' . DS . 'views' . DS . $templateName;
     } else {
         $templatePath = $templateName;
     }
     if (!file_exists($templatePath)) {
         throw new ViewException('Template file ' . $templatePath . ' does not exist');
     }
     parent::__construct($templateName);
 }
예제 #3
0
파일: ViewSmarty.php 프로젝트: stonedz/pff2
 public function __construct($templateName)
 {
     $this->_smarty = new \Smarty();
     // The smarty instance should be accessible before
     $smartyDir = ROOT . DS . 'app' . DS . 'views' . DS . 'smarty' . DS;
     $this->_smarty->template_dir = $smartyDir . 'templates' . DS;
     $this->_smarty->compile_dir = $smartyDir . 'compiled_templates' . DS;
     $this->_smarty->config_dir = $smartyDir . 'configs' . DS;
     $this->_smarty->cache_dir = $smartyDir . 'cache' . DS;
     $templatePath = ROOT . DS . 'app' . DS . 'views' . DS . 'smarty' . DS . 'templates' . DS . $templateName;
     if (!file_exists($templatePath)) {
         throw new \pff\ViewException('Template file ' . $templatePath . ' does not exist');
     }
     parent::__construct($templateName);
     $this->_smarty->registerPlugin('function', 'renderAction', array($this, 'smarty_plugin_renderAction'));
 }