1 | <?php
|
---|
2 | //if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
|
---|
3 |
|
---|
4 | function 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(' • ');
|
---|
61 | $category = ob_get_contents();
|
---|
62 | ob_end_clean();
|
---|
63 |
|
---|
64 | ob_start();
|
---|
65 | the_tags(__('Tags:', 'kubrick') . ' ',' • ','');
|
---|
66 | $tags = ob_get_contents();
|
---|
67 | ob_end_clean();
|
---|
68 |
|
---|
69 | if ($excerpt){
|
---|
70 | $excerpt_length_word = $excerpt_size;
|
---|
71 | $excerpt_length_character = $excerpt_size;
|
---|
72 | $more_link_text = '';
|
---|
73 | $post_content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text);
|
---|
74 | } else {
|
---|
75 | $post_content = get_the_content(__('more'),0,'',false);
|
---|
76 | $post_content = apply_filters('the_content', $post_content);
|
---|
77 | $post_content = str_replace(']]>', ']]>', $post_content);
|
---|
78 | }
|
---|
79 |
|
---|
80 | ob_start();
|
---|
81 | the_modified_date($date_format);
|
---|
82 | $post_modified_date = ob_get_contents();
|
---|
83 | ob_end_clean();
|
---|
84 |
|
---|
85 | ob_start();
|
---|
86 | the_modified_date($time_format);
|
---|
87 | $post_modified_time = ob_get_contents();
|
---|
88 | ob_end_clean();
|
---|
89 |
|
---|
90 | ob_start();
|
---|
91 | the_time($date_format);
|
---|
92 | $post_date = ob_get_contents();
|
---|
93 | ob_end_clean();
|
---|
94 |
|
---|
95 | ob_start();
|
---|
96 | the_time($time_format);
|
---|
97 | $post_time = ob_get_contents();
|
---|
98 | ob_end_clean();
|
---|
99 |
|
---|
100 |
|
---|
101 | ob_start();
|
---|
102 | comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
|
---|
103 | $comments_popup_link = ob_get_contents();
|
---|
104 | ob_end_clean();
|
---|
105 |
|
---|
106 | // all_in_one
|
---|
107 | ob_start();
|
---|
108 | ?>
|
---|
109 | <div class="xpress-post" id="post-<?php the_ID(); ?>">
|
---|
110 | <div class ="xpress-post-header">
|
---|
111 | <?php if (function_exists('hotDates')) { hotDates(); }?>
|
---|
112 | <div class ="xpress-post-title">
|
---|
113 | <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>
|
---|
114 | </div>
|
---|
115 | </div>
|
---|
116 | <div class="xpress-post-entry">
|
---|
117 | <?php echo $post_content; ?>
|
---|
118 | </div>
|
---|
119 | <div class="xpress-link-pages"><?php wp_link_pages() ?></div>
|
---|
120 | <div class ="xpress-post-footer">
|
---|
121 | <?php
|
---|
122 | the_time('Y/m/d l');
|
---|
123 | echo ' - ';
|
---|
124 | the_author_posts_link();
|
---|
125 | echo ' (' . xpress_post_views_count($post->ID,__('Views :%d', 'xpress'),false) . ')';
|
---|
126 | echo ' | ';
|
---|
127 | // echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');
|
---|
128 | printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
|
---|
129 | echo ' | ';
|
---|
130 | edit_post_link(__('Edit', 'xpress'), '', ' | ');
|
---|
131 | comments_popup_link(__('No Comments »', 'xpress'), __('1 Comment »', 'xpress'), __('% Comments »', 'xpress'), '', __('Comments Closed', 'xpress') );
|
---|
132 | ?>
|
---|
133 | </div>
|
---|
134 | </div>
|
---|
135 | <?php
|
---|
136 | $all_in_one = ob_get_contents();
|
---|
137 | ob_end_clean();
|
---|
138 |
|
---|
139 |
|
---|
140 | $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
|
---|
141 | $post_date_time = $post_date . ' ' . $post_time ;
|
---|
142 | $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
|
---|
143 | $trackback_url = trackback_url(false);
|
---|
144 | $post_viwes = xpress_post_views_count($post_id,'views: %d' ,false);
|
---|
145 | // if (empty($tags)) $tags = __('Not Tag');
|
---|
146 |
|
---|
147 | $row_data = array(
|
---|
148 | 'post_id' => $post_id ,
|
---|
149 | 'post_title' => $post_title ,
|
---|
150 | 'post_content' => $post_content ,
|
---|
151 | 'post_date' => $post_date ,
|
---|
152 | 'post_time' => $post_time ,
|
---|
153 | 'post_date_time' => $post_date_time ,
|
---|
154 | 'post_modified_date' => $post_modified_date ,
|
---|
155 | 'post_modified_time' => $post_modified_time ,
|
---|
156 | 'post_modified_date_time' => $post_modified_date_time ,
|
---|
157 | 'post_author' => $author ,
|
---|
158 | 'post_category' => $category ,
|
---|
159 | 'post_tags' => $tags,
|
---|
160 | 'post_views' => $post_viwes,
|
---|
161 | 'comment_link' => $comments_popup_link ,
|
---|
162 | 'trackback_url' => $trackback_url ,
|
---|
163 | 'all_in_one' => $all_in_one
|
---|
164 | );
|
---|
165 |
|
---|
166 | $block['contents']['item'.$item_no] = $row_data;
|
---|
167 | $item_no++;
|
---|
168 | }
|
---|
169 | $block['data_count'] = $item_no; //xml unserialise error
|
---|
170 | }
|
---|
171 | return $block ;
|
---|
172 | }
|
---|
173 |
|
---|
174 | ?> |
---|