[54] | 1 | <?php
|
---|
[95] | 2 | //if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
|
---|
[54] | 3 |
|
---|
| 4 | function recent_posts_content_block($options)
|
---|
| 5 | {
|
---|
| 6 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
[120] | 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;
|
---|
[145] | 9 | $excerpt = empty( $options[3] ) ? false : true ;
|
---|
| 10 | $excerpt_size = ($options[4])?intval($options[4]):100;
|
---|
[142] | 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 |
|
---|
[95] | 16 | $mydirpath = get_xpress_dir_path();
|
---|
[54] | 17 |
|
---|
[142] | 18 | if (empty($date_format)) $date_format = get_settings('date_format');
|
---|
| 19 | if (empty($time_format)) $time_format = get_settings('time_format');
|
---|
[58] | 20 | if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
|
---|
[54] | 21 |
|
---|
[272] | 22 | $selected_author_id = xpress_selected_author_id('echo=0');
|
---|
[157] | 23 | if (!empty($selected_author_id)){
|
---|
| 24 | $author_where ="author=$selected_author_id&";
|
---|
| 25 | } else {
|
---|
| 26 | $author_where = '';
|
---|
| 27 | }
|
---|
[58] | 28 | global $wpdb,$wp_query;
|
---|
[54] | 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) {
|
---|
[157] | 34 | $r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
|
---|
[54] | 35 |
|
---|
| 36 | } else {
|
---|
| 37 | $cat_id = implode(',',$selected);
|
---|
[157] | 38 | $r = new WP_Query($author_where . $tag_where . "cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
|
---|
[54] | 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 |
|
---|
[272] | 47 | $title = xpress_the_title('echo=0');
|
---|
[54] | 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 |
|
---|
[262] | 64 | if (function_exists('the_tags')){
|
---|
| 65 | ob_start();
|
---|
| 66 | the_tags(__('Tags:', 'xpress') . ' ',' • ','');
|
---|
| 67 | $tags = ob_get_contents();
|
---|
| 68 | ob_end_clean();
|
---|
| 69 | } else {
|
---|
| 70 | $tags = '';
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[145] | 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 {
|
---|
[197] | 79 | $post_content = get_the_content(__('more'),0,'',false);
|
---|
[198] | 80 | $post_content = apply_filters('the_content', $post_content);
|
---|
| 81 | $post_content = str_replace(']]>', ']]>', $post_content);
|
---|
[57] | 82 | }
|
---|
| 83 |
|
---|
[54] | 84 | ob_start();
|
---|
[142] | 85 | the_modified_date($date_format);
|
---|
[54] | 86 | $post_modified_date = ob_get_contents();
|
---|
| 87 | ob_end_clean();
|
---|
[262] | 88 |
|
---|
[54] | 89 | ob_start();
|
---|
[142] | 90 | the_modified_date($time_format);
|
---|
[54] | 91 | $post_modified_time = ob_get_contents();
|
---|
| 92 | ob_end_clean();
|
---|
| 93 |
|
---|
| 94 | ob_start();
|
---|
[142] | 95 | the_time($date_format);
|
---|
[54] | 96 | $post_date = ob_get_contents();
|
---|
| 97 | ob_end_clean();
|
---|
| 98 |
|
---|
| 99 | ob_start();
|
---|
[142] | 100 | the_time($time_format);
|
---|
[54] | 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();
|
---|
[165] | 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">
|
---|
[262] | 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 |
|
---|
[165] | 123 | </div>
|
---|
| 124 | </div>
|
---|
| 125 | <div class="xpress-post-entry">
|
---|
[197] | 126 | <?php echo $post_content; ?>
|
---|
[165] | 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();
|
---|
[272] | 134 | echo ' (' . xpress_post_views_count('post_id=' . $post->ID . '&format=' . __('Views :%d', 'xpress'). '&echo=0') . ')';
|
---|
| 135 |
|
---|
[165] | 136 | echo ' | ';
|
---|
| 137 | // echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');
|
---|
| 138 | printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
|
---|
| 139 | echo ' | ';
|
---|
| 140 | edit_post_link(__('Edit', 'xpress'), '', ' | ');
|
---|
| 141 | comments_popup_link(__('No Comments »', 'xpress'), __('1 Comment »', 'xpress'), __('% Comments »', 'xpress'), '', __('Comments Closed', 'xpress') );
|
---|
| 142 | ?>
|
---|
| 143 | </div>
|
---|
| 144 | </div>
|
---|
| 145 | <?php
|
---|
| 146 | $all_in_one = ob_get_contents();
|
---|
| 147 | ob_end_clean();
|
---|
| 148 |
|
---|
[54] | 149 |
|
---|
| 150 | $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
|
---|
| 151 | $post_date_time = $post_date . ' ' . $post_time ;
|
---|
| 152 | $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
|
---|
| 153 | $trackback_url = trackback_url(false);
|
---|
[272] | 154 | $post_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
|
---|
| 155 |
|
---|
[58] | 156 | // if (empty($tags)) $tags = __('Not Tag');
|
---|
[54] | 157 |
|
---|
| 158 | $row_data = array(
|
---|
| 159 | 'post_id' => $post_id ,
|
---|
| 160 | 'post_title' => $post_title ,
|
---|
| 161 | 'post_content' => $post_content ,
|
---|
| 162 | 'post_date' => $post_date ,
|
---|
| 163 | 'post_time' => $post_time ,
|
---|
| 164 | 'post_date_time' => $post_date_time ,
|
---|
| 165 | 'post_modified_date' => $post_modified_date ,
|
---|
| 166 | 'post_modified_time' => $post_modified_time ,
|
---|
| 167 | 'post_modified_date_time' => $post_modified_date_time ,
|
---|
| 168 | 'post_author' => $author ,
|
---|
| 169 | 'post_category' => $category ,
|
---|
| 170 | 'post_tags' => $tags,
|
---|
| 171 | 'post_views' => $post_viwes,
|
---|
| 172 | 'comment_link' => $comments_popup_link ,
|
---|
[165] | 173 | 'trackback_url' => $trackback_url ,
|
---|
| 174 | 'all_in_one' => $all_in_one
|
---|
[54] | 175 | );
|
---|
| 176 |
|
---|
| 177 | $block['contents']['item'.$item_no] = $row_data;
|
---|
| 178 | $item_no++;
|
---|
| 179 | }
|
---|
| 180 | $block['data_count'] = $item_no; //xml unserialise error
|
---|
| 181 | }
|
---|
| 182 | return $block ;
|
---|
| 183 | }
|
---|
[165] | 184 |
|
---|
[54] | 185 | ?> |
---|