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 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
8 |
|
|
* Copyright (c) 2004-2012 Scott Ullrich
|
9 |
|
|
*
|
10 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
11 |
|
|
* are permitted provided that the following conditions are met:
|
12 |
|
|
*
|
13 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
* this list of conditions and the following disclaimer.
|
15 |
|
|
*
|
16 |
|
|
* 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 |
|
|
*
|
21 |
|
|
* 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 |
|
|
*
|
26 |
|
|
* 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 |
|
|
*
|
31 |
|
|
* 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 |
|
|
*
|
35 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
36 |
|
|
* acknowledgment:
|
37 |
|
|
*
|
38 |
|
|
* "This product includes software developed by the pfSense Project
|
39 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
40 |
|
|
*
|
41 |
|
|
* 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 |
|
|
*
|
54 |
|
|
* ====================================================================
|
55 |
|
|
*
|
56 |
|
|
*/
|
57 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
58 |
|
|
pfSense_BUILDER_BINARIES: /sbin/ifconfig
|
59 |
|
|
pfSense_MODULE: interfaces
|
60 |
|
|
*/
|
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 |
005ac3ca
|
Marcello Coutinho
|
|
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 |
41b1ff89
|
Phil Davis
|
if (isset($_REQUEST['closenotice'])) {
|
83 |
005ac3ca
|
Marcello Coutinho
|
close_notice($_REQUEST['closenotice']);
|
84 |
|
|
echo get_menu_messages();
|
85 |
|
|
exit;
|
86 |
|
|
}
|
87 |
|
|
|
88 |
41b1ff89
|
Phil Davis
|
if ($g['disablecrashreporter'] != true) {
|
89 |
36365f49
|
Scott Ullrich
|
// Check to see if we have a crash report
|
90 |
eac584f3
|
Scott Ullrich
|
$x = 0;
|
91 |
41b1ff89
|
Phil Davis
|
if (file_exists("/tmp/PHP_errors.log")) {
|
92 |
dc43ff1e
|
jim-p
|
$total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
|
93 |
41b1ff89
|
Phil Davis
|
if ($total > 0) {
|
94 |
a9ee006d
|
Scott Ullrich
|
$x++;
|
95 |
41b1ff89
|
Phil Davis
|
}
|
96 |
a9ee006d
|
Scott Ullrich
|
}
|
97 |
|
|
$crash = glob("/var/crash/*");
|
98 |
36365f49
|
Scott Ullrich
|
$skip_files = array(".", "..", "minfree", "");
|
99 |
41b1ff89
|
Phil Davis
|
if (is_array($crash)) {
|
100 |
|
|
foreach ($crash as $c) {
|
101 |
|
|
if (!in_array(basename($c), $skip_files)) {
|
102 |
36365f49
|
Scott Ullrich
|
$x++;
|
103 |
41b1ff89
|
Phil Davis
|
}
|
104 |
36365f49
|
Scott Ullrich
|
}
|
105 |
41b1ff89
|
Phil Davis
|
if ($x > 0) {
|
106 |
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.";
|
107 |
41b1ff89
|
Phil Davis
|
}
|
108 |
104faa07
|
Scott Ullrich
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
acc5dd59
|
jim-p
|
##build list of widgets
|
112 |
1180e4f0
|
Sjon Hortensius
|
foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file)
|
113 |
|
|
{
|
114 |
41ea4cf3
|
Sjon Hortensius
|
$name = basename($file, '.widget.php');
|
115 |
|
|
$widgets[ $name ] = array('name' => ucwords(str_replace('_', ' ', $name)), 'display' => 'none');
|
116 |
acc5dd59
|
jim-p
|
}
|
117 |
|
|
|
118 |
|
|
##insert the system information widget as first, so as to be displayed first
|
119 |
1180e4f0
|
Sjon Hortensius
|
unset($widgets['system_information']);
|
120 |
|
|
$widgets = array_merge(array('system_information' => array('name' => 'System Information')), $widgets);
|
121 |
acc5dd59
|
jim-p
|
|
122 |
|
|
##if no config entry found, initialize config entry
|
123 |
|
|
if (!is_array($config['widgets'])) {
|
124 |
|
|
$config['widgets'] = array();
|
125 |
|
|
}
|
126 |
d772ac32
|
Erik Kristensen
|
|
127 |
41ea4cf3
|
Sjon Hortensius
|
if ($_POST && $_POST['sequence']) {
|
128 |
69b397dd
|
Sjon Hortensius
|
$config['widgets']['sequence'] = rtrim($_POST['sequence'], ',');
|
129 |
8191b36e
|
Scott Ullrich
|
|
130 |
1180e4f0
|
Sjon Hortensius
|
foreach($widgets as $widgetname => $widgetconfig){
|
131 |
|
|
if ($_POST[$widgetname . '-config']){
|
132 |
|
|
$config['widgets'][$widgetname . '-config'] = $_POST[$name . '-config'];
|
133 |
8191b36e
|
Scott Ullrich
|
}
|
134 |
|
|
}
|
135 |
|
|
|
136 |
1180e4f0
|
Sjon Hortensius
|
write_config(gettext("Widget configuration has been changed."));
|
137 |
69b397dd
|
Sjon Hortensius
|
header("Location: /");
|
138 |
1180e4f0
|
Sjon Hortensius
|
exit;
|
139 |
|
|
}
|
140 |
757733b5
|
Renato Botelho
|
|
141 |
1180e4f0
|
Sjon Hortensius
|
## Load Functions Files
|
142 |
|
|
require_once('includes/functions.inc.php');
|
143 |
d772ac32
|
Erik Kristensen
|
|
144 |
1180e4f0
|
Sjon Hortensius
|
## Check to see if we have a swap space,
|
145 |
|
|
## if true, display, if false, hide it ...
|
146 |
|
|
if(file_exists("/usr/sbin/swapinfo")) {
|
147 |
|
|
$swapinfo = `/usr/sbin/swapinfo`;
|
148 |
|
|
if(stristr($swapinfo,'%') == true) $showswap=true;
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
## User recently restored his config.
|
152 |
|
|
## If packages are installed lets resync
|
153 |
|
|
if(file_exists('/conf/needs_package_sync')) {
|
154 |
|
|
if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
|
155 |
|
|
if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
|
156 |
|
|
## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
|
157 |
|
|
## the package reinstall page. That is about to be done by the boot script anyway.
|
158 |
31f03b6c
|
Sjon Hortensius
|
## The code in head.inc will put up a notice to the user.
|
159 |
1180e4f0
|
Sjon Hortensius
|
if (!platform_booting()) {
|
160 |
|
|
header('Location: pkg_mgr_install.php?mode=reinstallall');
|
161 |
|
|
exit;
|
162 |
6cc843c3
|
Scott Ullrich
|
}
|
163 |
1df0159c
|
Erik Kristensen
|
}
|
164 |
1180e4f0
|
Sjon Hortensius
|
} else {
|
165 |
|
|
conf_mount_rw();
|
166 |
|
|
@unlink('/conf/needs_package_sync');
|
167 |
|
|
conf_mount_ro();
|
168 |
1df0159c
|
Erik Kristensen
|
}
|
169 |
1180e4f0
|
Sjon Hortensius
|
}
|
170 |
8fecad11
|
Scott Ullrich
|
|
171 |
1180e4f0
|
Sjon Hortensius
|
## If it is the first time webConfigurator has been
|
172 |
|
|
## accessed since initial install show this stuff.
|
173 |
|
|
if(file_exists('/conf/trigger_initial_wizard')) {
|
174 |
|
|
?>
|
175 |
|
|
<!DOCTYPE html>
|
176 |
|
|
<html lang="en">
|
177 |
702b324e
|
Scott Ullrich
|
<head>
|
178 |
1180e4f0
|
Sjon Hortensius
|
<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
|
179 |
f99c6a23
|
Erik Fonnesbeck
|
<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
|
180 |
1180e4f0
|
Sjon Hortensius
|
<meta http-equiv="refresh" content="1;url=wizard.php?xml=setup_wizard.xml" />
|
181 |
|
|
</head>
|
182 |
|
|
<body id="loading-wizard" class="no-menu">
|
183 |
|
|
<div id="jumbotron">
|
184 |
|
|
<div class="container">
|
185 |
c7d61071
|
Sander van Leeuwen
|
<div class="col-sm-offset-3 col-sm-6 col-xs-12">
|
186 |
|
|
<p><?=sprintf(gettext("Welcome to %s!\n"),$g['product_name'])?></p>
|
187 |
|
|
<p><?=gettext("One moment while we start the initial setup wizard.")?></p>
|
188 |
|
|
<p><?=gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.")?></p>
|
189 |
|
|
<p><?=sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name'])?></p>
|
190 |
|
|
</div>
|
191 |
1180e4f0
|
Sjon Hortensius
|
</div>
|
192 |
|
|
</div>
|
193 |
|
|
</body>
|
194 |
|
|
</html>
|
195 |
|
|
<?php
|
196 |
|
|
exit;
|
197 |
|
|
}
|
198 |
bf787c0a
|
Scott Ullrich
|
|
199 |
1180e4f0
|
Sjon Hortensius
|
## Find out whether there's hardware encryption or not
|
200 |
|
|
unset($hwcrypto);
|
201 |
|
|
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
|
202 |
|
|
if ($fd) {
|
203 |
|
|
while (!feof($fd)) {
|
204 |
|
|
$dmesgl = fgets($fd);
|
205 |
|
|
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
|
206 |
|
|
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
|
207 |
|
|
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
|
208 |
|
|
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
|
209 |
|
|
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
|
210 |
|
|
or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
|
211 |
|
|
or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
|
212 |
|
|
$hwcrypto = $matches[1];
|
213 |
|
|
break;
|
214 |
5b237745
|
Scott Ullrich
|
}
|
215 |
|
|
}
|
216 |
1180e4f0
|
Sjon Hortensius
|
fclose($fd);
|
217 |
|
|
}
|
218 |
45ee90ed
|
Matthew Grooms
|
|
219 |
7abf7db5
|
Scott Dale
|
##build widget saved list information
|
220 |
019a94df
|
Scott Dale
|
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
|
221 |
|
|
$pconfig['sequence'] = $config['widgets']['sequence'];
|
222 |
1180e4f0
|
Sjon Hortensius
|
$widgetsfromconfig = array();
|
223 |
757733b5
|
Renato Botelho
|
|
224 |
1180e4f0
|
Sjon Hortensius
|
foreach (explode(',', $pconfig['sequence']) as $line)
|
225 |
|
|
{
|
226 |
|
|
list($file, $col, $display) = explode(':', $line);
|
227 |
|
|
|
228 |
|
|
// be backwards compatible
|
229 |
|
|
$offset = strpos($file, '-container');
|
230 |
|
|
if (false !== $offset)
|
231 |
|
|
$file = substr($file, 0, $offset);
|
232 |
|
|
|
233 |
|
|
$widgetsfromconfig[ $file ] = array(
|
234 |
|
|
'name' => ucwords(str_replace('_', ' ', $file)),
|
235 |
|
|
'col' => $col,
|
236 |
|
|
'display' => $display,
|
237 |
|
|
);
|
238 |
1db766df
|
Scott Dale
|
}
|
239 |
757733b5
|
Renato Botelho
|
|
240 |
7abf7db5
|
Scott Dale
|
##add widgets that may not be in the saved configuration, in case they are to be displayed later
|
241 |
69b397dd
|
Sjon Hortensius
|
$widgets = $widgetsfromconfig + $widgets;
|
242 |
757733b5
|
Renato Botelho
|
|
243 |
019a94df
|
Scott Dale
|
##find custom configurations of a particular widget and load its info to $pconfig
|
244 |
1180e4f0
|
Sjon Hortensius
|
foreach($widgets as $widgetname => $widgetconfig){
|
245 |
|
|
if ($config['widgets'][$name . '-config']){
|
246 |
|
|
$pconfig[$name . '-config'] = $config['widgets'][$name . '-config'];
|
247 |
757733b5
|
Renato Botelho
|
}
|
248 |
|
|
}
|
249 |
3e4e94ce
|
Scott Dale
|
}
|
250 |
|
|
|
251 |
019a94df
|
Scott Dale
|
##build list of php include files
|
252 |
8b06c9ff
|
Scott Dale
|
$phpincludefiles = array();
|
253 |
|
|
$directory = "/usr/local/www/widgets/include/";
|
254 |
6c07db48
|
Phil Davis
|
$dirhandle = opendir($directory);
|
255 |
bf5ad142
|
Scott Dale
|
$filename = "";
|
256 |
|
|
while (false !== ($filename = readdir($dirhandle))) {
|
257 |
|
|
$phpincludefiles[] = $filename;
|
258 |
|
|
}
|
259 |
41b1ff89
|
Phil Davis
|
foreach ($phpincludefiles as $includename) {
|
260 |
|
|
if (!stristr($includename, ".inc")) {
|
261 |
757733b5
|
Renato Botelho
|
continue;
|
262 |
41b1ff89
|
Phil Davis
|
}
|
263 |
bf5ad142
|
Scott Dale
|
include($directory . $includename);
|
264 |
|
|
}
|
265 |
81db9b7b
|
Scott Dale
|
|
266 |
1db766df
|
Scott Dale
|
## Set Page Title and Include Header
|
267 |
a6e0e07b
|
Scott Ullrich
|
$pgtitle = array(gettext("Status: Dashboard"));
|
268 |
1db766df
|
Scott Dale
|
include("head.inc");
|
269 |
f6f6947e
|
Scott Ullrich
|
|
270 |
7c8f3711
|
jim-p
|
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
|
271 |
41b1ff89
|
Phil Davis
|
if (!verify_all_package_servers()) {
|
272 |
7c8f3711
|
jim-p
|
print_info_box(package_server_mismatch_message());
|
273 |
41b1ff89
|
Phil Davis
|
}
|
274 |
7c8f3711
|
jim-p
|
|
275 |
41b1ff89
|
Phil Davis
|
if ($savemsg) {
|
276 |
757733b5
|
Renato Botelho
|
print_info_box($savemsg);
|
277 |
41b1ff89
|
Phil Davis
|
}
|
278 |
fca795f8
|
Scott Ullrich
|
|
279 |
810a11bc
|
Scott Ullrich
|
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
|
280 |
c69c58e2
|
Vinicius Coque
|
|
281 |
0682e26b
|
Colin Smith
|
?>
|
282 |
1180e4f0
|
Sjon Hortensius
|
|
283 |
a2faa388
|
Sander van Leeuwen
|
<div class="panel panel-default">
|
284 |
f17594c7
|
Sjon Hortensius
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Available Widgets"); ?></h2></div>
|
285 |
a2faa388
|
Sander van Leeuwen
|
<div class="panel-body">
|
286 |
|
|
<?php foreach($widgets as $widgetname => $widgetconfig): ?>
|
287 |
|
|
<?php if ($widgetconfig['display'] == 'none'): ?>
|
288 |
|
|
<div class="col-sm-3"><a href="#"><i class="icon icon-plus"></i> <?=$widgetconfig['name']?></a></div>
|
289 |
|
|
<?php endif; ?>
|
290 |
|
|
<?php endforeach; ?>
|
291 |
1db766df
|
Scott Dale
|
</div>
|
292 |
|
|
</div>
|
293 |
|
|
|
294 |
7d5b007c
|
Sjon Hortensius
|
<div class="modal fade">
|
295 |
a2faa388
|
Sander van Leeuwen
|
<div class="modal-dialog">
|
296 |
|
|
<div class="modal-content">
|
297 |
|
|
<div class="modal-header">
|
298 |
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
299 |
|
|
<h4 class="modal-title"><?=gettext("Welcome to the Dashboard page"); ?>!</h4>
|
300 |
|
|
</div>
|
301 |
|
|
<div class="modal-body">
|
302 |
|
|
<p>
|
303 |
|
|
<?=gettext("This page allows you to customize the information you want to be displayed!");?>
|
304 |
|
|
<?=gettext("To get started click the");?> FIXME <?=gettext("icon to add widgets.");?><br />
|
305 |
|
|
<br />
|
306 |
|
|
<?=gettext("You can move any widget around by clicking and dragging the title.");?>
|
307 |
|
|
</p>
|
308 |
|
|
</div>
|
309 |
|
|
<div class="modal-footer">
|
310 |
|
|
<button type="button" class="btn btn-default btn-primary" data-dismiss="modal">Close</button>
|
311 |
|
|
</div>
|
312 |
|
|
</div>
|
313 |
7d5b007c
|
Sjon Hortensius
|
</div>
|
314 |
|
|
</div>
|
315 |
d72fc17b
|
Scott Dale
|
|
316 |
a2faa388
|
Sander van Leeuwen
|
<div class="hidden" id="widgetSequence">
|
317 |
41ea4cf3
|
Sjon Hortensius
|
<form action="/" method="post" id="widgetSequence">
|
318 |
|
|
<input type="hidden" name="sequence" value="" />
|
319 |
|
|
|
320 |
9a9c8e25
|
Sander van Leeuwen
|
<button type="submit" class="btn btn-primary">Store widget configuration</button>
|
321 |
41ea4cf3
|
Sjon Hortensius
|
</form>
|
322 |
|
|
</div>
|
323 |
|
|
|
324 |
1180e4f0
|
Sjon Hortensius
|
<?php
|
325 |
41ea4cf3
|
Sjon Hortensius
|
$widgetColumns = array();
|
326 |
|
|
foreach ($widgets as $widgetname => $widgetconfig)
|
327 |
|
|
{
|
328 |
|
|
if ($widgetconfig['display'] == 'none')
|
329 |
|
|
continue;
|
330 |
|
|
|
331 |
|
|
if (!isset($widgetColumns[ $widgetconfig['col'] ]))
|
332 |
|
|
$widgetColumns[ $widgetconfig['col'] ] = array();
|
333 |
|
|
|
334 |
|
|
$widgetColumns[ $widgetconfig['col'] ][ $widgetname ] = $widgetconfig;
|
335 |
|
|
}
|
336 |
1180e4f0
|
Sjon Hortensius
|
?>
|
337 |
41ea4cf3
|
Sjon Hortensius
|
|
338 |
a2faa388
|
Sander van Leeuwen
|
<div class="row">
|
339 |
41ea4cf3
|
Sjon Hortensius
|
<?php foreach ($widgetColumns as $column => $columnWidgets):?>
|
340 |
a2faa388
|
Sander van Leeuwen
|
<div class="col-md-6" id="widgets-<?=$column?>">
|
341 |
|
|
<?php foreach ($columnWidgets as $widgetname => $widgetconfig):?>
|
342 |
41ea4cf3
|
Sjon Hortensius
|
<div class="panel panel-default" id="widget-<?=$widgetname?>">
|
343 |
1180e4f0
|
Sjon Hortensius
|
<div class="panel-heading">
|
344 |
|
|
<?=$widgetconfig['name']?>
|
345 |
80169aa8
|
Sjon Hortensius
|
<span class="icons">
|
346 |
|
|
<a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-footer" class="config hidden">
|
347 |
|
|
<i class="icon icon-wrench"></i>
|
348 |
|
|
</a>
|
349 |
41ea4cf3
|
Sjon Hortensius
|
<a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-body">
|
350 |
80169aa8
|
Sjon Hortensius
|
<!-- actual icon is determined in css based on state of body -->
|
351 |
|
|
<i class="icon icon-plus-sign"></i>
|
352 |
|
|
</a>
|
353 |
|
|
<a data-toggle="close" href="#widget-<?=$widgetname?>">
|
354 |
|
|
<i class="icon icon-remove-sign"></i>
|
355 |
7d5b007c
|
Sjon Hortensius
|
</a>
|
356 |
1180e4f0
|
Sjon Hortensius
|
</span>
|
357 |
1db766df
|
Scott Dale
|
</div>
|
358 |
41ea4cf3
|
Sjon Hortensius
|
<div class="panel-body collapse<?=($widgetconfig['display']=='close' ? '' : ' in')?>">
|
359 |
1180e4f0
|
Sjon Hortensius
|
<?php include('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php'); ?>
|
360 |
1db766df
|
Scott Dale
|
</div>
|
361 |
8b06c9ff
|
Scott Dale
|
</div>
|
362 |
41ea4cf3
|
Sjon Hortensius
|
<?php endforeach; ?>
|
363 |
a2faa388
|
Sander van Leeuwen
|
</div>
|
364 |
|
|
<?php endforeach; ?>
|
365 |
|
|
</div>
|
366 |
561d55ff
|
Erik Kristensen
|
|
367 |
dc58b7b3
|
Sjon Hortensius
|
<script>
|
368 |
7f8f8808
|
Sjon Hortensius
|
function updateWidgets()
|
369 |
|
|
{
|
370 |
|
|
var sequence = '';
|
371 |
|
|
|
372 |
|
|
$('.container .col-md-6').each(function(idx, col){
|
373 |
|
|
$('.panel', col).each(function(idx, widget){
|
374 |
|
|
var isOpen = $('.panel-body', widget).hasClass('in');
|
375 |
|
|
|
376 |
|
|
sequence += widget.id.split('-')[1] +':'+ col.id.split('-')[1] +':'+ (isOpen ? 'open' : 'close') +',';
|
377 |
|
|
});
|
378 |
|
|
});
|
379 |
|
|
|
380 |
|
|
$('#widgetSequence').removeClass('hidden');
|
381 |
|
|
$('input[name=sequence]', $('#widgetSequence')).val(sequence);
|
382 |
|
|
}
|
383 |
|
|
|
384 |
dc58b7b3
|
Sjon Hortensius
|
events.push(function() {
|
385 |
|
|
// Hide configuration button for panels without configuration
|
386 |
|
|
$('.container .panel-heading a.config').each(function (idx, el){
|
387 |
|
|
var config = $(el).parents('.panel').children('.panel-footer');
|
388 |
|
|
if (config.length == 1)
|
389 |
|
|
$(el).removeClass('hidden');
|
390 |
|
|
});
|
391 |
|
|
|
392 |
|
|
// Initial state & toggle icons of collapsed panel
|
393 |
7f8f8808
|
Sjon Hortensius
|
$('.container .panel-heading a[data-toggle="collapse"]').each(function (idx, el){
|
394 |
dc58b7b3
|
Sjon Hortensius
|
var body = $(el).parents('.panel').children('.panel-body'), isOpen = body.hasClass('in');
|
395 |
|
|
$(el).toggleClass('icon-plus-sign', !isOpen);
|
396 |
|
|
$(el).toggleClass('icon-minus-sign', isOpen);
|
397 |
|
|
|
398 |
7f8f8808
|
Sjon Hortensius
|
body.on('shown.bs.collapse', function(){
|
399 |
|
|
$(el).toggleClass('icon-minus-sign', true);
|
400 |
|
|
$(el).toggleClass('icon-plus-sign', false);
|
401 |
|
|
|
402 |
|
|
updateWidgets();
|
403 |
|
|
});
|
404 |
|
|
|
405 |
|
|
body.on('hidden.bs.collapse', function(){
|
406 |
|
|
$(el).toggleClass('icon-minus-sign', false);
|
407 |
|
|
$(el).toggleClass('icon-plus-sign', true);
|
408 |
|
|
|
409 |
|
|
updateWidgets();
|
410 |
|
|
});
|
411 |
dc58b7b3
|
Sjon Hortensius
|
});
|
412 |
|
|
|
413 |
|
|
// Make panels destroyable
|
414 |
7f8f8808
|
Sjon Hortensius
|
$('.container .panel-heading a[data-toggle="close"]').each(function (idx, el){
|
415 |
dc58b7b3
|
Sjon Hortensius
|
$(el).on('click', function(e){
|
416 |
7f8f8808
|
Sjon Hortensius
|
$(el).parents('.panel').remove();
|
417 |
|
|
updateWidgets();
|
418 |
dc58b7b3
|
Sjon Hortensius
|
})
|
419 |
|
|
});
|
420 |
|
|
|
421 |
|
|
// Make panels sortable
|
422 |
|
|
$('.container .col-md-6').sortable({
|
423 |
|
|
handle: '.panel-heading',
|
424 |
|
|
cursor: 'grabbing',
|
425 |
|
|
connectWith: '.container .col-md-6',
|
426 |
7f8f8808
|
Sjon Hortensius
|
update: updateWidgets
|
427 |
dc58b7b3
|
Sjon Hortensius
|
});
|
428 |
|
|
});
|
429 |
|
|
</script>
|
430 |
41ea4cf3
|
Sjon Hortensius
|
<?php
|
431 |
1180e4f0
|
Sjon Hortensius
|
//build list of javascript include files
|
432 |
|
|
foreach (glob('widgets/javascript/*.js') as $file)
|
433 |
|
|
echo '<script src="'.$file.'"></script>';
|
434 |
927ea6e1
|
jim-p
|
|
435 |
7f8f8808
|
Sjon Hortensius
|
include("foot.inc");
|