XPressME Integration Kit

Trac

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

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

ブロックオプション、カテゴリのマルチセレクトをカンマ区切りデータとして格納するようにした。 #243

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