1<?php
2/**
3 * @link   http://resources.neolao.com/php/dokuwiki/templates
4 * @author neolao <neo@neolao.com>
5 */
6
7// Must be run from within DokuWiki
8if (!defined('DOKU_INC')) die();
9
10/**
11 * Fork inc/template.php
12 */
13function custom_toc()
14{
15    global $TOC;
16    global $ACT;
17    global $ID;
18    global $REV;
19    global $INFO;
20    global $conf;
21    global $lang;
22    $toc = array();
23
24    if(is_array($TOC)){
25        // if a TOC was prepared in global scope, always use it
26        $toc = $TOC;
27    }elseif(($ACT == 'show' || substr($ACT,0,6) == 'export') && !$REV && $INFO['exists']){
28        // get TOC from metadata, render if neccessary
29        $meta = p_get_metadata($ID, false, true);
30        if(isset($meta['internal']['toc'])){
31            $tocok = $meta['internal']['toc'];
32        }else{
33            $tocok = true;
34        }
35        $toc   = $meta['description']['tableofcontents'];
36        if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']){
37            $toc = array();
38        }
39    }elseif($ACT == 'admin'){
40        // try to load admin plugin TOC FIXME: duplicates code from tpl_admin
41        $plugin = null;
42        if (!empty($_REQUEST['page'])) {
43            $pluginlist = plugin_list('admin');
44            if (in_array($_REQUEST['page'], $pluginlist)) {
45                // attempt to load the plugin
46                $plugin =& plugin_load('admin',$_REQUEST['page']);
47            }
48        }
49        if ( ($plugin !== null) &&
50             (!$plugin->forAdminOnly() || $INFO['isadmin']) ){
51            $toc = $plugin->getTOC();
52            $TOC = $toc; // avoid later rebuild
53        }
54    }
55
56    trigger_event('TPL_TOC_RENDER', $toc, NULL, false);
57
58    if( !empty( $toc ) ){
59        echo DOKU_LF, '<section>', DOKU_LF;
60        echo '<h1>', $lang['toc'], '</h1>';
61
62        $level = 0;
63        foreach( $toc as $item )
64        {
65            if( $item['level'] > $level ){
66                //open new list
67                for($i=0; $i<($item['level'] - $level); $i++){
68                    if ($i) echo "<li class=\"clear\">\n";
69                    echo "\n<ul class=\"$class\">\n";
70                }
71            }elseif( $item['level'] < $level ){
72                //close last item
73                echo "</li>\n";
74                for ($i=0; $i<($level - $item['level']); $i++){
75                    //close higher lists
76                    echo "</ul>\n</li>\n";
77                }
78            }else{
79                //close last item
80                echo "</li>\n";
81            }
82
83            //remember current level
84            $level = $item['level'];
85
86            //print item
87            echo '<li>';
88            if( isset( $item['hid'] ) ){
89                $link = '#'.$item['hid'];
90            }else{
91                $link = $item['link'];
92            }
93            echo '<a href="'.$link.'" class="toc">'.hsc($item['title']).'</a>';
94        }
95
96        //close remaining items and lists
97        for ($i=0; $i < $level; $i++){
98            echo "</li></ul>\n";
99        }
100
101
102        //print_r( $toc );
103        echo '</section>', DOKU_LF;
104    }
105}
106
107
108/**
109 * Fork inc/template.php
110 */
111function custom_youarehere( $sep = '&raquo;' )
112{
113  global $conf;
114  global $ID;
115  global $lang;
116
117  // check if enabled
118  if(!$conf['youarehere']) return false;
119
120  $parts = explode(':', $ID);
121  $count = count($parts);
122
123  if($GLOBALS['ACT'] == 'search')
124  {
125    $parts = array($conf['start']);
126    $count = 1;
127  }
128
129
130  // always print the startpage
131  $title = useHeading('navigation') ? p_get_first_heading($conf['start']) : $conf['start'];
132  if(!$title) $title = $conf['start'];
133  tpl_link(wl($conf['start']),hsc($title),'title="'.$conf['start'].'"');
134
135  // print intermediate namespace links
136  $part = '';
137  for($i=0; $i<$count - 1; $i++){
138    $part .= $parts[$i].':';
139    $page = $part;
140    resolve_pageid('',$page,$exists);
141    if ($page == $conf['start']) continue; // Skip startpage
142
143    // output
144    echo $sep;
145    if($exists){
146      $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i];
147      tpl_link(wl($page),hsc($title),'title="'.$page.'"');
148    }else{
149      tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"');
150    }
151  }
152
153  // print current page, skipping start page, skipping for namespace index
154  if(isset($page) && $page==$part.$parts[$i]) return;
155  $page = $part.$parts[$i];
156  if($page == $conf['start']) return;
157  echo $sep;
158  if(page_exists($page)){
159    $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i];
160    tpl_link(wl($page),hsc($title),'title="'.$page.'"');
161  }else{
162    tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"');
163  }
164  return true;
165}
166
167
168
169?><!DOCTYPE html>
170<html lang="<?php echo $conf['lang']; ?>">
171    <head>
172        <meta charset="utf-8" />
173        <meta name="verify-v1" content="qgh3TZHu+ZRSRFmOPCG031BS0KO9MW4XtDnBtjMUfSk=" />
174        <?php tpl_metaheaders(); ?>
175        <title><?php tpl_pagetitle(); ?> - <?php echo strip_tags($conf['title']); ?></title>
176    </head>
177    <body>
178        <header role="banner">
179            <h1><?php tpl_link(wl(),$conf['title'],'name="dokuwiki__top" id="dokuwiki__top" accesskey="h" title="[H]"'); ?></h1>
180        </header>
181        <nav role="primary navigation">
182            <ul>
183                <li><a href="http://portfolio.neolao.com/">Portfolio</a></li>
184                <li class="selected"><a href="http://resources.neolao.com/">Ressources</a></li>
185                <li><a href="http://blog.neolao.com/">Blog</a></li>
186                <li><a href="http://forum.neolao.com/">Forum</a></li>
187            </ul>
188        </nav>
189        <nav role="secondary navigation">
190            <?php custom_youarehere(); ?>
191        </nav>
192        <aside>
193            <section>
194                <h1>Recherche</h1>
195                <form action="/" accept-charset="utf-8" id="dw__search">
196                    <input type="hidden" name="do" value="search" />
197                    <input type="text" id="qsearch__in" accesskey="f" name="id" size="10"/>
198                    <input type="submit" value="OK" class="button" title="Rechercher" />
199                </form>
200            </section>
201            <?php custom_toc(); ?>
202            <?php
203            if( $INFO['ismanager'] ){
204                echo '<section><h1>ADMIN</h1>';
205                tpl_button('edit');
206                tpl_button('history');
207                tpl_button('revert');
208                tpl_button('admin');
209                tpl_button('profile');
210                tpl_button('login');
211                echo '</section>';
212            }
213            ?>
214        </aside>
215        <section id="body" role="main">
216            <?php html_msgarea()?>
217
218            <article>
219            <?php flush()?>
220            <?php tpl_content(false)?>
221            <?php flush()?>
222            </article>
223
224            <hr class="clear"/>
225        </section>
226        <footer role="contentinfo">
227            <?php tpl_license(false); ?>
228            <address>Contact&nbsp;: <a href="mailto:webmaster@neolao.com">webmaster@neolao.com</a></address>
229            <p><?php /* provide DokuWiki housekeeping, required in all templates */ tpl_indexerWebBug()?></p>
230        </footer>
231   </body>
232</html>
233