content.php 6.72 KB
Newer Older
zYne's avatar
zYne committed
1 2 3 4 5 6 7 8 9 10
<table width=100% cellspacing=0 cellpadding=0>
    <tr>
        <td class='bordered' valign='top'>
            <?php
            if ( ! isset($_GET['chapter'])) {
            
                foreach ($i as $k => $v) {
                    $indexes = explode('.', $v['index']);
                    $level = count($indexes);
                    $e = explode(' - ', $v['name']);
zYne's avatar
zYne committed
11 12
                    $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . $v['name'] . '.php';

zYne's avatar
zYne committed
13
                    print '<div class=level' . $level . '><font class=level' . $level . '>&nbsp;'. $v['index'] . '. <a href=documentation2.php?chapter='
zYne's avatar
zYne committed
14 15 16 17 18
                          . urlencode($v['name']) . ">" . end($e) ."</a></font>";
                    if ( ! file_exists($file)) {
                        //print "<font color='red'>[code]</font>";
                    }
                    print "</div>";
zYne's avatar
zYne committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
                }
            } else {
            
            
                $e = explode(' - ', $_GET['chapter']);
                $subchapters = false;
                $found = false;
            
                foreach ($i as $k => $v) {
                    if ($found) {
                        if (strncmp($v['name'], $_GET['chapter'], strlen($_GET['chapter'])) === 0) {
                            $subchapters = true;                                                                     	
                        }
                        break;
                    }
                    $parts = explode(' - ', $v['name']);
                    $indexes = explode('.', $v['index']);
            
                    if ($v['name'] === $_GET['chapter']) {
                        if (isset($i[($k - 1)])) {
                            $prev = $i[($k - 1)];
                        }
                        if (isset($i[($k + 1)])) {
                            $next = $i[($k + 1)];
                        }
            
                        $foundKey   = ($k + 1);
                        $found = $v;
                    }
                }
            ?>
            <table width=100% cellspacing=5 cellpadding=1>
                <tr>
                    <td align='center' colspan=2>
                        <b class='title'>
                        <?php 
                            $chapter = array_shift($parts);
                            print 'Chapter ' . $indexes[0] . '. ' . $chapter;
                        ?>
                        </b>
                    </td>
                </tr>
                <tr>
                    <td align='left'>
                    <?php
                    if(isset($prev)) {
                    ?>
                        <b><a href=documentation2.php?chapter=<?php print urlencode($prev['name']); ?>>Prev</a></b>
                    <?php
                    }
                    ?>
                    </td>
                    <td align='right'>
                    <?php 
                    if(isset($next)) {
                    ?>
                    <b><a href=documentation2.php?chapter=<?php print urlencode($next['name']); ?>>Next</a></b></td>
                    <?php
                    }
                    ?>
                </tr>
                <tr>
                    <td colspan=2>


                        <b class='title'>
                        <?php
                    
                        //print implode('.', $indexes) . '. ' . implode(' - ', $parts);
                        ?>
                        </b>
                        <hr>
                        <b class='title'>
                        <?php
                            print implode('.', $indexes) . '. ';
                            $stack = array();
                            $links = array();
                            $tmp = array_merge(array($chapter), $parts);
                            foreach($tmp as $k => $v) {
                                $stack[] = $v;
                                $links[] = "<a href=documentation2.php?chapter=" . urlencode(implode(' - ', $stack)) . '>' . $v . '</a>';
                            }
                            print implode(' - ', $links);
                        ?>
                        <br \>
                        </b>
                        <hr class='small'>
                        <?php
                        if ($subchapters) {
                        ?>
                        <b class='title'>
                        <div class='level1'> Table of contents</div>
                        </b>
                        <?php
                            for ($x = $foundKey; $x < count($i); $x++) {
                                $p = explode(' - ', $i[$x]['name']);
                                $count = (count($parts) + 1);
                                $l = count($p) - count($parts);
                                while($count--) {
                                    array_shift($p);
                                }
zYne's avatar
zYne committed
120 121 122 123 124 125
                                if ( ! empty($p)) {
                                    print "<div class=level" . $l . '><font class=level' . $l . '>' . $i[$x]['index'];
                                    ?>
    
                                    <a href=documentation2.php?chapter=<?php print urlencode($i[$x]['name']) . '>' . end($p); ?></a>
                                    </font></div>
zYne's avatar
zYne committed
126 127 128 129
                                    <?php 
                                }
                                if (strncmp($i[$x]['name'], $_GET['chapter'], strlen($_GET['chapter'])) !== 0) {
                                    break;
zYne's avatar
zYne committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
                                }
                            }
                        }
                        $doc->renderBlock($found['name']);
                        }
                        ?>
                    </td>
                </tr>
              </table>
        </td>
        <td width=10>
        </td>
        <td valign='top' width=300>
            <div class='smallmenu'>
                <font class=smallmenu>&nbsp; -- <a href=documentation2.php>index</a></font><br \>
                <?php
                foreach ($i as $k => $v) {
                    $indexes = explode('.', $v['index']);
                    $level = count($indexes);
                    $e = explode(' - ', $v['name']);
                    if($level === 1) {
                        $level++;
                        print '<font class=smallmenu>&nbsp;'. $v['index'] . '. <a href=documentation2.php?chapter='
                            . urlencode($v['name']) . ">" . end($e) ."</a></font><br \>";
                    }
                }
                ?>
            </div>
        </td>
    </tr>
</table>