Project

General

Profile

Download (15.2 KB) Statistics
| Branch: | Tag: | Revision:
1 2cd6010c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 757733b5 Renato Botelho
	index.php
5 5b237745 Scott Ullrich
*/
6 fd9ebcd5 Stephen Beaver
/* ====================================================================
7 40547fe4 Stephen Beaver
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
8
 *	Copyright (c)  2004, 2005 Scott Ullrich
9 fd9ebcd5 Stephen Beaver
 *
10 40547fe4 Stephen Beaver
 *	Redistribution and use in source and binary forms, with or without modification,
11
 *	are permitted provided that the following conditions are met:
12 fd9ebcd5 Stephen Beaver
 *
13 40547fe4 Stephen Beaver
 *	1. Redistributions of source code must retain the above copyright notice,
14
 *		this list of conditions and the following disclaimer.
15 fd9ebcd5 Stephen Beaver
 *
16 40547fe4 Stephen Beaver
 *	2. Redistributions in binary form must reproduce the above copyright
17
 *		notice, this list of conditions and the following disclaimer in
18
 *		the documentation and/or other materials provided with the
19
 *		distribution.
20 fd9ebcd5 Stephen Beaver
 *
21 40547fe4 Stephen Beaver
 *	3. All advertising materials mentioning features or use of this software
22
 *		must display the following acknowledgment:
23
 *		"This product includes software developed by the pfSense Project
24
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
25 fd9ebcd5 Stephen Beaver
 *
26 40547fe4 Stephen Beaver
 *	4. The names "pfSense" and "pfSense Project" must not be used to
27
 *		 endorse or promote products derived from this software without
28
 *		 prior written permission. For written permission, please contact
29
 *		 coreteam@pfsense.org.
30 fd9ebcd5 Stephen Beaver
 *
31 40547fe4 Stephen Beaver
 *	5. Products derived from this software may not be called "pfSense"
32
 *		nor may "pfSense" appear in their names without prior written
33
 *		permission of the Electric Sheep Fencing, LLC.
34 fd9ebcd5 Stephen Beaver
 *
35 40547fe4 Stephen Beaver
 *	6. Redistributions of any form whatsoever must retain the following
36
 *		acknowledgment:
37 fd9ebcd5 Stephen Beaver
 *
38 40547fe4 Stephen Beaver
 *	"This product includes software developed by the pfSense Project
39
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
40 fd9ebcd5 Stephen Beaver
 *
41 40547fe4 Stephen Beaver
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
42
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
45
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
53 fd9ebcd5 Stephen Beaver
 *
54 40547fe4 Stephen Beaver
 *	====================================================================
55 fd9ebcd5 Stephen Beaver
 *
56
 */
57 7ac5a4cb Scott Ullrich
/*
58
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
59 40547fe4 Stephen Beaver
	pfSense_MODULE: interfaces
60 7ac5a4cb Scott Ullrich
*/
61 5b237745 Scott Ullrich
62 6b07c15a Matthew Grooms
##|+PRIV
63
##|*IDENT=page-system-login/logout
64 b7ccf315 Erik Fonnesbeck
##|*NAME=System: Login / Logout page / Dashboard
65
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
66 6b07c15a Matthew Grooms
##|*MATCH=index.php*
67
##|-PRIV
68
69 acc5dd59 jim-p
// Turn on buffering to speed up rendering
70 6c07db48 Phil Davis
ini_set('output_buffering', 'true');
71 acc5dd59 jim-p
72
// Start buffering with a cache size of 100000
73
ob_start(null, "1000");
74 880637d2 Scott Ullrich
75 acc5dd59 jim-p
## Load Essential Includes
76
require_once('guiconfig.inc');
77 32e834ff Ermal LUÇI
require_once('functions.inc');
78 acc5dd59 jim-p
require_once('notices.inc');
79 7c8f3711 jim-p
require_once("pkg-utils.inc");
80 acc5dd59 jim-p
81 888c3c1b Stephen Beaver
if (isset($_GET['closenotice'])) {
82
	close_notice($_GET['closenotice']);
83 005ac3ca Marcello Coutinho
	echo get_menu_messages();
84
	exit;
85
}
86
87 41b1ff89 Phil Davis
if ($g['disablecrashreporter'] != true) {
88 36365f49 Scott Ullrich
	// Check to see if we have a crash report
89 eac584f3 Scott Ullrich
	$x = 0;
90 41b1ff89 Phil Davis
	if (file_exists("/tmp/PHP_errors.log")) {
91 dc43ff1e jim-p
		$total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
92 41b1ff89 Phil Davis
		if ($total > 0) {
93 a9ee006d Scott Ullrich
			$x++;
94 41b1ff89 Phil Davis
		}
95 a9ee006d Scott Ullrich
	}
96 60e27eb0 Stephen Beaver
97 a9ee006d Scott Ullrich
	$crash = glob("/var/crash/*");
98 36365f49 Scott Ullrich
	$skip_files = array(".", "..", "minfree", "");
99 60e27eb0 Stephen Beaver
100 41b1ff89 Phil Davis
	if (is_array($crash)) {
101
		foreach ($crash as $c) {
102
			if (!in_array(basename($c), $skip_files)) {
103 36365f49 Scott Ullrich
				$x++;
104 41b1ff89 Phil Davis
			}
105 36365f49 Scott Ullrich
		}
106 60e27eb0 Stephen Beaver
107 41b1ff89 Phil Davis
		if ($x > 0) {
108 a9ee006d Scott Ullrich
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
109 41b1ff89 Phil Davis
		}
110 104faa07 Scott Ullrich
	}
111
}
112
113 acc5dd59 jim-p
##build list of widgets
114 1180e4f0 Sjon Hortensius
foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file)
115
{
116 41ea4cf3 Sjon Hortensius
	$name = basename($file, '.widget.php');
117
	$widgets[ $name ] = array('name' => ucwords(str_replace('_', ' ', $name)), 'display' => 'none');
118 acc5dd59 jim-p
}
119
120
##insert the system information widget as first, so as to be displayed first
121 1180e4f0 Sjon Hortensius
unset($widgets['system_information']);
122
$widgets = array_merge(array('system_information' => array('name' => 'System Information')), $widgets);
123 acc5dd59 jim-p
124
##if no config entry found, initialize config entry
125
if (!is_array($config['widgets'])) {
126
	$config['widgets'] = array();
127
}
128 d772ac32 Erik Kristensen
129 41ea4cf3 Sjon Hortensius
if ($_POST && $_POST['sequence']) {
130 60e27eb0 Stephen Beaver
131 69b397dd Sjon Hortensius
	$config['widgets']['sequence'] = rtrim($_POST['sequence'], ',');
132 8191b36e Scott Ullrich
133 1c428d53 Phil Davis
	foreach ($widgets as $widgetname => $widgetconfig) {
134
		if ($_POST[$widgetname . '-config']) {
135 1180e4f0 Sjon Hortensius
			$config['widgets'][$widgetname . '-config'] = $_POST[$name . '-config'];
136 8191b36e Scott Ullrich
		}
137
	}
138
139 1180e4f0 Sjon Hortensius
	write_config(gettext("Widget configuration has been changed."));
140 69b397dd Sjon Hortensius
	header("Location: /");
141 1180e4f0 Sjon Hortensius
	exit;
142
}
143 757733b5 Renato Botelho
144 1180e4f0 Sjon Hortensius
## Load Functions Files
145
require_once('includes/functions.inc.php');
146 d772ac32 Erik Kristensen
147 1180e4f0 Sjon Hortensius
## Check to see if we have a swap space,
148
## if true, display, if false, hide it ...
149 1c428d53 Phil Davis
if (file_exists("/usr/sbin/swapinfo")) {
150 1180e4f0 Sjon Hortensius
	$swapinfo = `/usr/sbin/swapinfo`;
151 1c428d53 Phil Davis
	if (stristr($swapinfo, '%') == true) $showswap=true;
152 1180e4f0 Sjon Hortensius
}
153
154
## User recently restored his config.
155
## If packages are installed lets resync
156 1c428d53 Phil Davis
if (file_exists('/conf/needs_package_sync')) {
157
	if ($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
158 2344bed4 Renato Botelho
		if ($g['platform'] == $g['product_name'] || $g['platform'] == "nanobsd") {
159 1180e4f0 Sjon Hortensius
			## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
160
			## the package reinstall page. That is about to be done by the boot script anyway.
161 31f03b6c Sjon Hortensius
			## The code in head.inc will put up a notice to the user.
162 1180e4f0 Sjon Hortensius
			if (!platform_booting()) {
163
				header('Location: pkg_mgr_install.php?mode=reinstallall');
164
				exit;
165 6cc843c3 Scott Ullrich
			}
166 1df0159c Erik Kristensen
		}
167 1180e4f0 Sjon Hortensius
	} else {
168
		conf_mount_rw();
169
		@unlink('/conf/needs_package_sync');
170
		conf_mount_ro();
171 1df0159c Erik Kristensen
	}
172 1180e4f0 Sjon Hortensius
}
173 8fecad11 Scott Ullrich
174 1180e4f0 Sjon Hortensius
## If it is the first time webConfigurator has been
175
## accessed since initial install show this stuff.
176 1c428d53 Phil Davis
if (file_exists('/conf/trigger_initial_wizard')) {
177 1180e4f0 Sjon Hortensius
?>
178
<!DOCTYPE html>
179
<html lang="en">
180 702b324e Scott Ullrich
<head>
181 1180e4f0 Sjon Hortensius
	<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
182 5bca8df4 Stephen Beaver
	<title><?=$g['product_name']?>.localdomain - <?=$g['product_name']?> first time setup</title>
183 1180e4f0 Sjon Hortensius
	<meta http-equiv="refresh" content="1;url=wizard.php?xml=setup_wizard.xml" />
184
</head>
185
<body id="loading-wizard" class="no-menu">
186
	<div id="jumbotron">
187
		<div class="container">
188 c7d61071 Sander van Leeuwen
			<div class="col-sm-offset-3 col-sm-6 col-xs-12">
189 40547fe4 Stephen Beaver
				<font color="white">
190
				<p><h3><?=sprintf(gettext("Welcome to %s!\n"), $g['product_name'])?></h3></p>
191 c7d61071 Sander van Leeuwen
				<p><?=gettext("One moment while we start the initial setup wizard.")?></p>
192
				<p><?=gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.")?></p>
193 1c428d53 Phil Davis
				<p><?=sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."), $g['product_name'])?></p>
194 40547fe4 Stephen Beaver
				</font>
195 c7d61071 Sander van Leeuwen
			</div>
196 1180e4f0 Sjon Hortensius
		</div>
197
	</div>
198
</body>
199
</html>
200
<?php
201
	exit;
202
}
203 bf787c0a Scott Ullrich
204 1180e4f0 Sjon Hortensius
## Find out whether there's hardware encryption or not
205
unset($hwcrypto);
206
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
207
if ($fd) {
208
	while (!feof($fd)) {
209
		$dmesgl = fgets($fd);
210
		if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
211
			or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
212
			or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
213
			or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
214
			or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
215
			or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
216
			or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
217
			$hwcrypto = $matches[1];
218
			break;
219 5b237745 Scott Ullrich
		}
220
	}
221 1180e4f0 Sjon Hortensius
	fclose($fd);
222
}
223 45ee90ed Matthew Grooms
224 7abf7db5 Scott Dale
##build widget saved list information
225 019a94df Scott Dale
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
226
	$pconfig['sequence'] = $config['widgets']['sequence'];
227 1180e4f0 Sjon Hortensius
	$widgetsfromconfig = array();
228 757733b5 Renato Botelho
229 1180e4f0 Sjon Hortensius
	foreach (explode(',', $pconfig['sequence']) as $line)
230
	{
231
		list($file, $col, $display) = explode(':', $line);
232
233
		// be backwards compatible
234
		$offset = strpos($file, '-container');
235
		if (false !== $offset)
236
			$file = substr($file, 0, $offset);
237
238
		$widgetsfromconfig[ $file ] = array(
239
			'name' => ucwords(str_replace('_', ' ', $file)),
240
			'col' => $col,
241
			'display' => $display,
242
		);
243 1db766df Scott Dale
	}
244 757733b5 Renato Botelho
245 5c7657d6 Renato Botelho
	// add widgets that may not be in the saved configuration, in case they are to be displayed later
246 69b397dd Sjon Hortensius
	$widgets = $widgetsfromconfig + $widgets;
247 757733b5 Renato Botelho
248 019a94df Scott Dale
	##find custom configurations of a particular widget and load its info to $pconfig
249 1c428d53 Phil Davis
	foreach ($widgets as $widgetname => $widgetconfig) {
250
		if ($config['widgets'][$name . '-config']) {
251 1180e4f0 Sjon Hortensius
			$pconfig[$name . '-config'] = $config['widgets'][$name . '-config'];
252 757733b5 Renato Botelho
		}
253
	}
254 3e4e94ce Scott Dale
}
255
256 019a94df Scott Dale
##build list of php include files
257 8b06c9ff Scott Dale
$phpincludefiles = array();
258
$directory = "/usr/local/www/widgets/include/";
259 6c07db48 Phil Davis
$dirhandle = opendir($directory);
260 bf5ad142 Scott Dale
$filename = "";
261 60e27eb0 Stephen Beaver
262 bf5ad142 Scott Dale
while (false !== ($filename = readdir($dirhandle))) {
263
	$phpincludefiles[] = $filename;
264
}
265 60e27eb0 Stephen Beaver
266 41b1ff89 Phil Davis
foreach ($phpincludefiles as $includename) {
267
	if (!stristr($includename, ".inc")) {
268 757733b5 Renato Botelho
		continue;
269 41b1ff89 Phil Davis
	}
270 e8bd1464 Renato Botelho
	if (file_exists($directory . $includename)) {
271
		include($directory . $includename);
272
	}
273 bf5ad142 Scott Dale
}
274 81db9b7b Scott Dale
275 1db766df Scott Dale
## Set Page Title and Include Header
276 a6e0e07b Scott Ullrich
$pgtitle = array(gettext("Status: Dashboard"));
277 1db766df Scott Dale
include("head.inc");
278 f6f6947e Scott Ullrich
279 41b1ff89 Phil Davis
if ($savemsg) {
280 757733b5 Renato Botelho
	print_info_box($savemsg);
281 41b1ff89 Phil Davis
}
282 fca795f8 Scott Ullrich
283 810a11bc Scott Ullrich
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
284 c69c58e2 Vinicius Coque
285 0682e26b Colin Smith
?>
286 1180e4f0 Sjon Hortensius
287 166b0099 Stephen Beaver
<div class="panel panel-default" id="widget-available">
288
	<div class="panel-heading"><?=gettext("Available Widgets"); ?>
289
		<span class="icons">
290 02597252 Stephen Beaver
			<a data-toggle="collapse" href="#widget-available .panel-body" name="widgets-available">
291 166b0099 Stephen Beaver
				<i class="icon-white icon-plus-sign"></i>
292
			</a>
293
		</span>
294
	</div>
295
	<div class="panel-body collapse out">
296 9239f765 Jared Dillard
		<div class="content">
297
			<div class="row">
298 60e27eb0 Stephen Beaver
<?php
299
foreach ($widgets as $widgetname => $widgetconfig):
300
	if ($widgetconfig['display'] == 'none'):
301
?>
302
		<div class="col-sm-3"><a href="#" name="btnadd-<?=$widgetname?>"><i class="icon icon-plus"></i> <?=$widgetconfig['name']?></a></div>
303 a2faa388 Sander van Leeuwen
	<?php endif; ?>
304
<?php endforeach; ?>
305 9239f765 Jared Dillard
			</div>
306
		</div>
307 1db766df Scott Dale
	</div>
308
</div>
309
310 7d5b007c Sjon Hortensius
<div class="modal fade">
311 a2faa388 Sander van Leeuwen
	<div class="modal-dialog">
312
		<div class="modal-content">
313
			<div class="modal-header">
314
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
315
				<h4 class="modal-title"><?=gettext("Welcome to the Dashboard page"); ?>!</h4>
316
			</div>
317
			<div class="modal-body">
318
				<p>
319
					<?=gettext("This page allows you to customize the information you want to be displayed!");?>
320 60e27eb0 Stephen Beaver
					<?=gettext("To get started click the ");?> FIXME <?=gettext(" icon to add widgets.");?><br />
321 a2faa388 Sander van Leeuwen
					<br />
322
					<?=gettext("You can move any widget around by clicking and dragging the title.");?>
323
				</p>
324
			</div>
325
			<div class="modal-footer">
326
				<button type="button" class="btn btn-default btn-primary" data-dismiss="modal">Close</button>
327
			</div>
328
		</div>
329 7d5b007c Sjon Hortensius
	</div>
330
</div>
331 d72fc17b Scott Dale
332 a2faa388 Sander van Leeuwen
<div class="hidden" id="widgetSequence">
333 60e27eb0 Stephen Beaver
	<form action="/" method="post" id="widgetSequence" name="widgetForm">
334 41ea4cf3 Sjon Hortensius
		<input type="hidden" name="sequence" value="" />
335
336 60e27eb0 Stephen Beaver
		<button type="submit" id="btnstore" class="btn btn-primary">Store widget configuration</button>
337 41ea4cf3 Sjon Hortensius
	</form>
338
</div>
339
340 1180e4f0 Sjon Hortensius
<?php
341 41ea4cf3 Sjon Hortensius
$widgetColumns = array();
342
foreach ($widgets as $widgetname => $widgetconfig)
343
{
344
	if ($widgetconfig['display'] == 'none')
345
		continue;
346
347 e8bd1464 Renato Botelho
	if (!file_exists('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php')) {
348
		continue;
349
	}
350
351 41ea4cf3 Sjon Hortensius
	if (!isset($widgetColumns[ $widgetconfig['col'] ]))
352
		$widgetColumns[ $widgetconfig['col'] ] = array();
353
354
	$widgetColumns[ $widgetconfig['col'] ][ $widgetname ] = $widgetconfig;
355
}
356 1180e4f0 Sjon Hortensius
?>
357 41ea4cf3 Sjon Hortensius
358 a2faa388 Sander van Leeuwen
<div class="row">
359 41ea4cf3 Sjon Hortensius
<?php foreach ($widgetColumns as $column => $columnWidgets):?>
360 a2faa388 Sander van Leeuwen
	<div class="col-md-6" id="widgets-<?=$column?>">
361
<?php foreach ($columnWidgets as $widgetname => $widgetconfig):?>
362 41ea4cf3 Sjon Hortensius
		<div class="panel panel-default" id="widget-<?=$widgetname?>">
363 1180e4f0 Sjon Hortensius
			<div class="panel-heading">
364
				<?=$widgetconfig['name']?>
365 80169aa8 Sjon Hortensius
				<span class="icons">
366
					<a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-footer" class="config hidden">
367 40c55526 Jared Dillard
						<i class="icon-white icon-wrench"></i>
368 80169aa8 Sjon Hortensius
					</a>
369 41ea4cf3 Sjon Hortensius
					<a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-body">
370 80169aa8 Sjon Hortensius
						<!--  actual icon is determined in css based on state of body -->
371 40c55526 Jared Dillard
						<i class="icon-white icon-plus-sign"></i>
372 80169aa8 Sjon Hortensius
					</a>
373
					<a data-toggle="close" href="#widget-<?=$widgetname?>">
374 40c55526 Jared Dillard
						<i class="icon-white icon-remove-sign"></i>
375 7d5b007c Sjon Hortensius
					</a>
376 1180e4f0 Sjon Hortensius
				</span>
377 1db766df Scott Dale
			</div>
378 41ea4cf3 Sjon Hortensius
			<div class="panel-body collapse<?=($widgetconfig['display']=='close' ? '' : ' in')?>">
379 1180e4f0 Sjon Hortensius
				<?php include('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php'); ?>
380 1db766df Scott Dale
			</div>
381 8b06c9ff Scott Dale
		</div>
382 41ea4cf3 Sjon Hortensius
<?php endforeach; ?>
383 a2faa388 Sander van Leeuwen
	</div>
384
<?php endforeach; ?>
385
</div>
386 561d55ff Erik Kristensen
387 dc58b7b3 Sjon Hortensius
<script>
388 60e27eb0 Stephen Beaver
function updateWidgets(newWidget)
389 7f8f8808 Sjon Hortensius
{
390
	var sequence = '';
391
392
	$('.container .col-md-6').each(function(idx, col){
393
		$('.panel', col).each(function(idx, widget){
394
			var isOpen = $('.panel-body', widget).hasClass('in');
395
396
			sequence += widget.id.split('-')[1] +':'+ col.id.split('-')[1] +':'+ (isOpen ? 'open' : 'close') +',';
397
		});
398
	});
399
400 60e27eb0 Stephen Beaver
	if (typeof newWidget !== 'undefined')
401
		sequence += newWidget + ':' + 'col2:close';
402
403 7f8f8808 Sjon Hortensius
	$('#widgetSequence').removeClass('hidden');
404
	$('input[name=sequence]', $('#widgetSequence')).val(sequence);
405
}
406
407 dc58b7b3 Sjon Hortensius
events.push(function() {
408
	// Hide configuration button for panels without configuration
409
	$('.container .panel-heading a.config').each(function (idx, el){
410
		var config = $(el).parents('.panel').children('.panel-footer');
411
		if (config.length == 1)
412
			$(el).removeClass('hidden');
413
	});
414
415
	// Initial state & toggle icons of collapsed panel
416 7f8f8808 Sjon Hortensius
	$('.container .panel-heading a[data-toggle="collapse"]').each(function (idx, el){
417 40c55526 Jared Dillard
		var body = $(el).parents('.panel').children('.panel-body')
418
		var isOpen = body.hasClass('in');
419
420
		$(el).children('i').toggleClass('icon-plus-sign', !isOpen);
421
		$(el).children('i').toggleClass('icon-minus-sign', isOpen);
422 dc58b7b3 Sjon Hortensius
423 7f8f8808 Sjon Hortensius
		body.on('shown.bs.collapse', function(){
424 40c55526 Jared Dillard
			$(el).children('i').toggleClass('icon-minus-sign', true);
425
			$(el).children('i').toggleClass('icon-plus-sign', false);
426 7f8f8808 Sjon Hortensius
427 02597252 Stephen Beaver
			if($(el).closest('a').attr('name') != 'widgets-available') {
428
				updateWidgets();
429
			}
430 7f8f8808 Sjon Hortensius
		});
431
432
		body.on('hidden.bs.collapse', function(){
433 40c55526 Jared Dillard
			$(el).children('i').toggleClass('icon-minus-sign', false);
434
			$(el).children('i').toggleClass('icon-plus-sign', true);
435 7f8f8808 Sjon Hortensius
436 02597252 Stephen Beaver
			if($(el).closest('a').attr('name') != 'widgets-available') {
437
				updateWidgets();
438
			}
439 7f8f8808 Sjon Hortensius
		});
440 dc58b7b3 Sjon Hortensius
	});
441
442
	// Make panels destroyable
443 7f8f8808 Sjon Hortensius
	$('.container .panel-heading a[data-toggle="close"]').each(function (idx, el){
444 dc58b7b3 Sjon Hortensius
		$(el).on('click', function(e){
445 7f8f8808 Sjon Hortensius
			$(el).parents('.panel').remove();
446
			updateWidgets();
447 dc58b7b3 Sjon Hortensius
		})
448
	});
449
450
	// Make panels sortable
451
	$('.container .col-md-6').sortable({
452
		handle: '.panel-heading',
453
		cursor: 'grabbing',
454
		connectWith: '.container .col-md-6',
455 7f8f8808 Sjon Hortensius
		update: updateWidgets
456 dc58b7b3 Sjon Hortensius
	});
457 60e27eb0 Stephen Beaver
458
	// On clicking a widget to install . .
459
	$('[name^=btnadd-]').click(function(event) {
460 19076df1 Stephen Beaver
		// Extract the widget name from the button name that got us here
461 60e27eb0 Stephen Beaver
		var widgetToAdd = this.name.replace('btnadd-', '');
462
463
		// Set its display type to 'close'
464
		<?php $widgets[widgetToAdd]['display'] = 'close'; ?>
465
466
		// Add it to the list of displayed widgets
467
		updateWidgets(widgetToAdd);
468
469 19076df1 Stephen Beaver
		// We don't want to see the "Store" button because we are doing that automatically
470 60e27eb0 Stephen Beaver
		$('#btnstore').hide();
471
472
		// Submit the form save/display all selected widgets
473
		$('[name=widgetForm]').submit();
474
	});
475
476 dc58b7b3 Sjon Hortensius
});
477
</script>
478 41ea4cf3 Sjon Hortensius
<?php
479 1180e4f0 Sjon Hortensius
//build list of javascript include files
480
foreach (glob('widgets/javascript/*.js') as $file)
481
	echo '<script src="'.$file.'"></script>';
482 927ea6e1 jim-p
483 1c428d53 Phil Davis
include("foot.inc");