Index: branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php
===================================================================
--- branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php	(revision 413)
+++ branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php	(revision 451)
@@ -22,4 +22,30 @@
 require_once dirname( __FILE__ ).'/include/functions_for_wp_old.php' ;
 
+if (!is_wordpress_style() && ( !empty($xpress_config->theme_select) || $xpress_config->theme_select != 'use_wordpress_select') ){
+	add_filter('stylesheet', 'xpress_Stylesheet');
+	add_filter('template', 'xpress_ThemeTemplate');
+}
+function xpress_Stylesheet($stylesheet) {
+	global $xpress_config;
+	$theme = $xpress_config->theme_select;
+    $theme = get_theme($theme);
+
+    if (empty($theme)) {
+        return $stylesheet;
+    }
+    return $theme['Stylesheet'];
+}
+
+function xpress_ThemeTemplate($template) {
+	global $xpress_config;
+	$theme = $xpress_config->theme_select;
+    $theme = get_theme($theme);
+
+    if (empty($theme)) {
+        return $template;
+    }
+    return $theme['Template'];
+}
+
 function my_plugin_menu()
 {
@@ -190,12 +216,14 @@
 		echo		'<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
 		echo			'<table class="form-table">'."\n";
+		$upload_title = __('Media Upload Base Path','xpressme');
+		if($xoops_config->is_wpmu) $upload_title = $upload_title . '(WPMU is not select)';
 		echo				$xpress_config->yes_no_radio_option('is_use_xoops_upload_path',
-												__('Media Upload Base Path','xpressme'),
+												$upload_title,
 												__('Use XOOPS UPLOAD PATH','xpressme'),
-												__('USE WordPress BASE_PATH','xpressme')
-												);
-		
-		echo				$xpress_config->groupe_role_option();		
-		
+												__('USE WordPress BASE_PATH','xpressme'),
+												$xoops_config->is_wpmu
+												);
+		$lock = ($xoops_config->module_url != get_bloginfo('url'));
+		echo				$xpress_config->groupe_role_option($lock);	
 		echo				$xpress_config->d3forum_option($do_message);		
 		echo			"</table>\n";
@@ -253,4 +281,9 @@
 												__('NO','xpressme')		
 												);
+		echo				$xpress_config->yes_no_radio_option('is_block_error_display',
+												__('Select warning display of block file version check','xpressme'),
+												__('Do display','xpressme'),
+												__('Do not display','xpressme')		
+												);
 		echo			"</table>\n";
 		
@@ -264,175 +297,10 @@
 }
 
-function upgrade_page()
-{
-	global $xoops_config,$xpress_config;
-	
-	$xpress_version = $xoops_config->module_version . $xoops_config->module_codename;
-	$check_url = "http://ja1.xpressme.info/version_check/?version=$xpress_version";
-
-	echo	'<div class="wrap">'."\n";
-	echo		'<div id="icon-options-general" class="icon32"><br /></div>'."\n";
-	echo		'<h2>' . __('XPressME Upgrade', 'xpressme') . "</h2><br>\n";
-	
-	if(get_xpress_latest_version()){
-		$latest = get_option('xpressme_latest_version');
-		if ($latest) {
-			$site_url=$latest['url'];
-			$package=$latest['package'];
-			$latest_version=$latest['latest_version'];
-			$check_time=$latest['check_time'];
-		}
-
-
-		if (version_compare($xpress_version, $latest_version, '>')){
-				echo '<h3 class="response">';
-				printf(__('You are using a XPressME Integration Kit development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.', 'xpressme') , $xpress_version , $site_url);
-				echo '</h3>';
-
-		} else if (version_compare($xpress_version, $latest_version, '<')) {
-			echo	'<h3 class="response">'. __('There is a new version of XPressME Integration Kit available for upgrade', 'xpressme') . '</h3>';
-			echo '<p>';
-	//		printf(__('You can upgrade to version %s automatically or download the package and install it manually:'),$latest_version);
-			printf(__('You can upgrade to version %s download the package and install it manually:', 'xpressme'),$latest_version);
-			echo '</p>';
-			echo '<a class="button" href="' . $package . '">';
-			printf(__('Download %s', 'xpressme') , $latest_version);
-			echo '</a>';
-		} else {
-			echo	'<h3 class="response">'. __('You have the latest version of XPressME Integration Kit. You do not need to upgrade', 'xpressme') . '</h3>';
-		}
-	} else {
-		echo '<h3 class="response">';
-		printf(__('There is no response from <a href="%s">version check API</a> now. sorry, please confirm it after.', 'xpressme'),$check_url);
-		echo	"</div>\n";
-	}
-}
-
-function xp_remote_get($url, $headers = ""){
-	global $xoops_config;
-	$xpress_version = $xoops_config->module_version . $xoops_config->module_codename;
-
-	require_once( $xoops_config->module_path . '/wp-includes/class-snoopy.php');
-
-	// Snoopy is an HTTP client in PHP
-	$client = new Snoopy();
-	$client->agent = 'XPressME/' . $xpress_version;
-	$client->read_timeout = 2;
-	if (is_array($headers) ) {
-		$client->rawheaders = $headers;
-	}
-
-	@$client->fetch($url);
-	$response['response']['code'] = $client->status;
-	$response['body'] = $client->results;
-	return $response;
-	return $client;
-
-}
-
-function get_xpress_latest_version(){
-	global $wp_version, $wpdb, $wp_local_package;
-	global $xoops_config;
-	
-	$xpress_version = $xoops_config->module_version . $xoops_config->module_codename;
-
-	$check_url = "http://ja.xpressme.info/version_check/?version=$xpress_version";
-	$request_options = array(
-	'timeout' => 3,
-	'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
-	);
-
-	if (! function_exists('wp_remote_get')) {
-		$response = xp_remote_get($check_url);
-		
-		if (empty($response['body'])) return false;
-	} else {
-	
-		$response = wp_remote_get($check_url, $request_options);
-		
-		if ( is_wp_error( $response ) )
-			return false;
-	}
-	if ( 200 != $response['response']['code'] )
-		return false;
-	$body = trim( $response['body'] );
-	$body = str_replace(array("\r\n", "\r"), "\n", $body);
-	$returns = explode("\n", $body);
-	$response = $returns[0];
-	if ( isset( $returns[1] ) )
-		$url = clean_url( $returns[1] );
-	if ( isset( $returns[2] ) )
-		$package = clean_url( $returns[2] );
-	if ( isset( $returns[3] ) )
-		$latest_version = $returns[3];
-
-	$write_options = array (
-		'url' => $url ,
-		'package' => $package ,
-		'latest_version' => $latest_version ,
-		'check_time' => time()
-	);
-	
-	$latest_version = get_option('xpressme_latest_version');
-	if (!$latest_version) {
-		add_option('xpressme_latest_version', $write_options);
-	} else {
-		update_option('xpressme_latest_version', $write_options);
-	}
-	return true;
-}
-
-function xpress_update_check() {
-	if ( defined('WP_INSTALLING') )
-		return;
-	global $pagenow;
-
-	$php_query_string = $_SERVER['QUERY_STRING'];
-
-	if ( 'admin.php' == $pagenow && 'page=upgrade_page' == $php_query_string)
-		return;
-
-	global $wp_version, $wpdb, $wp_local_package;
-	global $xoops_config;
-
-	$php_query_string = $_SERVER['QUERY_STRING'];
-	$xpress_version = $xoops_config->module_version . $xoops_config->module_codename;
-
-	$latest = get_option('xpressme_latest_version');
-	if (!$latest ) {
-		get_xpress_latest_version();
-		$latest = get_option('xpressme_latest_version');
-	}
-
-	if ($latest) {
-		$next_check = $latest['check_time'] + (60*60*24);
-		$now_time = time();
-		if ($next_check < $now_time ){
-			get_xpress_latest_version();
-			$latest = get_option('xpressme_latest_version');
-		}
-	}
-
-	if ($latest) {
-		$url=$latest['url'];
-		$package=$latest['package'];
-		$latest_version=$latest['latest_version'];
-		$check_time=$latest['check_time'];
-		$upgrade_page = $xoops_config->module_url . "/wp-admin/admin.php?page=upgrade_page";
-
-		if (version_compare($xpress_version, $latest_version, '<')) {
-			if ( current_user_can('manage_options') ){
-				$msg = sprintf( __('XPressME Integration Kit Version %1$s is available! <a href="%2$s">Please update now</a>.', 'xpressme'), $latest_version, $upgrade_page );
-			} else {
-				$msg = sprintf( __('XPressME Integration Kit Version %1$s is available! Please notify the site administrator.', 'xpressme'), $latest_version );
-			}
-			echo "<div id='update-nag'>$msg </div>";
-		}
-	}
-}
-
+include_once dirname( __FILE__ ).'/include/xpress_upgrade.php' ;
 add_action( 'admin_notices', 'xpress_update_check', 3 );
 
 include_once dirname( __FILE__ ).'/include/dashboard_feed.php' ;
 
+include_once dirname( __FILE__ ).'/xpressme_widget_class.php' ;
+
 ?>
