Index: trunk/wp-content/themes/xpress_default/blocks/recent_posts_list_block_theme.php
===================================================================
--- trunk/wp-content/themes/xpress_default/blocks/recent_posts_list_block_theme.php	(revision 100)
+++ trunk/wp-content/themes/xpress_default/blocks/recent_posts_list_block_theme.php	(revision 100)
@@ -0,0 +1,257 @@
+<?php
+function recent_posts_list_block($options)
+{
+	$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
+	$disp_count = empty( $options[1] ) ? '10' : $options[1] ;
+	$disp_red = empty( $options[2] ) ? '1' : $options[2] ;
+	$disp_green = empty( $options[3] ) ? '7' : $options[3] ;
+	$tag_select = $options[4] ;
+	$selected = array_slice($options,5); // get allowed cats
+	$this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_posts.html' : trim( $options[6] );
+//	$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+	$mydirpath = get_xpress_dir_path();
+
+	if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
+	
+	global $wpdb,$wp_query;
+	$block = array();
+	$item_no = 0;	
+	if (!is_null($wpdb)){
+		$wp_query->in_the_loop = true;		//for use the_tags() in multi lopp 
+		if (array_search(0,$selected)===0) {
+			$r = new WP_Query($tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
+
+		} else {
+			$cat_id = implode(',',$selected);
+			$r = new WP_Query($tag_where . "cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
+		}
+		while($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();	
+			
+			ob_start();
+				the_tags(__('Tags:', 'kubrick') . ' ',' &bull; ','');
+				$tags = ob_get_contents();
+			ob_end_clean();
+			
+			ob_start();
+				the_modified_date(get_settings('date_format'));
+				$post_modified_date = ob_get_contents();
+			ob_end_clean();
+			
+			ob_start();
+				the_modified_date(get_settings('time_format'));
+				$post_modified_time = ob_get_contents();
+			ob_end_clean();
+			
+			ob_start();
+				the_time(get_settings('date_format'));
+				$post_date = ob_get_contents();
+			ob_end_clean();
+			
+			ob_start();
+				the_time(get_settings('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();
+			
+			$red_sec = $disp_red *60*60*24;
+			$green_sec = $disp_green *60*60*24;
+			ob_start();
+				the_time('U');
+				$check_time = ob_get_contents();
+			ob_end_clean();
+			$elapse = time() - $check_time;
+			$new_mark = '';
+			if ($elapse < $red_sec ) {
+				$new_mark = '<em style="color: red; font-size: small;">New!</em>';
+
+			} else if ($elapse < $green_sec) {
+				$new_mark = '<em style="color: green; font-size: small;">New!</em>';
+			}
+			
+			$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_viwes = xpress_post_views_count($post_id,'views: %d' ,false);
+//			if (empty($tags)) $tags = __('Not Tag');
+
+			$row_data = array(
+				'post_id'		=> $post_id ,
+				'new_mark'		=> $new_mark ,
+				'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_viwes,
+				'comment_link' 	=> $comments_popup_link ,
+				'trackback_url' => $trackback_url
+			);
+			
+			$block['contents']['item'.$item_no] = $row_data;
+			$item_no++;
+		}
+		$block['data_count'] = $item_no;  //xml unserialise error
+	}
+	return $block ;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+		
+	if (strstr($call_url,$this_url)){
+		$output ='<!-- xpress_recent_entries direct load -->' . "\n";
+	 	if (array_search(0,$selected)===0) {
+			$r = new WP_Query("showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
+		} else {
+			$cat_id = implode(',',$selected);
+			$r = new WP_Query("cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
+		}	
+		if ($r->have_posts()) {
+			$red_sec = $disp_red *60*60*24;
+			$green_sec = $disp_green *60*60*24;
+			$output .= '<!-- xpress_recent_block -->' . "\n" . '<ul>';
+			while ($r->have_posts()){
+				$r->the_post();
+				ob_start();
+					if ( get_the_title() ) {
+						the_title();
+					} else {
+						the_ID();
+					}
+					$title = ob_get_contents();
+				ob_end_clean();
+				ob_start();
+					the_time('U');
+					$post_time = ob_get_contents();
+				ob_end_clean();
+				$elapse = time() - $post_time;
+				$new_mark = '';
+				if ($elapse < $red_sec ) {
+					$new_mark = '<em style="color: red; font-size: small;">New!</em>';
+
+				} else if ($elapse < $green_sec) {
+					$new_mark = '<em style="color: green; font-size: small;">New!</em>';
+				}
+				ob_start();
+					the_permalink();
+					$permalink = ob_get_contents();
+				ob_end_clean();	
+				ob_start();
+					the_author();
+					$author = ob_get_contents();
+				ob_end_clean();
+				$output .=  '<li><a href="' . $permalink . '">' . $title . '</a> ';
+				if ($show_new) {
+					$output .= $new_mark ;
+				}
+ 				if ($show_author){
+					$output .= ' ' . $author;
+				}
+				switch($show_date){
+					case 1 :
+						$format = get_settings('date_format');
+						$output .= '<p class="recentpost_time">(' . date($format,$post_time) . ')</p>';
+						break;
+					case 2 :
+						$format = get_settings('date_format') . ' ' . get_settings('time_format');
+						$output .= '<p class="recentpost_time">(' . date($format,$post_time) . ')</p>';
+						break;
+					default :							
+				}
+				$output .= '</li>'. "\n";				
+			}
+			$output .= '</ul>';
+		}
+		$block['content'] = $output;
+	} else {
+		$para  = '?showposts=' . $disp_count;
+		$para .= '&show_new=' . $show_new;
+		$para .= '&disp_red=' . $disp_red;
+		$para .= '&disp_green=' . $disp_green;
+		$para .= '&show_author=' . $show_author;
+		$para .= '&show_date=' .$show_date;
+		$para .= '&cat_id=' . implode(',',$selected);
+
+		$block['content'] = fetch_block($mydirname,$bid,'recent_entries_block',$para);
+	}
+	return $block ;	
+
+}
+
+?>
