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