getFirstPage() 공개 메소드

public getFirstPage ( ) : Todaymade\Daux\Tree\Content | null
리턴 Todaymade\Daux\Tree\Content | null
예제 #1
0
 /**
  * Recursively generate the documentation
  *
  * @param Directory $tree
  * @param string $output_dir
  * @param \Todaymade\Daux\Config $params
  * @param OutputInterface $output
  * @param int $width
  * @param bool $index_pages
  * @param string $base_url
  * @throws \Exception
  */
 private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, $index_pages, $base_url = '')
 {
     DauxHelper::rebaseConfiguration($params, $base_url);
     if ($base_url !== '' && empty($params['entry_page'])) {
         $params['entry_page'] = $tree->getFirstPage();
     }
     foreach ($tree->getEntries() as $key => $node) {
         if ($node instanceof Directory) {
             $new_output_dir = $output_dir . DIRECTORY_SEPARATOR . $key;
             mkdir($new_output_dir);
             $this->generateRecursive($node, $new_output_dir, $params, $output, $width, $index_pages, '../' . $base_url);
             // Rebase configuration again as $params is a shared object
             DauxHelper::rebaseConfiguration($params, $base_url);
         } else {
             $this->runAction('- ' . $node->getUrl(), $output, $width, function () use($node, $output_dir, $key, $params, $index_pages) {
                 if ($node instanceof Raw) {
                     copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
                     return;
                 }
                 $generated = $this->generateOne($node, $params);
                 file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
                 if ($index_pages) {
                     $this->indexed_pages[] = ['title' => $node->getTitle(), 'text' => utf8_encode($this->strip_html_tags($generated->getPureContent())), 'tags' => '', 'url' => $node->getUrl()];
                 }
             });
         }
     }
 }
예제 #2
0
 private function generateRecursive(Directory $tree, Config $params, $base_url = '')
 {
     $final = ['title' => $this->prefix . $tree->getTitle()];
     $params['base_url'] = $params['base_page'] = $base_url;
     $params['image'] = str_replace('<base_url>', $base_url, $params['image']);
     if ($base_url !== '') {
         $params['entry_page'] = $tree->getFirstPage();
     }
     foreach ($tree->getEntries() as $key => $node) {
         if ($node instanceof Directory) {
             $final['children'][$this->prefix . $node->getTitle()] = $this->generateRecursive($node, $params, '../' . $base_url);
         } elseif ($node instanceof Content) {
             $params['request'] = $node->getUrl();
             $contentType = $this->daux->getContentTypeHandler()->getType($node);
             $data = ['title' => $this->prefix . $node->getTitle(), 'file' => $node, 'page' => ContentPage::fromFile($node, $params, $contentType)];
             // As the page is lazily generated
             // We do it now to fail fast in case of problem
             $data['page']->getContent();
             if ($key == 'index.html') {
                 $final['title'] = $this->prefix . $tree->getTitle();
                 $final['file'] = $node;
                 $final['page'] = $data['page'];
             } else {
                 $final['children'][$data['title']] = $data;
             }
         }
     }
     return $final;
 }
예제 #3
0
 /**
  * Recursively generate the documentation
  *
  * @param Directory $tree
  * @param string $output_dir
  * @param \Todaymade\Daux\Config $params
  * @param OutputInterface $output
  * @param integer $width
  * @param string $base_url
  * @throws \Exception
  */
 private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, $base_url = '')
 {
     DauxHelper::rebaseConfiguration($params, $base_url);
     if ($base_url !== '' && empty($params['entry_page'])) {
         $params['entry_page'] = $tree->getFirstPage();
     }
     foreach ($tree->getEntries() as $key => $node) {
         if ($node instanceof Directory) {
             $new_output_dir = $output_dir . DIRECTORY_SEPARATOR . $key;
             mkdir($new_output_dir);
             $this->generateRecursive($node, $new_output_dir, $params, $output, $width, '../' . $base_url);
             // Rebase configuration again as $params is a shared object
             DauxHelper::rebaseConfiguration($params, $base_url);
         } else {
             $this->runAction("- " . $node->getUrl(), $output, $width, function () use($node, $output_dir, $key, $params) {
                 if (!$node instanceof Content) {
                     copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
                     return;
                 }
                 $generated = $this->generateOne($node, $params);
                 file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
             });
         }
     }
 }