예제 #1
0
파일: Page.php 프로젝트: tenebras/kalibri
 /**
  * Render page with layout and view
  */
 public function render($asString = false)
 {
     ob_start();
     header('Content-Type: ' . $this->_contentType);
     // Is view or layout passed
     if (!$this->getViewName() && !$this->_layout) {
         // Return available page content
         echo \Kalibri::data()->get(\Kalibri\View::VAR_CONTENT);
         return k_ob_get_end(!$asString);
     }
     $data = \Kalibri::data();
     // Convert inner resources and data format from array to string
     $data->set(\Kalibri\View::VAR_SCRIPTS, implode("\n", $data->get(\Kalibri\View::VAR_SCRIPTS)));
     $data->set(\Kalibri\View::VAR_STYLES, implode("\n", $data->get(\Kalibri\View::VAR_STYLES)));
     $data->set(\Kalibri\View::VAR_META, implode("\n", $data->get(\Kalibri\View::VAR_META)));
     // Add prefix and suffix to page title
     $data->set(\Kalibri\View::VAR_TITLE, $this->getTitle(true, true));
     // Is view name passed and this view exists
     if ($this->_view instanceof \Kalibri\View && $this->_view->isExists(null, $this->_alternativeViewLocation)) {
         // Render view content into content var ( Kalibri::data()->get( self::VAR_CONTENT ) )
         $this->_view->render(true, $this->_alternativeViewLocation);
     }
     // Is layout name passed and this layout exists
     if ($this->_layout instanceof \Kalibri\View\Layout && $this->_layout->isExists(null, $this->_alternativeViewLocation)) {
         // Render layout content into content var ( Data::get( self::VAR_CONTENT ) )
         $this->_layout->render(true, $this->_alternativeViewLocation);
     }
     // Send full page content to client
     echo \Kalibri::data()->get(\Kalibri\View::VAR_CONTENT);
     return k_ob_get_end(!$asString);
 }
예제 #2
0
 public function render($asString = false, $path = null)
 {
     return parent::render($asString, $path ?: $this->path);
 }