XPressME Integration Kit

Trac

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

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

Bump Ver0.28 #53 最近の記事内容ブロックのデザイン調整

モジュール外にブロックを配置したとき、ブロックCSSとして、テーマ内のstyle.cssとhotdateプラグインのCSSを取り込むようにした。 include/xpress_block_render.php xpress_get_plugin_css()
xpress_defaultのコンテンツ出力と同じ表示を行う all_in_oneタグを追加

File size: 6.0 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                        $title = xpress_the_title(false);
48                       
49                        ob_start();
50                                the_permalink();
51                                $permalink = ob_get_contents();
52                        ob_end_clean();                                 
53                       
54                        ob_start();
55                                the_author_posts_link();
56                                $author = ob_get_contents();
57                        ob_end_clean();
58                       
59                        ob_start();
60                                the_category(' &bull; ');
61                                $category = ob_get_contents();
62                        ob_end_clean();
63                       
64                        ob_start();
65                                the_tags(__('Tags:', 'kubrick') . ' ',' &bull; ','');
66                                $tags = ob_get_contents();
67                        ob_end_clean();
68                       
69                        if ($excerpt){
70                                $excerpt_length_word = $excerpt_size;
71                                $excerpt_length_character = $excerpt_size;
72                                $more_link_text = '';
73                                $post_content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
74                        } else {
75                                $post_content = xpress_the_content(__('more'),0,'',false);     
76                        }
77
78                        ob_start();
79                                the_modified_date($date_format);
80                                $post_modified_date = ob_get_contents();
81                        ob_end_clean();
82                       
83                        ob_start();
84                                the_modified_date($time_format);
85                                $post_modified_time = ob_get_contents();
86                        ob_end_clean();
87                       
88                        ob_start();
89                                the_time($date_format);
90                                $post_date = ob_get_contents();
91                        ob_end_clean();
92                       
93                        ob_start();
94                                the_time($time_format);
95                                $post_time = ob_get_contents();
96                        ob_end_clean();
97                       
98                       
99                        ob_start();
100                                comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
101                                $comments_popup_link = ob_get_contents();
102                        ob_end_clean();
103
104// all_in_one                   
105                        ob_start();
106?>
107                                <div class="xpress-post" id="post-<?php the_ID(); ?>">
108                                        <div class ="xpress-post-header">
109                                                <?php if (function_exists('hotDates')) { hotDates(); }?>
110                                                <div class ="xpress-post-title">
111                                                        <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>
112                                                </div>
113                                        </div>
114                                        <div class="xpress-post-entry">
115<?php
116                        if ($excerpt){
117                                $excerpt_length_word = $excerpt_size;
118                                $excerpt_length_character = $excerpt_size;
119                                $more_link_text = '';
120                                $post_content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
121                        } else {
122                                $post_content = xpress_the_content(__('more'),0,'',false);     
123                        }
124                        echo $post_content;
125?>                                                     
126                                        </div>
127                                        <div class="xpress-link-pages"><?php wp_link_pages() ?></div>
128                                        <div class ="xpress-post-footer">
129<?php
130                                                the_time('Y/m/d l');
131                                                echo ' - ';
132                                                the_author_posts_link();
133                                                echo ' (' . xpress_post_views_count($post->ID,__('Views :%d', 'xpress'),false) . ')';
134                                                echo ' | ';
135                                                // echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');
136                                                printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
137                                                echo ' | ';
138                                                edit_post_link(__('Edit', 'xpress'), '', ' | ');
139                                                comments_popup_link(__('No Comments &#187;', 'xpress'), __('1 Comment &#187;', 'xpress'), __('% Comments &#187;', 'xpress'), '', __('Comments Closed', 'xpress') );
140?>
141                                        </div>
142                                </div>
143<?php
144                        $all_in_one = ob_get_contents();
145                        ob_end_clean();
146                                               
147                       
148                        $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
149                        $post_date_time = $post_date . ' ' . $post_time ;
150                        $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
151                        $trackback_url = trackback_url(false);
152                        $post_viwes = xpress_post_views_count($post_id,'views: %d' ,false);
153//                      if (empty($tags)) $tags = __('Not Tag');
154
155                        $row_data = array(
156                                'post_id'               => $post_id ,
157                                'post_title'    => $post_title ,
158                                'post_content'          => $post_content ,
159                                'post_date' => $post_date ,
160                                'post_time' => $post_time ,
161                                'post_date_time' => $post_date_time ,
162                                'post_modified_date' => $post_modified_date ,
163                                'post_modified_time' => $post_modified_time ,
164                                'post_modified_date_time' => $post_modified_date_time ,
165                                'post_author'   => $author ,
166                                'post_category'         => $category , 
167                                'post_tags'             => $tags,
168                                'post_views'            => $post_viwes,
169                                'comment_link'  => $comments_popup_link ,
170                                'trackback_url' => $trackback_url ,
171                                'all_in_one' => $all_in_one
172                        );
173                       
174                        $block['contents']['item'.$item_no] = $row_data;
175                        $item_no++;
176                }
177                $block['data_count'] = $item_no;  //xml unserialise error
178        }
179        return $block ;
180}
181
182?>
Note: See TracBrowser for help on using the repository browser.