XPressME Integration Kit

Trac

source: trunk/wp-content/themes/xpress_default/blocks/recent_posts_content_block_theme.php @ 157

Last change on this file since 157 was 157, checked in by toemon, 15 years ago

#90 マルチループを使っているブロックがマルチユーザに対応していない に対する修正

File size: 4.4 KB
Line 
1<?php
2//if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
3
4function recent_posts_content_block($options)
5{
6        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
7        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_content_block.html' : trim( $options[1] );
8        $disp_count =  ($options[2])?intval($options[2]):10;
9        $excerpt = empty( $options[3] ) ? false : true ;
10        $excerpt_size =  ($options[4])?intval($options[4]):100;
11        $date_format = empty( $options[5] ) ? '' : $options[5] ;
12        $time_format = empty( $options[6] ) ? '' : $options[6] ;
13        $tag_select = $options[7] ;
14    $selected = array_slice($options,8); // get allowed cats
15
16        $mydirpath = get_xpress_dir_path();
17       
18        if (empty($date_format)) $date_format = get_settings('date_format');
19        if (empty($time_format)) $time_format = get_settings('time_format');
20        if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
21       
22        $selected_author_id = xpress_selected_author_id(false);
23        if (!empty($selected_author_id)){
24                $author_where ="author=$selected_author_id&";
25        } else {
26                $author_where = '';
27        }
28        global $wpdb,$wp_query;
29        $block = array();
30        $item_no = 0;   
31        if (!is_null($wpdb)){
32                $wp_query->in_the_loop = true;          //for use the_tags() in multi lopp
33                if (array_search(0,$selected)===0) {
34                        $r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
35
36                } else {
37                        $cat_id = implode(',',$selected);
38                        $r = new WP_Query($author_where . $tag_where . "cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
39                }
40                while($r->have_posts()){                       
41                        $r->the_post();
42                        ob_start();
43                                the_ID();
44                                $post_id = ob_get_contents();
45                        ob_end_clean();
46                       
47                        ob_start();
48                                the_title();
49                                $title = ob_get_contents();
50                        ob_end_clean();
51                       
52                        ob_start();
53                                the_permalink();
54                                $permalink = ob_get_contents();
55                        ob_end_clean();                                 
56                       
57                        ob_start();
58                                the_author_posts_link();
59                                $author = ob_get_contents();
60                        ob_end_clean();
61                       
62                        ob_start();
63                                the_category(' &bull; ');
64                                $category = ob_get_contents();
65                        ob_end_clean();
66                       
67                        ob_start();
68                                the_tags(__('Tags:', 'kubrick') . ' ',' &bull; ','');
69                                $tags = ob_get_contents();
70                        ob_end_clean();
71                       
72                        if ($excerpt){
73                                $excerpt_length_word = $excerpt_size;
74                                $excerpt_length_character = $excerpt_size;
75                                $more_link_text = '';
76                                $post_content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
77                        } else {
78                                $post_content = xpress_the_content(__('more'),0,'',false);     
79                        }
80
81                        ob_start();
82                                the_modified_date($date_format);
83                                $post_modified_date = ob_get_contents();
84                        ob_end_clean();
85                       
86                        ob_start();
87                                the_modified_date($time_format);
88                                $post_modified_time = ob_get_contents();
89                        ob_end_clean();
90                       
91                        ob_start();
92                                the_time($date_format);
93                                $post_date = ob_get_contents();
94                        ob_end_clean();
95                       
96                        ob_start();
97                                the_time($time_format);
98                                $post_time = ob_get_contents();
99                        ob_end_clean();
100                       
101                       
102                        ob_start();
103                                comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
104                                $comments_popup_link = ob_get_contents();
105                        ob_end_clean();
106                       
107                        $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
108                        $post_date_time = $post_date . ' ' . $post_time ;
109                        $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
110                        $trackback_url = trackback_url(false);
111                        $post_viwes = xpress_post_views_count($post_id,'views: %d' ,false);
112//                      if (empty($tags)) $tags = __('Not Tag');
113
114                        $row_data = array(
115                                'post_id'               => $post_id ,
116                                'post_title'    => $post_title ,
117                                'post_content'          => $post_content ,
118                                'post_date' => $post_date ,
119                                'post_time' => $post_time ,
120                                'post_date_time' => $post_date_time ,
121                                'post_modified_date' => $post_modified_date ,
122                                'post_modified_time' => $post_modified_time ,
123                                'post_modified_date_time' => $post_modified_date_time ,
124                                'post_author'   => $author ,
125                                'post_category'         => $category , 
126                                'post_tags'             => $tags,
127                                'post_views'            => $post_viwes,
128                                'comment_link'  => $comments_popup_link ,
129                                'trackback_url' => $trackback_url
130                        );
131                       
132                        $block['contents']['item'.$item_no] = $row_data;
133                        $item_no++;
134                }
135                $block['data_count'] = $item_no;  //xml unserialise error
136        }
137        return $block ;
138}
139?>
Note: See TracBrowser for help on using the repository browser.