Index: trunk/blocks/block_common.php
===================================================================
--- trunk/blocks/block_common.php	(revision 35)
+++ trunk/blocks/block_common.php	(revision 35)
@@ -0,0 +1,70 @@
+<?php
+
+if( ! function_exists( 'yes_no_radio_option' ) ) :
+function yes_no_radio_option($option_name,$label,$value,$yes = '',$no= ''){
+	if (empty( $yes ))  $yes = _YES ;
+	if (empty( $no ))  $no = _NO ;
+	$form = $label.' : ';
+	if ($value){
+		$form .= "<input type='radio' name='". $option_name . "' value='1' checked='checked' />" . $yes. "; " ;
+		$form .= "<input type='radio' name='". $option_name . "' value='0' />". $no ;
+	}else{
+		$form .= "<input type='radio' name='". $option_name . "' value='1' />" . $yes. "; " ;
+		$form .= "<input type='radio' name='". $option_name . "' value='0' checked='checked' />". $no ;
+	}		
+    return $form;
+	
+}
+endif;
+
+if(!function_exists("dropdown_cats_options")):
+function dropdown_cats_options($sort_column = 'ID', $sort_order = 'asc', $selected=array()) 
+{
+    global $wpdb, $wp_query, $wp_rewrite, $wp_roles;
+
+	$path = dirname(dirname(__FILE__)) . '/';
+	if (file_exists($path . 'wp-load.php')) {
+		require_once $path . 'wp-load.php';
+	} else {
+		require_once $path . 'wp-config.php';
+	}
+
+	$myts =& MyTextSanitizer::getInstance();
+    $selected = is_array($selected)?$selected:array($selected);
+    $sort_column = 'cat_'.$sort_column;
+	if ($wp_db_version < 6124) {
+		$query = "
+	    	SELECT cat_ID, cat_name, category_nicename,category_parent 
+	    	FROM $wpdb->categories 
+	    	WHERE cat_ID > 0 
+	        ";
+	$query .= " ORDER BY $sort_column $sort_order";
+
+    } else {
+    	$query = "
+			SELECT $wpdb->terms.term_id as cat_ID , $wpdb->terms.name as cat_name , $wpdb->term_taxonomy.taxonomy 
+			FROM $wpdb->terms LEFT JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id 
+			WHERE $wpdb->term_taxonomy.taxonomy = 'category' 
+        ";
+		$query .= " ORDER BY $sort_column $sort_order";
+    }
+
+    $categories = $wpdb->get_results($query);
+    if ($categories) {
+        foreach ($categories as $category) {
+            $cat_name = apply_filters('list_cats', $category->cat_name, $category);
+            echo "\t<option value=\"".$category->cat_ID."\"";
+            if (in_array($category->cat_ID, $selected))
+                echo ' selected="selected"';
+            echo '>';
+            echo $myts->htmlspecialchars($cat_name);
+            echo "</option>\n";
+        }
+    }
+    return;
+}
+endif;
+
+
+
+?>
Index: trunk/blocks/index.html
===================================================================
--- trunk/blocks/index.html	(revision 35)
+++ trunk/blocks/index.html	(revision 35)
@@ -0,0 +1,1 @@
+ <script>history.go(-1);</script>
Index: trunk/blocks/xpress_block_recent_comments.php
===================================================================
--- trunk/blocks/xpress_block_recent_comments.php	(revision 35)
+++ trunk/blocks/xpress_block_recent_comments.php	(revision 35)
@@ -0,0 +1,158 @@
+<?php
+if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
+$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
+
+eval( '
+function b_'.$mydirname.'_comments_show($options){
+	return _b_comments_show($options) ;
+}
+function b_'.$mydirname.'_comments_edit($options){
+	return _b_comments_edit($options) ;
+}
+' ) ;
+
+
+if( ! defined( 'XPRESS_COMMENTS_BLOCK_INCLUDED' ) ) {
+	define( 'XPRESS_COMMENTS_BLOCK_INCLUDED' , 1 ) ;
+	function _b_comments_edit($options)
+	{
+		$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
+		$disp_count = empty( $options[1] ) ? '10' : $options[1] ;
+		$disp_length = empty( $options[2] ) ? '30' : $options[2] ;
+	    $selected = array_slice($options,5); // get allowed cats
+		$this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_comments.html' : trim( $options[4] );
+		$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+
+		require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
+		
+		$form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
+		$form .= _MB_XPRESS_COUNT .": <input type='text' name='options[1]' value='" . $disp_count . "' /><br />";
+		$form .= _MB_XPRESS_LENGTH .": <input type='text' name='options[2]' value='" . $disp_length . "' />";
+	    $form .= "<br /><br />" . _MB_XPRESS_COM_TYPE ;
+	    $isAll = (count($selected)==0||empty($selected[0]))?true:false;
+	    $form .= "<br />&nbsp;&nbsp;<select name=\"options[]\" multiple=\"multiple\">";
+		    $form .= "<option value=\"0\" ";
+		    if ($isAll) $form .= " selected=\"selected\"";
+		    $form .= ">"._MB_XPRESS_ALL ."</option>";
+
+		    $form .= "<option value=\"1\" ";
+		    if (in_array(1, $selected))
+				$form .= " selected=\"selected\"";
+		    $form .= ">"._MB_XPRESS_COMMENT ."</option>";
+
+		    $form .= "<option value=\"2\" ";
+		    if (in_array(2, $selected))
+				$form .= " selected=\"selected\"";
+		    $form .= ">"._MB_XPRESS_TRUCKBACK ."</option>";
+
+		    $form .= "<option value=\"3\" ";
+		    if (in_array(3, $selected))
+				$form .= " selected=\"selected\"";
+		    $form .= ">"._MB_XPRESS_PINGBACK ."</option>";
+		$form .= "</select><br />";
+		//	    $form .="<br /><input type='text' size='60' name='options[5]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' />";
+
+
+		return $form;
+	}
+	
+	function _b_comments_show($options)
+	{
+		$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
+		$disp_count = empty( $options[1] ) ? '10' : $options[1] ;
+		$disp_length = empty( $options[2] ) ? '30' : $options[2] ;
+		$selected = array_slice($options,5); // get allowed cats
+		$this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_comments.html' : trim( $options[4] );
+		$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+		
+
+		$myts =& MyTextSanitizer::getInstance();
+
+		$this_url = '/modules/'. $mydirname;
+		$call_url = $_SERVER['REQUEST_URI'];
+		
+		$disp_all = in_array('0',$selected);
+		$disp_comment = in_array('1',$selected);
+		$disp_trackback = in_array('2',$selected);
+		$disp_pingback = in_array('3',$selected);
+		
+		$type_select = '';
+		if (!$disp_all){			
+			if ($disp_comment){
+				$in_where =  "''";
+			}
+			if ($disp_trackback){
+				if (empty($in_where)) $in_where =  "'trackback' "; else $in_where .=  ",'trackback'";
+			}
+					
+			if ($disp_pingback){
+				if (empty($in_where)) $in_where =  "'pingback' "; else $in_where .=  ",'pingback'";
+			}
+			
+			if (! empty($in_where)){
+				$type_select = " AND comment_type IN($in_where) ";				
+			}
+		}
+		
+		global $wpdb;
+		$block = array( 
+		'mydirname' => $mydirname ,
+		'mod_url' => XOOPS_URL.'/modules/'.$mydirname ,
+		) ;
+			
+		if (!is_null($wpdb)){
+
+			$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments LEFT JOIN $wpdb->posts ON  $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_type = 'post'  AND post_status = 'publish' $type_select ORDER BY comment_date_gmt DESC LIMIT $disp_count");
+			$format = get_settings('date_format') . ' ' . get_settings('time_format');				
+
+			if ( $comments ) {
+				$output .= '<ul>';
+				foreach ($comments as $comment){
+					$comment_content = $comment->comment_content;
+					$comment_excerpt = ($disp_length>0 ? xoops_substr($comment_content, 0, $disp_length): $comment->comment_content);
+
+					$comment_link = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID ;
+					$comment_title = $comment_excerpt;
+					$comment_title_link = "<a href='$comment_link' rel='external nofollow' class='url'>$comment_tytle</a>";
+
+					$post_link = get_comment_link($comment->comment_ID);
+					$post_title = get_the_title($comment->comment_post_ID);
+					$post_title_link = '<a href="'. $post_link . '">' . $post_title . '</a>';
+					
+					$author_link = $comment->comment_author_url;
+					$author_name = $comment->comment_author;
+					$author_name_link = (( empty( $author_link ) || 'http://' == $author_link ) ? $author_name : "<a href='$author_link' rel='external nofollow' class='url'>$author_name</a>");
+
+					$comment_type = (empty($comment->comment_type) ? 'comment': $comment->comment_type);
+					$from_auther_to_post = sprintf(__('%1$s on %2$s'), $author_name_link , $post_title_link );
+
+					$row_data = array(
+						'comment_ID' 		=> $comment->comment_ID ,
+						'comment_post_ID'	=> $comment->comment_post_ID ,
+						'comment_date' 		=> $comment->comment_date ,
+						'comment_content' 	=> $comment_content ,
+						'comment_excerpt' 	=> $comment_excerpt ,	
+						'comment_link' 		=> $comment_link,
+						'comment_title' 	=> $ccomment_title ,
+						'comment_title_link' => $comment_title_link ,
+						'post_link' 		=> $post_link,
+						'post_title' 		=> $post_title,
+						'post_title_link' 	=> $post_title_link,
+						'author_link' 		=> $author_link,
+						'author_name' 		=> $author_name,
+						'author_name_link' 	=> $author_name_link,		
+						'comment_type' 		=> $comment_type,																																		
+						'from_auther_to_post' => $from_auther_to_post
+					);
+					
+					$block['contents'][] = $row_data;
+				}
+			}
+		} else {
+//			$block['contents'] = "out of  module";
+		}
+			return $block ;
+
+	}
+}
+?>
Index: trunk/include/xml.php
===================================================================
--- trunk/include/xml.php	(revision 35)
+++ trunk/include/xml.php	(revision 35)
@@ -0,0 +1,117 @@
+<?php
+###################################################################################
+#
+# XML Library, by Keith Devens, version 1.2b
+# http://keithdevens.com/software/phpxml
+#
+# This code is Open Source, released under terms similar to the Artistic License.
+# Read the license at http://keithdevens.com/software/license
+#
+###################################################################################
+
+###################################################################################
+# XML_unserialize: takes raw XML as a parameter (a string)
+# and returns an equivalent PHP data structure
+###################################################################################
+function & XML_unserialize(&$xml){
+	$xml_parser = &new XML();
+	$data = &$xml_parser->parse($xml);
+	$xml_parser->destruct();
+	return $data;
+}
+###################################################################################
+# XML_serialize: serializes any PHP data structure into XML
+# Takes one parameter: the data to serialize. Must be an array.
+###################################################################################
+function & XML_serialize(&$data, $level = 0, $prior_key = NULL){
+	if($level == 0){ ob_start(); echo '<?xml version="1.0" ?>',"\n"; }
+	while(list($key, $value) = each($data))
+		if(!strpos($key, ' attr')) #if it's not an attribute
+			#we don't treat attributes by themselves, so for an empty element
+			# that has attributes you still need to set the element to NULL
+
+			if(is_array($value) and array_key_exists(0, $value)){
+				XML_serialize($value, $level, $key);
+			}else{
+				$tag = $prior_key ? $prior_key : $key;
+				echo str_repeat("\t", $level),'<',$tag;
+				if(array_key_exists("$key attr", $data)){ #if there's an attribute for this element
+					while(list($attr_name, $attr_value) = each($data["$key attr"]))
+						echo ' ',$attr_name,'="',htmlspecialchars($attr_value),'"';
+					reset($data["$key attr"]);
+				}
+
+				if(is_null($value)) echo " />\n";
+				elseif(!is_array($value)) echo '>',htmlspecialchars($value),"</$tag>\n";
+				else echo ">\n",XML_serialize($value, $level+1),str_repeat("\t", $level),"</$tag>\n";
+			}
+	reset($data);
+	if($level == 0){ $str = &ob_get_contents(); ob_end_clean(); return $str; }
+}
+###################################################################################
+# XML class: utility class to be used with PHP's XML handling functions
+###################################################################################
+class XML{
+	var $parser;   #a reference to the XML parser
+	var $document; #the entire XML structure built up so far
+	var $parent;   #a pointer to the current parent - the parent will be an array
+	var $stack;    #a stack of the most recent parent at each nesting level
+	var $last_opened_tag; #keeps track of the last tag opened.
+
+	function XML(){
+ 		$this->parser = &xml_parser_create();
+		xml_parser_set_option(&$this->parser, XML_OPTION_CASE_FOLDING, false);
+		xml_set_object(&$this->parser, &$this);
+		xml_set_element_handler(&$this->parser, 'open','close');
+		xml_set_character_data_handler(&$this->parser, 'data');
+	}
+	function destruct(){ xml_parser_free(&$this->parser); }
+	function & parse(&$data){
+		$this->document = array();
+		$this->stack    = array();
+		$this->parent   = &$this->document;
+		return xml_parse(&$this->parser, &$data, true) ? $this->document : NULL;
+	}
+	function open(&$parser, $tag, $attributes){
+		$this->data = ''; #stores temporary cdata
+		$this->last_opened_tag = $tag;
+		if(is_array($this->parent) and array_key_exists($tag,$this->parent)){ #if you've seen this tag before
+			if(is_array($this->parent[$tag]) and array_key_exists(0,$this->parent[$tag])){ #if the keys are numeric
+				#this is the third or later instance of $tag we've come across
+				$key = count_numeric_items($this->parent[$tag]);
+			}else{
+				#this is the second instance of $tag that we've seen. shift around
+				if(array_key_exists("$tag attr",$this->parent)){
+					$arr = array('0 attr'=>&$this->parent["$tag attr"], &$this->parent[$tag]);
+					unset($this->parent["$tag attr"]);
+				}else{
+					$arr = array(&$this->parent[$tag]);
+				}
+				$this->parent[$tag] = &$arr;
+				$key = 1;
+			}
+			$this->parent = &$this->parent[$tag];
+		}else{
+			$key = $tag;
+		}
+		if($attributes) $this->parent["$key attr"] = $attributes;
+		$this->parent  = &$this->parent[$key];
+		$this->stack[] = &$this->parent;
+	}
+	function data(&$parser, $data){
+		if($this->last_opened_tag != NULL) #you don't need to store whitespace in between tags
+			$this->data .= $data;
+	}
+	function close(&$parser, $tag){
+		if($this->last_opened_tag == $tag){
+			$this->parent = $this->data;
+			$this->last_opened_tag = NULL;
+		}
+		array_pop($this->stack);
+		if($this->stack) $this->parent = &$this->stack[count($this->stack)-1];
+	}
+}
+function count_numeric_items(&$array){
+	return is_array($array) ? count(array_filter(array_keys($array), 'is_numeric')) : 0;
+}
+?>
Index: trunk/include/xpress_chache.php
===================================================================
--- trunk/include/xpress_chache.php	(revision 35)
+++ trunk/include/xpress_chache.php	(revision 35)
@@ -0,0 +1,49 @@
+<?php
+	
+if(!function_exists("xpress_block_cache_set")):
+    function xpress_block_cache_set($mydirname,$collation_key)
+    {
+		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
+		$cache_time = 0;
+        $filename = $cache_dir .$mydirname . '_' . $collation_key;
+        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) {
+            return file_get_contents($filename);
+        } else {
+			return '';
+		}
+    } 
+endif;
+
+if(!function_exists("xpress_cache_make")):
+    function xpress_cache_make($mydirname,$collation_key,$content)
+    {
+		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
+		$cache_time = 0;
+
+        $filename = $cache_dir .$mydirname . '_' . $collation_key;
+        if ((time() - @filemtime($filename)) > $cache_time) {
+            $fp = fopen($filename, "w");
+            flock($fp, 2);
+            fputs($fp, $content);
+            fclose($fp);
+        } 
+    } 
+endif;
+
+if(!function_exists("xpress_block_cache_clear")):
+    function xpress_cache_clear($mydirname)
+    {
+		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
+		$cache_time = 0;
+        if ($dh = opendir($cache_dir)) {
+            while (($file = readdir($dh)) !== false) {
+                if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) {
+                    unlink($cache_dir.$file);
+                } 
+            } 
+            closedir($dh);
+        } 
+    } 
+endif;
+
+?>
Index: trunk/language/ja_utf8/blocks.php
===================================================================
--- trunk/language/ja_utf8/blocks.php	(revision 34)
+++ trunk/language/ja_utf8/blocks.php	(revision 35)
@@ -2,5 +2,13 @@
 if( ! defined( 'XPRESS_BLOCK_LANG_INCLUDED' ) ) {
 	define( 'XPRESS_BLOCK_LANG_INCLUDED' , 1 ) ;
-
+	define("_MB_XPRESS_COUNT",'表示数');
+	define("_MB_XPRESS_LENGTH","長さ");
+	define("_MB_XPRESS_COMM_DISP_AUTH","コメント投稿者を表示する");
+	define("_MB_XPRESS_COMM_DISP_TYPE","コメントタイプを表示する");
+	define("_MB_XPRESS_COM_TYPE","表示するコメントのタイプを選択");
+	define("_MB_XPRESS_COMMENT","コメント");
+	define("_MB_XPRESS_TRUCKBACK","トラックバック");
+	define("_MB_XPRESS_PINGBACK","ピンバック");
+	define("_MB_XPRESS_ALL","すべて");
 }
 ?>
Index: trunk/language/ja_utf8/modinfo.php
===================================================================
--- trunk/language/ja_utf8/modinfo.php	(revision 34)
+++ trunk/language/ja_utf8/modinfo.php	(revision 35)
@@ -12,4 +12,7 @@
 	define("_MI_XPRESS_MENU_POST_NEW","新規投稿");
 	define("_MI_XPRESS_MENU_EDIT","投稿管理");
+
+	// Block Name
+	define("_MI_XPRESS_BLOCK_COMMENTS","最近のコメント");
 }
 ?>
Index: trunk/templates/blocks/xpress_block_recent_comments.html
===================================================================
--- trunk/templates/blocks/xpress_block_recent_comments.html	(revision 35)
+++ trunk/templates/blocks/xpress_block_recent_comments.html	(revision 35)
@@ -0,0 +1,22 @@
+<ul class="xpress_recent_comments">
+	<{foreach from=$block.contents item=content}>
+		<li>
+				<{$content.from_auther_to_post}><br /><br />
+				<{$content.comment_ID}><br />
+				<{$content.comment_post_ID}><br />
+				<{$content.comment_date}><br />
+				<{$content.comment_content}><br />
+				<{$content.comment_excerpt}><br />
+				<{$content.comment_link}><br />
+				<{$content.comment_title}><br />
+				<{$content.comment_title_link}><br />
+				<{$content.post_link}><br />
+				<{$content.post_title}><br />
+				<{$content.post_title_link}><br />
+				<{$content.author_link}><br />
+				<{$content.author_name}><br />
+				<{$content.author_name_link}><br />
+				<{$content.comment_type}><br />
+		</li>
+	<{/foreach}>
+</ul>
Index: trunk/xoops_version.php
===================================================================
--- trunk/xoops_version.php	(revision 34)
+++ trunk/xoops_version.php	(revision 35)
@@ -93,8 +93,20 @@
 * Templates
 */
-//$modversion['templates'] = array() ;
-//$modversion['templates'][1]['file'] = 'xpress_index.html';
-//$modversion['templates'][1]['description'] = '';
+// All Templates can't be touched by modulesadmin.
+$modversion['templates'] = array() ;
 
 $modversion['hasconfig'] = 0;
+
+//BLOCKS
+$modversion['blocks'][1] = array(
+	'file' 			=> 'xpress_block_recent_comments.php' ,
+	'name' 			=> constant('_MI_XPRESS_BLOCK_COMMENTS') ,
+	'description'	=> '' ,
+	'show_func' 	=> "b_". $mydirname . "_comments_show" ,
+	'edit_func' 	=> "b_". $mydirname . "_comments_edit" ,
+	'template'		=> 'xpress_block_recent_comments.html' , 
+	'options'		=> $mydirname. '|10|30|' ,
+	'can_clone'		=> true ,
+	'func_num'		=> 1,	
+);
 ?>
