|
/** |
|
* get the top-navi for the bootstrap-framework (HTML) |
|
* |
|
* @param $naviArray |
|
* @param $tmpArrayChildOf |
|
* |
|
* @return string |
|
*/ |
|
function getHTMLNaviBootstrap($naviArray, $tmpArrayChildOf) |
|
{ |
|
$naviString = ''; |
|
$depth = 0; |
|
foreach ($naviArray as $index => $item) { |
|
|
|
$hasDropDown = false; |
|
$newDepth = (int)$item['level']; |
|
|
|
// is the navi-element "active"? |
|
if (in_array($item['id'], $tmpArrayChildOf, true)) { |
|
$tmpClass = ' active '; |
|
} else { |
|
$tmpClass = ''; |
|
} |
|
|
|
// add template-class |
|
$tmpClass .= ' menu_' . $item['template'] . ' ' . ' menu_pageid_' . $item['id'] . ' '; |
|
|
|
// check for sub-"ul" |
|
foreach ($naviArray as $item_tmp) { |
|
if ($item['id'] == $item_tmp['root_id']) { |
|
$tmpClass .= ' dropdown '; |
|
$hasDropDown = true; |
|
break; |
|
} |
|
} |
|
|
|
if ($newDepth > $depth) { |
|
|
|
while ($newDepth > $depth) { |
|
|
|
if ($depth > 0) { |
|
$ul_extra = 'mainnavSub dropdown-menu'; |
|
$li_extra = ''; |
|
} else { |
|
$ul_extra = 'nav navbar-nav'; |
|
$li_extra = 'mainnav'; |
|
} |
|
|
|
$naviString .= ' |
|
<ul class="' . $ul_extra . '"> |
|
<li class="' . $li_extra . ' ' . $tmpClass . '">'; |
|
$depth++; |
|
} |
|
|
|
} else if ($newDepth < $depth) { |
|
|
|
while ($newDepth < $depth) { |
|
$naviString .= ' |
|
</li> |
|
</ul>'; |
|
$depth--; |
|
} |
|
$naviString .= ' |
|
</li> |
|
<li class="mainnav ' . $tmpClass . '">'; |
|
|
|
} else if ($newDepth === $depth) { |
|
|
|
if ($index === 0) { |
|
$naviString .= ' |
|
<ul> |
|
<li class="mainnav ' . $tmpClass . '">'; |
|
} else if ($newDepth == 1) { |
|
$naviString .= ' |
|
</li> |
|
<li class="mainnav ' . $tmpClass . '">'; |
|
} else { |
|
$naviString .= ' |
|
</li> |
|
<li class="' . $tmpClass . '">'; |
|
} |
|
|
|
} |
|
|
|
if ($hasDropDown === true) { |
|
$extrasForLink = 'class="dropdown-toggle" data-toggle="dropdown"'; |
|
$extraIconForLink = '<b class="caret"></b>'; |
|
} else { |
|
$extrasForLink = ''; |
|
$extraIconForLink = ''; |
|
} |
|
|
|
$naviString .= '<a ' . $extrasForLink . ' href="' . $item['url'] . '">' . $item['name'] . ' ' . $extraIconForLink . '</a>'; |
|
$depth = $newDepth; |
|
} |
|
|
|
if (count($naviArray) > 0) { |
|
do { |
|
$naviString .= ' |
|
</li> |
|
</ul>'; |
|
$depth--; |
|
} |
|
while ($depth > 0); |
|
} |
|
|
|
return $naviString; |
|
} |