Example #1
0
 public function build()
 {
     $this->setLayout('shared/head.tpl');
     $params = $this->getParams();
     $this->assign('path', $params['path']);
     $this->getClass('Metadata', false);
     if (null == \Sifo\Metadata::get()) {
         \Sifo\Metadata::setKey('default');
     }
     $this->assign('metadata', \Sifo\Metadata::get());
     $this->assignMedia();
 }
Example #2
0
 public function buildChild()
 {
     $this->setLayout('static/docs.tpl');
     $params = $this->getParams();
     $path = $params['path'];
     $valid_paths = $this->getPossiblePaths($path);
     // Is a valid path
     if (in_array($path, $valid_paths)) {
         $file = ROOT_PATH . $this->docs_path . $path;
         // Show dir contents instead of markdown:
         if (is_dir($file)) {
             $file .= '/index';
         }
         $markdown_content = file_get_contents($file . '.md');
         // Substitute all <url:xxxx> entries with its corresponding URL:
         $markdown_content = preg_replace_callback('/\\<url\\:([a-z0-9]+)>/', array($this, 'getUrlByKey'), $markdown_content);
         $content = Markdown($markdown_content);
         $has_title = preg_match('#<h1>(.*)</h1>#', $content, $matches);
         if ($has_title) {
             $this->getClass('Metadata', false);
             \Sifo\Metadata::setKey('markdown_docs');
             \Sifo\Metadata::setValues('title', $matches[1]);
         }
         $this->assign('content', $content);
         $dir = new \Sifo\DirectoryList();
         // Get only immediate items, not the whole tree:
         $docs = $dir->getList(dirname($file), array('md'));
         $path = explode('/', $path);
         $this->assign('docs', $this->_formatFilesForMenu($docs));
         $this->assign('path', $path);
         $section = array_shift($path);
         $this->assign('section', $section);
     } else {
         throw new \Sifo\Exception_404('No markdown file is associated to this path, yet?');
     }
 }