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 | $except = empty( $options[3] ) ? false : true ;
|
---|
10 | $except_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 | global $wpdb,$wp_query;
|
---|
23 | $block = array();
|
---|
24 | $item_no = 0;
|
---|
25 | if (!is_null($wpdb)){
|
---|
26 | $wp_query->in_the_loop = true; //for use the_tags() in multi lopp
|
---|
27 | if (array_search(0,$selected)===0) {
|
---|
28 | $r = new WP_Query($tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
|
---|
29 |
|
---|
30 | } else {
|
---|
31 | $cat_id = implode(',',$selected);
|
---|
32 | $r = new WP_Query($tag_where . "cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
|
---|
33 | }
|
---|
34 | while($r->have_posts()){
|
---|
35 | $r->the_post();
|
---|
36 | ob_start();
|
---|
37 | the_ID();
|
---|
38 | $post_id = ob_get_contents();
|
---|
39 | ob_end_clean();
|
---|
40 |
|
---|
41 | ob_start();
|
---|
42 | the_title();
|
---|
43 | $title = ob_get_contents();
|
---|
44 | ob_end_clean();
|
---|
45 |
|
---|
46 | ob_start();
|
---|
47 | the_permalink();
|
---|
48 | $permalink = ob_get_contents();
|
---|
49 | ob_end_clean();
|
---|
50 |
|
---|
51 | ob_start();
|
---|
52 | the_author_posts_link();
|
---|
53 | $author = ob_get_contents();
|
---|
54 | ob_end_clean();
|
---|
55 |
|
---|
56 | ob_start();
|
---|
57 | the_category(' • ');
|
---|
58 | $category = ob_get_contents();
|
---|
59 | ob_end_clean();
|
---|
60 |
|
---|
61 | ob_start();
|
---|
62 | the_tags(__('Tags:', 'kubrick') . ' ',' • ','');
|
---|
63 | $tags = ob_get_contents();
|
---|
64 | ob_end_clean();
|
---|
65 |
|
---|
66 | if ($except){
|
---|
67 | $post_content = xpress_the_content(__('more'),$except_size,false);
|
---|
68 | } else {
|
---|
69 | $post_content = xpress_the_content(__('more'),0,false);
|
---|
70 | }
|
---|
71 |
|
---|
72 | ob_start();
|
---|
73 | the_modified_date($date_format);
|
---|
74 | $post_modified_date = ob_get_contents();
|
---|
75 | ob_end_clean();
|
---|
76 |
|
---|
77 | ob_start();
|
---|
78 | the_modified_date($time_format);
|
---|
79 | $post_modified_time = ob_get_contents();
|
---|
80 | ob_end_clean();
|
---|
81 |
|
---|
82 | ob_start();
|
---|
83 | the_time($date_format);
|
---|
84 | $post_date = ob_get_contents();
|
---|
85 | ob_end_clean();
|
---|
86 |
|
---|
87 | ob_start();
|
---|
88 | the_time($time_format);
|
---|
89 | $post_time = ob_get_contents();
|
---|
90 | ob_end_clean();
|
---|
91 |
|
---|
92 |
|
---|
93 | ob_start();
|
---|
94 | comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
|
---|
95 | $comments_popup_link = ob_get_contents();
|
---|
96 | ob_end_clean();
|
---|
97 |
|
---|
98 | $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
|
---|
99 | $post_date_time = $post_date . ' ' . $post_time ;
|
---|
100 | $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
|
---|
101 | $trackback_url = trackback_url(false);
|
---|
102 | $post_viwes = xpress_post_views_count($post_id,'views: %d' ,false);
|
---|
103 | // if (empty($tags)) $tags = __('Not Tag');
|
---|
104 |
|
---|
105 | $row_data = array(
|
---|
106 | 'post_id' => $post_id ,
|
---|
107 | 'post_title' => $post_title ,
|
---|
108 | 'post_content' => $post_content ,
|
---|
109 | 'post_date' => $post_date ,
|
---|
110 | 'post_time' => $post_time ,
|
---|
111 | 'post_date_time' => $post_date_time ,
|
---|
112 | 'post_modified_date' => $post_modified_date ,
|
---|
113 | 'post_modified_time' => $post_modified_time ,
|
---|
114 | 'post_modified_date_time' => $post_modified_date_time ,
|
---|
115 | 'post_author' => $author ,
|
---|
116 | 'post_category' => $category ,
|
---|
117 | 'post_tags' => $tags,
|
---|
118 | 'post_views' => $post_viwes,
|
---|
119 | 'comment_link' => $comments_popup_link ,
|
---|
120 | 'trackback_url' => $trackback_url
|
---|
121 | );
|
---|
122 |
|
---|
123 | $block['contents']['item'.$item_no] = $row_data;
|
---|
124 | $item_no++;
|
---|
125 | }
|
---|
126 | $block['data_count'] = $item_no; //xml unserialise error
|
---|
127 | }
|
---|
128 | return $block ;
|
---|
129 | }
|
---|
130 | ?> |
---|