Project

General

Profile

Download (23.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    index.php
5
    Copyright (C) 2004, 2005 Scott Ullrich
6
    All rights reserved.
7

    
8
    Originally part of m0n0wall (http://m0n0.ch/wall)
9
    Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
    All rights reserved.
11

    
12
    Redistribution and use in source and binary forms, with or without
13
    modification, are permitted provided that the following conditions are met:
14

    
15
    1. Redistributions of source code must retain the above copyright notice,
16
       this list of conditions and the following disclaimer.
17

    
18
    2. Redistributions in binary form must reproduce the above copyright
19
       notice, this list of conditions and the following disclaimer in the
20
       documentation and/or other materials provided with the distribution.
21

    
22
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
    oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
    POSSIBILITY OF SUCH DAMAGE.
32
*/
33
/*
34
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
35
	pfSense_MODULE:	interfaces
36
*/
37

    
38
##|+PRIV
39
##|*IDENT=page-system-login/logout
40
##|*NAME=System: Login / Logout page
41
##|*DESCR=Allow access to the 'System: Login / Logout' page.
42
##|*MATCH=index.php*
43
##|-PRIV
44

    
45
// Turn on buffering to speed up rendering
46
ini_set('output_buffering','true');
47

    
48
// Start buffering with a cache size of 100000
49
ob_start(null, "1000");
50

    
51
## Load Essential Includes
52
require_once('functions.inc');
53
require_once('guiconfig.inc');
54
require_once('notices.inc');
55

    
56
##build list of widgets
57
$directory = "/usr/local/www/widgets/widgets/";
58
$dirhandle  = opendir($directory);
59
$filename = "";
60
$widgetnames = array();
61
$widgetfiles = array();
62
$widgetlist = array();
63

    
64
while (false !== ($filename = readdir($dirhandle))) {
65
	$periodpos = strpos($filename, ".");
66
	$widgetname = substr($filename, 0, $periodpos);
67
	$widgetnames[] = $widgetname;
68
	if ($widgetname != "system_information")
69
		$widgetfiles[] = $filename;
70
}
71

    
72
##sort widgets alphabetically
73
sort($widgetfiles);
74

    
75
##insert the system information widget as first, so as to be displayed first
76
array_unshift($widgetfiles, "system_information.widget.php");
77

    
78
##if no config entry found, initialize config entry
79
if (!is_array($config['widgets'])) {
80
	$config['widgets'] = array();
81
}
82

    
83
	if ($_POST && $_POST['submit']) {
84
		$config['widgets']['sequence'] = $_POST['sequence'];
85

    
86
		foreach ($widgetnames as $widget){
87
			if ($_POST[$widget . '-config']){
88
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
89
			}
90
		}
91

    
92
		write_config(gettext("Widget configuration has been changed."));
93
		header("Location: index.php");
94
		exit;
95
	}
96

    
97
	## Load Functions Files
98
	require_once('includes/functions.inc.php');
99
	
100
	## Check to see if we have a swap space,
101
	## if true, display, if false, hide it ...
102
	if(file_exists("/usr/sbin/swapinfo")) {
103
		$swapinfo = `/usr/sbin/swapinfo`;
104
		if(stristr($swapinfo,'%') == true) $showswap=true;
105
	}
106

    
107
	## User recently restored his config.
108
	## If packages are installed lets resync
109
	if(file_exists('/conf/needs_package_sync')) {
110
		if($config['installedpackages'] <> '') {
111
			conf_mount_rw();
112
			@unlink('/conf/needs_package_sync');
113
			conf_mount_ro();
114
			if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
115
				header('Location: pkg_mgr_install.php?mode=reinstallall');
116
				exit;
117
			}
118
		}
119
	}
120

    
121
	## If it is the first time webConfigurator has been
122
	## accessed since initial install show this stuff.
123
	if(file_exists('/conf/trigger_initial_wizard')) {
124
		echo <<<EOF
125
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
126
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
127
<html>
128
<head>
129
	<title>{$g['product_name']}.local - {$g['product_name']} first time setup</title>
130
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
131
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
132
	<script type="text/javascript">var theme = "nervecenter"</script>
133
	<script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
134
		
135
EOF;
136

    
137
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
138

    
139
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
140
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
141
		else 
142
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
143

    
144
		echo "<form>\n";
145
		echo "<center>\n";
146
		echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
147
		echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
148
		echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>";
149
		echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
150
		echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
151
		echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n";
152
		echo "</div>\n";
153
		echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
154
		echo "<script type=\"text/javascript\">\n";
155
		echo "NiftyCheck();\n";
156
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
157
		echo "</script>\n";
158
		exit;
159
	}
160

    
161

    
162
	## Find out whether there's hardware encryption or not
163
	unset($hwcrypto);
164
	$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
165
	if ($fd) {
166
		while (!feof($fd)) {
167
			$dmesgl = fgets($fd);
168
			if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches) or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches) or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches) or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches) or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches) or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)) {
169
				$hwcrypto = $matches[1];
170
				break;
171
			}
172
		}
173
		fclose($fd);
174
	}
175

    
176
##build widget saved list information
177
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
178
	$pconfig['sequence'] = $config['widgets']['sequence'];
179
	
180
	$widgetlist = $pconfig['sequence'];
181
	$colpos = array();
182
	$savedwidgetfiles = array();
183
	$widgetname = "";
184
	$widgetlist = explode(",",$widgetlist);
185
	
186
	##read the widget position and display information
187
	foreach ($widgetlist as $widget){
188
		$dashpos = strpos($widget, "-");		
189
		$widgetname = substr($widget, 0, $dashpos);
190
		$colposition = strpos($widget, ":");		
191
		$displayposition = strrpos($widget, ":");
192
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
193
		$displayarray[] = substr($widget,$displayposition+1);
194
		$savedwidgetfiles[] = $widgetname . ".widget.php";
195
	}
196
	
197
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
198
    foreach ($widgetfiles as $defaultwidgets){         
199
         if (!in_array($defaultwidgets, $savedwidgetfiles)){
200
             $savedwidgetfiles[] = $defaultwidgets;
201
         }
202
     }   
203
	
204
	##find custom configurations of a particular widget and load its info to $pconfig
205
	foreach ($widgetnames as $widget){
206
        if ($config['widgets'][$widget . '-config']){
207
            $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
208
        }
209
    }   
210
	
211
	$widgetlist = $savedwidgetfiles;	
212
} else{
213
	// no saved widget sequence found, build default list.
214
	$widgetlist = $widgetfiles;
215
}
216

    
217
##build list of php include files
218
$phpincludefiles = array();
219
$directory = "/usr/local/www/widgets/include/";
220
$dirhandle  = opendir($directory);
221
$filename = "";
222
while (false !== ($filename = readdir($dirhandle))) {
223
	$phpincludefiles[] = $filename;
224
}
225
foreach($phpincludefiles as $includename) {
226
	if(!stristr($includename, ".inc"))
227
		continue;	
228
	include($directory . $includename);
229
}
230

    
231
##begin AJAX
232
$jscriptstr = <<<EOD
233
<script language="javascript" type="text/javascript">
234

    
235

    
236
function widgetAjax(widget) {	
237
	uri = "widgets/widgets/" + widget + ".widget.php";
238
	var opt = {
239
	    // Use GET
240
	    method: 'get',
241
		evalScripts: 'true',
242
	    asynchronous: true,
243
	    // Handle 404
244
	    on404: function(t) {
245
	        alert('Error 404: location "' + t.statusText + '" was not found.');
246
	    },
247
	    // Handle other errors
248
	    onFailure: function(t) {
249
	        alert('Error ' + t.status + ' -- ' + t.statusText);
250
	    },
251
		onSuccess: function(t) {
252
			widget2 = widget + "-loader";
253
			Effect.Fade(widget2, {queue:'front'});
254
			Effect.Appear(widget, {queue:'end'});			
255
	    }	
256
	}
257
	new Ajax.Updater(widget, uri, opt);
258
}
259

    
260

    
261
function addWidget(selectedDiv){	
262
	selectedDiv2 = selectedDiv + "-container";
263
	d = document;
264
	textlink = d.getElementById(selectedDiv2);
265
	Effect.Appear(selectedDiv2, {duration:1});
266
	if (textlink.style.display != "none")
267
	{
268
		Effect.Shake(selectedDiv2);	
269
	}
270
	else
271
	{
272
		widgetAjax(selectedDiv);
273
		selectIntLink = selectedDiv2 + "-input";
274
		textlink = d.getElementById(selectIntLink);
275
		textlink.value = "show";	
276
		showSave();
277
	}
278
}
279

    
280
function configureWidget(selectedDiv){
281
	selectIntLink = selectedDiv + "-settings";	
282
	d = document;
283
	textlink = d.getElementById(selectIntLink);
284
	if (textlink.style.display == "none")
285
		Effect.BlindDown(selectIntLink, {duration:1});
286
	else
287
		Effect.BlindUp(selectIntLink, {duration:1});
288
}
289

    
290
function showWidget(selectedDiv,swapButtons){
291
	//appear element
292
    Effect.BlindDown(selectedDiv, {duration:1});      
293
    showSave();    
294
	d = document;	
295
    if (swapButtons){
296
	    selectIntLink = selectedDiv + "-min";
297
		textlink = d.getElementById(selectIntLink);
298
		textlink.style.display = "inline";
299
	    
300
	    
301
	    selectIntLink = selectedDiv + "-open";
302
		textlink = d.getElementById(selectIntLink);
303
		textlink.style.display = "none";
304

    
305
    }
306
	selectIntLink = selectedDiv + "-container-input";
307
	textlink = d.getElementById(selectIntLink);
308
	textlink.value = "show";	
309
    
310
}
311
	
312
function minimizeWidget(selectedDiv,swapButtons){
313
	//fade element
314
    Effect.BlindUp(selectedDiv, {duration:1});      
315
    showSave();
316
	d = document;	
317
    if (swapButtons){
318
	    selectIntLink = selectedDiv + "-open";
319
		textlink = d.getElementById(selectIntLink);
320
		textlink.style.display = "inline";	    
321
	    
322
	    selectIntLink = selectedDiv + "-min";
323
		textlink = d.getElementById(selectIntLink);
324
		textlink.style.display = "none";
325
    }  		
326
	selectIntLink = selectedDiv + "-container-input";
327
	textlink = d.getElementById(selectIntLink);
328
	textlink.value = "hide";	  
329
    
330
}
331

    
332
function closeWidget(selectedDiv){	
333
	showSave();
334
	selectedDiv = selectedDiv + "-container";
335
	Effect.Fade(selectedDiv, {duration:1});
336
	d = document;
337
	selectIntLink = selectedDiv + "-input";
338
	textlink = d.getElementById(selectIntLink);
339
	textlink.value = "close";	
340
}
341

    
342
function showSave(){
343
	d = document;
344
	selectIntLink = "submit";
345
	textlink = d.getElementById(selectIntLink);
346
	textlink.style.display = "inline";	
347
}
348

    
349
function updatePref(){	
350
	var widgets = document.getElementsByClassName('widgetdiv');
351
	var widgetSequence = "";
352
	var firstprint = false;	
353
	d = document;
354
	for (i=0; i<widgets.length; i++){
355
		if (firstprint)
356
			widgetSequence += ",";
357
		var widget = widgets[i].id;
358
		widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
359
		widget = widget + "-input";
360
		textlink = d.getElementById(widget).value;
361
		widgetSequence += textlink;
362
		firstprint = true;		
363
	}
364
	selectLink = "sequence";
365
	textlink = d.getElementById(selectLink);
366
	textlink.value = widgetSequence;
367
	return true;	
368
}
369

    
370
function hideAllWidgets(){		
371
		Effect.Fade('niftyOutter', {to: 0.2});
372
}
373

    
374
function showAllWidgets(){		
375
		Effect.Fade('niftyOutter', {to: 1.0});
376
}
377

    
378

    
379
function changeTabDIV(selectedDiv){
380
	var dashpos = selectedDiv.indexOf("-");
381
	var tabclass = selectedDiv.substring(0,dashpos);
382
	d = document;
383

    
384
	//get deactive tabs first
385
	tabclass = tabclass + "-class-tabdeactive"; 
386
	var tabs = document.getElementsByClassName(tabclass);
387
	var incTabSelected = selectedDiv + "-deactive";
388
	for (i=0; i<tabs.length; i++){
389
		var tab = tabs[i].id;
390
		dashpos = tab.lastIndexOf("-");
391
		var tab2 = tab.substring(0,dashpos) + "-deactive";
392
		if (tab2 == incTabSelected){
393
			tablink = d.getElementById(tab2);
394
			tablink.style.display = "none";
395
			tab2 = tab.substring(0,dashpos) + "-active";
396
			tablink = d.getElementById(tab2);
397
			tablink.style.display = "table-cell";
398
			
399
			//now show main div associated with link clicked
400
			tabmain = d.getElementById(selectedDiv);
401
			tabmain.style.display = "block";
402
		}
403
		else
404
		{	
405
			tab2 = tab.substring(0,dashpos) + "-deactive";
406
			tablink = d.getElementById(tab2);
407
			tablink.style.display = "table-cell";
408
			tab2 = tab.substring(0,dashpos) + "-active";
409
			tablink = d.getElementById(tab2);
410
			tablink.style.display = "none";		
411
			
412
			//hide sections we don't want to see
413
			tab2 = tab.substring(0,dashpos);
414
			tabmain = d.getElementById(tab2);
415
			tabmain.style.display = "none";
416
				
417
		}
418
	}	
419
}
420

    
421
</script>
422
EOD;
423
$closehead = false;
424

    
425
## Set Page Title and Include Header
426
$pgtitle = array(sprintf(gettext("%s Dashboard"), $g['product_name']));
427
include("head.inc");
428

    
429
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
430
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n";
431
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n";
432
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n";
433

    
434
?>
435

    
436
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
437
<form action="index.php" method="post">
438
<script language="javascript" type="text/javascript">
439
// <![CDATA[
440
columns = ['col1','col2'];
441
// ]]>
442

    
443
</script>
444

    
445
<?php
446
include("fbegin.inc");
447
echo $jscriptstr;
448
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
449
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
450
?>
451
<div id="widgetcontainer" style="display:none">
452
		<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
453
			$widgetfiles_add = $widgetfiles;
454
			sort($widgetfiles_add);
455
			foreach($widgetfiles_add as $widget) {			
456
				if(!stristr($widget, "widget.php"))
457
					continue;		
458
				
459
				$periodpos = strpos($widget, ".");
460
				$widgetname = substr($widget, 0, $periodpos);
461
				$nicename = $widgetname;
462
				$nicename = str_replace("_", " ", $nicename);
463
				//make the title look nice
464
				$nicename = ucwords($nicename);
465
				
466
				$widgettitle = $widgetname . "_title";
467
				$widgettitlelink = $widgetname . "_title_link";
468
					if ($$widgettitle != "")
469
					{
470
						//echo widget title 
471
						?>
472
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
473
						<u><?php echo $$widgettitle; ?></u></span><br>
474
						<?php 
475
					}
476
					else {?>
477
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
478
						<u><?php echo $nicename; ?></u></span><br><?php
479
					}
480
			}
481
		?>
482
		</p>
483
	</div>
484
</div>
485

    
486
<div id="welcomecontainer" style="display:none">
487
		<div id="welcome-container">
488
			<h1>
489
				<div style="float:left;width:80%;padding: 2px">
490
					<?=gettext("Welcome to the Dashboard page"); ?>!
491
				</div>
492
				<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
493
					<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
494
				</div>
495
				<div style="clear:both;"></div>
496
			</h1>
497
			<p>
498
			<?=gettext("This page allows you to customize the information you want to be displayed!");?><br/>
499
			<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> <?=gettext("icon to add widgets.");?><br/>
500
			<br/>
501
			<?=gettext("You can move any widget around by clicking and dragging the title.");?>			
502
			</p>
503
	</div>
504
</div>
505

    
506
<input type="hidden" value="" name="sequence" id="sequence">
507
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="<?=gettext("Click here to add widgets"); ?>" style="cursor: pointer;" onmouseup="domTT_activate(this, event, 'content', document.getElementById('content1'), 'type', 'velcro', 'delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
508

    
509
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" alt="<?=gettext("Click here for help"); ?>" style="cursor: help;" onmouseup="hideAllWidgets();domTT_activate(this, event, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
510

    
511

    
512
&nbsp;&nbsp;&nbsp;
513
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
514
</p>
515

    
516
<div id="niftyOutter">
517
	<?php
518
	$totalwidgets = count($widgetfiles);
519
	$halftotal = $totalwidgets / 2 - 2;
520
	$widgetcounter = 0;
521
	$directory = "/usr/local/www/widgets/widgets/";
522
	$printed = false;
523
	$firstprint = false;
524
	?> 
525
	<div id="col1" style="float:left;width:49%;padding-bottom:40px">		
526
	<?php	
527
		
528
	foreach($widgetlist as $widget) {
529
		
530
		if(!stristr($widget, "widget.php"))
531
					continue;
532
		$periodpos = strpos($widget, ".");
533
		$widgetname = substr($widget, 0, $periodpos);	
534
		if ($widgetname != ""){
535
			$nicename = $widgetname;
536
			$nicename = str_replace("_", " ", $nicename);
537
			
538
			//make the title look nice
539
			$nicename = ucwords($nicename);
540
		}
541
		
542
		if ($config['widgets'] && $pconfig['sequence'] != ""){
543
			switch($displayarray[$widgetcounter]){
544
				case "show":
545
					$divdisplay = "block";
546
					$display = "block";
547
					$inputdisplay = "show";					
548
					$showWidget = "none";
549
					$mindiv = "inline";
550
					break;
551
				case "hide":
552
					$divdisplay = "block";
553
					$display = "none";
554
					$inputdisplay = "hide";		
555
					$showWidget = "inline";
556
					$mindiv = "none";
557
					break;
558
				case "close":
559
					$divdisplay = "none";
560
					$display = "block";
561
					$inputdisplay = "close";			
562
					$showWidget = "none";
563
					$mindiv = "inline";
564
					break;
565
				default:
566
					$divdisplay = "none";
567
					$display = "block";
568
					$inputdisplay = "none";
569
					$showWidget = "none";
570
					$mindiv = "inline";
571
					break;
572
			}
573
		} else {
574
			if ($firstprint == false){
575
				$divdisplay = "block";
576
				$display = "block";
577
				$inputdisplay = "show";
578
				$showWidget = "none";
579
				$mindiv = "inline";
580
				$firstprint = true;
581
			} else {
582
				switch ($widget) {
583
					case "interfaces.widget.php":
584
					case "traffic_graphs.widget.php":
585
						$divdisplay = "block";
586
						$display = "block";
587
						$inputdisplay = "show";
588
						$showWidget = "none";
589
						$mindiv = "inline";
590
						break;
591
					default:
592
						$divdisplay = "none";
593
						$display = "block";
594
						$inputdisplay = "close";
595
						$showWidget = "none";
596
						$mindiv = "inline";
597
						break;
598
				}
599
			}
600
		}
601
		
602
		if ($config['widgets'] && $pconfig['sequence'] != ""){
603
			if ($colpos[$widgetcounter] == "col2" && $printed == false)
604
			{
605
				$printed = true;
606
				?>
607
				</div>
608
				<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
609
				<?php
610
			}
611
		}
612
		else if ($widgetcounter >= $halftotal && $printed == false){
613
			$printed = true;
614
			?>
615
			</div>
616
			<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
617
			<?php
618
		}
619
		
620
		?>
621
		<div style="clear:both;"></div>
622
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
623
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input">
624
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
625
				<div style="float:left;">
626
					<?php 
627
					
628
					$widgettitle = $widgetname . "_title";
629
					$widgettitlelink = $widgetname . "_title_link";
630
					if ($$widgettitle != "")
631
					{
632
						//only show link if defined
633
						if ($$widgettitlelink != "") {?>						
634
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
635
						<?php }
636
							//echo widget title
637
							echo $$widgettitle; 
638
						if ($$widgettitlelink != "") { ?>
639
						</span></u>						
640
						<?php }
641
					}
642
					else{		
643
						if ($$widgettitlelink != "") {?>						
644
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
645
						<?php }
646
						echo $nicename;
647
							if ($$widgettitlelink != "") { ?>
648
						</span></u>						
649
						<?php }
650
					}
651
					?>
652
				</div>
653
				<div align="right" style="float:right;">	
654
					<div id="<?php echo $widgetname;?>-configure" onclick='return configureWidget("<?php echo $widgetname;?>")' style="display:none; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_configure.gif" /></div>									
655
					<div id="<?php echo $widgetname;?>-open" onclick='return showWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $showWidget;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" /></div>	
656
					<div id="<?php echo $widgetname;?>-min" onclick='return minimizeWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif"/></div>												
657
					<div id="<?php echo $widgetname;?>-close" onclick='return closeWidget("<?php echo $widgetname;?>",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" /></div>	
658
				</div>
659
				<div style="clear:both;"></div>
660
			</div>
661
			<?php if ($divdisplay != "block") { ?>
662
			<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;">
663
				<br>	
664
					<center>
665
						<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width=25 height=25 alt="<?=gettext("Loading selected widget"); ?>...">
666
					</center>	
667
				<br>
668
			</div> <?php } if ($divdisplay != "block") $display = none; ?>
669
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">				
670
				<?php 
671
					if ($divdisplay == "block")
672
					{
673
						include($directory . $widget);
674
					}	
675
				 ?>
676
			</div>
677
			<div style="clear:both;"></div>
678
		</div>
679
		<?php 	
680
	$widgetcounter++;
681
		
682
	}//end foreach	
683
	?>			
684
		</div>
685
	<div style="clear:both;"></div>
686
</div>
687

    
688
<?php include("fend.inc"); ?>
689
	    
690
<script type="text/javascript">
691
	document.observe('dom:loaded', function(in_event)
692
	{		
693
			Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});	
694
			Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});		
695
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
696
			hideAllWidgets();		    
697
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
698
	<?php } ?>
699
	});
700
</script>
701
<?php
702
	//build list of javascript include files
703
	$jsincludefiles = array();
704
	$directory = "widgets/javascript/";
705
	$dirhandle  = opendir($directory);
706
	$filename = "";
707
	while (false !== ($filename = readdir($dirhandle))) {
708
   		$jsincludefiles[] = $filename;
709
	}
710
	foreach($jsincludefiles as $jsincludename) {
711
		if(!stristr($jsincludename, ".js"))
712
			continue;
713
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
714
	}
715
?>
716
</script>
717
</form>
718
</body>
719
</html>
(79-79/220)