- Timestamp:
- May 18, 2011, 9:07:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Ver3.0/xpressme_integration_kit/class/wpInfo_class.php
r743 r744 9 9 */ 10 10 class wpInfo { 11 var $mod_dirpath; 12 var $mod_name; 13 var $mod_url; 14 15 var $xoops_Lang; 16 var $wp_Lang; 17 var $php_version; 18 var $mysql_version; 11 19 // The language of XOOPS is set as Key of the array. 12 20 // The language of WP is set as Value of the array. 13 var $xoops_Lang;14 var $wp_Lang;15 16 21 var $wp_lang_array = array( 17 'english' => array( 18 'wp_lang' =>'en', 19 'wp_site' =>'http://wordpress.org/', 20 ), 21 22 'japanese' => array( 23 'wp_lang' =>'ja', 24 'wp_site' =>'http://ja.wordpress.org/', 25 ), 26 27 'ja_utf8' => array( 28 'wp_lang' =>'ja', 29 'wp_site' =>'http://ja.wordpress.org/', 30 ), 31 32 'pt-br_utf8' => array( 33 'wp_lang' =>'en', 34 'wp_site' =>'http://br.wordpress.org/', 35 ), 36 22 'english' => 'en_US', 23 'japanese' => 'ja', 24 'ja_utf8' => 'ja', 25 'pt-br_utf8' => 'pt_BR', 37 26 // The key(language of XOOPS) of the following lists has not been set yet. 38 27 'Afrikaans' => 'af', … … 95 84 ); 96 85 97 public function get_wpLang($xoops_Lang = 'english') 98 { 99 $detect_lang = $this->wp_lang_array[$xoops_Lang]['wp_lang']; 100 if (empty($detect_lang)) return 'en'; 101 return $detect_lang; 102 } 103 public function get_download_info() 104 { 105 $check_url = 'http://api.wordpress.org/core/version-check/1.5/?locale='. $this->wp_lang; 106 } 107 } 86 function wpInfo(){ 87 $this->__construct(); 88 } 89 function __construct() { 90 $this->mod_dirpath = dirname(dirname(__FILE__)); 91 $this->mod_name = basename(dirname(dirname(__FILE__))); 92 $this->mod_url = XOOPS_URL . '/modules/'.$this->mod_name; 93 $this->load_lang(); 94 $this->xoops_Lang = @$GLOBALS["xoopsConfig"]['language']; 95 $this->php_version = phpversion(); 96 $xoopsDB =& Database::getInstance(); 97 list($SV) = $xoopsDB->fetchRow($xoopsDB->query('SELECT version()')); 98 $this->mysql_version = $SV; 99 100 $this->get_wpLang(); 101 } 102 function text_indent($text,$num = 1,$css_option='') 103 { 104 $ret = ''; 105 $px = 24 * $num; 106 $ret = '<div style="padding-left:' .$px .'px;'.$css_option.'">'; 107 $ret .= $text . '</div>'; 108 return $ret; 109 } 110 public function load_lang() 111 { 112 $lang = @$GLOBALS["xoopsConfig"]['language']; 113 114 // language file (modinfo.php) 115 if( file_exists( $this->mod_dirpath .'/language/'.$lang.'/admin.php' ) ) { 116 include_once $this->mod_dirpath .'/language/'.$lang.'/admin.php' ; 117 } else if( file_exists( $this->mod_dirpath .'/language/english/admin.php' ) ) { 118 include_once $this->mod_dirpath .'/language/english/admin.php' ; 119 } 120 } 121 122 public function get_php_version() 123 { 124 return $this->php_version; 125 } 126 public function get_mysql_version() 127 { 128 return $this->mysql_version; 129 } 130 public function get_wpLang($xoops_Lang = '') 131 { 132 if(!empty($xoops_Lang)) $this->xoops_Lang = $xoops_Lang; 133 $this->wp_Lang = $this->wp_lang_array[$this->xoops_Lang]; 134 if (empty($this->wp_Lang)) $this->wp_Lang = 'en_US'; 135 return $this->wp_Lang; 136 } 137 public function get_mod_image_link($file_name='') 138 { 139 $link_url = ''; 140 if(!empty($file_name)){ 141 if(file_exists($this->mod_dirpath.'/images/'.$file_name)){ 142 $link_url = '<img alt="'.$file_name.'" src="'. $this->mod_url .'/images/'.$file_name.'" title="'.$file_name.'" align=top>'; 143 } 144 } 145 return $link_url; 146 } 147 148 function is_wpdb_installed(){ 149 $prefix_mod = XOOPS_DB_PREFIX .'_' . preg_replace('/wordpress/','wp',$this->mod_name) . '_'; 150 $xoopsDB =& Database::getInstance(); 151 $sql = "SHOW TABLES LIKE '$prefix_mod%'"; 152 if ($result = $xoopsDB->queryf($sql)){ 153 if($xoopsDB->getRowsNum($result)) return true; 154 } 155 return false; 156 } 157 158 public function is_wp_file_found() 159 { 160 if (!file_exists($this->mod_dirpath . '/wp-settings.php')){ 161 return false; 162 } 163 return true; 164 } 165 public function get_download_info($locale='') 166 { 167 $sql_version = preg_replace('/[^0-9.].*/', '', $this->mysql_version); 168 $php_version = $this->php_version; 169 if (empty($locale)) $locale = $this->wp_Lang; 170 $url = "http://api.wordpress.org/core/version-check/1.5/?php=" . $php_version . "&locale=" . $locale . "&mysql=" . $sql_version; 171 172 $handle = @fopen($url,'r'); 173 if ($handle) { 174 $ans = array(); 175 $num = 0; 176 $pos = 0; 177 while (($buffer = fgets($handle, 4096)) !== false) { 178 $buffer = trim($buffer); 179 if (strlen($buffer) == 0) { 180 $num++; 181 $pos=0; 182 } else { 183 $ans[$num][$pos] = $buffer; 184 $pos++; 185 } 186 } 187 if (!feof($handle)) { 188 echo "Error: unexpected fgets() fail\n"; 189 } 190 fclose($handle); 191 } 192 $ressponce = $ans[0][0]; 193 $site_url = $ans[0][1]; 194 $download_url = $ans[0][2]; 195 $wp_version = $ans[0][3]; 196 $download_lang = $ans[0][4]; 197 // print_r($ans); 198 if (isset($ans[1])){ 199 $en_download_url = $ans[1][2]; 200 } 201 if ($locale == $download_lang){ 202 $ret = $this->text_indent(sprintf(_AM_XP2_WP_INFO_1,$locale),2); 203 $ret .= $this->text_indent('<a href="'.$download_url.'">' . $download_url .'</a>' ,3); 204 if (!empty($en_download_url)){ 205 $ret .= $this->text_indent(_AM_XP2_WP_INFO_4,2); 206 $ret .= $this->text_indent('<a href="'.$en_download_url .'">' . $en_download_url .'</a>' ,3); 207 } 208 } else { 209 $ret = $this->text_indent(sprintf(_AM_XP2_WP_INFO_2,$locale)); 210 $ret .= $this->text_indent(_AM_XP2_WP_INFO_3,2); 211 $ret .= $this->text_indent('<a href="http://codex.wordpress.org/WordPress_in_Your_Language" target=" _blank">WordPress_in_Your_Language</a>' ,3); 212 $ret .= $this->text_indent(_AM_XP2_WP_INFO_4,2); 213 $ret .= $this->text_indent('<a href="'.$download_url.'">' . $download_url .'</a>' ,3); 214 } 215 echo $ret; 216 } 217 } 108 218 ?>
Note: See TracChangeset
for help on using the changeset viewer.