From 0fc6d49d4be58f5de57a3143a091034f99783e65 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 27 Apr 2017 09:58:52 +0545 Subject: [PATCH] Allow customize of dashboard widget names --- src/usr/local/www/guiconfig.inc | 19 +++ src/usr/local/www/index.php | 21 ++- .../widgets/widgets/dyn_dns_status.widget.php | 2 + .../www/widgets/widgets/gateways.widget.php | 4 +- .../widgets/interface_statistics.widget.php | 2 + .../www/widgets/widgets/interfaces.widget.php | 2 + .../local/www/widgets/widgets/log.widget.php | 4 + .../www/widgets/widgets/openvpn.widget.php | 2 + .../www/widgets/widgets/picture.widget.php | 29 ++-- .../local/www/widgets/widgets/rss.widget.php | 10 +- .../widgets/services_status.widget.php | 2 + .../widgets/widgets/smart_status.widget.php | 2 + .../widgets/system_information.widget.php | 2 + .../widgets/thermal_sensors.widget.php | 156 ++++++++---------- .../widgets/widgets/wake_on_lan.widget.php | 8 +- 15 files changed, 148 insertions(+), 117 deletions(-) diff --git a/src/usr/local/www/guiconfig.inc b/src/usr/local/www/guiconfig.inc index 3902c22655..ff498d02ba 100644 --- a/src/usr/local/www/guiconfig.inc +++ b/src/usr/local/www/guiconfig.inc @@ -577,6 +577,25 @@ function genhtmltitle($title, $links=true) { return $bc; } +function gen_customwidgettitle_div($widgettitle) { + $divstr = '
'; + $divstr .= ' '; + $divstr .= '
'; + $divstr .= ' '; + $divstr .= '
'; + $divstr .= '
'; + + return $divstr; +} + +function set_customwidgettitle(& $user_settings) { + if ($_POST['descr']) { + $user_settings['widgets'][$_POST['widgetkey']]['descr'] = trim($_POST['descr']); + } else { + unset($user_settings['widgets'][$_POST['widgetkey']]['descr']); + } +} + /* update the changedesc and changecount(er) variables */ function update_changedesc($update) { global $changedesc; diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php index e4ac5c2ca7..a06b44e712 100644 --- a/src/usr/local/www/index.php +++ b/src/usr/local/www/index.php @@ -302,17 +302,20 @@ if ($user_settings['widgets']['sequence'] != "") { if (false !== $offset) { $basename = substr($basename, 0, $offset); } - - // Get the widget title that should be in a var defined in the widget's inc file. - $widgettitle = ${$basename . '_title'}; - - if (empty(trim($widgettitle))) { - // Fall back to constructing a title from the file name of the widget. - $widgettitle = ucwords(str_replace('_', ' ', $basename)); - } - $widgetkey = $basename . '-' . $copynum; + if (isset($user_settings['widgets'][$widgetkey]['descr'])) { + $widgettitle = htmlentities($user_settings['widgets'][$widgetkey]['descr']); + } else { + // Get the widget title that should be in a var defined in the widget's inc file. + $widgettitle = ${$basename . '_title'}; + + if (empty(trim($widgettitle))) { + // Fall back to constructing a title from the file name of the widget. + $widgettitle = ucwords(str_replace('_', ' ', $basename)); + } + } + $widgetsfromconfig[$widgetkey] = array( 'basename' => $basename, 'title' => $widgettitle, diff --git a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php index c5dfd98b3c..ce40a99dca 100644 --- a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php +++ b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php @@ -118,6 +118,7 @@ if ($_REQUEST['getdyndnsstatus']) { } exit; } else if ($_POST['widgetkey']) { + set_customwidgettitle($user_settings); $validNames = array(); @@ -227,6 +228,7 @@ if (!function_exists('get_dyndns_service_text')) {