Index: /branches/XPressMU/xpressme_integration_kit/include/general_functions.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 414)
+++ /branches/XPressMU/xpressme_integration_kit/include/general_functions.php	(revision 415)
@@ -120,5 +120,5 @@
 
 // Get Multi Blog table list for WordPressMU 
-if (!function_exists('get_multi_table_list')){
+if (!function_exists('get_table_list')){
 	function get_table_list($wp_prefix = '',$table_name = ''){
 		global $xoopsDB,$xoops_db;
Index: /branches/XPressMU/xpressme_integration_kit/include/search.php
===================================================================
--- /branches/XPressMU/xpressme_integration_kit/include/search.php	(revision 414)
+++ /branches/XPressMU/xpressme_integration_kit/include/search.php	(revision 415)
@@ -13,105 +13,105 @@
 
 if( ! function_exists( 'xpress_global_search_base' ) ) {
+	function xpress_global_search_base( $mydirname , $queryarray , $andor , $limit , $offset , $userid ){
+		global $xoopsDB, $myts;
+		
+		require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
 
-function xpress_global_search_base( $mydirname , $queryarray , $andor , $limit , $offset , $userid )
-{
-	global $xoopsDB, $myts;
-	
-	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
-
-	$myts =& MyTextSanitizer::getInstance();
-	
-	$time_difference = get_time_difference($mydirname);
-	$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
-	$where = "(post_status = 'publish') AND (post_date <= '".$now."')";
-
-	if ( is_array($queryarray) && $count = count($queryarray) ) {
-		$str_query = array();
-		for($i=0;$i<$count;$i++){
-			$str_query[] = "(post_title LIKE '%".$queryarray[$i]."%' OR post_content LIKE '%".$queryarray[$i]."%')";
+		$myts =& MyTextSanitizer::getInstance();
+		
+		$xp_prefix = $mydirname;
+		if ($xp_prefix == 'wordpress'){
+	 		$xp_prefix = 'wp';
 		}
-		$where .= " AND ".implode(" $andor ", $str_query);
-	}
-	if ($userid) {
-		$userid = xoops_uid_to_wp_uid(intval($userid),$mydirname);
-		$where  .= " AND (post_author=".$userid.")";
-	}
-	
-	$xp_prefix = $mydirname;
-	if ($xp_prefix == 'wordpress'){
- 		$xp_prefix = 'wp';
-	}
-	$views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_posts' ;
-	
-	$request = "SELECT * FROM " . $views_table ." WHERE ".$where;
-	$request .= " ORDER BY post_date DESC";
-	$result = $xoopsDB->query($request,$limit,$offset);
-
-	$ret = array();
-	$i = 0;
-	while($myrow = $xoopsDB->fetchArray($result)){
-		
-		
-//		$ret[$i]['link'] = str_replace(get_settings('home')."/","",get_permalink(($myrow['ID'])));
-		switch ($myrow['post_type']) {
-		case 'page':
-			$ret[$i]['link'] = '?page_id=' . $myrow['ID'];
-			break;
-		case 'post':
-		case '':
-			$ret[$i]['link'] = '?p=' . $myrow['ID'];
+		if ($userid) {
+			$userid = xoops_uid_to_wp_uid(intval($userid),$mydirname);
 		}
 
-		$ret[$i]['title'] = $myts->htmlSpecialChars($myrow['post_title']);
-		$date_str = $myrow['post_date'];
-		$yyyy = substr($date_str,0,4);
-		$mm   = substr($date_str,5,2);
-		$dd   = substr($date_str,8,2);
-		$hh   = substr($date_str,11,2);
-		$nn   = substr($date_str,14,2);
-		$ss   = substr($date_str,17,2);
-		$ret[$i]['time'] = mktime( $hh,$nn,$ss,$mm,$dd,$yyyy);
-		$ret[$i]['uid'] = wp_uid_to_xoops_uid($myrow['post_author'],$mydirname);
-//		$ret[$i]['page'] = $myts->htmlSpecialChars($myrow['post_title']);
+		$prefix= XOOPS_DB_PREFIX . '_' . $xp_prefix  ;
+		$posts_tables = get_table_list($prefix,'posts');
+		$i = 0;
+		$ret = array();
+		foreach( $posts_tables as $views_table){
+			$mid_prefix = get_multi_mid_prefix($prefix,'posts' , $views_table);
+			$option_table = $prefix . $mid_prefix . 'options';
+			$time_difference = get_blog_option($option_table ,'gmt_offset');
+			$blog_url = get_blog_option($option_table , 'siteurl');
+			$pattern = '/.*' . $mydirname . '/';
+			$mid_url = preg_replace($pattern, '' , $blog_url);
+			$mid_url = preg_replace('/\//' , '' , $mid_url);
+			if (!empty($mid_url)) $mid_url = $mid_url . '/' ;
+			
+			$blog_name = get_blog_option($option_table , 'blogname');
+			if (empty($mid_url)) $blog_name = ''; else $blog_name = $blog_name . ':: ';
+			
+			$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
+			$where = "(post_status = 'publish') AND (post_date <= '".$now."')";
 
-		$context = '' ;
-		$text =$myrow['post_content'];
-		// get context for module "search"
-		$showcontext = empty( $_GET['showcontext'] ) ? 0 : 1 ;
-		if( function_exists( 'search_make_context' ) && $showcontext ) {
-			if( function_exists( 'easiestml' ) ) $text = easiestml( $text ) ;
-			$full_context = strip_tags($text) ;
-			$context = search_make_context( $full_context , $queryarray ) ;
+			if ( is_array($queryarray) && $count = count($queryarray) ) {
+				$str_query = array();
+				for($i=0;$i<$count;$i++){
+					$str_query[] = "(post_title LIKE '%".$queryarray[$i]."%' OR post_content LIKE '%".$queryarray[$i]."%')";
+				}
+				$where .= " AND ".implode(" $andor ", $str_query);
+			}
+			if ($userid) {
+				$where  .= " AND (post_author=".$userid.")";
+			}
+
+			$request = "SELECT * FROM " . $views_table ." WHERE ".$where;
+			$request .= " ORDER BY post_date DESC";
+			$result = $xoopsDB->query($request,$limit,$offset);
+
+			while($myrow = $xoopsDB->fetchArray($result)){
+				switch ($myrow['post_type']) {
+				case 'page':
+					$ret[$i]['link'] = $mid_url . '?page_id=' . $myrow['ID'];
+					break;
+				case 'post':
+				case '':
+					$ret[$i]['link'] = $mid_url . '?p=' . $myrow['ID'];
+				}
+				$ret[$i]['title'] = $blog_name . $myts->htmlSpecialChars($myrow['post_title']);
+				$date_str = $myrow['post_date'];
+				$yyyy = substr($date_str,0,4);
+				$mm   = substr($date_str,5,2);
+				$dd   = substr($date_str,8,2);
+				$hh   = substr($date_str,11,2);
+				$nn   = substr($date_str,14,2);
+				$ss   = substr($date_str,17,2);
+				$ret[$i]['time'] = mktime( $hh,$nn,$ss,$mm,$dd,$yyyy);
+				$ret[$i]['uid'] = wp_uid_to_xoops_uid($myrow['post_author'],$mydirname);
+
+				$context = '' ;
+				$text =$myrow['post_content'];
+				// get context for module "search"
+				$showcontext = empty( $_GET['showcontext'] ) ? 0 : 1 ;
+				if( function_exists( 'search_make_context' ) && $showcontext ) {
+					if( function_exists( 'easiestml' ) ) $text = easiestml( $text ) ;
+					$full_context = strip_tags($text) ;
+					$context = search_make_context( $full_context , $queryarray ) ;
+				}
+				$ret[$i]['context']=$context;
+				$i++;
+			}
 		}
-		$ret[$i]['context']=$context;
+		return $ret;
 
-
-		$i++;
 	}
-	return $ret;
-
 }
 
-}
+if( ! function_exists( 'get_blog_option' ) ) {
+	function get_blog_option($option_table,$option_name){
+		$xoopsDB =& Database::getInstance();
 
-if( ! function_exists( 'get_time_difference' ) ) {
-function get_time_difference($mydirname){
-	$xoopsDB =& Database::getInstance();
-
-	$xp_prefix = $mydirname;
-	if ($xp_prefix == 'wordpress'){
- 		$xp_prefix = 'wp';
+		$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;
 	}
-	$option_tbl = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_options' ;
-	
-	$sql = "SELECT option_value FROM $option_tbl WHERE option_name = 'gmt_offset'";
-	
-	$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 414)
+++ /trunk/xpressme_integration_kit/include/general_functions.php	(revision 415)
@@ -120,5 +120,5 @@
 
 // Get Multi Blog table list for WordPressMU 
-if (!function_exists('get_multi_table_list')){
+if (!function_exists('get_table_list')){
 	function get_table_list($wp_prefix = '',$table_name = ''){
 		global $xoopsDB,$xoops_db;
Index: /trunk/xpressme_integration_kit/include/search.php
===================================================================
--- /trunk/xpressme_integration_kit/include/search.php	(revision 414)
+++ /trunk/xpressme_integration_kit/include/search.php	(revision 415)
@@ -13,105 +13,105 @@
 
 if( ! function_exists( 'xpress_global_search_base' ) ) {
+	function xpress_global_search_base( $mydirname , $queryarray , $andor , $limit , $offset , $userid ){
+		global $xoopsDB, $myts;
+		
+		require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
 
-function xpress_global_search_base( $mydirname , $queryarray , $andor , $limit , $offset , $userid )
-{
-	global $xoopsDB, $myts;
-	
-	require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
-
-	$myts =& MyTextSanitizer::getInstance();
-	
-	$time_difference = get_time_difference($mydirname);
-	$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
-	$where = "(post_status = 'publish') AND (post_date <= '".$now."')";
-
-	if ( is_array($queryarray) && $count = count($queryarray) ) {
-		$str_query = array();
-		for($i=0;$i<$count;$i++){
-			$str_query[] = "(post_title LIKE '%".$queryarray[$i]."%' OR post_content LIKE '%".$queryarray[$i]."%')";
+		$myts =& MyTextSanitizer::getInstance();
+		
+		$xp_prefix = $mydirname;
+		if ($xp_prefix == 'wordpress'){
+	 		$xp_prefix = 'wp';
 		}
-		$where .= " AND ".implode(" $andor ", $str_query);
-	}
-	if ($userid) {
-		$userid = xoops_uid_to_wp_uid(intval($userid),$mydirname);
-		$where  .= " AND (post_author=".$userid.")";
-	}
-	
-	$xp_prefix = $mydirname;
-	if ($xp_prefix == 'wordpress'){
- 		$xp_prefix = 'wp';
-	}
-	$views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_posts' ;
-	
-	$request = "SELECT * FROM " . $views_table ." WHERE ".$where;
-	$request .= " ORDER BY post_date DESC";
-	$result = $xoopsDB->query($request,$limit,$offset);
-
-	$ret = array();
-	$i = 0;
-	while($myrow = $xoopsDB->fetchArray($result)){
-		
-		
-//		$ret[$i]['link'] = str_replace(get_settings('home')."/","",get_permalink(($myrow['ID'])));
-		switch ($myrow['post_type']) {
-		case 'page':
-			$ret[$i]['link'] = '?page_id=' . $myrow['ID'];
-			break;
-		case 'post':
-		case '':
-			$ret[$i]['link'] = '?p=' . $myrow['ID'];
+		if ($userid) {
+			$userid = xoops_uid_to_wp_uid(intval($userid),$mydirname);
 		}
 
-		$ret[$i]['title'] = $myts->htmlSpecialChars($myrow['post_title']);
-		$date_str = $myrow['post_date'];
-		$yyyy = substr($date_str,0,4);
-		$mm   = substr($date_str,5,2);
-		$dd   = substr($date_str,8,2);
-		$hh   = substr($date_str,11,2);
-		$nn   = substr($date_str,14,2);
-		$ss   = substr($date_str,17,2);
-		$ret[$i]['time'] = mktime( $hh,$nn,$ss,$mm,$dd,$yyyy);
-		$ret[$i]['uid'] = wp_uid_to_xoops_uid($myrow['post_author'],$mydirname);
-//		$ret[$i]['page'] = $myts->htmlSpecialChars($myrow['post_title']);
+		$prefix= XOOPS_DB_PREFIX . '_' . $xp_prefix  ;
+		$posts_tables = get_table_list($prefix,'posts');
+		$i = 0;
+		$ret = array();
+		foreach( $posts_tables as $views_table){
+			$mid_prefix = get_multi_mid_prefix($prefix,'posts' , $views_table);
+			$option_table = $prefix . $mid_prefix . 'options';
+			$time_difference = get_blog_option($option_table ,'gmt_offset');
+			$blog_url = get_blog_option($option_table , 'siteurl');
+			$pattern = '/.*' . $mydirname . '/';
+			$mid_url = preg_replace($pattern, '' , $blog_url);
+			$mid_url = preg_replace('/\//' , '' , $mid_url);
+			if (!empty($mid_url)) $mid_url = $mid_url . '/' ;
+			
+			$blog_name = get_blog_option($option_table , 'blogname');
+			if (empty($mid_url)) $blog_name = ''; else $blog_name = $blog_name . ':: ';
+			
+			$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
+			$where = "(post_status = 'publish') AND (post_date <= '".$now."')";
 
-		$context = '' ;
-		$text =$myrow['post_content'];
-		// get context for module "search"
-		$showcontext = empty( $_GET['showcontext'] ) ? 0 : 1 ;
-		if( function_exists( 'search_make_context' ) && $showcontext ) {
-			if( function_exists( 'easiestml' ) ) $text = easiestml( $text ) ;
-			$full_context = strip_tags($text) ;
-			$context = search_make_context( $full_context , $queryarray ) ;
+			if ( is_array($queryarray) && $count = count($queryarray) ) {
+				$str_query = array();
+				for($i=0;$i<$count;$i++){
+					$str_query[] = "(post_title LIKE '%".$queryarray[$i]."%' OR post_content LIKE '%".$queryarray[$i]."%')";
+				}
+				$where .= " AND ".implode(" $andor ", $str_query);
+			}
+			if ($userid) {
+				$where  .= " AND (post_author=".$userid.")";
+			}
+
+			$request = "SELECT * FROM " . $views_table ." WHERE ".$where;
+			$request .= " ORDER BY post_date DESC";
+			$result = $xoopsDB->query($request,$limit,$offset);
+
+			while($myrow = $xoopsDB->fetchArray($result)){
+				switch ($myrow['post_type']) {
+				case 'page':
+					$ret[$i]['link'] = $mid_url . '?page_id=' . $myrow['ID'];
+					break;
+				case 'post':
+				case '':
+					$ret[$i]['link'] = $mid_url . '?p=' . $myrow['ID'];
+				}
+				$ret[$i]['title'] = $blog_name . $myts->htmlSpecialChars($myrow['post_title']);
+				$date_str = $myrow['post_date'];
+				$yyyy = substr($date_str,0,4);
+				$mm   = substr($date_str,5,2);
+				$dd   = substr($date_str,8,2);
+				$hh   = substr($date_str,11,2);
+				$nn   = substr($date_str,14,2);
+				$ss   = substr($date_str,17,2);
+				$ret[$i]['time'] = mktime( $hh,$nn,$ss,$mm,$dd,$yyyy);
+				$ret[$i]['uid'] = wp_uid_to_xoops_uid($myrow['post_author'],$mydirname);
+
+				$context = '' ;
+				$text =$myrow['post_content'];
+				// get context for module "search"
+				$showcontext = empty( $_GET['showcontext'] ) ? 0 : 1 ;
+				if( function_exists( 'search_make_context' ) && $showcontext ) {
+					if( function_exists( 'easiestml' ) ) $text = easiestml( $text ) ;
+					$full_context = strip_tags($text) ;
+					$context = search_make_context( $full_context , $queryarray ) ;
+				}
+				$ret[$i]['context']=$context;
+				$i++;
+			}
 		}
-		$ret[$i]['context']=$context;
+		return $ret;
 
-
-		$i++;
 	}
-	return $ret;
-
 }
 
-}
+if( ! function_exists( 'get_blog_option' ) ) {
+	function get_blog_option($option_table,$option_name){
+		$xoopsDB =& Database::getInstance();
 
-if( ! function_exists( 'get_time_difference' ) ) {
-function get_time_difference($mydirname){
-	$xoopsDB =& Database::getInstance();
-
-	$xp_prefix = $mydirname;
-	if ($xp_prefix == 'wordpress'){
- 		$xp_prefix = 'wp';
+		$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;
 	}
-	$option_tbl = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_options' ;
-	
-	$sql = "SELECT option_value FROM $option_tbl WHERE option_name = 'gmt_offset'";
-	
-	$result =  $xoopsDB->query($sql, 0, 0);
-	if ($xoopsDB->getRowsNum($result)  > 0){
-		$row = $xoopsDB->fetchArray($result);
-		return $row['option_value'];
-	}
-	return 0;
-}
 }
 
