Project

General

Profile

1 1009 Ruebenwurz
<?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-2009, 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
// obtain the admin folder (e.g. /admin)
36
$admin_folder = str_replace(WB_PATH, '', ADMIN_PATH);
37
38
$JSADMIN_PATH = WB_URL.'/modules/jsadmin';
39
$YUI_PATH = WB_URL.'/include/yui';
40
$script = $_SERVER['SCRIPT_NAME'];
41
if(!$script)
42
	$script = $PHP_SELF;
43
44
if(strstr($script, $admin_folder."/pages/index.php"))
45
	$page_type = 'pages';
46
elseif(strstr($script, $admin_folder."/pages/sections.php"))
47
	$page_type = 'sections';
48
elseif(strstr($script, $admin_folder."/settings/tool.php")
49
	&& isset($_REQUEST["tool"]) && $_REQUEST["tool"] == 'jsadmin')
50
	$page_type = 'config';
51
else
52
	$page_type = '';
53
if($page_type) {
54
	require_once(WB_PATH.'/modules/jsadmin/jsadmin.php');
55
56
	// Default scripts
57
	$js_buttonCell = 3;
58
	$js_scripts = Array();
59
	$js_scripts[] = 'jsadmin.js';
60
61
	if($page_type == 'pages') {
62
		if(!get_setting('mod_jsadmin_persist_order', '1')) {   //Maybe Bug settings to negativ for persist , by Swen Uth
63
			$js_scripts[] = 'restore_pages.js';
64
  		}
65
		if(get_setting('mod_jsadmin_ajax_order_pages', '1')) {
66
			$js_scripts[] = 'dragdrop.js';
67 1048 Ruebenwurz
			$js_buttonCell= 7; // This ist the Cell where the Button "Up" is , by Swen Uth
68 1009 Ruebenwurz
		}
69
	} elseif($page_type == 'sections') {
70
		if(get_setting('mod_jsadmin_ajax_order_sections', '1')) {
71
			$js_scripts[] = 'dragdrop.js';
72
			if(SECTION_BLOCKS) {
73
			$js_buttonCell= 5;}
74
      else{ $js_buttonCell= 5;} // This ist the Cell where the Button "Up" is , by Swen Uth
75
		}
76
	} elseif($page_type == 'config') {
77
		$js_scripts[] = 'tool.js';
78
	}
79
?>
80
81
<script  type="text/javascript" language="JavaScript">
82
<!--
83
var JsAdmin = { WB_URL : '<?php echo WB_URL ?>', ADMIN_URL : '<?php echo ADMIN_URL ?>' };
84
var JsAdminTheme = { THEME_URL : '<?php echo THEME_URL ?>' };
85
//-->
86
</script>
87
<?php
88
 // For variable cell structure in the tables of admin content
89
  echo "<script type='text/javascript'>buttonCell=".$js_buttonCell.";</script>\n";   // , by Swen  Uth
90
91
 // Check and Load the needed YUI functions  //, all by Swen Uth
92
  $YUI_ERROR=false; // ist there an Error
93
  $YUI_PUT ='';   // String with javascipt includes
94
  $YUI_PUT_MISSING_Files=''; // Strin with missing files
95
  reset($js_yui_scripts);
96
  foreach($js_yui_scripts as $script) {
97
    if(file_exists($WB_MAIN_RELATIVE_PATH.$script)){
98
        $YUI_PUT=$YUI_PUT."<script type='text/javascript' src='".$WB_MAIN_RELATIVE_PATH.$script."'></script>\n"; // go and include
99
    } else {
100
        $YUI_ERROR=true;
101
        $YUI_PUT_MISSING_Files=$YUI_PUT_MISSING_Files."- ".WB_URL.$script."\\n";   // catch all missing files
102
    }
103
	}
104
	if(!$YUI_ERROR)
105
	{
106
    echo $YUI_PUT;  // no Error so go and include
107
    // Load the needed functions
108
	  foreach($js_scripts as $script) {
109
		  echo "<script type='text/javascript' src='".$JSADMIN_PATH."/js/".$script."'></script>\n";
110
	  }
111
  } else  {
112
      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
113
  }
114
115
 }
116
?>