Skip to content

Commit

Permalink
Conditionnal display of submenu if maps are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
PipoCanaja committed Jul 11, 2018
1 parent 794df10 commit 01b92d3
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions Weathermap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,31 @@
class Weathermap {

public static function menu() {
//Include config
include_once 'config.inc.php';

include_once 'config.inc.php';
//Parse config files
$files = list_weathermaps($mapdir);

echo('<li class="dropdown-submenu"><a href="plugin/p='.get_class().'">'.get_class().'</a>');
$files = list_weathermaps($mapdir);
echo (' <ul class="dropdown-menu scrollable-menu">');
//Create submenu
$submenu = ' <ul class="dropdown-menu scrollable-menu">';
$count = 0;
foreach ($files as $file=>$data) {
$nicefile = htmlspecialchars($file);
echo '<li><a href="/plugins/'.get_class().'/'.htmlspecialchars($data['page']).'"><i class="fa fa-map fa-fw fa-lg" aria-hidden="true"></i> '.htmlspecialchars($data['title']).'</a></li>';
$submenu .= ' <li><a href="/plugins/'.get_class().'/'.htmlspecialchars($data['page']).'"><i class="fa fa-map fa-fw fa-lg" aria-hidden="true"></i> '.htmlspecialchars($data['title']).'</a></li>';
$count ++;
}
$submenu .= ' </ul>';

//Display it if not empty
if ($count > 0) {
echo('<li class="dropdown-submenu"><a href="plugin/p='.get_class().'">'.get_class().'</a>');
echo $submenu;
echo ('</li>');
} else {
//Create menu without submenu
echo('<li><a href="plugin/p='.get_class().'">'.get_class().'</a></li>');
}
echo (' </ul>');
echo ('</li>');
}
}
?>

0 comments on commit 01b92d3

Please sign in to comment.