Example #1
0
 /**
  * _render_layout
  * Renders the page
  *
  * @param string $_html HTML of the template to use
  * @param string $template_type Content type of the template
  * @return string
  */
 public function _render_layout($_html, $template_type = 'html')
 {
     if (self::$_layout) {
         $this->data['layout_content'] = $_html;
         if ($template_type != 'html' or self::$_control_panel) {
             extract($this->data);
             ob_start();
             require self::$_layout . ".php";
             $html = ob_get_clean();
         } else {
             if (!File::exists(self::$_layout . ".html")) {
                 Log::fatal("Can't find the specified theme.", 'core', 'template');
                 return '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">We can\'t find your theme files. Please check your settings.';
             }
             $this->appendNewData($this->data);
             // Fetch layout and parse any front matter
             $layout = Parse::frontMatter(File::get(self::$_layout . '.html'), false);
             $html = Parse::template($layout['content'], Statamic_View::$_dataStore, array($this, 'callback'));
             $html = Lex\Parser::injectNoparse($html);
         }
     } else {
         $html = $_html;
     }
     // post-render hook
     $html = \Hook::run('_render', 'after', 'replace', $html, $html);
     return $html;
 }
 /**
  * Swap out form content if necessary
  *
  * @param array $data The form data that is going to be used unless changed
  * @return array
  */
 public function control_panel__form_content($data)
 {
     // master switch for revisions
     if (!$this->core->isEnabled()) {
         return $data;
     }
     if ($this->core->isRevisionSelected()) {
         $revision = Request::get('revision');
         $file = Request::get('path');
         $this->core->normalizePath($file);
         // does this revision exist?
         if ($this->core->isRevision($file, $revision)) {
             $this->blink->set('is_revision', true);
             $this->blink->set('is_latest_revision', $this->core->isLatestRevision($file, $revision));
             $this->blink->set('current_revision', $revision);
             // load revision content
             $raw_file = $this->core->getRevision($file, $revision);
             $raw_data = Parse::frontMatter($raw_file);
             $data = $raw_data['data'] + array('content' => $raw_data['content']);
         }
     } else {
         // save first revision is none are set
         $file = $this->core->getPath();
         if (!$this->core->hasRevisions($file)) {
             $this->core->saveFirstRevision($file);
         }
     }
     return $data;
 }