XPressME Integration Kit

Trac

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

Last change on this file since 54 was 54, checked in by toemon, 16 years ago

最近の記事内容ブロック 実装
概要処理の部分と、閲覧数の部分は未完です。

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