Project

General

Profile

1 601 doc
<?php
2
3
// $Id$
4
5
// JsAdmin module for Website Baker
6
// Copyright (C) 2006, Stepan Riha
7
// www.nonplus.net
8
9
// modified by Swen Uth for Website Baker 2.7
10
11
/*
12
13
 Website Baker Project <http://www.websitebaker.org/>
14
 Copyright (C) 2004-2008, Ryan Djurovich
15
16
 Website Baker is free software; you can redistribute it and/or modify
17
 it under the terms of the GNU General Public License as published by
18
 the Free Software Foundation; either version 2 of the License, or
19
 (at your option) any later version.
20
21
 Website Baker is distributed in the hope that it will be useful,
22
 but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 GNU General Public License for more details.
25
26
 You should have received a copy of the GNU General Public License
27
 along with Website Baker; if not, write to the Free Software
28
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
30
*/
31
32
// Direct access prevention
33
defined('WB_PATH') OR die(header('Location: ../index.php'));
34
35
$JSADMIN_PATH = WB_URL.'/modules/jsadmin';
36
$YUI_PATH = WB_URL.'/include/yui';
37
$script = $_SERVER['SCRIPT_NAME'];
38
if(!$script)
39
	$script = $PHP_SELF;
40
41
if(strstr($script, "/admin/pages/index.php"))
42
	$page_type = 'pages';
43
elseif(strstr($script, "/admin/pages/sections.php"))
44
	$page_type = 'sections';
45
elseif(strstr($script, "/admin/settings/tool.php")
46
	&& isset($_REQUEST["tool"]) && $_REQUEST["tool"] == 'jsadmin')
47
	$page_type = 'config';
48
else
49
	$page_type = '';
50
if($page_type) {
51
	require_once(WB_PATH.'/modules/jsadmin/jsadmin.php');
52
53
	// Default scripts
54
	$js_buttonCell = 3;
55
	$js_scripts = Array();
56
	$js_scripts[] = 'jsadmin.js';
57
58
	if($page_type == 'pages') {
59
		if(!get_setting('mod_jsadmin_persist_order', '1')) {   //Maybe Bug settings to negativ for persist , by Swen Uth
60
			$js_scripts[] = 'restore_pages.js';
61
  		}
62
		if(get_setting('mod_jsadmin_ajax_order_pages', '1')) {
63
			$js_scripts[] = 'dragdrop.js';
64
			$js_buttonCell= 6; // This ist the Cell where the Button "Up" is , by Swen Uth
65
		}
66
	} elseif($page_type == 'sections') {
67
		if(get_setting('mod_jsadmin_ajax_order_sections', '1')) {
68
			$js_scripts[] = 'dragdrop.js';
69 677 thorn
			if(SECTION_BLOCKS) {
70
			$js_buttonCell= 4;}
71
      else{ $js_buttonCell= 3;} // This ist the Cell where the Button "Up" is , by Swen Uth
72 601 doc
		}
73
	} elseif($page_type == 'config') {
74
		$js_scripts[] = 'tool.js';
75
	}
76
?>
77
<style type="text/css">
78
/* Fix for funky spacing on page listing */
79
.pages_list li {
80
	margin-bottom: -2px;
81
}
82
83
body.jsadmin_busy td.content {
84
	background: white url(<?php echo WB_URL ?>/modules/jsadmin/images/busy.gif) 4px 4px no-repeat;
85
}
86
87
body.jsadmin_success td.content {
88
	background: white url(<?php echo WB_URL ?>/modules/jsadmin/images/success.gif) 4px 4px no-repeat;
89
}
90
91
body.jsadmin_failure td.content {
92
	background: white url(<?php echo WB_URL ?>/modules/jsadmin/images/failure.gif) 4px 4px no-repeat;
93
}
94
95
.jsadmin_drag {
96
	cursor: move;
97
}
98
99
.jsadmin_drag a, .jsadmin_drag input, .jsadmin_drag select {
100
	cursor: pointer;
101
	cursor: hand;
102
}
103
104
ul.jsadmin_drag_area {
105
	border: solid 1px #99f;
106
}
107
108
</style>
109
110
<script language="JavaScript">
111
<!--
112
var JsAdmin = { WB_URL : '<?php echo WB_URL ?>' };
113
//-->
114
</script>
115
<?php
116
 // For variable cell structure in the tables of admin content
117
  echo "<script type='text/javascript'>buttonCell=".$js_buttonCell.";</script>\n";   // , by Swen  Uth
118
119
 // Check and Load the needed YUI functions  //, all by Swen Uth
120
  $YUI_ERROR=false; // ist there an Error
121
  $YUI_PUT ='';   // String with javascipt includes
122
  $YUI_PUT_MISSING_Files=''; // Strin with missing files
123 626 doc
  reset($js_yui_scripts);
124 601 doc
  foreach($js_yui_scripts as $script) {
125 626 doc
    if(file_exists($WB_MAIN_RELATIVE_PATH.$script)){
126
        $YUI_PUT=$YUI_PUT."<script type='text/javascript' src='".$WB_MAIN_RELATIVE_PATH.$script."'></script>\n"; // go and include
127 601 doc
    } else {
128
        $YUI_ERROR=true;
129 626 doc
        $YUI_PUT_MISSING_Files=$YUI_PUT_MISSING_Files."- ".WB_URL.$script."\\n";   // catch all missing files
130 601 doc
    }
131
	}
132
	if(!$YUI_ERROR)
133
	{
134
    echo $YUI_PUT;  // no Error so go and include
135
    // Load the needed functions
136
	  foreach($js_scripts as $script) {
137
		  echo "<script type='text/javascript' src='".$JSADMIN_PATH."/js/".$script."'></script>\n";
138
	  }
139
  } else  {
140
      echo "<script type='text/javascript'>alert('YUI ERROR!! File not Found!! > \\n".$YUI_PUT_MISSING_Files." so look in the include folder or switch Javascript Admin off!');</script>\n"; //, by Swen Uth
141
  }
142
143
 }
144
?>