summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorNewEraCracker <neweracracker@gmail.com>2016-01-18 16:24:42 +0000
committerNewEraCracker <neweracracker@gmail.com>2016-01-18 16:24:42 +0000
commitdffe24be0153e5cfd3d99068f7b7f36b92795121 (patch)
treeab632d62092d303d8da4ebea309ca130fe1d76db /src/usr
parentb12cb9535d0822ebfbcb64e0c865864e1e079a68 (diff)
downloadpfsense-dffe24be0153e5cfd3d99068f7b7f36b92795121.zip
pfsense-dffe24be0153e5cfd3d99068f7b7f36b92795121.tar.gz
Small tunning to all aspects involving widgets
1) Perform exclusion of non .inc files while reading directory. 2) Be more strict when checking for widget title. 3) We are in the PHP 5.5 age. We can convert certain pieces to anonymous functions and overall better coding.
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/local/www/index.php16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php
index 3816c0a..c9b60a8 100644
--- a/src/usr/local/www/index.php
+++ b/src/usr/local/www/index.php
@@ -120,15 +120,15 @@ $dirhandle = opendir($directory);
$filename = "";
while (false !== ($filename = readdir($dirhandle))) {
+ if (!stristr($filename, ".inc")) {
+ continue;
+ }
$phpincludefiles[] = $filename;
}
## Include each widget include file.
## These define vars that specify the widget title and title link.
foreach ($phpincludefiles as $includename) {
- if (!stristr($includename, ".inc")) {
- continue;
- }
if (file_exists($directory . $includename)) {
include($directory . $includename);
}
@@ -140,7 +140,7 @@ foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file) {
// Get the widget title that should be in a var defined in the widget's inc file.
$widgettitle = ${$name . '_title'};
- if ((strlen($widgettitle) == 0)) {
+ if (empty(trim($widgettitle))) {
// Fall back to constructing a title from the file name of the widget.
$widgettitle = ucwords(str_replace('_', ' ', $name));
}
@@ -277,7 +277,7 @@ if ($config['widgets'] && $config['widgets']['sequence'] != "") {
// Get the widget title that should be in a var defined in the widget's inc file.
$widgettitle = ${$file . '_title'};
- if ((strlen($widgettitle) == 0)) {
+ if (empty(trim($widgettitle))) {
// Fall back to constructing a title from the file name of the widget.
$widgettitle = ucwords(str_replace('_', ' ', $file));
}
@@ -328,12 +328,8 @@ pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
<?php
// Build the Available Widgets table using a sorted copy of the $widgets array
-function wgtcmp($a, $b) {
- return(strtolower($a['name']) > strtolower($b['name']));
-}
-
$available = $widgets;
-uasort($available, 'wgtcmp');
+uasort($available, function($a, $b){ return strcasecmp($a['name'], $b['name']); });
foreach ($available as $widgetname => $widgetconfig):
if ($widgetconfig['display'] == 'none'):
OpenPOWER on IntegriCloud