XPressME Integration Kit

Trac

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

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

#137 WordPressME2.0.11への対応(ブロックの対応)

File size: 6.2 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                        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                        if ($excerpt){
74                                $excerpt_length_word = $excerpt_size;
75                                $excerpt_length_character = $excerpt_size;
76                                $more_link_text = '';
77                                $post_content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
78                        } else {
79                                $post_content = get_the_content(__('more'),0,'',false);
80                                $post_content = apply_filters('the_content', $post_content);
81                                $post_content = str_replace(']]>', ']]&gt;', $post_content);
82                        }
83
84                        ob_start();
85                                the_modified_date($date_format);
86                                $post_modified_date = ob_get_contents();
87                        ob_end_clean();
88                               
89                        ob_start();
90                                the_modified_date($time_format);
91                                $post_modified_time = ob_get_contents();
92                        ob_end_clean();
93                       
94                        ob_start();
95                                the_time($date_format);
96                                $post_date = ob_get_contents();
97                        ob_end_clean();
98                       
99                        ob_start();
100                                the_time($time_format);
101                                $post_time = ob_get_contents();
102                        ob_end_clean();
103                       
104                       
105                        ob_start();
106                                comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
107                                $comments_popup_link = ob_get_contents();
108                        ob_end_clean();
109
110// all_in_one                   
111                        ob_start();
112?>
113                                <div class="xpress-post" id="post-<?php the_ID(); ?>">
114                                        <div class ="xpress-post-header">
115                                                <?php if (function_exists('hotDates')) { hotDates(); }?>
116                                                <div class ="xpress-post-title">
117                                                        <?php if(function_exists('the_title_attribute')) : ?>                   
118                                                                <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>
119                                                        <?php else : ?>
120                                                                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title('','',false)); ?>"><?php the_title(); ?></a></h2>
121                                                        <?php endif; ?>
122
123                                                </div>
124                                        </div>
125                                        <div class="xpress-post-entry">
126                                        <?php   echo $post_content; ?>                                                 
127                                        </div>
128                                        <div class="xpress-link-pages"><?php wp_link_pages() ?></div>
129                                        <div class ="xpress-post-footer">
130<?php
131                                                the_time('Y/m/d l');
132                                                echo ' - ';
133                                                the_author_posts_link();
134                                                echo ' (' . xpress_post_views_count($post->ID,__('Views :%d', 'xpress'),false) . ')';
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,'views: %d' ,false);
154//                      if (empty($tags)) $tags = __('Not Tag');
155
156                        $row_data = array(
157                                'post_id'               => $post_id ,
158                                'post_title'    => $post_title ,
159                                'post_content'          => $post_content ,
160                                'post_date' => $post_date ,
161                                'post_time' => $post_time ,
162                                'post_date_time' => $post_date_time ,
163                                'post_modified_date' => $post_modified_date ,
164                                'post_modified_time' => $post_modified_time ,
165                                'post_modified_date_time' => $post_modified_date_time ,
166                                'post_author'   => $author ,
167                                'post_category'         => $category , 
168                                'post_tags'             => $tags,
169                                'post_views'            => $post_viwes,
170                                'comment_link'  => $comments_popup_link ,
171                                'trackback_url' => $trackback_url ,
172                                'all_in_one' => $all_in_one
173                        );
174                       
175                        $block['contents']['item'.$item_no] = $row_data;
176                        $item_no++;
177                }
178                $block['data_count'] = $item_no;  //xml unserialise error
179        }
180        return $block ;
181}
182
183?>
Note: See TracBrowser for help on using the repository browser.