[35] | 1 | <?php
|
---|
| 2 | if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
|
---|
| 3 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
| 4 |
|
---|
| 5 | eval( '
|
---|
| 6 | function b_'.$mydirname.'_comments_show($options){
|
---|
| 7 | return _b_comments_show($options) ;
|
---|
| 8 | }
|
---|
| 9 | function b_'.$mydirname.'_comments_edit($options){
|
---|
| 10 | return _b_comments_edit($options) ;
|
---|
| 11 | }
|
---|
| 12 | ' ) ;
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | if( ! defined( 'XPRESS_COMMENTS_BLOCK_INCLUDED' ) ) {
|
---|
| 16 | define( 'XPRESS_COMMENTS_BLOCK_INCLUDED' , 1 ) ;
|
---|
| 17 | function _b_comments_edit($options)
|
---|
| 18 | {
|
---|
| 19 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
| 20 | $disp_count = empty( $options[1] ) ? '10' : $options[1] ;
|
---|
| 21 | $disp_length = empty( $options[2] ) ? '30' : $options[2] ;
|
---|
| 22 | $selected = array_slice($options,5); // get allowed cats
|
---|
| 23 | $this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_comments.html' : trim( $options[4] );
|
---|
| 24 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
| 25 |
|
---|
| 26 | require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
|
---|
| 27 |
|
---|
| 28 | $form = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
|
---|
| 29 | $form .= _MB_XPRESS_COUNT .": <input type='text' name='options[1]' value='" . $disp_count . "' /><br />";
|
---|
| 30 | $form .= _MB_XPRESS_LENGTH .": <input type='text' name='options[2]' value='" . $disp_length . "' />";
|
---|
| 31 | $form .= "<br /><br />" . _MB_XPRESS_COM_TYPE ;
|
---|
| 32 | $isAll = (count($selected)==0||empty($selected[0]))?true:false;
|
---|
| 33 | $form .= "<br /> <select name=\"options[]\" multiple=\"multiple\">";
|
---|
| 34 | $form .= "<option value=\"0\" ";
|
---|
| 35 | if ($isAll) $form .= " selected=\"selected\"";
|
---|
| 36 | $form .= ">"._MB_XPRESS_ALL ."</option>";
|
---|
| 37 |
|
---|
| 38 | $form .= "<option value=\"1\" ";
|
---|
| 39 | if (in_array(1, $selected))
|
---|
| 40 | $form .= " selected=\"selected\"";
|
---|
| 41 | $form .= ">"._MB_XPRESS_COMMENT ."</option>";
|
---|
| 42 |
|
---|
| 43 | $form .= "<option value=\"2\" ";
|
---|
| 44 | if (in_array(2, $selected))
|
---|
| 45 | $form .= " selected=\"selected\"";
|
---|
| 46 | $form .= ">"._MB_XPRESS_TRUCKBACK ."</option>";
|
---|
| 47 |
|
---|
| 48 | $form .= "<option value=\"3\" ";
|
---|
| 49 | if (in_array(3, $selected))
|
---|
| 50 | $form .= " selected=\"selected\"";
|
---|
| 51 | $form .= ">"._MB_XPRESS_PINGBACK ."</option>";
|
---|
| 52 | $form .= "</select><br />";
|
---|
| 53 | // $form .="<br /><input type='text' size='60' name='options[5]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' />";
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | return $form;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | function _b_comments_show($options)
|
---|
| 60 | {
|
---|
| 61 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
| 62 | $disp_count = empty( $options[1] ) ? '10' : $options[1] ;
|
---|
| 63 | $disp_length = empty( $options[2] ) ? '30' : $options[2] ;
|
---|
| 64 | $selected = array_slice($options,5); // get allowed cats
|
---|
| 65 | $this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_comments.html' : trim( $options[4] );
|
---|
| 66 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
| 67 |
|
---|
| 68 | $myts =& MyTextSanitizer::getInstance();
|
---|
| 69 |
|
---|
| 70 | $this_url = '/modules/'. $mydirname;
|
---|
| 71 | $call_url = $_SERVER['REQUEST_URI'];
|
---|
| 72 |
|
---|
| 73 | $disp_all = in_array('0',$selected);
|
---|
| 74 | $disp_comment = in_array('1',$selected);
|
---|
| 75 | $disp_trackback = in_array('2',$selected);
|
---|
| 76 | $disp_pingback = in_array('3',$selected);
|
---|
| 77 |
|
---|
| 78 | $type_select = '';
|
---|
| 79 | if (!$disp_all){
|
---|
| 80 | if ($disp_comment){
|
---|
| 81 | $in_where = "''";
|
---|
| 82 | }
|
---|
| 83 | if ($disp_trackback){
|
---|
| 84 | if (empty($in_where)) $in_where = "'trackback' "; else $in_where .= ",'trackback'";
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | if ($disp_pingback){
|
---|
| 88 | if (empty($in_where)) $in_where = "'pingback' "; else $in_where .= ",'pingback'";
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | if (! empty($in_where)){
|
---|
| 92 | $type_select = " AND comment_type IN($in_where) ";
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | global $wpdb;
|
---|
| 97 |
|
---|
| 98 | if (!is_null($wpdb)){
|
---|
[36] | 99 | $comment_sql = "SELECT comment_ID,comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_content, comment_type,UNIX_TIMESTAMP(comment_date) as comment_unix_time ";
|
---|
| 100 | $comment_sql .= "FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID ";
|
---|
| 101 | $comment_sql .= "WHERE comment_approved = '1' AND post_type = 'post' AND post_status = 'publish' $type_select ";
|
---|
| 102 | $comment_sql .= "ORDER BY comment_date_gmt DESC LIMIT $disp_count";
|
---|
[35] | 103 |
|
---|
[36] | 104 | $comments = $wpdb->get_results($comment_sql);
|
---|
[35] | 105 | $format = get_settings('date_format') . ' ' . get_settings('time_format');
|
---|
| 106 |
|
---|
| 107 | if ( $comments ) {
|
---|
| 108 | $output .= '<ul>';
|
---|
[36] | 109 | $item_no = 0;
|
---|
[35] | 110 | foreach ($comments as $comment){
|
---|
| 111 | $comment_content = $comment->comment_content;
|
---|
| 112 | $comment_excerpt = ($disp_length>0 ? xoops_substr($comment_content, 0, $disp_length): $comment->comment_content);
|
---|
| 113 |
|
---|
| 114 | $comment_link = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID ;
|
---|
| 115 | $comment_title = $comment_excerpt;
|
---|
[36] | 116 | $comment_title_link = "<a href='$comment_link' rel='external nofollow' class='url'>$comment_title</a>";
|
---|
[35] | 117 |
|
---|
| 118 | $post_link = get_comment_link($comment->comment_ID);
|
---|
| 119 | $post_title = get_the_title($comment->comment_post_ID);
|
---|
| 120 | $post_title_link = '<a href="'. $post_link . '">' . $post_title . '</a>';
|
---|
| 121 |
|
---|
| 122 | $author_link = $comment->comment_author_url;
|
---|
| 123 | $author_name = $comment->comment_author;
|
---|
| 124 | $author_name_link = (( empty( $author_link ) || 'http://' == $author_link ) ? $author_name : "<a href='$author_link' rel='external nofollow' class='url'>$author_name</a>");
|
---|
| 125 |
|
---|
| 126 | $comment_type = (empty($comment->comment_type) ? 'comment': $comment->comment_type);
|
---|
| 127 | $from_auther_to_post = sprintf(__('%1$s on %2$s'), $author_name_link , $post_title_link );
|
---|
| 128 |
|
---|
| 129 | $row_data = array(
|
---|
| 130 | 'comment_ID' => $comment->comment_ID ,
|
---|
| 131 | 'comment_post_ID' => $comment->comment_post_ID ,
|
---|
[36] | 132 | 'comment_date' => date(get_settings('date_format'),$comment->comment_unix_time) ,
|
---|
| 133 | 'comment_date_time' => date(get_settings('date_format') . ' ' . get_settings('time_format'),$comment->comment_unix_time) ,
|
---|
[35] | 134 | 'comment_content' => $comment_content ,
|
---|
| 135 | 'comment_excerpt' => $comment_excerpt ,
|
---|
| 136 | 'comment_link' => $comment_link,
|
---|
[36] | 137 | 'comment_title' => $comment_title ,
|
---|
[35] | 138 | 'comment_title_link' => $comment_title_link ,
|
---|
| 139 | 'post_link' => $post_link,
|
---|
| 140 | 'post_title' => $post_title,
|
---|
| 141 | 'post_title_link' => $post_title_link,
|
---|
| 142 | 'author_link' => $author_link,
|
---|
| 143 | 'author_name' => $author_name,
|
---|
| 144 | 'author_name_link' => $author_name_link,
|
---|
| 145 | 'comment_type' => $comment_type,
|
---|
| 146 | 'from_auther_to_post' => $from_auther_to_post
|
---|
| 147 | );
|
---|
| 148 |
|
---|
[36] | 149 | $block['contents']['item'.$item_no] = $row_data;
|
---|
| 150 | $item_no++;
|
---|
[35] | 151 | }
|
---|
| 152 | }
|
---|
[36] | 153 | require_once dirname(dirname( __FILE__ )).'/include/xoops_block_cache.php';
|
---|
| 154 | xpress_block_cache_write($mydirname,'recent_comment_block',$block);
|
---|
[35] | 155 | } else {
|
---|
[36] | 156 | require_once dirname(dirname( __FILE__ )).'/include/xoops_block_cache.php';
|
---|
| 157 | $block = xpress_block_cache_read($mydirname,'recent_comment_block');
|
---|
[35] | 158 | }
|
---|
[36] | 159 | return $block ;
|
---|
[35] | 160 | }
|
---|
| 161 | }
|
---|
| 162 | ?> |
---|