コード例 #1
0
ファイル: toc.php プロジェクト: naneau/MadoquaBundle
/**
 * recursive chapter output 
 * 
 * ... yeah :(
 *
 * @param Chapter $chapter 
 * @return string
 */
function outputChapter(Chapter $chapter, View $view)
{
    ?>
    <li class="chapter">
        <h2><?php 
    echo $chapter->getName();
    ?>
</h2>
    
        <?php 
    if (count($chapter->getChapters()) > 0) {
        ?>
        <ul class="chapters">

            <?php 
        foreach ($chapter->getChapters() as $subChapter) {
            ?>
            <?php 
            outputChapter($subChapter, $view);
            ?>
            <?php 
        }
        ?>
    
        </ul>
        <?php 
    }
    ?>

        <?php 
    if (count($chapter->getPages()) > 0) {
        ?>

        <ul class="pages">
            <?php 
        foreach ($chapter->getPages() as $page) {
            ?>
            <li>
                <a href="<?php 
            echo $view['router']->generate('book_page', array('path' => $page->getPath()));
            ?>
">
                    <?php 
            echo $page->getTitle();
            ?>
                </a>
            </li>
            <?php 
        }
        ?>
        </ul>

        <?php 
    }
    ?>
    </li>
<?php 
}
コード例 #2
0
ファイル: full.php プロジェクト: naneau/MadoquaBundle
/**
 * recursive chapter output 
 * 
 * ... yeah :(
 *
 * @param Chapter $chapter 
 * @return string
 */
function outputChapter(Chapter $chapter)
{
    ?>
    <h1><?php 
    echo $chapter->getName();
    ?>
</h1>
    
    <?php 
    if (count($chapter->getChapters()) > 0) {
        ?>
    <ul class="chapters">

        <?php 
        foreach ($chapter->getChapters() as $subChapter) {
            ?>
        <?php 
            outputChapter($subChapter);
            ?>
        <?php 
        }
        ?>
    
    </ul>
    <?php 
    }
    ?>

    <?php 
    if (count($chapter->getPages()) > 0) {
        ?>

    <ul class="pages">
        <h2>Pagina's</h2>
        <?php 
        foreach ($chapter->getPages() as $page) {
            ?>
        <?php 
            echo $page->getParsedText();
            ?>
        <?php 
        }
        ?>
    
    </ul>

    <?php 
    }
}
コード例 #3
0
ファイル: Chapter.php プロジェクト: naneau/MadoquaBundle
 /**
  * add a chapter
  *
  * @param Chapter $chapter 
  * @return void
  */
 public function addChapter(Chapter $chapter)
 {
     $chapter->setParent($this);
     $this->chapters[] = $chapter;
 }
コード例 #4
0
ファイル: Book.php プロジェクト: naneau/MadoquaBundle
 /**
  * find chapter from path recursively
  *
  * @param Chapter $chapter 
  * @param string $path 
  * @return bool|Chapter
  */
 private function findPageFromPath(Chapter $chapter, $path)
 {
     foreach ($chapter->getPages() as $page) {
         if ($page->getPath() == $path) {
             return $page;
         }
     }
     foreach ($chapter->getChapters() as $subChapter) {
         $found = $this->findPageFromPath($subChapter, $path);
         if ($found !== false) {
             return $found;
         }
     }
     return false;
 }
コード例 #5
0
ファイル: Mapper.php プロジェクト: naneau/MadoquaBundle
 /**
  * create chapter from directory name
  *
  * @param string $name 
  * @return Chapter
  */
 private function createChapterFromFileInfo(\SplFileInfo $fileInfo)
 {
     $chapter = new Chapter();
     $chapter->setName($this->stripNumberFromString($fileInfo->getFilename()));
     $chapter->setPath($this->parsePath($fileInfo));
     //set "path" like identifier
     return $chapter;
 }