XPressME Integration Kit

Trac

source: tags/Ver2.2.0RC1/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/recent_posts_content_block_theme.php @ 450

Last change on this file since 450 was 450, checked in by toemon, 14 years ago

Ver2.2.0RC1 リリース

File size: 6.8 KB
Line 
1<?php
2// Block Version: 1.0
3function recent_posts_content_block($options)
4{
5        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
6        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_content_block.html' : trim( $options[1] );
7        $disp_count =  ($options[2])?intval($options[2]):10;
8        $excerpt = empty( $options[3] ) ? false : true ;
9        $excerpt_size =  ($options[4])?intval($options[4]):100;
10        $date_format = empty( $options[5] ) ? '' : $options[5] ;
11        $time_format = empty( $options[6] ) ? '' : $options[6] ;
12        $tag_select = $options[7] ;
13        $cat_select = empty( $options[8] ) ? '0' : $options[8] ;
14        $day_select = ($options[9])?intval($options[9]):0;
15        $day_size = ($options[10])?intval($options[10]):0;
16
17        $selected = explode(',' , $cat_select);
18       
19        $mydirpath = get_xpress_dir_path();
20       
21        if (empty($date_format)) $date_format = get_settings('date_format');
22        if (empty($time_format)) $time_format = get_settings('time_format');
23        if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
24        if (array_search(0,$selected)===0) $cat_select = 0;
25
26        $selected_author_id = xpress_selected_author_id('echo=0');     
27        if (!empty($selected_author_id)){
28                $author_where ="author=$selected_author_id&";
29        } else {
30                $author_where = '';
31        }
32       
33        $date_today = mktime (0, 0, 0, date("m"), date("d"), date("Y"));
34        $between_days = $day_size * 60 * 60 * 24;
35       
36        global $wpdb,$wp_query;
37        $block = array();
38        $item_no = 0;   
39        if (!is_null($wpdb)){
40                $wp_query->in_the_loop = true;          //for use the_tags() in multi lopp
41                if ($cat_select) {
42                        $r = new WP_Query($author_where . $tag_where ."cat=$cat_select&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
43                } else {
44                        $r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
45                }
46                while($r->have_posts()){                       
47                        $r->the_post();
48                        if ($day_select == 1){
49                                $post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y"));
50                                $base_date = $date_today - $between_days;
51                                if ($post_date < $base_date) continue;
52                        }
53                        if ($day_select == 2){
54                                $post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y"));
55                                if (empty($latest_date)) $latest_date = $post_date;
56                                $base_date = $latest_date - $between_days;
57                                if ($post_date < $base_date) continue;
58                        }
59                       
60                        ob_start();
61                                the_ID();
62                                $post_id = ob_get_contents();
63                        ob_end_clean();
64                       
65                        $title = xpress_the_title('echo=0');
66                       
67                        ob_start();
68                                the_permalink();
69                                $permalink = ob_get_contents();
70                        ob_end_clean();                                 
71                       
72                        ob_start();
73                                the_author_posts_link();
74                                $author = ob_get_contents();
75                        ob_end_clean();
76                       
77                        ob_start();
78                                the_category(' &bull; ');
79                                $category = ob_get_contents();
80                        ob_end_clean();
81                       
82                        if (function_exists('the_tags')){
83                                ob_start();
84                                        the_tags(__('Tags:', 'xpress') . ' ',' &bull; ','');
85                                        $tags = ob_get_contents();
86                                ob_end_clean();
87                        } else {
88                                $tags = '';
89                        }
90
91                        $param = array(
92                                'configration_select' => 0,
93                                'do_excerpt' => $excerpt,
94                                'excerpt_length_word' => $excerpt_size,
95                                'excerpt_length_character' => $excerpt_size,
96                                'echo' => 0
97                        );
98
99                        $post_content = xpress_the_content($param);
100                       
101                        ob_start();
102                                the_modified_date($date_format);
103                                $post_modified_date = ob_get_contents();
104                        ob_end_clean();
105                               
106                        ob_start();
107                                the_modified_date($time_format);
108                                $post_modified_time = ob_get_contents();
109                        ob_end_clean();
110                       
111                        ob_start();
112                                the_time($date_format);
113                                $post_date = ob_get_contents();
114                        ob_end_clean();
115                       
116                        ob_start();
117                                the_time($time_format);
118                                $post_time = ob_get_contents();
119                        ob_end_clean();
120                       
121                       
122                        ob_start();
123                                comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
124                                $comments_popup_link = ob_get_contents();
125                        ob_end_clean();
126
127// all_in_one                   
128                        ob_start();
129?>
130                                <div class="xpress-post" id="post-<?php the_ID(); ?>">
131                                        <div class ="xpress-post-header">
132                                                <?php if (function_exists('hotDates')) { hotDates(); }?>
133                                                <div class ="xpress-post-title">
134                                                        <?php if(function_exists('the_title_attribute')) : ?>                   
135                                                                <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>
136                                                        <?php else : ?>
137                                                                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title('','',false)); ?>"><?php the_title(); ?></a></h2>
138                                                        <?php endif; ?>
139
140                                                </div>
141                                        </div>
142                                        <div class="xpress-post-entry">
143                                        <?php   echo $post_content; ?>                                                 
144                                        </div>
145                                        <div class="xpress-link-pages"><?php wp_link_pages() ?></div>
146                                        <div class ="xpress-post-footer">
147<?php
148                                                the_time('Y/m/d l');
149                                                echo ' - ';
150                                                the_author_posts_link();
151                                                echo ' (' . xpress_post_views_count('post_id=' . $post->ID . '&format=' . __('Views :%d', 'xpress'). '&echo=0') . ')';
152                                               
153                                                echo ' | ';
154                                                // echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');
155                                                printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
156                                                echo ' | ';
157                                                edit_post_link(__('Edit', 'xpress'), '', ' | ');
158                                                comments_popup_link(__('No Comments &#187;', 'xpress'), __('1 Comment &#187;', 'xpress'), __('% Comments &#187;', 'xpress'), '', __('Comments Closed', 'xpress') );
159?>
160                                        </div>
161                                </div>
162<?php
163                        $all_in_one = ob_get_contents();
164                        ob_end_clean();
165                                               
166                       
167                        $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
168                        $post_date_time = $post_date . ' ' . $post_time ;
169                        $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
170                        $trackback_url = trackback_url(false);
171                        $post_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
172
173//                      if (empty($tags)) $tags = __('Not Tag');
174
175                        $row_data = array(
176                                'post_id'               => $post_id ,
177                                'post_title'    => $post_title ,
178                                'post_content'          => $post_content ,
179                                'post_date' => $post_date ,
180                                'post_time' => $post_time ,
181                                'post_date_time' => $post_date_time ,
182                                'post_modified_date' => $post_modified_date ,
183                                'post_modified_time' => $post_modified_time ,
184                                'post_modified_date_time' => $post_modified_date_time ,
185                                'post_author'   => $author ,
186                                'post_category'         => $category , 
187                                'post_tags'             => $tags,
188                                'post_views'            => $post_viwes,
189                                'comment_link'  => $comments_popup_link ,
190                                'trackback_url' => $trackback_url ,
191                                'all_in_one' => $all_in_one
192                        );
193                       
194                        $block['contents']['item'.$item_no] = $row_data;
195                        $item_no++;
196                }
197                $block['data_count'] = $item_no;  //xml unserialise error
198        }
199        return $block ;
200}
201
202?>
Note: See TracBrowser for help on using the repository browser.