Index: /branches/XPressMU/xpressme_integration_kit/include/general_functions.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 422)
+++ /branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 423)
@@ -155,3 +155,10 @@
 }
 
+// Get Prefix from Table name for WordPressMU 
+if (!function_exists('get_multi_prefix')){
+	function get_multi_prefix($full_table_name,$table_name = ''){
+		$pattern = '/'. $table_name . '/';
+		return preg_replace($pattern,'',$full_table_name);
+	}
+}
 ?>
Index: /branches/XPressMU/xpressme_integration_kit/include/sitemap.plugin.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/sitemap.plugin.php	(revision 422)
+++ /branches/XPressMU/xpressme_integration_kit/include/sitemap.plugin.php	(revision 423)
@@ -17,80 +17,151 @@
 if(!function_exists('_sitemap_xpress')){
 	function _sitemap_xpress($mydirname){
-		global $sitemap_configs;
-		
-		$xpress_sitemap =array();	
-		$disp_sub =@$sitemap_configs["show_subcategoris"];		
-		get_sitemap_category_list($mydirname,&$xpress_sitemap, 0, 0, $disp_sub,1);		
-		return $xpress_sitemap;
-	}
-}
-
-if(!function_exists('get_sitemap_category_list')){
-	function get_sitemap_category_list($mydirname,$xpress_sitemap,$parent = 0, $parent_index ,$disp_sub,$depth) 
-	{
-		global $xoopsModule, $wp_db_version;
+		global $sitemap_configs , $xoopsDB;
 
 		if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php')){
 			return '';
 		}
+		include (XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php');
+		if ($wp_db_version < 6124) {  // UNDER WP2.3
+			    $block = sitemap_get_categoires_map($xoopsDB->prefix("wp_categories"), "cat_ID", "category_parent", "cat_name", "index.php?cat=", "cat_name");
+			return $block;
+		}
 		
-		include_once (XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php');
-		$db_version = $wp_db_version;
-		$xoopsDB =& Database::getInstance();
-		$myts =& MyTextSanitizer::getInstance();
+		$disp_sub =@$sitemap_configs["show_subcategoris"];
 		
 		$prefix = $mydirname;
 		if ($prefix == 'wordpress') $prefix ='wp';
-		$wp_prefix = $xoopsDB->prefix($prefix);
+		$prefix = $xoopsDB->prefix($prefix);
+		require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+		$options_tables = get_table_list($prefix,'options');
 		
-		switch($db_version){
-			case ($db_version>= 6000):
-				$id_name = "term_taxonomy_id";
-				$pid_name = "parent";
-				$title_name = "name";
-				$term_taxonomy_db = $wp_prefix . '_term_taxonomy';
-				$terms_db = $wp_prefix . '_terms';
-				$sql  = "SELECT $term_taxonomy_db.$id_name,$terms_db.$title_name ";
-				$sql .= "FROM $term_taxonomy_db INNER JOIN $terms_db ON $term_taxonomy_db.term_id = $terms_db.term_id ";
-				$sql .= "WHERE $term_taxonomy_db.parent = $parent AND $term_taxonomy_db.taxonomy = 'category'";
-				break;
-			default:
-				$id_name = "cat_ID";
-				$pid_name = "category_parent";
-				$title_name = "cat_name";
-				$cat_db = $wp_prefix . '_categories';
-	 			$sql  = "SELECT $id_name , $title_name ";
-				$sql .= "FROM  $cat_db ";
-				$sql .= "WHERE $pid_name = $parent";				
-				break;
+		$index = 0;
+		$blogs =array();
+		foreach( $options_tables as $options_table){
+			$blog_url = get_blog_option($options_table , 'siteurl');
+			$blog_sub_url = preg_replace('/.*\/' . $mydirname . '/' , '' , $blog_url);
+			$blog_sub_url = preg_replace('/\//' , '' , $blog_sub_url);
+			if (!empty($blog_sub_url)) {
+				$blog_sub_url = $blog_sub_url . '/';
+			}
+			$blog_name = get_blog_option($options_table , 'blogname');
+			$db_prefix = get_multi_prefix($options_table , 'options');
+
+			$data = array(
+				'blog_name' => $blog_name ,
+				'blog_sub_url' => $blog_sub_url ,
+				'term_taxonomy' => $db_prefix. 'term_taxonomy' ,
+				'terms' => $db_prefix . 'terms'
+			);
+			$blogs[$index] = $data;
+			$index++;
 		}
-						
-		$res =  $xoopsDB->query($sql, 0, 0);
-	    if ($res === false){
-	    	return ;
-		} else {
-			$index = 0;
-			while($row = $xoopsDB->fetchArray($res)){
-				if ($depth == 1){
-					$xpress_sitemap['parent'][$index]['id'] = $row[$id_name];
-					$xpress_sitemap['parent'][$index]['title'] = $myts->makeTboxData4Show( $row[$title_name] ) ;
-					$url = "index.php?cat=";
-					$xpress_sitemap['parent'][$index]['url'] = $url.$row[$id_name];
-					if ($disp_sub){
-						get_sitemap_category_list($mydirname,&$xpress_sitemap,$row[$id_name] , $index, $disp_sub,$depth + 1);	
-					}
-				} else {
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['id'] = $row[$id_name];
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['title'] = $myts->makeTboxData4Show( $row[$title_name] ) ;
-					$url = "index.php?cat=";
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['url'] = $url.$row[$id_name];
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['image'] = (($depth > 3) ? 4 : $depth);;
-//					get_sitemap_category_list($mydirname,&$xpress_sitemap,$row[$id_name] , $index, $disp_sub,$depth +1);
-				}
-				$index++;
-			}
-	    }
+		return xpress_get_categoires_map($blogs,$disp_sub);
 	}
 }
 
+if(!function_exists('xpress_get_categoires_map')){
+	function xpress_get_categoires_map($blogs ,$disp_sub){
+		global $sitemap_configs;
+		
+		$xoopsDB =& Database::getInstance();
+		
+		$sitemap = array();
+		$myts =& MyTextSanitizer::getInstance();
+		
+		$blogs_count = count($blogs);
+		$i = 0;
+		$blog = array();
+		for ($b_no = 0 ; $b_no < $blogs_count ; $b_no++){
+			$blog = $blogs[$b_no];
+			$terms = $blog['terms'];
+			$term_taxonomy = $blog['term_taxonomy'];
+			$blog_sub_url = $blog['blog_sub_url'];
+			$cat_url = $blog['blog_sub_url'] . '?cat=';
+			$blog_name = $blog['blog_name'];
+			
+			$sql  = "SELECT term_id , name FROM $terms";
+			$result = $xoopsDB->query($sql);
+			$cat_name = array();
+			while (list($id, $name) = $xoopsDB->fetchRow($result)){
+				$cat_name["'ID" . $id . "'"] = $name;
+			}
+			if ($blogs_count > 1){
+					$sitemap['parent'][$i]['id'] = 0;
+					$sitemap['parent'][$i]['title'] = $blog_name ;
+					$sitemap['parent'][$i]['image'] = 1 ;
+					$sitemap['parent'][$i]['url'] = $blog_sub_url;
+					$blog_index = $i;
+					$i++;
+			}
+
+			$mytree = new XoopsTree($term_taxonomy, 'term_id' , 'parent');
+			$sql  = "SELECT term_id  FROM $term_taxonomy WHERE parent = 0 AND taxonomy = 'category'";
+			$result = $xoopsDB->query($sql);
+			while (list($catid) = $xoopsDB->fetchRow($result)){
+				if ($blogs_count <= 1){
+					$dipth = 1;
+					$sitemap['parent'][$i]['id'] = $catid;
+					$sitemap['parent'][$i]['title'] = $cat_name["'ID" . $catid . "'"] ; ;
+					$sitemap['parent'][$i]['image'] = $dipth ;
+					$sitemap['parent'][$i]['url'] = $cat_url.$catid;
+
+					if($disp_sub){ 
+						$j = 0;
+						$child_ary = $mytree->getChildTreeArray($catid, '');
+						foreach ($child_ary as $child)
+						{
+							$count = strlen($child['prefix']) + $dipth;
+							$sitemap['parent'][$i]['child'][$j]['id'] = $child['term_id'];
+							$sitemap['parent'][$i]['child'][$j]['title'] = $cat_name["'ID" .$child['term_id'] . "'"];
+							$sitemap['parent'][$i]['child'][$j]['image'] = (($count > 3) ? 4 : $count);
+							$sitemap['parent'][$i]['child'][$j]['url'] = $cat_url.$child['term_id'];
+							$j++;
+						}
+					}
+					$i++;
+				} else {
+					$dipth = 2;
+					$sitemap['parent'][$blog_index]['child'][$i]['id'] = $catid;
+					$sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" . $catid . "'"];
+					$sitemap['parent'][$blog_index]['child'][$i]['image'] = $dipth;
+					$sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$catid;
+					$i++;
+					$parent_id = $blog_index;
+					if($disp_sub){ 
+						$child_ary = $mytree->getChildTreeArray($catid, '');
+						foreach ($child_ary as $child)
+						{
+							$count = strlen($child['prefix']) + $dipth; 
+							$sitemap['parent'][$blog_index]['child'][$i]['id'] = $child['term_id'];
+							$sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" .$child['term_id'] . "'"];
+							$sitemap['parent'][$blog_index]['child'][$i]['image'] = (($count > 3) ? 4 : $count);
+							$sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$child['term_id'];
+							$i++;
+						}
+					}
+				}
+			$i++;
+			}
+		}
+		return $sitemap;
+	}
+}
+
+if( ! function_exists( 'get_blog_option' ) ) {
+	function get_blog_option($option_table,$option_name){
+		$xoopsDB =& Database::getInstance();
+
+		$sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'";
+		
+		$result =  $xoopsDB->query($sql, 0, 0);
+		if ($xoopsDB->getRowsNum($result)  > 0){
+			$row = $xoopsDB->fetchArray($result);
+			return $row['option_value'];
+		}
+		return 0;
+	}
+}
+
+
 ?>
Index: /trunk/xpressme_integration_kit/include/general_functions.php
===================================================================
--- /trunk/xpressme_integration_kit/include/general_functions.php	(revision 422)
+++ /trunk/xpressme_integration_kit/include/general_functions.php	(revision 423)
@@ -155,3 +155,10 @@
 }
 
+// Get Prefix from Table name for WordPressMU 
+if (!function_exists('get_multi_prefix')){
+	function get_multi_prefix($full_table_name,$table_name = ''){
+		$pattern = '/'. $table_name . '/';
+		return preg_replace($pattern,'',$full_table_name);
+	}
+}
 ?>
Index: /trunk/xpressme_integration_kit/include/sitemap.plugin.php
===================================================================
--- /trunk/xpressme_integration_kit/include/sitemap.plugin.php	(revision 422)
+++ /trunk/xpressme_integration_kit/include/sitemap.plugin.php	(revision 423)
@@ -17,80 +17,151 @@
 if(!function_exists('_sitemap_xpress')){
 	function _sitemap_xpress($mydirname){
-		global $sitemap_configs;
-		
-		$xpress_sitemap =array();	
-		$disp_sub =@$sitemap_configs["show_subcategoris"];		
-		get_sitemap_category_list($mydirname,&$xpress_sitemap, 0, 0, $disp_sub,1);		
-		return $xpress_sitemap;
-	}
-}
-
-if(!function_exists('get_sitemap_category_list')){
-	function get_sitemap_category_list($mydirname,$xpress_sitemap,$parent = 0, $parent_index ,$disp_sub,$depth) 
-	{
-		global $xoopsModule, $wp_db_version;
+		global $sitemap_configs , $xoopsDB;
 
 		if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php')){
 			return '';
 		}
+		include (XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php');
+		if ($wp_db_version < 6124) {  // UNDER WP2.3
+			    $block = sitemap_get_categoires_map($xoopsDB->prefix("wp_categories"), "cat_ID", "category_parent", "cat_name", "index.php?cat=", "cat_name");
+			return $block;
+		}
 		
-		include_once (XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php');
-		$db_version = $wp_db_version;
-		$xoopsDB =& Database::getInstance();
-		$myts =& MyTextSanitizer::getInstance();
+		$disp_sub =@$sitemap_configs["show_subcategoris"];
 		
 		$prefix = $mydirname;
 		if ($prefix == 'wordpress') $prefix ='wp';
-		$wp_prefix = $xoopsDB->prefix($prefix);
+		$prefix = $xoopsDB->prefix($prefix);
+		require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
+		$options_tables = get_table_list($prefix,'options');
 		
-		switch($db_version){
-			case ($db_version>= 6000):
-				$id_name = "term_taxonomy_id";
-				$pid_name = "parent";
-				$title_name = "name";
-				$term_taxonomy_db = $wp_prefix . '_term_taxonomy';
-				$terms_db = $wp_prefix . '_terms';
-				$sql  = "SELECT $term_taxonomy_db.$id_name,$terms_db.$title_name ";
-				$sql .= "FROM $term_taxonomy_db INNER JOIN $terms_db ON $term_taxonomy_db.term_id = $terms_db.term_id ";
-				$sql .= "WHERE $term_taxonomy_db.parent = $parent AND $term_taxonomy_db.taxonomy = 'category'";
-				break;
-			default:
-				$id_name = "cat_ID";
-				$pid_name = "category_parent";
-				$title_name = "cat_name";
-				$cat_db = $wp_prefix . '_categories';
-	 			$sql  = "SELECT $id_name , $title_name ";
-				$sql .= "FROM  $cat_db ";
-				$sql .= "WHERE $pid_name = $parent";				
-				break;
+		$index = 0;
+		$blogs =array();
+		foreach( $options_tables as $options_table){
+			$blog_url = get_blog_option($options_table , 'siteurl');
+			$blog_sub_url = preg_replace('/.*\/' . $mydirname . '/' , '' , $blog_url);
+			$blog_sub_url = preg_replace('/\//' , '' , $blog_sub_url);
+			if (!empty($blog_sub_url)) {
+				$blog_sub_url = $blog_sub_url . '/';
+			}
+			$blog_name = get_blog_option($options_table , 'blogname');
+			$db_prefix = get_multi_prefix($options_table , 'options');
+
+			$data = array(
+				'blog_name' => $blog_name ,
+				'blog_sub_url' => $blog_sub_url ,
+				'term_taxonomy' => $db_prefix. 'term_taxonomy' ,
+				'terms' => $db_prefix . 'terms'
+			);
+			$blogs[$index] = $data;
+			$index++;
 		}
-						
-		$res =  $xoopsDB->query($sql, 0, 0);
-	    if ($res === false){
-	    	return ;
-		} else {
-			$index = 0;
-			while($row = $xoopsDB->fetchArray($res)){
-				if ($depth == 1){
-					$xpress_sitemap['parent'][$index]['id'] = $row[$id_name];
-					$xpress_sitemap['parent'][$index]['title'] = $myts->makeTboxData4Show( $row[$title_name] ) ;
-					$url = "index.php?cat=";
-					$xpress_sitemap['parent'][$index]['url'] = $url.$row[$id_name];
-					if ($disp_sub){
-						get_sitemap_category_list($mydirname,&$xpress_sitemap,$row[$id_name] , $index, $disp_sub,$depth + 1);	
-					}
-				} else {
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['id'] = $row[$id_name];
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['title'] = $myts->makeTboxData4Show( $row[$title_name] ) ;
-					$url = "index.php?cat=";
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['url'] = $url.$row[$id_name];
-					$xpress_sitemap['parent'][$parent_index]['child'][$index]['image'] = (($depth > 3) ? 4 : $depth);;
-//					get_sitemap_category_list($mydirname,&$xpress_sitemap,$row[$id_name] , $index, $disp_sub,$depth +1);
-				}
-				$index++;
-			}
-	    }
+		return xpress_get_categoires_map($blogs,$disp_sub);
 	}
 }
 
+if(!function_exists('xpress_get_categoires_map')){
+	function xpress_get_categoires_map($blogs ,$disp_sub){
+		global $sitemap_configs;
+		
+		$xoopsDB =& Database::getInstance();
+		
+		$sitemap = array();
+		$myts =& MyTextSanitizer::getInstance();
+		
+		$blogs_count = count($blogs);
+		$i = 0;
+		$blog = array();
+		for ($b_no = 0 ; $b_no < $blogs_count ; $b_no++){
+			$blog = $blogs[$b_no];
+			$terms = $blog['terms'];
+			$term_taxonomy = $blog['term_taxonomy'];
+			$blog_sub_url = $blog['blog_sub_url'];
+			$cat_url = $blog['blog_sub_url'] . '?cat=';
+			$blog_name = $blog['blog_name'];
+			
+			$sql  = "SELECT term_id , name FROM $terms";
+			$result = $xoopsDB->query($sql);
+			$cat_name = array();
+			while (list($id, $name) = $xoopsDB->fetchRow($result)){
+				$cat_name["'ID" . $id . "'"] = $name;
+			}
+			if ($blogs_count > 1){
+					$sitemap['parent'][$i]['id'] = 0;
+					$sitemap['parent'][$i]['title'] = $blog_name ;
+					$sitemap['parent'][$i]['image'] = 1 ;
+					$sitemap['parent'][$i]['url'] = $blog_sub_url;
+					$blog_index = $i;
+					$i++;
+			}
+
+			$mytree = new XoopsTree($term_taxonomy, 'term_id' , 'parent');
+			$sql  = "SELECT term_id  FROM $term_taxonomy WHERE parent = 0 AND taxonomy = 'category'";
+			$result = $xoopsDB->query($sql);
+			while (list($catid) = $xoopsDB->fetchRow($result)){
+				if ($blogs_count <= 1){
+					$dipth = 1;
+					$sitemap['parent'][$i]['id'] = $catid;
+					$sitemap['parent'][$i]['title'] = $cat_name["'ID" . $catid . "'"] ; ;
+					$sitemap['parent'][$i]['image'] = $dipth ;
+					$sitemap['parent'][$i]['url'] = $cat_url.$catid;
+
+					if($disp_sub){ 
+						$j = 0;
+						$child_ary = $mytree->getChildTreeArray($catid, '');
+						foreach ($child_ary as $child)
+						{
+							$count = strlen($child['prefix']) + $dipth;
+							$sitemap['parent'][$i]['child'][$j]['id'] = $child['term_id'];
+							$sitemap['parent'][$i]['child'][$j]['title'] = $cat_name["'ID" .$child['term_id'] . "'"];
+							$sitemap['parent'][$i]['child'][$j]['image'] = (($count > 3) ? 4 : $count);
+							$sitemap['parent'][$i]['child'][$j]['url'] = $cat_url.$child['term_id'];
+							$j++;
+						}
+					}
+					$i++;
+				} else {
+					$dipth = 2;
+					$sitemap['parent'][$blog_index]['child'][$i]['id'] = $catid;
+					$sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" . $catid . "'"];
+					$sitemap['parent'][$blog_index]['child'][$i]['image'] = $dipth;
+					$sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$catid;
+					$i++;
+					$parent_id = $blog_index;
+					if($disp_sub){ 
+						$child_ary = $mytree->getChildTreeArray($catid, '');
+						foreach ($child_ary as $child)
+						{
+							$count = strlen($child['prefix']) + $dipth; 
+							$sitemap['parent'][$blog_index]['child'][$i]['id'] = $child['term_id'];
+							$sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" .$child['term_id'] . "'"];
+							$sitemap['parent'][$blog_index]['child'][$i]['image'] = (($count > 3) ? 4 : $count);
+							$sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$child['term_id'];
+							$i++;
+						}
+					}
+				}
+			$i++;
+			}
+		}
+		return $sitemap;
+	}
+}
+
+if( ! function_exists( 'get_blog_option' ) ) {
+	function get_blog_option($option_table,$option_name){
+		$xoopsDB =& Database::getInstance();
+
+		$sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'";
+		
+		$result =  $xoopsDB->query($sql, 0, 0);
+		if ($xoopsDB->getRowsNum($result)  > 0){
+			$row = $xoopsDB->fetchArray($result);
+			return $row['option_value'];
+		}
+		return 0;
+	}
+}
+
+
 ?>
