forked from hbeyer/libreto
/
makeNavigation.php
51 lines (44 loc) · 1.38 KB
/
makeNavigation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
<?php
function makeToC($structure) {
$ToC = array();
foreach($structure as $section) {
if($section->level == 1) {
$ToC[] = $section->label;
}
}
return($ToC);
}
function makeULContent($toc, $nameCat, $type) {
$result = '';
foreach($toc as $category) {
$result .= '<li><a href="'.$nameCat.'-'.$type.'.html#'.translateAnchor($category).'">'.$category.'</a></li>';
}
return($result);
}
function makeNavigation($nameCat, $tocs, $type) {
/*$tocs is an associative array of arrays created by the function makeToC,
the index of which is the field the function makeIndex used to create the index categories
$type is the field used for the actual page
*/
$nameCat = fileNameTrans($nameCat);
$result = '<ul class="nav navbar-nav">';
foreach($tocs as $field => $toc) {
$classLiTop = 'download';
if($field == $type) {
$classLiTop = 'active';
}
$listItems = makeULContent($toc, $nameCat, $field);
$fieldGer = translateFieldNames($field);
$result .= '
<li class="'.$classLiTop.'">
<a class="dropdown-toggle" data-toggle="dropdown" href="'.$nameCat.'-'.$field.'.html">nach '.$fieldGer.'<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="'.$nameCat.'-'.$field.'.html">Seitenanfang</a></li>
'.$listItems.'
</ul>
</li>';
}
$result .= '</ul>';
return($result);
}
?>