Index: /trunk/extras/xpress_i18n/portuguese-br/xpressme_modules_root/language/pt-br_utf8/modinfo.php
===================================================================
--- /trunk/extras/xpress_i18n/portuguese-br/xpressme_modules_root/language/pt-br_utf8/modinfo.php	(revision 551)
+++ /trunk/extras/xpress_i18n/portuguese-br/xpressme_modules_root/language/pt-br_utf8/modinfo.php	(revision 552)
@@ -52,4 +52,5 @@
 	define("_MI_XP2_BLOCK_GLOBAL_POSTS","Posts recentes(Todo o blog)");
 	define("_MI_XP2_BLOCK_GLOBAL_COMM","Comentários recentes(Todo o blog)");
+	define("_MI_XP2_BLOCK_GLOBAL_POPU","Posts mais lidos(Todo o blog)");
 
 	// Notify Categories
Index: /trunk/extras/xpress_i18n/template/xpressme_modules_root/language/english/modinfo.php
===================================================================
--- /trunk/extras/xpress_i18n/template/xpressme_modules_root/language/english/modinfo.php	(revision 551)
+++ /trunk/extras/xpress_i18n/template/xpressme_modules_root/language/english/modinfo.php	(revision 552)
@@ -52,4 +52,5 @@
 	define("_MI_XP2_BLOCK_GLOBAL_POSTS","Recent Posts(All blogs)");
 	define("_MI_XP2_BLOCK_GLOBAL_COMM","Recent Comments(All blogs)");
+	define("_MI_XP2_BLOCK_GLOBAL_POPU","Popular post(All blogs)");
 
 	// Notify Categories
Index: /trunk/xpressme_integration_kit/blocks/global_popular_posts_block.php
===================================================================
--- /trunk/xpressme_integration_kit/blocks/global_popular_posts_block.php	(revision 552)
+++ /trunk/xpressme_integration_kit/blocks/global_popular_posts_block.php	(revision 552)
@@ -0,0 +1,49 @@
+<?php
+if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
+$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
+
+eval( '
+function b_'.$mydirname.'_global_popular_show($options){
+	return _b_global_popular_show($options) ;
+}
+function b_'.$mydirname.'_global_popular_edit($options){
+	return _b_global_popular_edit($options) ;
+}
+' ) ;
+
+if( ! defined( 'XPRESS_GLOBAL_POPULAR_BLOCK_INCLUDED' ) ) {
+	define( 'XPRESS_GLOBAL_POPULAR_BLOCK_INCLUDED' , 1 ) ;
+	function _b_global_popular_edit($options)
+	{
+		$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
+		$this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_grobal_popular_posts_block.html' : trim( $options[1] );
+		$disp_count = empty( $options[2] ) ? '10' : $options[2] ;
+		$show_month_range = empty( $options[3] ) ? '0' : $options[3] ;
+		$date_format = empty( $options[4] ) ? '' : $options[4] ;
+		$time_format = empty( $options[5] ) ? '' : $options[5] ;
+
+		$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+		
+		require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
+		$form  = javascript_check();
+		$form .= "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n";
+		$form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
+		$form .= "<br />\n";
+		$form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n";
+		$form .= _MB_XP2_MONTH_RANGE .": <input type='text' name='options[3]' value='" . $show_month_range . "' /><br />\n";
+		$form .= _MB_XP2_DATE_FORMAT .": <input type='text' name='options[4]' value='" . $date_format . "' /><br />\n";
+		$form .= _MB_XP2_TIME_FORMAT .": <input type='text' name='options[5]' value='" . $time_format . "' /><br />\n";
+		return $form;
+	}
+
+	function _b_global_popular_show($options)
+	{
+		$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
+		$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+		$block_function_name = basename( __FILE__ );
+		
+		require_once $mydirpath.'/include/xpress_block_render.php';
+		return xpress_block_render($mydirname,$block_function_name,$options);
+	}
+}
+?>
Index: /trunk/xpressme_integration_kit/include/xpress_templates_make.php
===================================================================
--- /trunk/xpressme_integration_kit/include/xpress_templates_make.php	(revision 551)
+++ /trunk/xpressme_integration_kit/include/xpress_templates_make.php	(revision 552)
@@ -110,4 +110,5 @@
 		'global_recent_posts_list_block.html' ,
 		'global_recent_comments_block.html',
+		'global_popular_posts_block.html',
 		'index.html',
 	);
Index: /trunk/xpressme_integration_kit/language/english/modinfo.php
===================================================================
--- /trunk/xpressme_integration_kit/language/english/modinfo.php	(revision 551)
+++ /trunk/xpressme_integration_kit/language/english/modinfo.php	(revision 552)
@@ -52,4 +52,5 @@
 	define("_MI_XP2_BLOCK_GLOBAL_POSTS","Recent Posts(All blogs)");
 	define("_MI_XP2_BLOCK_GLOBAL_COMM","Recent Comments(All blogs)");
+	define("_MI_XP2_BLOCK_GLOBAL_POPU","Popular post(All blogs)");
 
 	// Notify Categories
Index: /trunk/xpressme_integration_kit/language/ja_utf8/modinfo.php
===================================================================
--- /trunk/xpressme_integration_kit/language/ja_utf8/modinfo.php	(revision 551)
+++ /trunk/xpressme_integration_kit/language/ja_utf8/modinfo.php	(revision 552)
@@ -52,4 +52,5 @@
 	define("_MI_XP2_BLOCK_GLOBAL_POSTS","最近の記事(全ブログ)");
 	define("_MI_XP2_BLOCK_GLOBAL_COMM","最近のコメント(全ブログ)");
+	define("_MI_XP2_BLOCK_GLOBAL_POPU","人気記事リスト(全ブログ)");
 
 	// Notify Categories
Index: /trunk/xpressme_integration_kit/language/japanese/modinfo.php
===================================================================
--- /trunk/xpressme_integration_kit/language/japanese/modinfo.php	(revision 551)
+++ /trunk/xpressme_integration_kit/language/japanese/modinfo.php	(revision 552)
@@ -52,4 +52,5 @@
 	define("_MI_XP2_BLOCK_GLOBAL_POSTS","ºÇ¶á¤Îµ­»ö(Á´¥Ö¥í¥°)");
 	define("_MI_XP2_BLOCK_GLOBAL_COMM","ºÇ¶á¤Î¥³¥á¥ó¥È(Á´¥Ö¥í¥°)");
+	define("_MI_XP2_BLOCK_GLOBAL_POPU","¿Íµ¤µ­»ö¥ê¥¹¥È(Á´¥Ö¥í¥°)");
 
 	// Notify Categories
Index: /trunk/xpressme_integration_kit/templates/source/global_popular_posts_block.html
===================================================================
--- /trunk/xpressme_integration_kit/templates/source/global_popular_posts_block.html	(revision 552)
+++ /trunk/xpressme_integration_kit/templates/source/global_popular_posts_block.html	(revision 552)
@@ -0,0 +1,37 @@
+<{* **************************  usage ****************************
+ 	The template tag of the following list can be used. 
+ 		<{$block.err_message}> 					// When the block cannot be displayed, this outputs the reason. Please do not delete it.
+		<{$block.data_count}>					// The number of contents is displayed. 
+		<{$block.contents}>						// Data array of contents. 
+		// Examples of <{$block.contents}>
+		<{foreach from=$block.contents item=content}>	// Loop
+		<{$content.post_id}>					// Displays the numeric ID of the post.
+		<{$content.post_title}>					// Displays the post's permalink, where the link text value is the posts title name.
+		<{$content.post_date}>					// Displays the published date of a post. Format at date set by general setting of Wordpress.
+		<{$content.post_time}>					// Displays the published time of a post. Format at time set by general setting of Wordpress.
+		<{$content.post_date_time}>				// Displays the published date-time of a post.
+		<{$content.post_modified_date}>			// Displays the modified date of a post. Format at date set by general setting of Wordpress.
+		<{$content.post_modified_time}>			// Displays the modified date of a post. Format at date set by general setting of Wordpress.
+		<{$content.post_modified_date_time}>	// Displays the modified date-time of a post.
+		<{$content.post_author}>				// Displays the author's archive link, where the link text value is the user's Display name. 
+		<{$content.post_category}>				// Displays a link to the category or categories a post belongs to.
+		<{$content.post_tags}>					// Displays a link to the tag or tags a post belongs to.
+		<{$content.post_views}>					// Displays the number of posts viewer.
+		<{$content.comment_link}>				// Displays a link to the comments popup window if comments_popup_script() is used, otherwise it displays a normal link to comments. 
+		<{$content.trackback_url}>				// Displays the trackback URL for the current post.
+		<{/foreach}>							// End of Loop
+************************* End of usage ************************ *}>
+<{* Start Template *}>
+
+<div class="xpress_block">
+	<{$block.err_message}>
+	<div class="xpress_global_popular_post_block">
+		<ul>
+		<{foreach from=$block.contents item=content}>
+			<li>
+			<{$content.post_title}>&nbsp;(<{$content.post_views}>)
+			</li>
+		<{/foreach}>
+		</ul>
+	</div>
+</div>
Index: /trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php
===================================================================
--- /trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 551)
+++ /trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 552)
@@ -146,5 +146,5 @@
 		
 		// Avoid the failure of the operation when switch_to_blog() and other plugin code is called on the admin page.
-		$excludes = '|global_recent_posts_list_block.php|my_.*_block.php|global_recent_comments_block.php|';
+		$excludes = '|global_recent_posts_list_block.php|my_.*_block.php|global_recent_comments_block.php|global_popular_posts_block.php|';
 		if (preg_match('/' . $excludes . '/' , $func_file)) continue;
 		
Index: /trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/global_popular_posts_block_theme.php
===================================================================
--- /trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/global_popular_posts_block_theme.php	(revision 552)
+++ /trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/global_popular_posts_block_theme.php	(revision 552)
@@ -0,0 +1,193 @@
+<?php
+// Block Version: 1.0
+function global_popular_posts_block($options)
+{
+	$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
+	$this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_block_popular.html' : trim( $options[1] );
+	$disp_count = empty( $options[2] ) ? '10' : $options[2] ;
+	$show_month_range = empty( $options[3] ) ? '0' : $options[3] ;
+	$date_format = empty( $options[4] ) ? '' : $options[4] ;
+	$time_format = empty( $options[5] ) ? '' : $options[5] ;
+	
+	$selected = explode(',' , $cat_select);
+
+	$mydirpath = get_xpress_dir_path();
+	
+	if (empty($date_format)) $date_format = get_settings('date_format');
+	if (empty($time_format)) $time_format = get_settings('time_format');
+	
+	$cat_select;
+	$block = array();
+	$item_no = 0;	
+	
+	$selected_author_id = xpress_selected_author_id('echo=0');	
+	
+	$data_array = array();
+
+	global $wpdb,$wp_query,$xoops_db,$wp_rewrite;
+	
+	if (xpress_is_multiblog()){
+		$blogs = get_blog_list(0,'all');
+		foreach ($blogs AS $blog) {
+			switch_to_blog($blog['blog_id']);
+			$wp_rewrite->init();
+
+			$db_prefix = get_wp_prefix();
+			
+			$post_tb = $wpdb->posts;
+			$view_tb = $db_prefix . 'views';
+			$user_tb = $db_prefix . 'users';
+			
+			$term_relationships_tb = $wpdb->term_relationships;	// upper 2.3
+			$term_taxonomy = $wpdb->term_taxonomy;				// upper 2.3
+			$terms_tb = $wpdb->terms;							// upper 2.3
+
+			$post2cat_tb = $wpdb->post2cat; 					//under 2.3
+			$categories_tb = $wpdb->categories; 				//under 2.3
+			
+			include ($mydirpath . '/wp-includes/version.php');
+				
+			$select = "SELECT $view_tb.post_views, $post_tb.ID, $post_tb.post_title, $post_tb.post_date";				
+			if ($wp_db_version >= 6124){
+		 		$from  = " FROM (((";
+		 		$from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)";
+		 		$from .= " INNER JOIN $term_relationships_tb ON $post_tb.ID = $term_relationships_tb.object_id)";
+		 		$from .= " INNER JOIN $term_taxonomy ON $term_relationships_tb.term_taxonomy_id = $term_taxonomy.term_taxonomy_id)";
+		 		$from .= " INNER JOIN $terms_tb ON $term_taxonomy.term_id = $terms_tb.term_id ";
+		 		
+			 	$where = " WHERE $post_tb.post_type = 'post' AND $post_tb.post_status = 'publish'";
+			} else {
+				$from  = " FROM ((";
+				$from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)";
+				$from .= " LEFT JOIN $post2cat_tb ON $post_tb.ID = $post2cat_tb.post_id)";
+				$from .= " INNER JOIN $user_tb ON $post_tb.post_author = $user_tb.ID";
+				
+				$where = " WHERE ($post_tb.post_status = 'publish') AND  (UNIX_TIMESTAMP($post_tb.post_date) <= UNIX_TIMESTAMP())" ;
+				
+			}
+				
+
+			if ($show_month_range > 0) {
+			 		$where .= " AND (UNIX_TIMESTAMP($post_tb.post_date) >= UNIX_TIMESTAMP(DATE_ADD(CURRENT_DATE, INTERVAL -$show_month_range month)))";
+			}
+			$order_limmit = " GROUP BY $post_tb.ID ORDER BY $view_tb.post_views DESC LIMIT 0, $disp_count";
+			$sql = $select . $from . $where . $order_limmit;
+
+			$populars = $wpdb->get_results($sql);
+			
+			foreach ($populars as $popular){
+				$wp_query->in_the_loop = true;		//for use the_tags() in multi lopp 
+				$r = new WP_Query("p=$popular->ID");
+				if($r->have_posts()){
+					$r->the_post();
+					ob_start();
+						the_ID();
+						$post_id = ob_get_contents();
+					ob_end_clean();
+					
+					ob_start();
+						the_title();
+						$title = ob_get_contents();
+					ob_end_clean();
+					
+					ob_start();
+						the_permalink();
+						$permalink = ob_get_contents();
+					ob_end_clean();					
+					
+					ob_start();
+						the_author_posts_link();
+						$author = ob_get_contents();
+					ob_end_clean();
+					
+					ob_start();
+						the_category(' &bull; ');
+						$category = ob_get_contents();
+					ob_end_clean();	
+					
+					if (function_exists('the_tags')){
+						ob_start();
+							the_tags(__('Tags:', 'xpress') . ' ',' &bull; ','');
+							$tags = ob_get_contents();
+						ob_end_clean();	
+					} else {
+						$tags = '';
+					}
+					
+					ob_start();
+						the_modified_date($date_format);
+						$post_modified_date = ob_get_contents();
+					ob_end_clean();
+						
+					ob_start();
+						the_modified_date($time_format);
+						$post_modified_time = ob_get_contents();
+					ob_end_clean();
+					
+					ob_start();
+						the_time($date_format);
+						$post_date = ob_get_contents();
+					ob_end_clean();
+					
+					ob_start();
+						the_time($time_format);
+						$post_time = ob_get_contents();
+					ob_end_clean();
+					
+					
+					ob_start();
+						comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
+						$comments_popup_link = ob_get_contents();
+					ob_end_clean();
+					
+
+					$post_title = '<a href="' . $permalink . '">' . $title . '</a>';
+					$post_date_time = $post_date . ' ' . $post_time ;
+					$post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
+					$trackback_url = trackback_url(false);
+					$post_views = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
+					$post_views_num = (int) xpress_post_views_count("post_id={$post_id}&format=%d&echo=0");
+					$row_data = array(
+						'post_id'		=> $post_id ,
+						'post_title'	=> $post_title ,
+						'post_date' => $post_date ,
+						'post_time' => $post_time ,
+						'post_date_time' => $post_date_time ,
+						'post_modified_date' => $post_modified_date ,
+						'post_modified_time' => $post_modified_time ,
+						'post_modified_date_time' => $post_modified_date_time ,
+						'post_author' 	=> $author ,
+						'post_category' 	=> $category ,	
+						'post_tags' 		=> $tags,
+						'post_views' 		=> $post_views,
+						'post_views_num'	=> $post_views_num,
+						'comment_link' 	=> $comments_popup_link ,
+						'trackback_url' => $trackback_url
+					);
+					$data_array[] = $row_data;
+				}
+			}  // end of foreach
+			restore_current_blog();
+			$wp_rewrite->init();
+		}
+	}
+	
+	usort($data_array, "post_views_cmp");
+	if (!empty($disp_count)){
+		$data_array = array_slice($data_array,0,$disp_count);
+	}
+
+	$item_no = 0;
+	foreach ($data_array as $data) {
+		$block['contents']['item'.$item_no] = $data;
+		$item_no++;
+	}
+	$block['data_count'] = $item_no;
+
+	return $block ;
+}
+function post_views_cmp($a, $b)
+{
+    return $b['post_views_num'] - $a['post_views_num'];
+}
+?>
Index: /trunk/xpressme_integration_kit/xoops_version.php
===================================================================
--- /trunk/xpressme_integration_kit/xoops_version.php	(revision 551)
+++ /trunk/xpressme_integration_kit/xoops_version.php	(revision 552)
@@ -392,5 +392,15 @@
 		'func_num'		=> $b_no,	
 	);
-
+	$b_no++;
+	$modversion['blocks'][$b_no] = array(
+		'file' 			=> 'global_popular_posts_block.php' ,
+		'name' 			=> constant('_MI_XP2_BLOCK_GLOBAL_POPU') ,
+		'description'	=> '' ,
+		'show_func' 	=> "b_". $mydirname . "_global_popular_show" ,
+		'edit_func' 	=> "b_". $mydirname . "_global_popular_edit" ,
+		'options'		=> $mydirname. '||10|0||' ,
+		'can_clone'		=> true ,
+		'func_num'		=> $b_no,	
+	);
 }
 
