예제 #1
0
 /**
  * Renders the given page and sends the result to the standard output.
  */
 public function render()
 {
     $pieCrust = $this->page->getApp();
     $pageConfig = $this->page->getConfig();
     // Get the template name.
     $templateName = $this->page->getConfig()->getValue('layout');
     if ($templateName == null or $templateName == '' or $templateName == 'none') {
         $templateName = false;
     } else {
         if (!preg_match('/\\.[a-zA-Z0-9]+$/', $templateName)) {
             $templateName .= '.html';
         }
     }
     if ($templateName !== false) {
         // Get the template engine and the page data.
         $extension = pathinfo($templateName, PATHINFO_EXTENSION);
         $templateEngine = PieCrustHelper::getTemplateEngine($pieCrust, $extension);
         // Render the page.
         $data = DataBuilder::getTemplateRenderingData($this->page);
         $templateEngine->renderFile($templateName, $data);
     } else {
         // No template... just output the 'content' segment.
         echo $this->page->getContentSegment();
     }
     if ($pieCrust->isDebuggingEnabled()) {
         // Add a footer with version, caching and timing information.
         $this->renderStatsFooter($this->page);
     }
 }
예제 #2
0
 /**
  * Renders the given page and sends the result to the standard output.
  */
 public function render()
 {
     $pieCrust = $this->page->getApp();
     $pageConfig = $this->page->getConfig();
     // Set the page as the current context.
     $executionContext = $pieCrust->getEnvironment()->getExecutionContext(true);
     $executionContext->pushPage($this->page);
     // Get the template name.
     $templateNames = $this->page->getConfig()->getValue('layout');
     if ($templateNames == null or $templateNames == '' or $templateNames == 'none') {
         $templateNames = false;
     } else {
         $templateNames = explode(',', $templateNames);
         foreach ($templateNames as &$name) {
             if (!preg_match('/\\.[a-zA-Z0-9]+$/', $name)) {
                 $name .= '.html';
             }
         }
     }
     if ($templateNames !== false) {
         // Get the template engine and the page data.
         $extension = pathinfo($templateNames[0], PATHINFO_EXTENSION);
         $templateEngine = PieCrustHelper::getTemplateEngine($pieCrust, $extension);
         // Render the page.
         $data = DataBuilder::getTemplateRenderingData($this->page);
         $templateEngine->renderFile($templateNames, $data);
     } else {
         // No template... just output the 'content' segment.
         echo $this->page->getContentSegment();
     }
     // Restore the previous context.
     $executionContext->popPage();
 }