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