From acc5dd59f9c5f60ae67e135376506e9c9f70c154 Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 6 May 2010 12:46:58 -0400 Subject: Fix widget settings in general. Initialize widget list before use. Fixes #285. --- usr/local/www/index.php | 71 +++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/index.php b/usr/local/www/index.php index ffc9a4d..4125b51 100755 --- a/usr/local/www/index.php +++ b/usr/local/www/index.php @@ -42,16 +42,43 @@ ##|*MATCH=index.php* ##|-PRIV - // Turn on buffering to speed up rendering - ini_set('output_buffering','true'); - - // Start buffering with a cache size of 100000 - ob_start(null, "1000"); +// Turn on buffering to speed up rendering +ini_set('output_buffering','true'); + +// Start buffering with a cache size of 100000 +ob_start(null, "1000"); - ## Load Essential Includes - require_once('functions.inc'); - require_once('guiconfig.inc'); - require_once('notices.inc'); +## Load Essential Includes +require_once('functions.inc'); +require_once('guiconfig.inc'); +require_once('notices.inc'); + +##build list of widgets +$directory = "/usr/local/www/widgets/widgets/"; +$dirhandle = opendir($directory); +$filename = ""; +$widgetnames = array(); +$widgetfiles = array(); +$widgetlist = array(); + +while (false !== ($filename = readdir($dirhandle))) { + $periodpos = strpos($filename, "."); + $widgetname = substr($filename, 0, $periodpos); + $widgetnames[] = $widgetname; + if ($widgetname != "system_information") + $widgetfiles[] = $filename; +} + +##sort widgets alphabetically +sort($widgetfiles); + +##insert the system information widget as first, so as to be displayed first +array_unshift($widgetfiles, "system_information.widget.php"); + +##if no config entry found, initialize config entry +if (!is_array($config['widgets'])) { + $config['widgets'] = array(); +} if ($_POST && $_POST['submit']) { $config['widgets']['sequence'] = $_POST['sequence']; @@ -146,32 +173,6 @@ EOF; fclose($fd); } -##build list of widgets -$directory = "/usr/local/www/widgets/widgets/"; -$dirhandle = opendir($directory); -$filename = ""; -$widgetnames = array(); -$widgetfiles = array(); -$widgetlist = array(); -while (false !== ($filename = readdir($dirhandle))) { - $periodpos = strpos($filename, "."); - $widgetname = substr($filename, 0, $periodpos); - $widgetnames[] = $widgetname; - if ($widgetname != "system_information") - $widgetfiles[] = $filename; -} - -##sort widgets alphabetically -sort($widgetfiles); - -##insert the system information widget as first, so as to be displayed first -array_unshift($widgetfiles, "system_information.widget.php"); - -##if no config entry found, initialize config entry -if (!is_array($config['widgets'])) { - $config['widgets'] = array(); -} - ##build widget saved list information if ($config['widgets'] && $config['widgets']['sequence'] != "") { $pconfig['sequence'] = $config['widgets']['sequence']; -- cgit v1.1