Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1440)
+++ branches/2.8.x/CHANGELOG	(revision 1441)
@@ -11,6 +11,10 @@
 ! = Update/Change
 
 ------------------------------------- 2.8.2 -------------------------------------
+10 Apr-2011 Build 1441 Dietmar Woellbrink (Luisehahne)
+# recoded /modules/admin.php info_banner, now compare with modify in pages
+# security fixes remove defined WB_PATH for backend templates
+# fixed class.admin.php missing $TEXT declaration, add get_section_details
 26 Mar-2011 Build 1440 Dietmar Woellbrink (Luisehahne)
 # add missing methode is_group_match in class.wb.php 
 17 Mar-2011 Build 1439 Werner v.d.Decken(DarkViper)
Index: branches/2.8.x/wb/admin/groups/index.php
===================================================================
--- branches/2.8.x/wb/admin/groups/index.php	(revision 1440)
+++ branches/2.8.x/wb/admin/groups/index.php	(revision 1441)
@@ -184,7 +184,6 @@
 								'CHECKED' => ' checked="checked"',
 								'ADMIN_URL' => ADMIN_URL,
 								'WB_URL' => WB_URL,
-								'WB_PATH' => WB_PATH,
 								'THEME_URL' => THEME_URL,
 								'FTAN' => $ftan
 								)
Index: branches/2.8.x/wb/admin/pages/index.php
===================================================================
--- branches/2.8.x/wb/admin/pages/index.php	(revision 1440)
+++ branches/2.8.x/wb/admin/pages/index.php	(revision 1441)
@@ -553,7 +553,6 @@
 $template->set_var(array(
 								'THEME_URL' => THEME_URL,
 								'WB_URL' => WB_URL,
-								'WB_PATH' => WB_PATH,
 								'ADMIN_URL' => ADMIN_URL,
 								)
 						);
Index: branches/2.8.x/wb/admin/pages/modify.php
===================================================================
--- branches/2.8.x/wb/admin/pages/modify.php	(revision 1440)
+++ branches/2.8.x/wb/admin/pages/modify.php	(revision 1441)
@@ -72,7 +72,6 @@
 			'MENU_TITLE' => ($results_array['menu_title']),
 			'ADMIN_URL' => ADMIN_URL,
 			'WB_URL' => WB_URL,
-			'WB_PATH' => WB_PATH,
 			'THEME_URL' => THEME_URL
 			));
 
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1440)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1441)
@@ -52,6 +52,6 @@
 
 // check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
 if(!defined('VERSION')) define('VERSION', '2.8.2.RC5');
-if(!defined('REVISION')) define('REVISION', '1440');
+if(!defined('REVISION')) define('REVISION', '1441');
 
 ?>
Index: branches/2.8.x/wb/admin/settings/index.php
===================================================================
--- branches/2.8.x/wb/admin/settings/index.php	(revision 1440)
+++ branches/2.8.x/wb/admin/settings/index.php	(revision 1441)
@@ -147,10 +147,8 @@
 	}
 
 	$template->set_var(array(
-						'WB_PATH' => WB_PATH,
 						'WB_URL' => WB_URL,
 						'THEME_URL' => THEME_URL,
-						'ADMIN_PATH' => ADMIN_PATH,
 						'ADMIN_URL' => ADMIN_URL,
 					 ));
 
Index: branches/2.8.x/wb/admin/users/users.php
===================================================================
--- branches/2.8.x/wb/admin/users/users.php	(revision 1440)
+++ branches/2.8.x/wb/admin/users/users.php	(revision 1441)
@@ -61,7 +61,6 @@
 							'EMAIL' => $user['email'],
 							'ADMIN_URL' => ADMIN_URL,
 							'WB_URL' => WB_URL,
-							'WB_PATH' => WB_PATH,
 							'THEME_URL' => THEME_URL
 							)
 					);
Index: branches/2.8.x/wb/admin/users/index.php
===================================================================
--- branches/2.8.x/wb/admin/users/index.php	(revision 1440)
+++ branches/2.8.x/wb/admin/users/index.php	(revision 1441)
@@ -76,7 +76,6 @@
 $template->set_var(array(
 		'ADMIN_URL' => ADMIN_URL,
 		'WB_URL' => WB_URL,
-		'WB_PATH' => WB_PATH,
 		'THEME_URL' => THEME_URL
 		)
 );
@@ -106,7 +105,6 @@
 $template->set_var(array(
 		'ADMIN_URL' => ADMIN_URL,
 		'WB_URL' => WB_URL,
-		'WB_PATH' => WB_PATH,
 		'THEME_URL' => THEME_URL
 		)
 );
Index: branches/2.8.x/wb/admin/languages/details.php
===================================================================
--- branches/2.8.x/wb/admin/languages/details.php	(revision 1440)
+++ branches/2.8.x/wb/admin/languages/details.php	(revision 1441)
@@ -64,7 +64,6 @@
 								'DESIGNED_FOR' => $language_platform,
 								'ADMIN_URL' => ADMIN_URL,
 								'WB_URL' => WB_URL,
-								'WB_PATH' => WB_PATH,
 								'THEME_URL' => THEME_URL
 								)
 						);
Index: branches/2.8.x/wb/admin/languages/index.php
===================================================================
--- branches/2.8.x/wb/admin/languages/index.php	(revision 1440)
+++ branches/2.8.x/wb/admin/languages/index.php	(revision 1441)
@@ -66,7 +66,6 @@
 $template->set_var(array(
 								'ADMIN_URL' => ADMIN_URL,
 								'WB_URL' => WB_URL,
-								'WB_PATH' => WB_PATH,
 								'THEME_URL' => THEME_URL
 								)
 						);
Index: branches/2.8.x/wb/admin/modules/details.php
===================================================================
--- branches/2.8.x/wb/admin/modules/details.php	(revision 1440)
+++ branches/2.8.x/wb/admin/modules/details.php	(revision 1441)
@@ -81,7 +81,6 @@
 								'DESIGNED_FOR' => $module['platform'],
 								'ADMIN_URL' => ADMIN_URL,
 								'WB_URL' => WB_URL,
-								'WB_PATH' => WB_PATH,
 								'THEME_URL' => THEME_URL
 								)
 						);
Index: branches/2.8.x/wb/framework/class.admin.php
===================================================================
--- branches/2.8.x/wb/framework/class.admin.php	(revision 1440)
+++ branches/2.8.x/wb/framework/class.admin.php	(revision 1441)
@@ -223,40 +223,73 @@
 			}
 		}
 	}
-		
+/*
 	function get_user_details($user_id) {
 		global $database;
-		$query_user = "SELECT username,display_name FROM ".TABLE_PREFIX."users WHERE user_id = '$user_id'";
-		$get_user = $database->query($query_user);
-		if($get_user->numRows() != 0) {
-			$user = $get_user->fetchRow();
-		} else {
-			$user['display_name'] = 'Unknown';
-			$user['username'] = 'unknown';
+		$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'users` ';
+		$sql .= 'WHERE `user_id`='.(int)$user_id.' LIMIT 1';
+		if(($resUser = $database->query($sql))){
+			if(!($recUser = $resUser->fetchRow())) {
+				$recUser['display_name'] = 'Unknown';
+				$recUser['username'] = 'unknown';
+			}
 		}
-		return $user;
-	}	
-	
-	function get_page_details($page_id) {
-		global $database;
-		$query = "SELECT page_id,page_title,menu_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
-		$results = $database->query($query);
-		if($database->is_error()) {
-			$this->print_header();
-			$this->print_error($database->get_error());
-		}
-		if($results->numRows() == 0) {
-			$this->print_header();
-			$this->print_error($MESSAGE['PAGES']['NOT_FOUND']);
-		}
-		$results_array = $results->fetchRow();
-		return $results_array;
-	}	
-	
+		return $recUser;
+	}
+*/
+ function get_user_details($user_id) {
+  global $database;
+  $retval = array('username'=>'unknown','display_name'=>'Unknown','email'=>'');
+  $sql  = 'SELECT `username`,`display_name`,`email` ';
+  $sql .= 'FROM `'.TABLE_PREFIX.'users` ';
+  $sql .= 'WHERE `user_id`='.(int)$user_id.' ';
+  // $sql .= 'AND (`statusflags` & '.USERS_DELETED.') > 0';
+  if( ($resUsers = $database->query($sql)) ) {
+   if( ($recUser = $resUsers->fetchRow()) ) {
+    $retval = $recUser;
+   }
+  }
+  return $retval;
+ }
+
+    //
+	function get_section_details( $section_id, $backLink = 'index.php' ) {
+	global $database, $TEXT;
+		$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'sections` ';
+		$sql .= 'WHERE `section_id`='.intval($section_id).' LIMIT 1';
+		if(($resSection = $database->query($sql))){
+			if(!($recSection = $resSection->fetchRow())) {
+				$this->print_header();
+				$this->print_error($TEXT['SECTION'].' '.$TEXT['NOT_FOUND'], $backLink, true);
+			}
+			} else {
+				$this->print_header();
+				$this->print_error($database->get_error(), $backLink, true);
+			}
+		return $recSection;
+	}
+
+	function get_page_details( $page_id, $backLink = 'index.php' ) {
+	  global $database, $TEXT;
+	  $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
+	  $sql .= 'WHERE `page_id`='.(int)$page_id.' LIMIT 1';
+	  if(($resPages = $database->query($sql))){
+	   if(!($recPage = $resPages->fetchRow())) {
+	    $this->print_header();
+	    $this->print_error($TEXT['PAGE'].' '.$TEXT['NOT_FOUND'], $backLink, true);
+	   }
+	  } else {
+	   $this->print_header();
+	   $this->print_error($database->get_error(), $backLink, true);
+	  }
+	  return $recPage;
+	 }
+
 	/** Function get_page_permission takes either a numerical page_id,
 	 * upon which it looks up the permissions in the database,
-	 * or an array with keys admin_groups and admin_users  
+	 * or an array with keys admin_groups and admin_users
 	 */
+/*
 	function get_page_permission($page,$action='admin') {
 		if ($action!='viewing') $action='admin';
 		$action_groups=$action.'_groups';
@@ -264,7 +297,7 @@
 		if (is_array($page)) {
 				$groups=$page[$action_groups];
 				$users=$page[$action_users];
-		} else {				
+		} else {
 			global $database;
 			$results = $database->query("SELECT $action_groups,$action_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page'");
 			$result = $results->fetchRow();
@@ -283,8 +316,31 @@
 		}
 		return true;
 	}
-		
+*/
 
+	function get_page_permission($page,$action='admin') {
+		if($action != 'viewing') { $action = 'admin'; }
+		$action_groups = $action.'_groups';
+		$action_users  = $action.'_users';
+		$groups = $users = '0';
+		if(is_array($page)) {
+			$groups = $page[$action_groups];
+			$users  = $page[$action_users];
+		} else {
+			global $database;
+			$sql  = 'SELECT `'.$action_groups.'`,`'.$action_users.'` ';
+			$sql .= 'FROM `'.TABLE_PREFIX.'pages` ';
+			$sql .= 'WHERE `page_id`='.(int)$page;
+			if( ($res = $database->query($sql)) ) {
+				if( ($rec = $res->fetchRow()) ) {
+					$groups = $rec[$action_groups];
+					$users  = $rec[$action_users];
+				}
+			}
+		}
+		return ($this->ami_group_member($groups) || $this->is_group_match($this->get_user_id(), $users));
+	}
+
 	// Returns a system permission for a menu link
 	function get_link_permission($title) {
 		$title = str_replace('_blank', '', $title);
@@ -318,7 +374,7 @@
         $body_links = "";
 		// define default baselink and filename for optional module javascript and stylesheet files
 		if($file_id == "js") {
-			$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend_body.js"></script>';
+			$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend_body.js" type="text/javascript"></script>';
 			$base_file = "backend_body.js";
 		}
 		// check if backend_body.js files needs to be included to the <body></body> section of the backend
@@ -382,7 +438,7 @@
 			$base_link.= ' rel="stylesheet" type="text/css" media="screen" />';
 			$base_file = "backend.css";
 		} else {
-			$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.js"></script>';
+			$base_link = '<script src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.js" type="text/javascript"></script>';
 			$base_file = "backend.js";
 		}
 
@@ -400,7 +456,7 @@
 					return str_replace("{MODULE_DIRECTORY}", $tool['directory'], $base_link);
 				}
 			}
-		} elseif(isset($_GET['page_id']) or isset($_POST['page_id'])) {
+		} elseif(isset($_GET['page_id']) || isset($_POST['page_id'])) {
 			// check if displayed page in the backend contains a page module
 			if (isset($_GET['page_id'])) {
 				$page_id = (int)$_GET['page_id'];
Index: branches/2.8.x/wb/search/search_modext.php
===================================================================
--- branches/2.8.x/wb/search/search_modext.php	(revision 1440)
+++ branches/2.8.x/wb/search/search_modext.php	(revision 1441)
@@ -5,11 +5,11 @@
  * @package         search
  * @author          WebsiteBaker Project
  * @copyright       2004-2009, Ryan Djurovich
- * @copyright       2009-2011, Website Baker Org. e.V.
+ * @copyright       2009-2010, Website Baker Org. e.V.
  * @link			http://www.websitebaker2.org/
  * @license         http://www.gnu.org/licenses/gpl.html
  * @platform        WebsiteBaker 2.8.x
- * @requirements    PHP 5.2.2 and higher
+ * @requirements    PHP 4.3.4 and higher
  * @version         $Id$
  * @filesource		$HeadURL$
  * @lastmodified    $Date$
@@ -16,15 +16,10 @@
  *
  */
 
-// Must include code to stop this file being access directly
-if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
-
 // make the url-string for highlighting
-function make_url_searchstring($search_match, $search_url_array)
-{
+function make_url_searchstring($search_match, $search_url_array) {
 	$link = "";
-	if ($search_match != 'exact')
-    {
+	if ($search_match != 'exact') {
 		$str = implode(" ", $search_url_array);
 		$link = "?searchresult=1&amp;sstring=".urlencode($str);
 	} else {
@@ -35,11 +30,9 @@
 }
 
 // make date and time for "last modified by... on ..."-string
-function get_page_modified($page_modified_when)
-{
+function get_page_modified($page_modified_when) {
 	global $TEXT;
-	if($page_modified_when > 0)
-    {
+	if($page_modified_when > 0) {
 		$date = gmdate(DATE_FORMAT, $page_modified_when+TIMEZONE);
 		$time = gmdate(TIME_FORMAT, $page_modified_when+TIMEZONE);
 	} else {
@@ -50,28 +43,23 @@
 }
 
 // make username and displayname for "last modified by... on ..."-string
-function get_page_modified_by($page_modified_by, $users)
-{
+function get_page_modified_by($page_modified_by, $users) {
 	global $TEXT;
-	// check for existing user-id
-	if(!isset($users[$page_modified_by]))
-    {
-        $page_modified_by = 0;
-    }
-
-	$username = $users[$page_modified_by]['username'];
-	$displayname = $users[$page_modified_by]['display_name'];
+	if($page_modified_by>0) {
+		$username = $users[$page_modified_by]['username'];
+		$displayname = $users[$page_modified_by]['display_name'];
+	} else {
+		$username = "";
+		$displayname = $TEXT['UNKNOWN'];
+	}
 	return array($username, $displayname);
 }
 
 // checks if _all_ searchwords matches
-function is_all_matched($text, $search_words)
-{
+function is_all_matched($text, $search_words) {
 	$all_matched = true;
-	foreach ($search_words AS $word)
-    {
-		if(!preg_match('/'.$word.'/ui', $text))
-        {
+	foreach ($search_words AS $word) {
+		if(!preg_match('/'.$word.'/i', $text)) {
 			$all_matched = false;
 			break;
 		}
@@ -80,12 +68,10 @@
 }
 
 // checks if _any_ of the searchwords matches
-function is_any_matched($text, $search_words)
-{
+function is_any_matched($text, $search_words) {
 	$any_matched = false;
 	$word = '('.implode('|', $search_words).')';
-	if(preg_match('/'.$word.'/ui', $text))
-    {
+	if(preg_match('/'.$word.'/i', $text)) {
 		$any_matched = true;
 	}
 	return $any_matched;
@@ -92,74 +78,42 @@
 }
 
 // collects the matches from text in excerpt_array
-function get_excerpts($text, $search_words, $max_excerpt_num)
-{
-	$match_array = array();
-	$excerpt_array = array();
+function get_excerpts($text, $search_words, $max_excerpt_num) {
+	$excerpt_array = FALSE;
 	$word = '('.implode('|', $search_words).')';
-
-	//Filter droplets from the page data
-	preg_match_all('~\[\[(.*?)\]\]~', $text, $matches);
-	foreach ($matches[1] as $match)
-    {
-		$text = str_replace('[['.$match.']]', '', $text);					
-	}
-
-	// Build the regex-string
-	if(strpos(strtoupper(PHP_OS), 'WIN')===0)  // windows -> see below
-    {
-		$str1=".!?;";
-		$str2=".!?;";
-	} else { // linux & Co.
-		// start-sign: .!?; + INVERTED EXCLAMATION MARK - INVERTED QUESTION MARK - DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA
-		$str1=".!?;"."\xC2\xA1"."\xC2\xBF"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81";
-		// stop-sign: .!?; + DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA
-		$str2=".!?;"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81";
-	}
-	$regex='/(?:^|\b|['.$str1.'])([^'.$str1.']{0,200}?'.$word.'[^'.$str2.']{0,200}(?:['.$str2.']|\b|$))/uis';
-	if(version_compare(PHP_VERSION, '4.3.3', '>=') &&
-	   strpos(strtoupper(PHP_OS), 'WIN')!==0
-	) { // this may crash windows server, so skip if on windows
-		// jump from match to match, get excerpt, stop if $max_excerpt_num is reached
-		$last_end = 0; $offset = 0;
-		while(preg_match('/'.$word.'/uis', $text, $match_array, PREG_OFFSET_CAPTURE, $last_end))
-        {
-			$offset = ($match_array[0][1]-206 < $last_end)?$last_end:$match_array[0][1]-206;
-			if(preg_match($regex, $text, $matches, PREG_OFFSET_CAPTURE, $offset))
-            {
-				$last_end = $matches[1][1]+strlen($matches[1][0])-1;
-				if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $matches[1][0])) // skip excerpts with email-addresses
-				{
-				  $excerpt_array[] = trim($matches[1][0]);
-                }
-				if(count($excerpt_array)>=$max_excerpt_num)
-                {
-					$excerpt_array = array_unique($excerpt_array);
-					if(count($excerpt_array) >= $max_excerpt_num) { break; }
-				}
-			} else { // problem: preg_match failed - can't find a start- or stop-sign
-				$last_end += 201; // jump forward and try again
-			}
+	// start-sign: .!?; + INVERTED EXCLAMATION MARK - INVERTED QUESTION MARK - DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA
+	$p_start=".!?;"."\xC2\xA1"."\xC2\xBF"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81";
+	// stop-sign: .!?; + DOUBLE EXCLAMATION MARK - INTERROBANG - EXCLAMATION QUESTION MARK - QUESTION EXCLAMATION MARK - DOUBLE QUESTION MARK - HALFWIDTH IDEOGRAPHIC FULL STOP - IDEOGRAPHIC FULL STOP - IDEOGRAPHIC COMMA
+	$p_stop=".!?;"."\xE2\x80\xBC"."\xE2\x80\xBD"."\xE2\x81\x89"."\xE2\x81\x88"."\xE2\x81\x87"."\xEF\xBD\xA1"."\xE3\x80\x82"."\xE3\x80\x81";
+	// jump from match to match, get excerpt, stop if $max_excerpt_num is reached
+	$match_array = $matches = array();
+	$startpos = $wordpos = $endpos = 0; // although preg_match with u-switch handles unicode correctly, the ...pos-variables will count bytes (not chars) 
+	while(preg_match("/$word/i", $text, $match_array, PREG_OFFSET_CAPTURE, $startpos)) {
+		$wordpos = $match_array[0][1];
+		$startpos = ($wordpos-200 < $endpos)?$endpos:$wordpos-200;
+		$endpos = $wordpos+200;
+		// look for better start position
+		if(preg_match_all("/[$p_start]/u", substr($text, $startpos, $wordpos-$startpos), $matches, PREG_OFFSET_CAPTURE))
+			$startpos += $matches[0][count($matches[0])-1][1]; // set startpos at last punctuation before word
+		// look for better end position
+		if(preg_match_all("/[$p_stop]/u", substr($text, $wordpos, $endpos-$wordpos), $matches, PREG_OFFSET_CAPTURE))
+			$endpos = $wordpos+$matches[0][0][1]; // set endpos at first punctuation after word
+		$match = substr($text, $startpos+1, $endpos-$startpos);
+		if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $match)) // skip excerpts with email-addresses
+			$excerpt_array[] = trim($match);
+		if(count($excerpt_array)>=$max_excerpt_num) {
+			$excerpt_array = array_unique($excerpt_array);
+			if(count($excerpt_array) >= $max_excerpt_num)
+				break;
 		}
-	} else { // compatible, but may be very slow with large pages
-		if(preg_match_all($regex, $text, $match_array))
-        {
-			foreach($match_array[1] AS $string)
-            {
-				if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $string))  // skip excerpts with email-addresses
-				{
-				  $excerpt_array[] = trim($string);
-                }
-
-			}
-		}
+		// restart at last endpos
+		$startpos = $endpos;
 	}
 	return $excerpt_array;
 }
 
 // makes excerpt_array a string ready to print out
-function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num)
-{
+function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num) {
 	// excerpts: text before and after a single excerpt, html-tag for markup
 	$EXCERPT_BEFORE =       '...&nbsp;';
 	$EXCERPT_AFTER =        '&nbsp;...<br />';
@@ -168,8 +122,7 @@
 	// remove duplicate matches from $excerpt_array, if any.
 	$excerpt_array = array_unique($excerpt_array);
 	// use the first $max_excerpt_num excerpts only
-	if(count($excerpt_array) > $max_excerpt_num)
-    {
+	if(count($excerpt_array) > $max_excerpt_num) {
 		$excerpt_array = array_slice($excerpt_array, 0, $max_excerpt_num);
 	}
 	// prepare search-string
@@ -177,16 +130,14 @@
 	// we want markup on search-results page,
 	// but we need some 'magic' to prevent <br />, <b>... from being highlighted
 	$excerpt = '';
-	foreach($excerpt_array as $str)
-    {
-		$excerpt .= '#,,#'.preg_replace("/($string)/iu","#,,,,#$1#,,,,,#",$str).'#,,,#';
+	foreach($excerpt_array as $str) {
+		$excerpt .= '#,,#'.preg_replace("/($string)/i","#,,,,#$1#,,,,,#",$str).'#,,,#';
 	}
-	$excerpt = str_replace(array('&','<','>','"','\'',"\xC2\xA0"), array('&amp;','&lt;','&gt;','&quot;','&#039;','&nbsp;'), $excerpt);
+	$excerpt = str_replace(array('&','<','>','"','\'',"\xC2\xA0"), array('&amp;','&lt;','&gt;','&quot;','&#039;',' '), $excerpt);
 	$excerpt = str_replace(array('#,,,,#','#,,,,,#'), array($EXCERPT_MARKUP_START,$EXCERPT_MARKUP_END), $excerpt);
 	$excerpt = str_replace(array('#,,#','#,,,#'), array($EXCERPT_BEFORE,$EXCERPT_AFTER), $excerpt);
 	// prepare to write out
-	if(DEFAULT_CHARSET != 'utf-8')
-    {
+	if(DEFAULT_CHARSET != 'utf-8') {
 		$excerpt = umlauts_to_entities($excerpt, 'UTF-8');
 	}
 	return $excerpt;
@@ -193,46 +144,29 @@
 }
 
 // work out what the link-anchor should be
-function make_url_target($page_link_target, $text, $search_words)
-{
+function make_url_target($page_link_target, $text, $search_words) {
 	// 1. e.g. $page_link_target=="&monthno=5&year=2007" - module-dependent target. Do nothing.
 	// 2. $page_link_target=="#!wb_section_..." - the user wants the section-target, so do nothing.
 	// 3. $page_link_target=="#wb_section_..." - try to find a better target, use the section-target as fallback.
 	// 4. $page_link_target=="" - do nothing
-	if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_')
-    {
+	if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_') {
 		$word = '('.implode('|', $search_words).')';
-		preg_match('/'.$word.'/ui', $text, $match, PREG_OFFSET_CAPTURE);
-		if($match && is_array($match[0]))
-        {
+		preg_match('/'.$word.'/i', $text, $match, PREG_OFFSET_CAPTURE);
+		if($match && is_array($match[0])) {
 			$x=$match[0][1]; // position of first match
 			// is there an anchor nearby?
-			if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iU', substr($text,0,$x), $match, PREG_OFFSET_CAPTURE))
-            {
-				$anchor='';
-				foreach($match[1] AS $array)
-                {
-					if($array[1] > $x)
-                    {
-						break;
-					}
-					$anchor = $array[0];
-				}
-				if($anchor != '')
-                {
-					$page_link_target = '#'.$anchor;
-				}
+			if(preg_match_all('/<\s*(?:a[^>]+?name|[^>]+?id)\s*=\s*"([^"]+)"/i', substr($text,0,$x), $match)) {
+				$page_link_target = '#'.$match[1][count($match[1])-1];
 			}
 		}
-	} elseif(substr($page_link_target,0,13)=='#!wb_section_') {
+	}
+	elseif(substr($page_link_target,0,13)=='#!wb_section_') {
 		$page_link_target = '#'.substr($page_link_target, 2);
 	}
 	
 	// since wb 2.7.1 the section-anchor is configurable - SEC_ANCHOR holds the anchor name
-	if(substr($page_link_target,0,12)=='#wb_section_')
-    {
-		if(defined('SEC_ANCHOR') && SEC_ANCHOR!='')
-        {
+	if(substr($page_link_target,0,12)=='#wb_section_') {
+		if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
 			$sec_id = substr($page_link_target, 12);
 			$page_link_target = '#'.SEC_ANCHOR.$sec_id;
 		} else { // section-anchors are disabled
@@ -244,8 +178,7 @@
 }
 
 // wrapper for compatibility with old print_excerpt()
-function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="")
-{
+function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="") {
 	$mod_vars = array(
 		'page_link' => $page_link,
 		'page_link_target' => $page_link_target,
@@ -267,31 +200,26 @@
  * list_files_dirs() - lists all files and dirs below a given directory
  * clear_filelist() - keeps only wanted or removes unwanted entries in file-list.
  */
-
+ 
 // prints the excerpts for one section
-function print_excerpt2($mod_vars, $func_vars)
-{
+function print_excerpt2($mod_vars, $func_vars) {
 	extract($func_vars, EXTR_PREFIX_ALL, 'func');
 	extract($mod_vars, EXTR_PREFIX_ALL, 'mod');
 	global $TEXT;
 	// check $mod_...vars
-	if(!isset($mod_page_link))          { $mod_page_link = $func_page_link; }
-	if(!isset($mod_page_link_target))   { $mod_page_link_target = ''; }
-	if(!isset($mod_page_title))         { $mod_page_title = $func_page_title; }
-	if(!isset($mod_page_description))   { $mod_page_description = $func_page_description; }
-	if(!isset($mod_page_modified_when)) { $mod_page_modified_when = $func_page_modified_when; }
-	if(!isset($mod_page_modified_by))   { $mod_page_modified_by = $func_page_modified_by; }
-	if(!isset($mod_text))               { $mod_text = ''; }
-	if(!isset($mod_max_excerpt_num))    { $mod_max_excerpt_num = $func_default_max_excerpt; }
-	if(!isset($mod_pic_link))           { $mod_pic_link = ''; }
-	if(!isset($mod_no_highlight))       { $mod_no_highlight = false; }
-	if(!isset($func_enable_flush))      { $func_enable_flush = false; } // set this in db: wb_search.cfg_enable_flush [READ THE DOC BEFORE]
-	if(isset($mod_ext_charset))
-    {
-      $mod_ext_charset = strtolower($mod_ext_charset);
-    } else {
-      $mod_ext_charset = '';
-    }
+	if(!isset($mod_page_link))          $mod_page_link = $func_page_link;
+	if(!isset($mod_page_link_target))   $mod_page_link_target = "";
+	if(!isset($mod_page_title))         $mod_page_title = $func_page_title;
+	if(!isset($mod_page_description))   $mod_page_description = $func_page_description;
+	if(!isset($mod_page_modified_when)) $mod_page_modified_when = $func_page_modified_when;
+	if(!isset($mod_page_modified_by))   $mod_page_modified_by = $func_page_modified_by;
+	if(!isset($mod_text))               $mod_text = "";
+	if(!isset($mod_max_excerpt_num))    $mod_max_excerpt_num = $func_default_max_excerpt;
+	if(!isset($mod_pic_link))           $mod_pic_link = "";
+	if(!isset($mod_no_highlight))       $mod_no_highlight = false;
+	if(!isset($func_enable_flush))      $func_enable_flush = false; // set this in db: wb_search.cfg_enable_flush [READ THE DOC BEFORE]
+	if(isset($mod_ext_charset)) $mod_ext_charset = strtolower($mod_ext_charset);
+	else $mod_ext_charset = '';
 
 	if($mod_text == "") // nothing to do
 		{ return false; }
@@ -299,10 +227,10 @@
 	if($mod_no_highlight) // no highlighting
 		{ $mod_page_link_target = "&amp;nohighlight=1".$mod_page_link_target; }
 	// clean the text:
+	$mod_text = preg_replace('#<(br|dt|/dd|/?(?:h[1-6]|tr|table|p|li|ul|pre|code|div|hr))[^>]*>#i', '.', $mod_text);
 	$mod_text = preg_replace('#<(!--.*--|style.*</style|script.*</script)>#iU', ' ', $mod_text);
-	$mod_text = preg_replace('#<(br( /)?|dt|/dd|/?(h[1-6]|tr|table|p|li|ul|pre|code|div|hr))[^>]*>#i', '.', $mod_text);
-	// $mod_text = preg_replace('/(\v\s?|\s\s)+/', ' ', $mod_text);
-	$mod_text = preg_replace('/\s\./', '.', $mod_text);
+	$mod_text = preg_replace('#\[\[.*?\]\]#', '', $mod_text); //Filter droplets from the page data
+	// strip_tags() is called below
 	if($mod_ext_charset!='') { // data from external database may have a different charset
 		require_once(WB_PATH.'/framework/functions-utf8.php');
 		switch($mod_ext_charset) {
@@ -333,13 +261,13 @@
 			$mod_text = charset_to_utf8($mod_text, 'UTF-8');
 		}
 	} else {
-	$mod_text = entities_to_umlauts($mod_text, 'UTF-8');
+		$mod_text = entities_to_umlauts($mod_text, 'UTF-8');
 	}
 	$anchor_text = $mod_text; // make an copy containing html-tags
 	$mod_text = strip_tags($mod_text);
-	$mod_text = str_replace(array('&gt;','&lt;','&amp;','&quot;','&#039;','&apos;','&nbsp;'), array('>','<','&','"','\'','\'',"\xC2\xA0"), $mod_text);
+	$mod_text = str_replace(array('&gt;','&lt;','&amp;','&quot;','&#039;','&apos;','&nbsp;'), array('>','<','&','"','\'','\'',' '), $mod_text);
 	$mod_text = '.'.trim($mod_text).'.';
-	// Do a fast scan over $mod_text first. This will speedup things a lot.
+	// Do a fast scan over $mod_text first. This may speedup things a lot.
 	if($func_search_match == 'all') {
 		if(!is_all_matched($mod_text, $func_search_words))
 			return false;
@@ -349,7 +277,6 @@
 	}
 	// search for an better anchor - this have to be done before strip_tags() (may fail if search-string contains <, &, amp, gt, lt, ...)
 	$anchor =  make_url_target($mod_page_link_target, $anchor_text, $func_search_words);
-
 	// make the link from $mod_page_link, add anchor
 	$link = "";
 	$link = page_link($mod_page_link);
@@ -366,10 +293,12 @@
 		}
 		$excerpt = prepare_excerpts($excerpt_array, $func_search_words, $mod_max_excerpt_num);
 	}
-
 	// handle thumbs - to deactivate this look in the module's search.php: $show_thumb (or maybe in the module's settings-page)
 	if($mod_pic_link != "") {
-		$excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top"><a href="'.$link.'"><img src="'.WB_URL.'/'.MEDIA_DIRECTORY.$mod_pic_link.'" alt="" /></a></td><td>'.$excerpt.'</td></tr></tbody></table>';
+		if(isset($mod_special) && $mod_special=='lightbox2_plus')
+			$excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top">'.$mod_special_piclink.'<img src="'.WB_URL.'/'.MEDIA_DIRECTORY.$mod_pic_link.'" alt="" /></a></td><td>'.$excerpt.'</td></tr></tbody></table>';
+		else
+			$excerpt = '<table class="excerpt_thumb" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="110" valign="top"><a href="'.$link.'"><img src="'.WB_URL.'/'.MEDIA_DIRECTORY.$mod_pic_link.'" alt="" /></a></td><td>'.$excerpt.'</td></tr></tbody></table>';
 	}
 
 	// print-out the excerpt
@@ -377,10 +306,12 @@
 	$values = array();
 	list($date, $time) = get_page_modified($mod_page_modified_when);
 	list($username, $displayname) = get_page_modified_by($mod_page_modified_by, $func_users);
-	$vars = array('[LINK]', '[TITLE]', '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]','[EXCERPT]');
+	$vars = array('[LINK]', '[TITLE]','[PAGE_TITLE]' ,'[MENU_TITLE]' , '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]','[EXCERPT]');
 	$values = array(
 		$link,
 		$mod_page_title,
+		$func_page_title,
+		$func_page_menu_title,
 		$mod_page_description,
 		$username,
 		$displayname,
@@ -423,25 +354,19 @@
 }
 
 // keeps only wanted entries in array $files. $str have to be an eregi()-compatible regex
-/*
-function clear_filelist($files, $str, $keep=true)
-{
+function clear_filelist($files, $str, $keep=true) {
 	// options: $keep = true  : remove all non-matching entries
 	//          $keep = false : remove all matching entries
 	$c_filelist = array();
 	if($str == '')
 		return $files;
-	foreach($files as $file)
-    {
-		if($keep)
-        {
-			if(eregi($str, $file))
-            {
+	foreach($files as $file) {
+		if($keep) {
+			if(eregi($str, $file)) {
 				$c_filelist[] = $file;
 			}
 		} else {
-			if(!eregi($str, $file))
-            {
+			if(!eregi($str, $file)) {
 				$c_filelist[] = $file;
 			}
 		}
@@ -448,5 +373,97 @@
 	}
 	return($c_filelist);
 }
-*/
-?>
\ No newline at end of file
+
+function search_make_sql_part($words, $match, $columns) {
+	// $words are utf-8 encoded, will be converted to DEFAULT_CHARSET below
+	if(empty($words) || empty($columns)) return('(1=1)');
+	global $database;
+
+	// check if we can use SQL'S "LIKE"
+	// work-around for WB'S missing-SET-NAMES-problem
+	static $checked = FALSE;
+	if($checked===FALSE) {
+		$checked = TRUE;
+		$lowers = array('utf8'=>"\xc3\xa1", 'iso'=>"\xe1");
+		$uppers = array('utf8'=>"\xc3\x81", 'iso'=>"\xc1");
+		switch(DEFAULT_CHARSET) {
+			case 'utf-8':
+				$lo = $lowers['utf8'];
+				$up = $uppers['utf8'];
+				break;
+			case 'iso-8859-1':
+			case 'iso-8859-2':
+			case 'iso-8859-3':
+			case 'iso-8859-4':
+			case 'iso-8859-5':
+			case 'iso-8859-7':
+			case 'iso-8859-9':
+			case 'iso-8859-10':
+				$lo = $lowers['iso'];
+				$up = $uppers['iso'];
+				break;
+			default:
+				$checked = 'check failed'; // we can't handle arabic,hebrew,thai
+		}
+		if($checked===TRUE && $query = $database->query("SELECT UPPER('$lo')='$up'")) {
+			$res = $query->fetchRow();
+			if($res[0]==0) {
+				$checked = 'check failed';
+			}
+		} else
+			$checked = 'check failed';
+	}
+
+	require_once(WB_PATH.'/framework/functions-utf8.php');
+	global $search_table_sql_local;
+	$altnum = count($search_table_sql_local);
+
+	if($match=='all') $op = 'AND';
+	else $op = ' OR'; // keep the leading space!
+
+	// create sql-template
+	$sql = '';
+	$i = 0;
+	foreach($words as $w) {
+		if(empty($w)) continue;
+		$w_alts = $e_alts = array();
+		if($altnum) {
+			for($x=0;$x<$altnum;$x++)
+				$w_alts[$x] = strtr($w, $search_table_sql_local[$x]);
+		} else {
+			$w_alts[0] = $w;
+		}
+		$w_alts = array_unique($w_alts);
+		foreach($w_alts as $a) {
+			$tmp = htmlentities($a, ENT_COMPAT, 'UTF-8');
+			// if the missing-SET-NAMES-issue appears and $tmp contains non-ascii characters: exit and use the normal (slow) search-function instead
+			if($checked!==TRUE && preg_match('/[\x80-\xFF]/', $tmp)) return('(1=1)'); // missing-SET-NAMES-issue
+			$e_alts[] = $tmp;
+		}
+		$sql .= "";
+		foreach($w_alts as $a)
+			$sql .= "{{COL}} LIKE '%".addslashes(utf8_to_charset($a))."%' OR ";
+		if(isset($e_alts[$i]) && $e_alts[$i]!=$w)
+			$sql .= " {{COL}} LIKE '%".addslashes($e_alts[$i])."%'";
+		else {
+			$sql = substr($sql, 0, strlen($sql)-4);
+			$sql .= '';
+		}
+		$sql .= " $op ";
+		$i++;
+	}
+	$sql = substr($sql, 0, strlen($sql)-5);
+	$sql_template = $sql;
+
+	// create SQL-string from template
+	$sql = '(';
+	foreach($columns as $c) {
+		$sql .= '(';
+		$sql .= str_replace('{{COL}}', $c, $sql_template);
+		$sql .= ")  OR ";
+	}
+	$sql = substr($sql, 0, strlen($sql)-4);
+	$sql .= ')';
+
+	return($sql);
+}
Index: branches/2.8.x/wb/modules/jsadmin/info.php
===================================================================
--- branches/2.8.x/wb/modules/jsadmin/info.php	(revision 1440)
+++ branches/2.8.x/wb/modules/jsadmin/info.php	(revision 1441)
@@ -1,74 +1,29 @@
-<?php
-
-// $Id$
-
-// JsAdmin module for Website Baker
-// Copyright (C) 2006, Stepan Riha
-// www.nonplus.net
-
-/*
-Javascript Admin for Website Baker
-
-Software License Agreement (BSD License)
-
-Copyright (c) 2006, Stepan Riha.
-All rights reserved.
-
-Portions of this software are Copyright Yahoo! Inc.
-
-Redistribution and use of this software in source and binary forms, with 
-or without modification, are permitted provided that the following 
-conditions are met:
-
-* Redistributions of source code must retain the above
-  copyright notice, this list of conditions and the
-  following disclaimer.
-
-* Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the
-  following disclaimer in the documentation and/or other
-  materials provided with the distribution.
-
-* Neither the name of Stepan Riha may be used to endorse or
-  promote products derived from this software without specific prior
-  written permission of Stepan Riha.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/*
- -----------------------------------------------------------------------------------------------------------
-  Javascript Admin module for Website Baker v2.7
-  Copyright (C) 2006, Stepan Riha
-  Adapted for Website Baker 2.7 by Swen Uth
- -----------------------------------------------------------------------------------------------------------
-	v1.2 (swen, Swen Uth; Jan 24, 2008)
-		+ updated YUI framework to version 2.4.1
-   	+ adapted module to work with Website Baker 2.7
-   	+ added multilingual support and support of the module.css and module.js files
-		
-	v1.0.2 (nonplus, Stepan Riha; May 5, 2006
-		initial release by Stepan Riha (all rights reserved)
- -----------------------------------------------------------------------------------------------------------
-*/
-
-$module_directory 		= 'jsadmin';
-$module_name 				= 'Javascript Admin';
-$module_function 			= 'tool';
-$module_version 			= '1.2.1';
-$module_platform 			= '2.7 | 2.8.x';
-$module_author 			= 'Stepan Riha, Swen Uth';
-$module_license 			= 'BSD License';
-$module_description 		= 'This module adds Javascript functionality to the Website Baker Admin to improve some of the UI interactions. Uses the YahooUI library.';
-
+<?php
+/**
+ *
+ * @category        modules
+ * @package         jsadmin
+ * @author          Independend-Software-Team
+ * @author          WebsiteBaker Project
+ * @copyright       2004-2009, Ryan Djurovich
+ * @copyright       2009-2011, Website Baker Org. e.V.
+ * @link            http://www.websitebaker2.org/
+ * @license         http://www.gnu.org/licenses/gpl.html
+ * @platform        WebsiteBaker 2.8.x
+ * @requirements    PHP 5.2.2 and higher
+ * @version         $Id$
+ * @filesource      $HeadURL:  $
+ * @lastmodified    $Date:  $
+ *
+ */
+
+$module_directory = 'jsadmin';
+$module_name = 'Javascript Admin';
+$module_function = 'tool';
+$module_version = '1.3.0';
+$module_platform = '2.7 | 2.8.x';
+$module_author = 'Stepan Riha, Swen Uth';
+$module_license	= 'BSD License';
+$module_description = 'This module adds Javascript functionality to the Website Baker Admin to improve some of the UI interactions. Uses the YahooUI library.';
+
 ?>
\ No newline at end of file
Index: branches/2.8.x/wb/modules/jsadmin/jsadmin_backend_include.php
===================================================================
--- branches/2.8.x/wb/modules/jsadmin/jsadmin_backend_include.php	(revision 1440)
+++ branches/2.8.x/wb/modules/jsadmin/jsadmin_backend_include.php	(revision 1441)
@@ -34,17 +34,21 @@
 elseif(strstr($script, $admin_folder."/settings/tool.php")
 	&& isset($_REQUEST["tool"]) && $_REQUEST["tool"] == 'jsadmin')
 	$page_type = 'config';
+elseif(strstr($script, $admin_folder."/pages/modify.php"))
+	$page_type = 'modules';
 else
 	$page_type = '';
+
 if($page_type) {
+
 	require_once(WB_PATH.'/modules/jsadmin/jsadmin.php');
 
 	// Default scripts
-	$js_buttonCell = 3;
+	$js_buttonCell = 5;
 	$js_scripts = Array();
 	$js_scripts[] = 'jsadmin.js';
 
-	if($page_type == 'pages') {
+	if($page_type == 'modules') {
 		if(!get_setting('mod_jsadmin_persist_order', '1')) {   //Maybe Bug settings to negativ for persist , by Swen Uth
 			$js_scripts[] = 'restore_pages.js';
   		}
@@ -52,19 +56,28 @@
 			$js_scripts[] = 'dragdrop.js';
 			$js_buttonCell= 7; // This ist the Cell where the Button "Up" is , by Swen Uth
 		}
+	} elseif($page_type == 'pages') {
+		if(!get_setting('mod_jsadmin_persist_order', '1')) {   //Maybe Bug settings to negativ for persist , by Swen Uth
+			$js_scripts[] = 'restore_pages.js';
+  		}
+		if(get_setting('mod_jsadmin_ajax_order_pages', '1')) {
+			$js_scripts[] = 'dragdrop.js';
+			$js_buttonCell= 7; // This ist the Cell where the Button "Up" is , by Swen Uth
+		}
 	} elseif($page_type == 'sections') {
 		if(get_setting('mod_jsadmin_ajax_order_sections', '1')) {
 			$js_scripts[] = 'dragdrop.js';
 			if(SECTION_BLOCKS) {
-			$js_buttonCell= 5;}
-      else{ $js_buttonCell= 5;} // This ist the Cell where the Button "Up" is , by Swen Uth
+			$js_buttonCell= 5; }
+      else{ $js_buttonCell= 5; } // This ist the Cell where the Button "Up" is , by Swen Uth
 		}
 	} elseif($page_type == 'config') {
 		$js_scripts[] = 'tool.js';
+	} else {
+		$admin->print_error('PageTtype '.$TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
 	}
 ?>
-
-<script  type="text/javascript" language="JavaScript">
+<script  type="text/javascript">
 <!--
 var JsAdmin = { WB_URL : '<?php echo WB_URL ?>', ADMIN_URL : '<?php echo ADMIN_URL ?>' };
 var JsAdminTheme = { THEME_URL : '<?php echo THEME_URL ?>' };
@@ -71,32 +84,39 @@
 //-->
 </script>
 <?php
- // For variable cell structure in the tables of admin content
-  echo "<script type='text/javascript'>buttonCell=".$js_buttonCell.";</script>\n";   // , by Swen  Uth
-
- // Check and Load the needed YUI functions  //, all by Swen Uth
-  $YUI_ERROR=false; // ist there an Error
-  $YUI_PUT ='';   // String with javascipt includes
-  $YUI_PUT_MISSING_Files=''; // Strin with missing files
-  reset($js_yui_scripts);
-  foreach($js_yui_scripts as $script) {
-    if(file_exists($WB_MAIN_RELATIVE_PATH.$script)){
-        $YUI_PUT=$YUI_PUT."<script type='text/javascript' src='".$WB_MAIN_RELATIVE_PATH.$script."'></script>\n"; // go and include
-    } else {
-        $YUI_ERROR=true;
-        $YUI_PUT_MISSING_Files=$YUI_PUT_MISSING_Files."- ".WB_URL.$script."\\n";   // catch all missing files
-    }
+	// For variable cell structure in the tables of admin content
+	echo "<script type='text/javascript'>buttonCell=".$js_buttonCell.";</script>\n";   // , by Swen  Uth
+	// Check and Load the needed YUI functions  //, all by Swen Uth
+	$YUI_ERROR=false; // ist there an Error
+	$YUI_PUT ='';   // String with javascipt includes
+	$YUI_PUT_MISSING_Files=''; // String with missing files
+	reset($js_yui_scripts);
+	foreach($js_yui_scripts as $script) {
+		if(file_exists($WB_MAIN_RELATIVE_PATH.$script)){
+			$YUI_PUT=$YUI_PUT."<script src='".$WB_MAIN_RELATIVE_PATH.$script."' type='text/javascript'></script>\n"; // go and include
+		} else {
+			$YUI_ERROR=true;
+			$YUI_PUT_MISSING_Files=$YUI_PUT_MISSING_Files."- ".WB_URL.$script."\\n";   // catch all missing files
+		}
 	}
+/*  */
 	if(!$YUI_ERROR)
 	{
-    echo $YUI_PUT;  // no Error so go and include
-    // Load the needed functions
-	  foreach($js_scripts as $script) {
-		  echo "<script type='text/javascript' src='".$JSADMIN_PATH."/js/".$script."'></script>\n";
-	  }
-  } else  {
-      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
-  }
+		echo $YUI_PUT;  // no Error so go and include
+		// Load the needed functions
+		foreach($js_scripts as $script) {
+			echo "<script src='".$JSADMIN_PATH."/js/".$script."' type='text/javascript'></script>\n";
+		}
+	} else {
+	    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
+	}
 
- }
+} else {
+/*
+print '<pre><strong>function '.__FUNCTION__.'();</strong> line: '.__LINE__.' -> ';
+print_r( $page_type.'/'.$buttonCell ); print '</pre>'; // die();
+*/
+}
+
+
 ?>
\ No newline at end of file
Index: branches/2.8.x/wb/modules/jsadmin/js/dragdrop.js
===================================================================
--- branches/2.8.x/wb/modules/jsadmin/js/dragdrop.js	(revision 1440)
+++ branches/2.8.x/wb/modules/jsadmin/js/dragdrop.js	(revision 1441)
@@ -1,346 +1,383 @@
-// Copyright 2006 Stepan Riha
-// www.nonplus.net
-// $Id: dragdrop.js 2 2006-04-18 03:04:39Z stepan $
-/**
-* -----------------------------------------------------------------------------------------
-*  MODIFICATON FOR THE JSADMIN MODULE
-* -----------------------------------------------------------------------------------------
-*	MODIFICATION HISTORY:
-*   Swen Uth; 01/24/2008
-*   +INCLUDE VARIABLE buttonCell FOR ADAPTATION TO LATER LAYOUTS
-*
-**/
-JsAdmin.DD = {};
-JsAdmin.movable_rows = {};
-	
-JsAdmin.init_drag_drop = function() {
-
-	// There seems to be many different ways the ordering is set up
-	//		pages/index.php has UL/LI containing tables with single row
-	//		pages/sections.php has a TABLE with many rows
-	//		pages/modify.php for manuals is completely weird...
-	// So we only want to deal with pages & sections...
-
-	var page_type = '';
-	var is_tree = false;
-
-	if(document.URL.indexOf(JsAdmin.ADMIN_URL + "/pages/index.php") > -1) {
-		page_type = 'pages';
-		is_tree = true;
-
-		// This page uses duplicate IDs and incorrectly nested lists:
-		// <ul id="p1">
-		//		<li id="p1"><table /></li>
-		//		<ul>... sub items ...</ul>
-		// </ul>
-		//
-		// We need to fix that to the following:
-		// <ul id="p1">
-		//		<li id="uniqueID"><table />
-		//		<ul>... sub items ...</ul>
-		//		</li>
-		// </ul>
-
-		// Stash all UL ids
-		var ids = {};
-		var lists = document.getElementsByTagName('ul');
-		for(var i = 0; i < lists.length; i++) {
-			if(lists[i].id) {
-				ids[lists[i].id] = true;
-			}
-		}
-
-		// Now fix all LIs
-		var items = document.getElementsByTagName('li');
- 		for(var i = 0; i < items.length; i++) {
-			var item = items[i];
-
-			// Fix duplicate ID
-			if(ids[item.id]) {
-				item.id =  JsAdmin.util.getUniqueId();
-			}
-
-			// Fix UL parented by UL
-			var ul = JsAdmin.util.getNextSiblingNode(item, 'ul');
-			if(ul) {
-				var lis = ul.getElementsByTagName('li');
- 				if(!lis || lis.length == 0) {
-					// Remove list without items
-					ul.parentNode.removeChild(ul);
-				} else {
-					// Make list child of list item
-					item.appendChild(ul);
-				}
-			}
-		}
-
-	} else if(document.URL.indexOf("/admin/pages/sections.php") > 0) {
-		page_type = 'sections';
-	} else {
-		// We don't do any other pages
-		return;
-	}
-
-	var links = document.getElementsByTagName('a');
-	var reImg = /(.*)move_(down|up)\.php(.*)/;
-
-	for(var i = 0; i < links.length; i++) {
-		var link = links[i];
-		var href = link.href || '';
-		var match = href.match(reImg);
-		if(!match) {
-			continue;
-		}
-		var url = match[1];
-		var op = match[2];
-		var params = match[3];
-		var tr = JsAdmin.util.getAncestorNode(link, 'tr');
-		var item = is_tree ? JsAdmin.util.getAncestorNode(tr, 'li') : tr;
-		if(!item) {
-			continue;
-		}
-
-		// Make sure we have a unique id
-		if(!item.id || YAHOO.util.Dom.get(item.id) != item) {
-			item.id = JsAdmin.util.getUniqueId();
-		}
-
-		if(is_tree) {
-			var parent = JsAdmin.util.getAncestorNode(item, 'ul');
-			new JsAdmin.DD.liDDSwap(item.id, (parent && parent.id) ? parent.id : 'top');
-		} else {
-			new JsAdmin.DD.trDDSwap(item.id);
-		}
-		item.className += " jsadmin_drag";
-
-		this.movable_rows[item.id] = { item: item, tr : tr, url : url, params : params };
-	}
-};
-
-//==========================================================================
-// Drag-drop utils
-//==========================================================================
-
-JsAdmin.DD.dragee = null;
-
-JsAdmin.DD.addMoveButton = function(tr, cell, op) {
-	if(op == 'down') {
-		cell++;
-	}
-	var item = JsAdmin.movable_rows[tr.id];
-	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
-		var rows = tr.getElementsByTagName('tr');
-		tr = rows[0];
-	}
-	
-	var html = '<a href="' + item.url + 'move_' + op + '.php' + item.params
-				+ '"><img src="' + JsAdminTheme.THEME_URL + '/images/' + op
-				+ '_16.png" border="0" alt="' + op + '" /></a>';
-	tr.cells[cell].innerHTML = html;
-};
-
-JsAdmin.DD.deleteMoveButton = function(tr, cell, op) {
-	if(op == 'down') {
-		cell++;
-	}
-	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
-		var rows = tr.getElementsByTagName('tr');
-		tr = rows[0];
-	}
-	
-	tr.cells[cell].innerHTML = "";
-};
-
-//==========================================================================
-// Drag-drop handling for table rows
-//==========================================================================
-
-JsAdmin.DD.trDDSwap = function(id, sGroup) {
-    this.init(id, sGroup);
-	this.addInvalidHandleType('a');
-	this.addInvalidHandleType('input');
-	this.addInvalidHandleType('select');
-    this.initFrame();
-	this.buttonCell = buttonCell;//, by Swen Uth
-	
-	// For Connection
-	this.scope = this;
-};
-
-JsAdmin.DD.trDDSwap.prototype = new YAHOO.util.DDProxy();
-
-JsAdmin.DD.trDDSwap.prototype.startDrag = function(x, y) {
-	if (JsAdmin.DD.dragee != this) {
-		this.rowIndex = this.getEl().rowIndex;
-		this.numRows = this.getEl().parentNode.rows.length;
-		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
-		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
-		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
-		YAHOO.util.Dom.setStyle(this.getEl(), "background", "transparent");
-	}
-	JsAdmin.DD.dragee = this;
-};
-
-JsAdmin.DD.trDDSwap.prototype.onDragEnter = function(e, id) {
-  var elt = id ? YAHOO.util.Dom.get(id) : null;
-	var item = JsAdmin.movable_rows[this.getEl().id];
-	var rows = item.tr.parentNode.rows;
-	var wasFirst = item.tr.rowIndex == 1;
-	var wasLast = item.tr.rowIndex == this.numRows - 2;
-	if(elt.rowIndex < item.tr.rowIndex) {
-		elt.parentNode.insertBefore(item.tr, elt);
-	} else {
-		elt.parentNode.insertBefore(elt, item.tr);
-	}
-	// Fixup buttons
-	var isFirst = item.tr.rowIndex == 1;
-	var isLast = item.tr.rowIndex == this.numRows - 2;
-
-	if(wasFirst != isFirst) {
-		if(isFirst) {
-			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
-			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.tr), this.buttonCell, 'up');
-		} else {
-			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'up');
-			JsAdmin.DD.deleteMoveButton(rows[1], this.buttonCell, 'up');
-		}
-	}
-	if(wasLast != isLast) {
-		if(isLast) {
-			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
-			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.tr), this.buttonCell, 'down');
-		} else {
-			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'down');
-			JsAdmin.DD.deleteMoveButton(rows[rows.length-2], this.buttonCell, 'down');
-		}
-	}
-
-	this.DDM.refreshCache(this.groups);
-};
-
-JsAdmin.DD.trDDSwap.prototype.endDrag = function(e) {
-	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
-	YAHOO.util.Dom.setStyle(this.getEl(), "background", "#f0f0f0");
-	
-	JsAdmin.DD.dragee = null;
-
-	var newIndex = this.getEl().rowIndex;
-	if(newIndex != this.rowIndex) {
-		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
-		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + newIndex;
-		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
-		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
-	}
-};
-
-JsAdmin.DD.trDDSwap.prototype.success = function(o) {
-	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
-};
-
-JsAdmin.DD.trDDSwap.prototype.failure = function(o) {
-	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
-};
-
-//==========================================================================
-// Drag-drop handling for list items
-//==========================================================================
-
-JsAdmin.DD.liDDSwap = function(id, sGroup) {
-    this.init(id, sGroup);
-	this.addInvalidHandleType('a');
-	this.addInvalidHandleType('input');
-	this.addInvalidHandleType('select');
-    this.initFrame();
- this.buttonCell = buttonCell;//, by Swen Uth
-	this.counter = 0;
-};
-
-JsAdmin.DD.liDDSwap.prototype = new YAHOO.util.DDProxy();
-
-JsAdmin.DD.liDDSwap.prototype.startDrag = function(x, y) {
-	// On IE, startDrag is sometimes called twice
-	if(JsAdmin.DD.dragee && JsAdmin.DD.dragee != this) {
-		JsAdmin.DD.dragee.endDrag(null);
-	}
-	if(JsAdmin.DD.dragee != this) {
-		this.rowIndex = JsAdmin.util.getItemIndex(this.getEl());
-		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
-		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
-		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
-
-		this.list = JsAdmin.util.getAncestorNode(this.getEl(), "ul");
-		this.list.className += " jsadmin_drag_area";
-	}
-	JsAdmin.DD.dragee = this;
-};
-
-JsAdmin.DD.liDDSwap.prototype.onDragEnter = function(e, id) {
-	// Swap with other element
-	var elt = id ? YAHOO.util.Dom.get(id) : null;
-	var item = JsAdmin.movable_rows[this.getEl().id];
-	var eltRowIndex = JsAdmin.util.getItemIndex(elt);
-	var rowIndex = JsAdmin.util.getItemIndex(this.getEl());
-	var wasFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
-	var wasLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
-
-	if(eltRowIndex < rowIndex) {
-		elt.parentNode.insertBefore(this.getEl(), elt);
-	} else {
-		elt.parentNode.insertBefore(elt, this.getEl());
-	}
-	// Fixup buttons
-	var isFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
-	var isLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
-
-	if(wasFirst != isFirst) {
-		if(isFirst) {
-			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
-			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.item), this.buttonCell, 'up');
-		} else {
-			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'up');
-			var first, prev = JsAdmin.util.getPreviousSiblingNode(item.item);
-			while(prev) {
-				first = prev;
-				prev = JsAdmin.util.getPreviousSiblingNode(prev);
-			}
-			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[first.id].tr, this.buttonCell, 'up');
-		}
-	}
-	if(wasLast != isLast) {
-		if(isLast) {
-			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
-			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.item), this.buttonCell, 'down');
-		} else {
-			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'down');
-			var last, next = JsAdmin.util.getNextSiblingNode(item.item);
-			while(next) {
-				last = next;
-				next = JsAdmin.util.getNextSiblingNode(next);
-			}
-			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[last.id].tr, this.buttonCell, 'down');
-		}
-	}
-
-	this.DDM.refreshCache(this.groups);
-};
-
-JsAdmin.DD.liDDSwap.prototype.endDrag = function(e) {
-	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
-	this.list.className = String(this.list.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1");
-	JsAdmin.DD.dragee = null;
-	var newIndex = JsAdmin.util.getItemIndex(this.getEl());
-	if(newIndex != this.rowIndex) {
-		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
-		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + (newIndex+1);
-		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
-		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
-	}
-};
-
-JsAdmin.DD.liDDSwap.prototype.success = function(o) {
-	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
-};
-
-JsAdmin.DD.liDDSwap.prototype.failure = function(o) {
-	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
-};
+// Copyright 2006 Stepan Riha
+// www.nonplus.net
+// $Id: dragdrop.js 2 2006-04-18 03:04:39Z stepan $
+/**
+* -----------------------------------------------------------------------------------------
+*  MODIFICATON FOR THE JSADMIN MODULE
+* -----------------------------------------------------------------------------------------
+*	MODIFICATION HISTORY:
+*   Swen Uth; 01/24/2008
+*   +INCLUDE VARIABLE buttonCell FOR ADAPTATION TO LATER LAYOUTS
+*
+**/
+JsAdmin.DD = {};
+JsAdmin.movable_rows = {};
+
+JsAdmin.init_drag_drop = function() {
+
+	// There seems to be many different ways the ordering is set up
+	//		pages/index.php has UL/LI containing tables with single row
+	//		pages/sections.php has a TABLE with many rows
+	//		pages/modify.php for manuals is completely weird...
+	// So we only want to deal with pages & sections...
+
+	var page_type = '';
+	var is_tree = false;
+
+	if(document.URL.indexOf(JsAdmin.ADMIN_URL + "/pages/index.php") > -1) {
+		page_type = 'pages';
+		is_tree = true;
+
+		// This page uses duplicate IDs and incorrectly nested lists:
+		// <ul id="p1">
+		//		<li id="p1"><table /></li>
+		//		<ul>... sub items ...</ul>
+		// </ul>
+		//
+		// We need to fix that to the following:
+		// <ul id="p1">
+		//		<li id="uniqueID"><table />
+		//		<ul>... sub items ...</ul>
+		//		</li>
+		// </ul>
+
+		// Stash all UL ids
+		var ids = {};
+		var lists = document.getElementsByTagName('ul');
+		for(var i = 0; i < lists.length; i++) {
+			if(lists[i].id) {
+				ids[lists[i].id] = true;
+			}
+		}
+
+		// Now fix all LIs
+		var items = document.getElementsByTagName('li');
+ 		for(var i = 0; i < items.length; i++) {
+			var item = items[i];
+
+			// Fix duplicate ID
+			if(ids[item.id]) {
+				item.id =  JsAdmin.util.getUniqueId();
+			}
+
+			// Fix UL parented by UL
+			var ul = JsAdmin.util.getNextSiblingNode(item, 'ul');
+			if(ul) {
+				var lis = ul.getElementsByTagName('li');
+ 				if(!lis || lis.length == 0) {
+					// Remove list without items
+					ul.parentNode.removeChild(ul);
+				} else {
+					// Make list child of list item
+					item.appendChild(ul);
+				}
+			}
+		}
+
+	} else if(document.URL.indexOf("/admin/pages/sections.php") > 0) {
+		page_type = 'sections';
+	} else if(document.URL.indexOf("/admin/pages/modify.php") > 0) {
+		page_type = 'modules';
+		is_tree = true;
+		// Stash all UL ids
+		var ids = {};
+		var lists = document.getElementsByTagName('ul');
+		for(var i = 0; i < lists.length; i++) {
+			if(lists[i].id) {
+				ids[lists[i].id] = true;
+			}
+		}
+
+		// Now fix all LIs
+		var items = document.getElementsByTagName('li');
+ 		for(var i = 0; i < items.length; i++) {
+			var item = items[i];
+
+			// Fix duplicate ID
+			if(ids[item.id]) {
+				item.id =  JsAdmin.util.getUniqueId();
+			}
+
+			// Fix UL parented by UL
+			var ul = JsAdmin.util.getNextSiblingNode(item, 'ul');
+			if(ul) {
+				var lis = ul.getElementsByTagName('li');
+ 				if(!lis || lis.length == 0) {
+					// Remove list without items
+					ul.parentNode.removeChild(ul);
+				} else {
+					// Make list child of list item
+					item.appendChild(ul);
+				}
+			}
+		}
+
+	} else {
+		// We don't do any other pages
+		return;
+		// page_type = 'modules';
+	}
+
+	var links = document.getElementsByTagName('a');
+	var reImg = /(.*)move_(down|up)\.php(.*)/;
+
+	for(var i = 0; i < links.length; i++) {
+		var link = links[i];
+		var href = link.href || '';
+		var match = href.match(reImg);
+		if(!match) {
+			continue;
+		}
+		var url = match[1];
+		var op = match[2];
+		var params = match[3];
+		var tr = JsAdmin.util.getAncestorNode(link, 'tr');
+		var item = is_tree ? JsAdmin.util.getAncestorNode(tr, 'li') : tr;
+		if(!item) {
+			continue;
+		}
+
+		// Make sure we have a unique id
+		if(!item.id || YAHOO.util.Dom.get(item.id) != item) {
+			item.id = JsAdmin.util.getUniqueId();
+		}
+
+		if(is_tree) {
+			var parent = JsAdmin.util.getAncestorNode(item, 'ul');
+			new JsAdmin.DD.liDDSwap(item.id, (parent && parent.id) ? parent.id : 'top');
+		} else {
+			new JsAdmin.DD.trDDSwap(item.id);
+		}
+		item.className += " jsadmin_drag";
+
+		this.movable_rows[item.id] = { item: item, tr : tr, url : url, params : params };
+	}
+};
+
+//==========================================================================
+// Drag-drop utils
+//==========================================================================
+
+JsAdmin.DD.dragee = null;
+
+JsAdmin.DD.addMoveButton = function(tr, cell, op) {
+	if(op == 'down') {
+		cell++;
+	}
+	var item = JsAdmin.movable_rows[tr.id];
+	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
+		var rows = tr.getElementsByTagName('tr');
+		tr = rows[0];
+	}
+
+	var html = '<a href="' + item.url + 'move_' + op + '.php' + item.params
+				+ '"><img src="' + JsAdminTheme.THEME_URL + '/images/' + op
+				+ '_16.png" border="0" alt="' + op + '" /></a>';
+	tr.cells[cell].innerHTML = html;
+};
+
+JsAdmin.DD.deleteMoveButton = function(tr, cell, op) {
+	if(op == 'down') {
+		cell++;
+	}
+	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
+		var rows = tr.getElementsByTagName('tr');
+		tr = rows[0];
+	}
+	
+	tr.cells[cell].innerHTML = "";
+};
+
+//==========================================================================
+// Drag-drop handling for table rows
+//==========================================================================
+
+JsAdmin.DD.trDDSwap = function(id, sGroup) {
+    this.init(id, sGroup);
+	this.addInvalidHandleType('a');
+	this.addInvalidHandleType('input');
+	this.addInvalidHandleType('select');
+    this.initFrame();
+	this.buttonCell = buttonCell;//, by Swen Uth
+	
+	// For Connection
+	this.scope = this;
+};
+
+JsAdmin.DD.trDDSwap.prototype = new YAHOO.util.DDProxy();
+
+JsAdmin.DD.trDDSwap.prototype.startDrag = function(x, y) {
+	if (JsAdmin.DD.dragee != this) {
+		this.rowIndex = this.getEl().rowIndex;
+		this.numRows = this.getEl().parentNode.rows.length;
+		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
+		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
+		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
+		YAHOO.util.Dom.setStyle(this.getEl(), "background", "transparent");
+	}
+	JsAdmin.DD.dragee = this;
+};
+
+JsAdmin.DD.trDDSwap.prototype.onDragEnter = function(e, id) {
+  var elt = id ? YAHOO.util.Dom.get(id) : null;
+	var item = JsAdmin.movable_rows[this.getEl().id];
+	var rows = item.tr.parentNode.rows;
+	var wasFirst = item.tr.rowIndex == 1;
+	var wasLast = item.tr.rowIndex == this.numRows - 2;
+	if(elt.rowIndex < item.tr.rowIndex) {
+		elt.parentNode.insertBefore(item.tr, elt);
+	} else {
+		elt.parentNode.insertBefore(elt, item.tr);
+	}
+	// Fixup buttons
+	var isFirst = item.tr.rowIndex == 1;
+	var isLast = item.tr.rowIndex == this.numRows - 2;
+
+	if(wasFirst != isFirst) {
+		if(isFirst) {
+			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
+			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.tr), this.buttonCell, 'up');
+		} else {
+			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'up');
+			JsAdmin.DD.deleteMoveButton(rows[1], this.buttonCell, 'up');
+		}
+	}
+	if(wasLast != isLast) {
+		if(isLast) {
+			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
+			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.tr), this.buttonCell, 'down');
+		} else {
+			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'down');
+			JsAdmin.DD.deleteMoveButton(rows[rows.length-2], this.buttonCell, 'down');
+		}
+	}
+
+	this.DDM.refreshCache(this.groups);
+};
+
+JsAdmin.DD.trDDSwap.prototype.endDrag = function(e) {
+	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
+	YAHOO.util.Dom.setStyle(this.getEl(), "background", "#f0f0f0");
+	
+	JsAdmin.DD.dragee = null;
+
+	var newIndex = this.getEl().rowIndex;
+	if(newIndex != this.rowIndex) {
+		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
+		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + newIndex;
+		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
+		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
+	}
+};
+
+JsAdmin.DD.trDDSwap.prototype.success = function(o) {
+	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
+};
+
+JsAdmin.DD.trDDSwap.prototype.failure = function(o) {
+	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
+};
+
+//==========================================================================
+// Drag-drop handling for list items
+//==========================================================================
+
+JsAdmin.DD.liDDSwap = function(id, sGroup) {
+    this.init(id, sGroup);
+	this.addInvalidHandleType('a');
+	this.addInvalidHandleType('input');
+	this.addInvalidHandleType('select');
+    this.initFrame();
+ this.buttonCell = buttonCell;//, by Swen Uth
+	this.counter = 0;
+};
+
+JsAdmin.DD.liDDSwap.prototype = new YAHOO.util.DDProxy();
+
+JsAdmin.DD.liDDSwap.prototype.startDrag = function(x, y) {
+	// On IE, startDrag is sometimes called twice
+	if(JsAdmin.DD.dragee && JsAdmin.DD.dragee != this) {
+		JsAdmin.DD.dragee.endDrag(null);
+	}
+	if(JsAdmin.DD.dragee != this) {
+		this.rowIndex = JsAdmin.util.getItemIndex(this.getEl());
+		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
+		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
+		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
+
+		this.list = JsAdmin.util.getAncestorNode(this.getEl(), "ul");
+		this.list.className += " jsadmin_drag_area";
+	}
+	JsAdmin.DD.dragee = this;
+};
+
+JsAdmin.DD.liDDSwap.prototype.onDragEnter = function(e, id) {
+	// Swap with other element
+	var elt = id ? YAHOO.util.Dom.get(id) : null;
+	var item = JsAdmin.movable_rows[this.getEl().id];
+	var eltRowIndex = JsAdmin.util.getItemIndex(elt);
+	var rowIndex = JsAdmin.util.getItemIndex(this.getEl());
+	var wasFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
+	var wasLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
+
+	if(eltRowIndex < rowIndex) {
+		elt.parentNode.insertBefore(this.getEl(), elt);
+	} else {
+		elt.parentNode.insertBefore(elt, this.getEl());
+	}
+	// Fixup buttons
+	var isFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
+	var isLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
+
+	if(wasFirst != isFirst) {
+		if(isFirst) {
+			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
+			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.item), this.buttonCell, 'up');
+		} else {
+			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'up');
+			var first, prev = JsAdmin.util.getPreviousSiblingNode(item.item);
+			while(prev) {
+				first = prev;
+				prev = JsAdmin.util.getPreviousSiblingNode(prev);
+			}
+			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[first.id].tr, this.buttonCell, 'up');
+		}
+	}
+	if(wasLast != isLast) {
+		if(isLast) {
+			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
+			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.item), this.buttonCell, 'down');
+		} else {
+			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'down');
+			var last, next = JsAdmin.util.getNextSiblingNode(item.item);
+			while(next) {
+				last = next;
+				next = JsAdmin.util.getNextSiblingNode(next);
+			}
+			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[last.id].tr, this.buttonCell, 'down');
+		}
+	}
+
+	this.DDM.refreshCache(this.groups);
+};
+
+JsAdmin.DD.liDDSwap.prototype.endDrag = function(e) {
+	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
+	this.list.className = String(this.list.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1");
+	JsAdmin.DD.dragee = null;
+	var newIndex = JsAdmin.util.getItemIndex(this.getEl());
+	if(newIndex != this.rowIndex) {
+		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
+		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + (newIndex+1);
+		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
+		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
+	}
+};
+
+JsAdmin.DD.liDDSwap.prototype.success = function(o) {
+	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
+};
+
+JsAdmin.DD.liDDSwap.prototype.failure = function(o) {
+	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
+};
Index: branches/2.8.x/wb/modules/jsadmin/backend.css
===================================================================
--- branches/2.8.x/wb/modules/jsadmin/backend.css	(revision 1440)
+++ branches/2.8.x/wb/modules/jsadmin/backend.css	(revision 1441)
@@ -1,28 +1,28 @@
-/* Fix for funky spacing on page listing */
-.pages_list li {
-	margin-bottom: -2px;
-}
-
-body.jsadmin_busy td.content {
-	background: url(images/busy.gif) 4px 4px no-repeat;
-}
-
-body.jsadmin_success td.content {
-	background: url(images/success.gif) 4px 4px no-repeat;
-}
-
-body.jsadmin_failure td.content {
-	background: url(images/failure.gif) 4px 4px no-repeat;
-}
-
-.jsadmin_drag {
-	cursor: move;
-}
-
-.jsadmin_drag a, .jsadmin_drag input, .jsadmin_drag select {
-	cursor: pointer;
-}
-
-ul.jsadmin_drag_area {
-	border: solid 1px #99f;
+/* Fix for funky spacing on page listing */
+.pages_list li {
+	margin-bottom: -2px;
+}
+
+body.jsadmin_busy td.content {
+	background: url(images/busy.gif) 4px 4px no-repeat;
+}
+
+body.jsadmin_success td.content {
+	background: url(images/success.gif) 4px 4px no-repeat;
+}
+
+body.jsadmin_failure td.content {
+	background: url(images/failure.gif) 4px 4px no-repeat;
+}
+
+.jsadmin_drag {
+	cursor: move;
+}
+
+.jsadmin_drag a, .jsadmin_drag input, .jsadmin_drag select {
+	cursor: pointer;
+}
+
+ul.jsadmin_drag_area {
+	border: solid 1px #99f;
 }
\ No newline at end of file
Index: branches/2.8.x/wb/modules/jsadmin/move_to.php
===================================================================
--- branches/2.8.x/wb/modules/jsadmin/move_to.php	(revision 1440)
+++ branches/2.8.x/wb/modules/jsadmin/move_to.php	(revision 1441)
@@ -18,26 +18,41 @@
 
 require('../../config.php');
 
- if(isset($_GET['page_id']) AND is_numeric($_GET['page_id']) AND is_numeric(@$_GET['position'])) {
-	$position = $_GET['position'];
+if(isset($_GET['page_id']) AND is_numeric($_GET['page_id']) AND is_numeric(@$_GET['position'])) {
+	$position = (int)$_GET['position'];
 
 	// Include WB admin wrapper script
-	$update_when_modified = true; // Tells script to update when this page was last updated
+	$update_when_modified = true;
+	// Tells script to update when this page was last updated
 	require(WB_PATH.'/modules/admin.php');
 
+if( isset($_GET['file_id']) || (isset($_GET['group_id'])) ) {
+	if(isset($_GET['group_id']) && is_numeric($_GET['group_id'])) {
+		$id = (int)$_GET['group_id'];
+		$id_field = 'group_id';
+		$table = TABLE_PREFIX.'mod_download_gallery_groups';
+		$common_field = 'section_id';
+	} else {
+		$id = (int)$_GET['file_id'];
+		$id_field = 'file_id';
+		$table = TABLE_PREFIX.'mod_download_gallery_files';
+		$common_field = 'group_id';
+	}
+} elseif( isset($_GET['page_id']) || (isset($_GET['section_id'])) ) {
 	// Get common fields
-	if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
-		$page_id = $_GET['page_id'];
-		$id = $_GET['section_id'];
+	if(isset($_GET['section_id']) && is_numeric($_GET['section_id'])) {
+		$page_id = (int)$_GET['page_id'];
+		$id = (int)$_GET['section_id'];
 		$id_field = 'section_id';
 		$common_field = 'page_id';
 		$table = TABLE_PREFIX.'sections';
 	} else {
-		$id = $_GET['page_id'];
+		$id = (int)$_GET['page_id'];
 		$id_field = 'page_id';
 		$common_field = 'parent';
 		$table = TABLE_PREFIX.'pages';
 	}
+}
 
 	// Get current index
 	$sql = <<<EOT
@@ -81,4 +96,3 @@
 	header("Location: index.php");
 	exit(0);
 }
-?>
Index: branches/2.8.x/wb/modules/admin.php
===================================================================
--- branches/2.8.x/wb/modules/admin.php	(revision 1440)
+++ branches/2.8.x/wb/modules/admin.php	(revision 1441)
@@ -1,172 +1,193 @@
-<?php
-/**
- *
- * @category        backend
- * @package         modules
- * @author          WebsiteBaker Project
- * @copyright       2004-2009, Ryan Djurovich
- * @copyright       2009-2010, Website Baker Org. e.V.
- * @link			http://www.websitebaker2.org/
- * @license         http://www.gnu.org/licenses/gpl.html
- * @platform        WebsiteBaker 2.8.x
- * @requirements    PHP 5.2.2 and higher
- * @version         $Id$
- * @filesource		$HeadURL$
- * @lastmodified    $Date$
- *
-*/
-
-// Stop this file being access directly
-if(!defined('WB_PATH')) { die('Direct access to this file is not allowed'); }
-
-// Get page id
-if(isset($_GET['page_id']) && is_numeric($_GET['page_id'])) {
-	$page_id = (int)$_GET['page_id'];
-} elseif(isset($_POST['page_id']) && is_numeric($_POST['page_id'])) {
-	$page_id = (int)$_POST['page_id'];
-} else {
-	header("Location: index.php");
-	exit(0);
-}
-
-// Get section id if there is one
-if(isset($_GET['section_id']) && is_numeric($_GET['section_id'])) {
-	$section_id = (int)$_GET['section_id'];
-} elseif(isset($_POST['section_id']) && is_numeric($_POST['section_id'])) {
-	$section_id = (int)$_POST['section_id'];
-} else {
-	// Check if we should redirect the user if there is no section id
-	if(!isset($section_required)) {
-		$section_id = 0;
-	} else {
-		header("Location: $section_required");
-		exit(0);
-	}
-}
-
-// Create js back link
-$js_back = 'javascript: history.go(-1);';
-
-// Create new admin object
-require(WB_PATH.'/framework/class.admin.php');
-$admin = new admin('Pages', 'pages_modify');
-
-// Get perms
-// $database = new database();
-$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
-$results_array = $results->fetchRow();
-$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
-$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
-
-$in_group = FALSE;
-foreach($admin->get_groups_id() as $cur_gid){
-    if (in_array($cur_gid, $old_admin_groups)) {
-        $in_group = TRUE;
-    }
-}
-if((!$in_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
-	echo $admin->get_group_id().$admin->get_user_id();
-	print_r ($old_admin_groups);
-	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-}
-
-// some additional security checks:
-// Check whether the section_id belongs to the page_id at all
-if ($section_id != 0) {
-	$sql  = "SELECT module FROM `".TABLE_PREFIX."sections` WHERE `page_id` = '$page_id' AND `section_id` = '$section_id'";
-	$res_sec = $database->query($sql);
-	if ($database->is_error())
-	{
-		$admin->print_error($database->get_error());
-	}
-	if ($res_sec->numRows() == 0)
-	{
-		$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
-	}
-
-	// check module permissions:
-	$sec = $res_sec->fetchRow();
-	if (!$admin->get_permission($sec['module'], 'module'))
-	{
-		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
-	}	
-}
-
-// Workout if the developer wants to show the info banner
-if(isset($print_info_banner) && $print_info_banner == true) {
-	
-// Get page details
-// $database = new database();
-$query = "SELECT page_id,page_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
-$results = $database->query($query);
-if($database->is_error()) {
-	$admin->print_header();
-	$admin->print_error($database->get_error());
-}
-if($results->numRows() == 0) {
-	$admin->print_header();
-	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
-}
-$results_array = $results->fetchRow();
-
-// Get display name of person who last modified the page
-$user=$admin->get_user_details($results_array['modified_by']);
-
-// Convert the unix ts for modified_when to human a readable form
-if($results_array['modified_when'] != 0) {
-	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
-} else {
-	$modified_ts = 'Unknown';
-}
-
-// Include page info script
-$template = new Template(THEME_PATH.'/templates');
-$template->set_file('page', 'pages_modify.htt');
-$template->set_block('page', 'main_block', 'main');
-$template->set_var(array(
-					'PAGE_ID' => $results_array['page_id'],
-					'PAGE_TITLE' => ($results_array['page_title']),
-					'MODIFIED_BY' => $user['display_name'],
-					'MODIFIED_BY_USERNAME' => $user['username'],
-					'MODIFIED_WHEN' => $modified_ts,
-					'ADMIN_URL' => ADMIN_URL
-					)
-				);
-if($modified_ts == 'Unknown') {
-	$template->set_var('DISPLAY_MODIFIED', 'hide');
-} else {
-	$template->set_var('DISPLAY_MODIFIED', '');
-}
-
-// Work-out if we should show the "manage sections" link
-$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
-if($query_sections->numRows() > 0) {
-	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
-} elseif(MANAGE_SECTIONS == 'enabled') {
-	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
-} else {
-	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
-}
-
-// Insert language TEXT
-$template->set_var(array(
-					'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
-					'TEXT_CHANGE' => $TEXT['CHANGE'],
-					'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
-					'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
-					'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
-					)
-				);
-
-// Parse and print header template
-$template->parse('main', 'main_block', false);
-$template->pparse('output', 'page');
-
-}
-
-// Work-out if the developer wants us to update the timestamp for when the page was last modified
-if(isset($update_when_modified) && $update_when_modified == true) {
-	$database->query("UPDATE ".TABLE_PREFIX."pages SET modified_when = '".time()."', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'");
-}
-
-?>
\ No newline at end of file
+<?php
+/**
+ *
+ * @category        backend
+ * @package         modules
+ * @author          WebsiteBaker Project
+ * @copyright       2004-2009, Ryan Djurovich
+ * @copyright       2009-2010, Website Baker Org. e.V.
+ * @link			http://www.websitebaker2.org/
+ * @license         http://www.gnu.org/licenses/gpl.html
+ * @platform        WebsiteBaker 2.8.x
+ * @requirements    PHP 5.2.2 and higher
+ * @version         $Id$
+ * @filesource		$HeadURL$
+ * @lastmodified    $Date$
+ *
+*/
+
+// Stop this file being access directly
+if(defined('WB_PATH') == false)
+{
+	die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
+}
+
+// if admin is be call from admin modify core you have $page_id
+if(!isset($page_id)) {
+	// Get page id
+	if(isset($_GET['page_id']) && is_numeric($_GET['page_id'])) {
+		$page_id = (int)$_GET['page_id'];
+	} elseif(isset($_POST['page_id']) && is_numeric($_POST['page_id'])) {
+		$page_id = (int)$_POST['page_id'];
+	} else {
+		header("Location: index.php");
+		exit(0);
+	}
+}
+
+// if admin is be call from admin modify core you have $section_id
+if(!isset($section_id)) {
+// Get section id if there is one
+	if(isset($_GET['section_id']) && is_numeric($_GET['section_id'])) {
+		$section_id = (int)$_GET['section_id'];
+	} elseif(isset($_POST['section_id']) && is_numeric($_POST['section_id'])) {
+		$section_id = (int)$_POST['section_id'];
+	} else {
+		// Check if we should redirect the user if there is no section id
+		if(!isset($section_required)) {
+			$section_id = 0;
+		} else {
+			header("Location: $section_required");
+			exit(0);
+		}
+	}
+}
+// be sure is is numeric
+$page_id = intval($page_id);
+$section_id = intval($section_id);
+
+// Create js back link
+// $js_back = 'javascript: history.go(-1);';
+$js_back = ADMIN_URL.'/pages/sections.php?page_id='.(int)$page_id;
+// Create new admin object, you can set the next variable in your module
+// to print with or without header, default is with header
+// it is recommed to set the variable before including the /modules/admin.php
+$admin_header = (!isset($admin_header)) ? true : $admin_header;
+require_once(WB_PATH.'/framework/class.admin.php');
+$admin = new admin('Pages', 'pages_modify',(bool)$admin_header);
+// Get perms
+// unset($admin_header);
+
+$page = $admin->get_page_details($page_id,ADMIN_URL.'/pages/index.php' );
+
+$old_admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
+$old_admin_users = explode(',', str_replace('_', '', $page['admin_users']));
+
+$in_group = false;
+foreach($admin->get_groups_id() as $cur_gid){
+    if (in_array($cur_gid, $old_admin_groups)) {
+        $in_group = true;
+    }
+}
+
+if((!$in_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
+	print $admin->get_group_id().$admin->get_user_id();
+	print_r ($old_admin_groups);
+	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+}
+
+// some additional security checks:
+// Check whether the section_id belongs to the page_id at all
+if ($section_id != 0) {
+	$section = $admin->get_section_details($section_id,ADMIN_URL.'/pages/index.php');
+	if (!$admin->get_permission($section['module'], 'module'))
+	{
+		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
+	}	
+}
+
+// Workout if the developer wants to show the info banner
+if(isset($print_info_banner) && $print_info_banner == true) {
+	// Get page details already defined
+
+	// Get display name of person who last modified the page
+	$user = $admin->get_user_details($page['modified_by']);
+
+	// Convert the unix ts for modified_when to human a readable form
+	if($page['modified_when'] != 0) {
+		$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $page['modified_when']+TIMEZONE);
+	} else {
+		$modified_ts = 'Unknown';
+	}
+
+	// Include page info script
+	$template = new Template(THEME_PATH.'/templates');
+	$template->set_file('page', 'pages_modify.htt');
+	$template->set_block('page', 'main_block', 'main');
+	$template->set_block('main_block', 'section_block', 'section_list');
+	$template->set_block('section_block', 'block_block', 'block_list');
+	$template->set_var(array(
+				'PAGE_ID' => $page['page_id'],
+				// 'PAGE_IDKEY' => $admin->getIDKEY($page['page_id']),
+				'PAGE_IDKEY' => $page['page_id'],
+				'PAGE_TITLE' => ($page['page_title']),
+				'MENU_TITLE' => ($page['menu_title']),
+				'ADMIN_URL' => ADMIN_URL,
+				'WB_URL' => WB_URL,
+				'THEME_URL' => THEME_URL
+				));
+
+	$template->set_var(array(
+				'MODIFIED_BY' => $user['display_name'],
+				'MODIFIED_BY_USERNAME' => $user['username'],
+				'MODIFIED_WHEN' => $modified_ts,
+				'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
+				));
+
+	$template->set_block('main_block', 'show_modify_block', 'show_modify');
+	if($modified_ts == 'Unknown')
+	{
+	    $template->set_block('show_modify', '');
+		$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
+
+	} else {
+		$template->set_var('CLASS_DISPLAY_MODIFIED', '');
+	    $template->parse('show_modify', 'show_modify_block', true);
+	}
+
+	// Work-out if we should show the "manage sections" link
+	$sql  = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.(int)$page_id.' ';
+	$sql .= 'AND `module` = "menu_link"';
+	$query_sections = $database->query($sql);
+
+	$template->set_block('main_block', 'show_section_block', 'show_section');
+	if($query_sections->numRows() > 0)
+	{
+		$template->set_block('show_section', '');
+		$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
+
+	} elseif(MANAGE_SECTIONS == 'enabled')
+	{
+
+		$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
+	    $template->parse('show_section', 'show_section_block', true);
+
+	} else {
+		$template->set_block('show_section', '');
+		$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
+
+	}
+
+	// Insert language TEXT
+	$template->set_var(array(
+					'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
+					'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
+					'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
+					));
+
+	// Parse and print header template
+	$template->parse('main', 'main_block', false);
+	$template->pparse('output', 'page');
+
+	// unset($print_info_banner);
+	unset($template);
+	print '<div id="wb_'.$section['section_id'].'"><b>' . $TEXT['BLOCK'] . ': </b>' . $section['block'];
+	print '<b>  Modul: </b>' . $section['module']." ";
+	print '<b>  ID: </b>' . $section_id."</div>\n";
+
+} //
+
+// Work-out if the developer wants us to update the timestamp for when the page was last modified
+if(isset($update_when_modified) && $update_when_modified == true) {
+	$database->query("UPDATE ".TABLE_PREFIX."pages SET modified_when = '".time()."', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'");
+}
