Project

General

Profile

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