XPressME Integration Kit

Trac

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

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

#130 カスタムテンプレートタグでwp_parse_argsを利用 get_xpress_excerpt_contents()はサブ関数としてxpress_the_content()にパラメータを追加して全てをまかなうように変更

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