XPressME Integration Kit

Trac


Ignore:
Timestamp:
Mar 11, 2010, 11:49:11 PM (14 years ago)
Author:
toemon
Message:

MultiBlog用に最近の投稿(全ブログ)を追加 r537とあわせ Fixes #302

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/blog_list_block_theme.php

    r533 r536  
    33function blog_list_block($options) 
    44{ 
     5        if(is_admin()) return; // wp-admin page is not exists 
    56        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ; 
    67        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_block_category.html' : trim( $options[1] ); 
     
    89        $order = empty( $options[3] ) ? 'ASC' : $options[3] ; 
    910 
    10         $blogs = get_blog_list(0,'all'); 
    11         $data = array(); 
    12         foreach ($blogs AS $blog) { 
    13                 $url =  get_blog_option($blog['blog_id'],'siteurl'); 
    14                 $blog_name = get_blog_option( $blog['blog_id'], 'blogname' ); 
    15                 $blog_link = "<a href=\" $url \"> $blog_name </a>"; 
    16                 $blog_id = $blog['blog_id']; 
    17                 $post_count = $blog['postcount']; 
    18                 $last_post_date = ''; 
    19                 $last_post_time = ''; 
    20                 $last_post_date_time = ''; 
    21                          
    22                 $row_data = array( 
    23                         'blog_id'               => $blog_id , 
    24                         'blog_name'     => $blog_link , 
    25                         'last_post_date' => $last_post_date , 
    26                         'last_post_time' => $last_post_time , 
    27                         'post_date_time' => $last_post_date_time , 
    28                         'last_post_date_time' => $post_modified_date , 
    29                         'post_count' => $post_count 
    30                 ); 
    31                 $data[] = $row_data; 
     11        if (xpress_is_multiblog() && function_exists('get_blog_list')){ 
     12                $blogs = get_blog_list(0,'all'); 
     13                $data = array(); 
     14                foreach ($blogs AS $blog) { 
     15                        $url =  get_blog_option($blog['blog_id'],'siteurl'); 
     16                        $blog_name = get_blog_option( $blog['blog_id'], 'blogname' ); 
     17                        $blog_link = "<a href=\" $url \"> $blog_name </a>"; 
     18                        $blog_id = $blog['blog_id']; 
     19                        $post_count = $blog['postcount']; 
     20                        $last_post_date = ''; 
     21                        $last_post_time = ''; 
     22                        $last_post_date_time = ''; 
     23                                 
     24                        $row_data = array( 
     25                                'blog_id'               => $blog_id , 
     26                                'blog_name'     => $blog_link , 
     27                                'last_post_date' => $last_post_date , 
     28                                'last_post_time' => $last_post_time , 
     29                                'post_date_time' => $last_post_date_time , 
     30                                'last_post_date_time' => $post_modified_date , 
     31                                'post_count' => $post_count 
     32                        ); 
     33                        $data[] = $row_data; 
     34                } 
     35                if (strcmp($order,'ASC') == 0){ 
     36                        switch($orderby){ 
     37                                case 'count': 
     38                                        usort($data, "r_post_count_cmp"); 
     39                                        break; 
     40                                case 'ID' : 
     41                                        usort($data, "r_blog_id_cmp"); 
     42                                        break; 
     43                                default : 
     44                                        usort($data, "r_blog_name_cmp"); 
     45                        } 
     46                } else { 
     47                        switch($orderby){ 
     48                                case 'count': 
     49                                        usort($data, "post_count_cmp"); 
     50                                        break; 
     51                                case 'ID' : 
     52                                        usort($data, "blog_id_cmp"); 
     53                                        break; 
     54                                default : 
     55                                        usort($data, "blog_name_cmp"); 
     56                        } 
     57                } 
     58                 
     59                $block = array(); 
     60                $item_no = 0;    
     61                foreach ($data AS $row) { 
     62                        $block['contents']['item'.$item_no] = $row; 
     63                        $item_no++; 
     64                }// end of foreach 
     65                $block['data_count'] = $item_no;  //xml unserialise error 
     66        } else { 
     67                $block['err_message'] = __('This blog is not set to the multi blog.', 'xpress'); 
    3268        } 
    33         if (strcmp($order,'ASC') == 0){ 
    34                 switch($orderby){ 
    35                         case 'count': 
    36                                 usort($data, "r_post_count_cmp"); 
    37                                 break; 
    38                         case 'ID' : 
    39                                 usort($data, "r_blog_id_cmp"); 
    40                                 break; 
    41                         default : 
    42                                 usort($data, "r_blog_name_cmp"); 
    43                 } 
    44         } else { 
    45                 switch($orderby){ 
    46                         case 'count': 
    47                                 usort($data, "post_count_cmp"); 
    48                                 break; 
    49                         case 'ID' : 
    50                                 usort($data, "blog_id_cmp"); 
    51                                 break; 
    52                         default : 
    53                                 usort($data, "blog_name_cmp"); 
    54                 } 
    55         } 
    56          
    57         $block = array(); 
    58         $item_no = 0;    
    59         foreach ($data AS $row) { 
    60                 $block['contents']['item'.$item_no] = $row; 
    61                 $item_no++; 
    62         }// end of foreach 
    63         $block['data_count'] = $item_no;  //xml unserialise error 
    6469        return $block ; 
    6570} 
Note: See TracChangeset for help on using the changeset viewer.