Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - A few more consequences of the Namespace #53

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Weathermap.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Assume that this should only be printed if it's not setup correctly.
if(! is_writable('plugins/Weathermap/configs')) {
print_error("The map config directory is not writable by the web server user. You will not be able to edit any files until this is corrected.");
echo("The map config directory is not writable by the web server user. You will not be able to edit any files until this is corrected.");
$readme = @file_get_contents('plugins/Weathermap/INSTALL.md');
$readme = nl2br($readme);
echo('<h3>Please ensure you follow the installation instructions below.</h3>');
Expand Down
14 changes: 11 additions & 3 deletions Weathermap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@ public static function menu() {
//Create submenu
$submenu = ' <ul class="dropdown-menu scrollable-menu">';
$count = 0;

//getShortName - might make sense to include this ShortName code into Plugin class somewhere ?
Copy link
Contributor

@murrant murrant Jul 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use __CLASS__ can't you?

if ($pos = strrpos(get_class(), '\\')) {
$short= substr(get_class(), $pos + 1);
} else {
$short = $pos;
};

foreach ($files as $file=>$data) {
$nicefile = htmlspecialchars($file);
$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>';
$submenu .= ' <li><a href="/plugins/'.$short.'/'.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().'">Weathermap</a>');
echo('<li class="dropdown-submenu"><a href="plugin/p='.$short.'">'.$short.'</a>');
echo $submenu;
echo ('</li>');
} else {
//Create menu without submenu
echo('<li><a href="plugin/p='.get_class().'">Weathermap</a></li>');
echo('<li><a href="plugin/p='.$short.'">'.$short.'</a></li>');
}
}
}
Expand Down