XPressME Integration Kit

Trac

source: trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/blog_list_block_theme.php @ 540

Last change on this file since 540 was 540, checked in by toemon, 14 years ago

投稿後のブロックのキャッシュリフレッシュでエラーが発生するバグ修正 Fixes #304

File size: 2.5 KB
Line 
1<?php
2// Block Version: 1.0
3function blog_list_block($options)
4{
5        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
6        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_block_category.html' : trim( $options[1] );
7        $orderby = empty( $options[2] ) ? 'name' : $options[2] ;
8        $order = empty( $options[3] ) ? 'ASC' : $options[3] ;
9
10        if (xpress_is_multiblog() && function_exists('get_blog_list')){
11                $blogs = get_blog_list(0,'all');
12                $data = array();
13                foreach ($blogs AS $blog) {
14                        $url =  get_blog_option($blog['blog_id'],'siteurl');
15                        $blog_name = get_blog_option( $blog['blog_id'], 'blogname' );
16                        $blog_link = "<a href=\" $url \"> $blog_name </a>";
17                        $blog_id = $blog['blog_id'];
18                        $post_count = $blog['postcount'];
19                        $last_post_date = '';
20                        $last_post_time = '';
21                        $last_post_date_time = '';
22                               
23                        $row_data = array(
24                                'blog_id'               => $blog_id ,
25                                'blog_name'     => $blog_link ,
26                                'last_post_date' => $last_post_date ,
27                                'last_post_time' => $last_post_time ,
28                                'post_date_time' => $last_post_date_time ,
29                                'last_post_date_time' => $post_modified_date ,
30                                'post_count' => $post_count
31                        );
32                        $data[] = $row_data;
33                }
34                if (strcmp($order,'ASC') == 0){
35                        switch($orderby){
36                                case 'count':
37                                        usort($data, "r_post_count_cmp");
38                                        break;
39                                case 'ID' :
40                                        usort($data, "r_blog_id_cmp");
41                                        break;
42                                default :
43                                        usort($data, "r_blog_name_cmp");
44                        }
45                } else {
46                        switch($orderby){
47                                case 'count':
48                                        usort($data, "post_count_cmp");
49                                        break;
50                                case 'ID' :
51                                        usort($data, "blog_id_cmp");
52                                        break;
53                                default :
54                                        usort($data, "blog_name_cmp");
55                        }
56                }
57               
58                $block = array();
59                $item_no = 0;   
60                foreach ($data AS $row) {
61                        $block['contents']['item'.$item_no] = $row;
62                        $item_no++;
63                }// end of foreach
64                $block['data_count'] = $item_no;  //xml unserialise error
65        } else {
66                $block['err_message'] = __('This blog is not set to the multi blog.', 'xpress');
67        }
68        return $block ;
69}
70function blog_name_cmp($a, $b)
71{
72    return - strcasecmp($a["blog_name"], $b["blog_name"]);
73}
74function blog_id_cmp($a, $b)
75{
76    return $b["blog_id"] - $a["blog_id"];
77}
78function post_count_cmp($a, $b)
79{
80    return $b["post_count"] - $a["post_count"];
81}
82
83function r_blog_name_cmp($a, $b)
84{
85    return strcasecmp($a["blog_name"], $b["blog_name"]);
86}
87function r_blog_id_cmp($a, $b)
88{
89    return $a["blog_id"] - $b["blog_id"];
90}
91function r_post_count_cmp($a, $b)
92{
93    return $a["post_count"] - $b["post_count"];
94}
95
96?>
Note: See TracBrowser for help on using the repository browser.