| 1 |
2
|
Manuela
|
<?php
|
| 2 |
|
|
/**
|
| 3 |
|
|
*
|
| 4 |
|
|
* @category modules
|
| 5 |
|
|
* @package JsAdmin
|
| 6 |
|
|
* @author WebsiteBaker Project, modified by Swen Uth for Website Baker 2.7
|
| 7 |
|
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
| 8 |
|
|
* @link http://www.websitebaker2.org/
|
| 9 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
| 10 |
|
|
* @platform WebsiteBaker 2.8.3
|
| 11 |
|
|
* @requirements PHP 5.3.6 and higher
|
| 12 |
|
|
* @version $Id$
|
| 13 |
|
|
* @filesource $HeadURL$
|
| 14 |
|
|
* @lastmodified $Date$
|
| 15 |
|
|
*
|
| 16 |
|
|
*/
|
| 17 |
|
|
|
| 18 |
|
|
|
| 19 |
|
|
// Must include code to stop this file being access directly
|
| 20 |
|
|
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
|
| 21 |
|
|
|
| 22 |
|
|
// obtain the admin folder (e.g. /admin)
|
| 23 |
|
|
$admin_folder = str_replace(WB_PATH, '', ADMIN_PATH);
|
| 24 |
|
|
|
| 25 |
|
|
$JSADMIN_PATH = WB_URL.'/modules/jsadmin';
|
| 26 |
|
|
$YUI_PATH = WB_URL.'/include/yui';
|
| 27 |
|
|
$sCallingScript = $_SERVER['SCRIPT_NAME'];
|
| 28 |
|
|
$sAddonName = basename(__DIR__);
|
| 29 |
|
|
$page_type = '';
|
| 30 |
|
|
//$module_dir = $script;
|
| 31 |
|
|
if( !isset( $module_dir ) ) { $module_dir = $sAddonName; }
|
| 32 |
|
|
|
| 33 |
|
|
if(strstr($sCallingScript, $admin_folder."/pages/index.php")){
|
| 34 |
|
|
$page_type = 'pages';
|
| 35 |
|
|
}elseif(strstr($sCallingScript, $admin_folder."/pages/sections.php")){
|
| 36 |
|
|
$page_type = 'sections';
|
| 37 |
|
|
/*
|
| 38 |
|
|
}elseif(strstr($sCallingScript, $admin_folder."/settings/tool.php")
|
| 39 |
|
|
&& isset($_REQUEST["tool"]) && $_REQUEST["tool"] == $sAddonName){
|
| 40 |
|
|
$page_type = 'settings';
|
| 41 |
|
|
*/
|
| 42 |
|
|
}elseif(strstr($sCallingScript, $admin_folder."/pages/modify.php")) {
|
| 43 |
|
|
$page_type = 'modules';
|
| 44 |
|
|
}elseif(strstr($sCallingScript, $admin_folder."/admintools/tool.php")) {
|
| 45 |
|
|
$page_type = 'tool';
|
| 46 |
|
|
}
|
| 47 |
|
|
|
| 48 |
|
|
if( preg_match( '/'.'(pages|sections|settings|modules|tool|config)$/is', $page_type)) {
|
| 49 |
|
|
//if($page_type!='') {
|
| 50 |
|
|
if (!function_exists('get_setting')){require(WB_PATH.'/modules/'.$sAddonName.'/jsadmin.php');}
|
| 51 |
|
|
// Default scripts
|
| 52 |
|
|
$js_scripts = Array();
|
| 53 |
|
|
$js_scripts[] = 'jsadmin.js';
|
| 54 |
|
|
|
| 55 |
|
|
switch ($page_type):
|
| 56 |
|
|
case 'tool':
|
| 57 |
|
|
case 'modules':
|
| 58 |
|
|
// This ist the Cell where the Button "Up" is , by Swen Uth
|
| 59 |
|
|
$js_buttonCell= (isset($js_buttonCell)?$js_buttonCell:6);
|
| 60 |
|
|
if(!get_setting('mod_jsadmin_persist_order', '0')) { //Maybe Bug settings to negativ for persist , by Swen Uth
|
| 61 |
|
|
$js_scripts[] = 'restore_pages.js';
|
| 62 |
|
|
}
|
| 63 |
|
|
if(get_setting('mod_jsadmin_ajax_order_pages', '1')) {
|
| 64 |
|
|
$js_scripts[] = 'dragdrop.js';
|
| 65 |
|
|
}
|
| 66 |
|
|
break;
|
| 67 |
|
|
case 'pages':
|
| 68 |
|
|
$js_buttonCell= (isset($js_buttonCell)?$js_buttonCell:7);
|
| 69 |
|
|
if(!get_setting('mod_jsadmin_persist_order', '0')) { //Maybe Bug settings to negativ for persist , by Swen Uth
|
| 70 |
|
|
$js_scripts[] = 'restore_pages.js';
|
| 71 |
|
|
}
|
| 72 |
|
|
if(get_setting('mod_jsadmin_ajax_order_pages', '1')) {
|
| 73 |
|
|
$js_scripts[] = 'dragdrop.js';
|
| 74 |
|
|
// This ist the Cell where the Button "Up" is , by Swen Uth
|
| 75 |
|
|
$js_buttonCell= 7;
|
| 76 |
|
|
}
|
| 77 |
|
|
break;
|
| 78 |
|
|
case 'sections':
|
| 79 |
|
|
$js_buttonCell= (isset($js_buttonCell)?$js_buttonCell:9);
|
| 80 |
|
|
if(get_setting('mod_jsadmin_ajax_order_sections', '1')) {
|
| 81 |
|
|
$js_scripts[] = 'dragdrop.js';
|
| 82 |
|
|
// This ist the Cell where the Button "Up" is , by Swen Uth
|
| 83 |
|
|
if(SECTION_BLOCKS) {
|
| 84 |
|
|
} else {
|
| 85 |
|
|
--$js_buttonCell;
|
| 86 |
|
|
}
|
| 87 |
|
|
}
|
| 88 |
|
|
break;
|
| 89 |
|
|
case 'config':
|
| 90 |
|
|
$js_buttonCell= (isset($js_buttonCell)?$js_buttonCell:5);
|
| 91 |
|
|
$js_scripts[] = 'tool.js';
|
| 92 |
|
|
break;
|
| 93 |
|
|
default:
|
| 94 |
|
|
$admin->print_error('PageTtype '.$TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
| 95 |
|
|
endswitch;
|
| 96 |
|
|
// if not declared set it to buttoncell 10
|
| 97 |
|
|
$js_buttonCell = (isset($js_buttonCell)?$js_buttonCell:9);
|
| 98 |
|
|
// For variable cell structure in the tables of admin content
|
| 99 |
|
|
// echo "<script >buttonCell=".$js_buttonCell.";</script>\n"; // , by Swen Uth
|
| 100 |
|
|
unset($js_buttonCell);
|
| 101 |
|
|
|
| 102 |
|
|
?>
|
| 103 |
|
|
<script type="text/javascript">
|
| 104 |
|
|
<!--
|
| 105 |
|
|
|
| 106 |
|
|
var JsAdmin = {
|
| 107 |
|
|
ADMIN_DIRECTORY : '<?php echo '/'.ADMIN_DIRECTORY; ?>',
|
| 108 |
|
|
WB_URL : '<?php echo WB_URL; ?>',
|
| 109 |
|
|
ADMIN_URL : '<?php echo ADMIN_URL; ?>',
|
| 110 |
|
|
ModuleUrl : '<?php echo $module_dir; ?>'
|
| 111 |
|
|
};
|
| 112 |
|
|
var JsAdminTheme = { THEME_URL : '<?php echo THEME_URL; ?>' };
|
| 113 |
|
|
|
| 114 |
|
|
// Get the Cell where the Button "Up" is
|
| 115 |
|
|
function callFunc(){
|
| 116 |
|
|
var trim = function (str, chr) {
|
| 117 |
|
|
var rgxtrim = (!chr) ? new RegExp('^\\s+|\\s+$', 'g') : new RegExp('^' + chr + '+|' + chr + '+$', 'g');
|
| 118 |
|
|
return str.replace(rgxtrim, '');
|
| 119 |
|
|
};
|
| 120 |
|
|
|
| 121 |
|
|
var aRetVal = null;
|
| 122 |
|
|
var reImg = /(.*)move_(up)\.php(.*)/;
|
| 123 |
|
|
var oTable = document.getElementsByTagName('table');
|
| 124 |
|
|
//gets rows of table
|
| 125 |
|
|
for(var i = 0, table; table = oTable[i]; i++){
|
| 126 |
|
|
for (var j = 0, row; row = oTable[i].rows[j]; j++) {
|
| 127 |
|
|
// console.info("Content in row" + j+" : \n" );
|
| 128 |
|
|
for (var k = 0, col; col = row.cells[k]; k++) {
|
| 129 |
|
|
var value = col.innerHTML;
|
| 130 |
|
|
// console.log("cell "+k+" value : " + value);
|
| 131 |
|
|
var match = value.match(reImg);
|
| 132 |
|
|
if(!match) {
|
| 133 |
|
|
continue;
|
| 134 |
|
|
} else {
|
| 135 |
|
|
return {
|
| 136 |
|
|
buttonCell : k,
|
| 137 |
|
|
url : trim(match[1]),
|
| 138 |
|
|
op : match[2],
|
| 139 |
|
|
params : match[3]
|
| 140 |
|
|
}
|
| 141 |
|
|
}
|
| 142 |
|
|
}
|
| 143 |
|
|
}
|
| 144 |
|
|
}
|
| 145 |
|
|
}
|
| 146 |
|
|
var aCell = callFunc();
|
| 147 |
|
|
if(aCell){
|
| 148 |
|
|
var buttonCell = aCell.buttonCell;
|
| 149 |
|
|
console.log('buttonCell: '+buttonCell);
|
| 150 |
|
|
//console.log(aCell);
|
| 151 |
|
|
}
|
| 152 |
|
|
//
|
| 153 |
|
|
//-->
|
| 154 |
|
|
</script>
|
| 155 |
|
|
<?php
|
| 156 |
|
|
// Check and Load the needed YUI functions //, all by Swen Uth
|
| 157 |
|
|
$YUI_ERROR = false; // ist there an Error
|
| 158 |
|
|
$YUI_PUT =''; // String with javascipt includes
|
| 159 |
|
|
$YUI_PUT_MISSING_Files=''; // String with missing files
|
| 160 |
|
|
|
| 161 |
|
|
reset($js_yui_scripts);
|
| 162 |
|
|
foreach($js_yui_scripts as $script) {
|
| 163 |
|
|
if(file_exists($WB_MAIN_RELATIVE_PATH.$script)){
|
| 164 |
|
|
$YUI_PUT = $YUI_PUT."<script src='".$WB_MAIN_RELATIVE_PATH.$script."' ></script>\n"; // go and include
|
| 165 |
|
|
} else {
|
| 166 |
|
|
$YUI_ERROR=true;
|
| 167 |
|
|
$YUI_PUT_MISSING_Files=$YUI_PUT_MISSING_Files."- ".WB_URL.$script."\\n"; // catch all missing files
|
| 168 |
|
|
}
|
| 169 |
|
|
}
|
| 170 |
|
|
/* */
|
| 171 |
|
|
if(!$YUI_ERROR)
|
| 172 |
|
|
{
|
| 173 |
|
|
echo $YUI_PUT; // no Error so go and include
|
| 174 |
|
|
// Load the needed functions
|
| 175 |
|
|
foreach($js_scripts as $script) {
|
| 176 |
|
|
echo "<script src='".$JSADMIN_PATH."/js/".$script."' type='text/javascript'></script>\n";
|
| 177 |
|
|
}
|
| 178 |
|
|
} else {
|
| 179 |
|
|
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
|
| 180 |
|
|
}
|
| 181 |
|
|
} else {
|
| 182 |
|
|
}
|
| 183 |
|
|
|
| 184 |
|
|
/*
|
| 185 |
|
|
print '<pre class="mod-pre rounded">function <span>'.__FUNCTION__.'( '.''.' );</span> filename: <span>'.basename(__FILE__).'</span> line: '.__LINE__.' -> <br />';
|
| 186 |
|
|
print_r( $page_type.'/'.$js_buttonCell ); print '</pre>'; flush (); // ob_flush();;sleep(10); die();
|
| 187 |
|
|
*/
|