コード例 #1
0
ファイル: single.php プロジェクト: nouphet/rata
						<?php 
        the_content('<p class="serif">' . __('Read the rest of this entry &raquo;', 'xpress') . '</p>');
        ?>
					</div>
							
					<div class="xpress-link-pages"><?php 
        wp_link_pages();
        ?>
</div>
						
					<div class ="xpress-post-footer">
						<?php 
        the_time('Y/m/d l');
        echo ' - ';
        the_author_posts_link();
        echo ' (' . xpress_post_views_count('post_id=' . $post->ID . '&format=' . __('Views :%d', 'xpress') . '&echo=0') . ')';
        echo ' | ';
        // echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');
        printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
        echo ' | ';
        edit_post_link(__('Edit', 'xpress'), '', ' | ');
        comments_popup_link(__('No Comments &#187;', 'xpress'), __('1 Comment &#187;', 'xpress'), __('% Comments &#187;', 'xpress'), '', __('Comments Closed', 'xpress'));
        ?>
					</div>
							
					<div id ="xpress-pings-block">
						<h3><?php 
        xpress_pings_number('zero=' . __('No Trackback/Pingback', 'xpress') . '&one=' . __('One Trackback/Pingback', 'xpress') . '&more=' . __('% TrackBack/Pingback', 'xpress'));
        ?>
</h3>
						<p class="xpress_pings_status"><small>
コード例 #2
0
function 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];
    $tag_select = $options[6];
    $cat_select = empty($options[7]) ? '0' : $options[7];
    $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');
    }
    if (array_search(0, $selected) === 0) {
        $cat_select = 0;
    }
    $cat_select;
    $block = array();
    $item_no = 0;
    $selected_author_id = xpress_selected_author_id('echo=0');
    global $wpdb, $wp_query, $xoops_db;
    $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'";
        //		if (!empty($selected_author_id)){
        //			$where  .= " AND ($post_tb.post_author = $selected_author_id) ";
        //			$where  .= " AND ($post_tb.post_author = 2) ";
        //		}
        if ($cat_select) {
            $where .= " AND ({$term_taxonomy}.term_id IN ({$cat_select}))";
        }
        if (!empty($tag_select)) {
            $tag_id_list = get_tag_id($tag_select);
            if (!empty($tag_id_list)) {
                $where .= " AND ({$term_taxonomy}.term_id IN ({$tag_id_list}))";
            }
        }
    } 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 ($cat_select) {
            $where .= " AND ({$post2cat_tb}.category_id IN ({$cat_select}))";
        }
    }
    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_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress') . '&echo=0');
            //			if (empty($tags)) $tags = __('Not Tag');
            $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_viwes, 'comment_link' => $comments_popup_link, 'trackback_url' => $trackback_url);
            $block['contents']['item' . $item_no] = $row_data;
            $item_no++;
        }
    }
    // end of foreach
    $block['data_count'] = $item_no;
    //xml unserialise error
    return $block;
}
コード例 #3
0
function recent_posts_list_block($options)
{
    $mydirname = empty($options[0]) ? 'xpress' : $options[0];
    $this_template = empty($options[1]) ? 'db:' . $mydirname . '_recent_posts_list_block.html' : trim($options[1]);
    $disp_count = empty($options[2]) ? '10' : $options[2];
    $disp_red = empty($options[3]) ? '1' : $options[3];
    $disp_green = empty($options[4]) ? '7' : $options[4];
    $date_format = empty($options[5]) ? '' : $options[5];
    $time_format = empty($options[6]) ? '' : $options[6];
    $tag_select = $options[7];
    $cat_select = empty($options[8]) ? '0' : $options[8];
    $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');
    }
    if (empty($tag_select)) {
        $tag_where = '';
    } else {
        $tag_where = "tag='{$tag_select}'&";
    }
    if (array_search(0, $selected) === 0) {
        $cat_select = 0;
    }
    $selected_author_id = xpress_selected_author_id('echo=0');
    if (!empty($selected_author_id)) {
        $author_where = "author={$selected_author_id}&";
    } else {
        $author_where = '';
    }
    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 ($cat_select) {
            $r = new WP_Query($author_where . $tag_where . "cat={$cat_select}&showposts={$disp_count}&what_to_show=posts&nopaging=0&post_status=publish");
        } else {
            $r = new WP_Query($author_where . $tag_where . "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();
            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();
            $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=' . $post_id . '&format=' . __('Views :%d', 'xpress') . '&echo=0');
            //			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;
}
コード例 #4
0
ファイル: custom_functions.php プロジェクト: nunoluciano/uxcl
function xpress_grobal_recent_posts($num = 10,$exclusion_blog = 0, $shown_for_each_blog = false)
{
	global $wpdb, $wp_rewrite , $switched , $blog_id;
	if (empty($date_format)) $date_format = get_settings('date_format');
	if (empty($time_format)) $time_format = get_settings('time_format');
	$exclusion = explode(',' , $exclusion_blog);


	$first_blogid = $blog_id;
	$num = (int)$num;
//	$wp_query->in_the_loop = true;		//for use the_tags() in multi lopp 
	$data_array = array();
	if (xpress_is_multiblog()){
		$blogs = get_blog_list(0,'all');
		foreach ($blogs AS $blog) {
			if (!in_array(0, $exclusion) && in_array($blog['blog_id'], $exclusion)) continue;
			switch_to_blog($blog['blog_id']);
			$wp_rewrite->init();  // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.

				if (empty($num)){
					query_posts("post_status=publish");
				} else {
					query_posts("showposts=$num&post_status=publish");
				}
				if (have_posts()){
					while(have_posts()){
						$data = new stdClass();
						
						the_post();
						ob_start();
							the_ID();
							$data->post_id = ob_get_contents();
						ob_end_clean();
						
						$data->blog_id = $blog['blog_id'];
						$data->blog_name = get_bloginfo('name');
						$data->blog_url = get_bloginfo('url');
						$data->blog_link = '<a href="' . $data->blog_url . '">' . $data->blog_name . '</a>' ;


						ob_start();
							the_title();
							$data->title = ob_get_contents();
						ob_end_clean();
						$data->post_permalink = get_blog_permalink($data->brog_id, $data->post_id);
						$data->title_link = '<a href="' . $data->post_permalink . '">' . $data->title . '</a>' ;

						ob_start();
							the_author_posts_link();
							$data->post_author = ob_get_contents();
						ob_end_clean();

						ob_start();
							the_category(' &bull; ');
							$data->post_category = ob_get_contents();
						ob_end_clean();	
						
						if (function_exists('the_tags')){
							ob_start();
								the_tags(__('Tags:', 'xpress') . ' ',' &bull; ','');
								$data->post_tags = ob_get_contents();
							ob_end_clean();	
						} else {
							$data->tags = '';
						}

						$data->the_content = xpress_the_content('echo=0');
						
						ob_start();
							the_content();
							$data->the_full_content = ob_get_contents();
						ob_end_clean();
						
						ob_start();
							the_modified_date($date_format);
							$data->post_modified_date = ob_get_contents();
						ob_end_clean();
							
						ob_start();
							the_modified_date($time_format);
							$data->post_modified_time = ob_get_contents();
						ob_end_clean();
						$data->post_modified_date_time = $data->post_modified_date . ' ' . $data->post_modified_time;
						
						ob_start();
							the_time('U');
							$data->post_unix_time = ob_get_contents();
						ob_end_clean();
						
						ob_start();
							the_time($date_format);
							$data->post_date = ob_get_contents();
						ob_end_clean();
						
						ob_start();
							the_time($time_format);
							$data->post_time = ob_get_contents();
						ob_end_clean();
						
						$data->post_date_time = $data->post_date . ' ' . $data->post_time;

						ob_start();
							comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
							$data->comments_link = ob_get_contents();
						ob_end_clean();
						
						$data->post_views = xpress_post_views_count('post_id=' . $data->post_id . '&blogid=' . $data->brog_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
						if (function_exists('the_qf_get_thumb_one')){
							$data->post_thumbnail = the_qf_get_thumb_one("num=0&width=120&tag=1","",$data->the_full_content);
						} else {
							$data->post_thumbnail = get_the_post_thumbnail(null,'thumbnail');
						}
						$data->author_avatar =get_avatar(get_the_author_meta('ID'),$size = '32');

						$data_array[] = $data;
	        		}  // end whilwe
				} // end if
			restore_current_blog();
//			$wp_rewrite->init();
		} // end foreach
//		switch_to_blog($first_blogid);
		$wp_rewrite->init(); // http://core.trac.wordpress.org/ticket/12040 is solved, it is unnecessary.

		restore_current_blog();
	}
	if (!$shown_for_each_blog){
		usort($data_array, "the_time_cmp");
		if (!empty($num)){
			$data_array = array_slice($data_array,0,$num);
		}
	}
	return $data_array;
}
コード例 #5
0
function recent_posts_content_block($options)
{
	$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
	$this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_content_block.html' : trim( $options[1] );
	$disp_count =  ($options[2])?intval($options[2]):10;
	$excerpt = empty( $options[3] ) ? false : true ;
	$excerpt_size =  ($options[4])?intval($options[4]):100;
	$date_format = empty( $options[5] ) ? '' : $options[5] ;
	$time_format = empty( $options[6] ) ? '' : $options[6] ;
	$tag_select = $options[7] ;
	$cat_select = empty( $options[8] ) ? '0' : $options[8] ;
	$day_select = ($options[9])?intval($options[9]):0;
	$day_size = ($options[10])?intval($options[10]):0;

	$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');
	if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
	if (array_search(0,$selected)===0) $cat_select = 0;

	$selected_author_id = xpress_selected_author_id('echo=0');	
	if (!empty($selected_author_id)){
		$author_where ="author=$selected_author_id&";
	} else {
		$author_where = '';
	}
	
	$date_today = mktime (0, 0, 0, date("m"), date("d"), date("Y"));
	$between_days = $day_size * 60 * 60 * 24;
	
	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 ($cat_select) {
			$r = new WP_Query($author_where . $tag_where ."cat=$cat_select&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
		} else {
			$r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
		}
		while($r->have_posts()){			
			$r->the_post();
			if ($day_select == 1){
				$post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y"));
				$base_date = $date_today - $between_days;
				if ($post_date < $base_date) continue;
			}
			if ($day_select == 2){
				$post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y"));
				if (empty($latest_date)) $latest_date = $post_date;
				$base_date = $latest_date - $between_days;
				if ($post_date < $base_date) continue;
			}
			
			ob_start();
				the_ID();
				$post_id = ob_get_contents();
			ob_end_clean();
			
			$title = xpress_the_title('echo=0');
			
			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 = '';
			}

			$param = array(
				'configration_select' => 0, 
				'do_excerpt' => $excerpt,
				'excerpt_length_word' => $excerpt_size, 
				'excerpt_length_character' => $excerpt_size, 
				'echo' => 0
			);

			$post_content = xpress_the_content($param);
			
			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();

// all_in_one			
			ob_start();
?>
				<div class="xpress-post" id="post-<?php the_ID(); ?>">
					<div class ="xpress-post-header">
						<?php if (function_exists('hotDates')) { hotDates(); }?>
						<div class ="xpress-post-title">
							<?php if(function_exists('the_title_attribute')) : ?>			
								<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
							<?php else : ?>
								<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title('','',false)); ?>"><?php the_title(); ?></a></h2>
							<?php endif; ?>

						</div>
					</div>
					<div class="xpress-post-entry">
					<?php	echo $post_content; ?>							
					</div>
					<div class="xpress-link-pages"><?php wp_link_pages() ?></div>
					<div class ="xpress-post-footer">
<?php
						the_time('Y/m/d l');
						echo ' - ';
						the_author_posts_link();
						echo ' (' . xpress_post_views_count('post_id=' . $post->ID . '&format=' . __('Views :%d', 'xpress'). '&echo=0') . ')'; 
						
						echo ' | ';
						// echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');
						printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
						echo ' | ';
						edit_post_link(__('Edit', 'xpress'), '', ' | ');
						comments_popup_link(__('No Comments &#187;', 'xpress'), __('1 Comment &#187;', 'xpress'), __('% Comments &#187;', 'xpress'), '', __('Comments Closed', 'xpress') );
?>
					</div>
				</div>
<?php
			$all_in_one = 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_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');

//			if (empty($tags)) $tags = __('Not Tag');

			$row_data = array(
				'post_id'		=> $post_id ,
				'post_title'	=> $post_title ,
				'post_content' 		=> $post_content ,
				'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 ,
				'all_in_one' => $all_in_one
			);
			
			$block['contents']['item'.$item_no] = $row_data;
			$item_no++;
		}
		$block['data_count'] = $item_no;  //xml unserialise error
	}
	return $block ;
}
コード例 #6
0
function global_popular_posts_block($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] ;
	
	$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();
			
			$blog_title = get_bloginfo('name');
			$blog_link = get_bloginfo('url');
			$blog_title_link = '<a href="' . $blog_link . '">' . $blog_title . '</a>' ;

			$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(
						'blog_title' => $blog_title ,
						'blog_link' => $blog_link ,
						'blog_title_link' => $blog_title_link ,
						'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;
	} else {
		$block['err_message'] = __('This blog is not set to the multi blog.', 'xpress');
	}
	return $block ;
}