XPressME Integration Kit

Trac

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

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

単語修正 (#240)

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