Index: branches/Ver3.0/xpressme_integration_kit/class/wpInfo_class.php
===================================================================
--- branches/Ver3.0/xpressme_integration_kit/class/wpInfo_class.php	(revision 743)
+++ branches/Ver3.0/xpressme_integration_kit/class/wpInfo_class.php	(revision 744)
@@ -9,30 +9,19 @@
  */
 class wpInfo {
+	var	$mod_dirpath;
+	var	$mod_name;
+	var $mod_url;
+
+	var $xoops_Lang;
+	var $wp_Lang;
+	var $php_version;
+	var $mysql_version;
 	// The language of XOOPS is set as Key of the array. 
 	// The language of WP is set as Value of the array. 
-	var $xoops_Lang;
-	var $wp_Lang;
-	
 	var $wp_lang_array = array(
-		'english' => array( 
-				'wp_lang' =>'en',
-				'wp_site' =>'http://wordpress.org/',
-			),
-									
-		'japanese' => array( 
-				'wp_lang' =>'ja',
-				'wp_site' =>'http://ja.wordpress.org/',
-			),
-		
-		'ja_utf8' => array( 
-				'wp_lang' =>'ja',
-				'wp_site' =>'http://ja.wordpress.org/',
-			),
-		
-		'pt-br_utf8' =>	array( 
-				'wp_lang' =>'en',
-				'wp_site' =>'http://br.wordpress.org/',
-			),
-		
+		'english' => 	'en_US',
+		'japanese' => 	'ja',
+		'ja_utf8' => 	'ja',
+		'pt-br_utf8' =>	'pt_BR',
 		// The key(language of XOOPS) of the following lists has not been set yet. 
 		'Afrikaans' =>	'af',
@@ -95,14 +84,135 @@
 	);
 
-	public function get_wpLang($xoops_Lang = 'english') 
-	{
-		$detect_lang = $this->wp_lang_array[$xoops_Lang]['wp_lang'];
-		if (empty($detect_lang)) return 'en';
-		return $detect_lang;
-	}
-	public function get_download_info()
-	{
-		$check_url = 	'http://api.wordpress.org/core/version-check/1.5/?locale='. $this->wp_lang;
-	}
-}
+	function wpInfo(){
+		$this->__construct();
+	}
+	function __construct() {
+		$this->mod_dirpath = dirname(dirname(__FILE__));
+		$this->mod_name = basename(dirname(dirname(__FILE__)));
+		$this->mod_url = XOOPS_URL . '/modules/'.$this->mod_name;
+		$this->load_lang();
+		$this->xoops_Lang = @$GLOBALS["xoopsConfig"]['language'];
+		$this->php_version    = phpversion();
+		$xoopsDB =& Database::getInstance();
+		list($SV) = $xoopsDB->fetchRow($xoopsDB->query('SELECT version()'));
+		$this->mysql_version = $SV;
+
+		$this->get_wpLang();
+	}
+	function text_indent($text,$num = 1,$css_option='')
+	{
+		$ret = '';
+		$px = 24 * $num;
+		$ret = '<div style="padding-left:' .$px .'px;'.$css_option.'">';
+		$ret .= $text . '</div>';
+		return $ret;
+	}
+	public function load_lang()
+	{
+		$lang = @$GLOBALS["xoopsConfig"]['language'];
+
+		// language file (modinfo.php)
+		if( file_exists( $this->mod_dirpath .'/language/'.$lang.'/admin.php' ) ) {
+			include_once $this->mod_dirpath .'/language/'.$lang.'/admin.php' ;
+		} else if( file_exists(  $this->mod_dirpath .'/language/english/admin.php' ) ) {
+			include_once $this->mod_dirpath .'/language/english/admin.php' ;
+		}
+	}
+	
+	public function get_php_version()
+	{
+		return $this->php_version;
+	}
+	public function get_mysql_version()
+	{
+		return $this->mysql_version;
+	}
+	public function get_wpLang($xoops_Lang = '') 
+	{
+		if(!empty($xoops_Lang)) $this->xoops_Lang = $xoops_Lang;
+		$this->wp_Lang = $this->wp_lang_array[$this->xoops_Lang];
+		if (empty($this->wp_Lang)) $this->wp_Lang =  'en_US';
+		return $this->wp_Lang;
+	}
+	public function get_mod_image_link($file_name='') 
+	{
+		$link_url = '';
+		if(!empty($file_name)){
+			if(file_exists($this->mod_dirpath.'/images/'.$file_name)){
+				$link_url = '<img alt="'.$file_name.'" src="'. $this->mod_url .'/images/'.$file_name.'" title="'.$file_name.'" align=top>';
+			}
+		}
+		return $link_url;
+	}
+
+	function is_wpdb_installed(){
+		$prefix_mod = XOOPS_DB_PREFIX .'_' . preg_replace('/wordpress/','wp',$this->mod_name) . '_';
+		$xoopsDB =& Database::getInstance();
+		$sql = "SHOW TABLES LIKE '$prefix_mod%'";
+		if ($result = $xoopsDB->queryf($sql)){
+			if($xoopsDB->getRowsNum($result))  return true;
+		}
+		return false;
+	}
+	
+	public function is_wp_file_found()
+	{
+		if (!file_exists($this->mod_dirpath . '/wp-settings.php')){
+			return false;
+		}
+		return true;
+	}
+	public function get_download_info($locale='')
+	{
+		$sql_version = preg_replace('/[^0-9.].*/', '', $this->mysql_version);
+		$php_version = $this->php_version;
+		if (empty($locale)) $locale = $this->wp_Lang;
+		$url = "http://api.wordpress.org/core/version-check/1.5/?php=" . $php_version . "&locale=" . $locale . "&mysql=" . $sql_version;
+
+		$handle = @fopen($url,'r');
+		if ($handle) {
+			$ans = array();
+			$num = 0;
+			$pos = 0;
+	    	while (($buffer = fgets($handle, 4096)) !== false) {
+	    		$buffer = trim($buffer);
+	    		if (strlen($buffer) == 0) {
+	    			$num++;
+	    			$pos=0;
+	    		} else {
+	    			$ans[$num][$pos] = $buffer;
+	    			$pos++;
+	    		}
+	    	}
+	    	if (!feof($handle)) {
+	        	echo "Error: unexpected fgets() fail\n";
+	    	}
+	    	fclose($handle);
+		}
+			$ressponce = $ans[0][0];
+			$site_url = $ans[0][1];
+			$download_url = $ans[0][2];
+			$wp_version = $ans[0][3];
+			$download_lang = $ans[0][4];
+//			print_r($ans);
+			if (isset($ans[1])){
+				$en_download_url = $ans[1][2];
+			}
+			if ($locale == $download_lang){
+				$ret = $this->text_indent(sprintf(_AM_XP2_WP_INFO_1,$locale),2);
+				$ret .= $this->text_indent('<a href="'.$download_url.'">' . $download_url .'</a>' ,3);
+				if (!empty($en_download_url)){
+					$ret .= $this->text_indent(_AM_XP2_WP_INFO_4,2);
+					$ret .= $this->text_indent('<a href="'.$en_download_url .'">' . $en_download_url .'</a>' ,3);
+				}
+			} else {
+				$ret = $this->text_indent(sprintf(_AM_XP2_WP_INFO_2,$locale));
+				$ret .= $this->text_indent(_AM_XP2_WP_INFO_3,2);
+				$ret .= $this->text_indent('<a href="http://codex.wordpress.org/WordPress_in_Your_Language" target="	_blank">WordPress_in_Your_Language</a>' ,3);
+				$ret .= $this->text_indent(_AM_XP2_WP_INFO_4,2);
+				$ret .= $this->text_indent('<a href="'.$download_url.'">' . $download_url .'</a>' ,3);
+			}
+			echo $ret;
+		}
+	}
 ?>
