Ticket #4038: 4038.diff
File 4038.diff, 17.4 KB (added by , 17 years ago) |
---|
-
wp-includes/script-loader.php
34 34 'strangeText' => __("Something strange happened. Try refreshing the page."), 35 35 'whoaText' => __("Slow down, I'm still sending your data!") 36 36 ) ); 37 $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306' );37 $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306' + mt_rand()); 38 38 $this->localize( 'listman', 'listManL10n', array( 39 39 'jumpText' => __('Jump to new item'), 40 40 'delText' => __('Are you sure you want to delete this %thing%?') … … 84 84 ) ); 85 85 $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' ); 86 86 $this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' ); 87 $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );87 $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' + mt_rand() ); 88 88 $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' ); 89 89 $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' ); 90 90 $this->add( 'upload', '/wp-admin/upload.js', array('prototype'), '20070306' ); -
wp-admin/edit-comments.js
2 2 theCommentList = new listMan('the-comment-list'); 3 3 if ( !theCommentList ) 4 4 return false; 5 6 theExtraCommentList = new listMan('the-extra-comment-list'); 7 if ( theExtraCommentList ) { 8 theExtraCommentList.showLink = 0; 9 theExtraCommentList.altOffset = 1; 10 if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes ) 11 var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; 12 else 13 var commentNum = 0; 14 var urlQ = document.location.href.split('?'); 15 var params = urlQ[1] ? urlQ[1].toQueryParams() : []; 16 var search = params['s'] ? params['s'] : ''; 17 var page = params['apage'] ? params['apage'] : 1; 18 } 19 5 20 theCommentList.dimComplete = function(what,id,dimClass) { 6 21 var m = document.getElementById('awaitmod'); 7 if ( document.getElementById(what + '-' + id).className.match(dimClass) ) m.innerHTML = parseInt(m.innerHTML,10) + 1; 8 else m.innerHTML = parseInt(m.innerHTML,10) - 1; 22 if ( document.getElementById(what + '-' + id).className.match(dimClass) ) 23 m.innerHTML = parseInt(m.innerHTML,10) + 1; 24 else 25 m.innerHTML = parseInt(m.innerHTML,10) - 1; 9 26 } 27 10 28 theCommentList.delComplete = function(what,id) { 11 29 var m = document.getElementById('awaitmod'); 12 if ( document.getElementById(what + '-' + id).className.match('unapproved') ) m.innerHTML = parseInt(m.innerHTML,10) - 1; 30 if ( document.getElementById(what + '-' + id).className.match('unapproved') ) 31 m.innerHTML = parseInt(m.innerHTML,10) - 1; 32 if ( theExtraCommentList && commentNum ) { 33 var theMover = theExtraCommentList.theList.childNodes[0]; 34 Element.removeClassName(theMover,'alternate'); 35 theCommentList.theList.appendChild(theMover); 36 theExtraCommentList.inputData += '&page=' + page; 37 if ( search ) 38 theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box 39 theExtraCommentList.addComplete = function() { 40 if ( theExtraCommentList.theList.childNodes ) 41 var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; 42 else 43 var commentNum = 0; 44 } 45 theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request 46 } 13 47 } 48 14 49 if ( theList ) // the post list: edit.php 15 50 theList.delComplete = function() { 16 51 var comments = document.getElementById('comments'); -
wp-admin/edit-comments.php
75 75 echo '</p></div>'; 76 76 endif; 77 77 78 if (isset($_GET['s'])) { 79 $s = $wpdb->escape($_GET['s']); 80 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE 81 (comment_author LIKE '%$s%' OR 82 comment_author_email LIKE '%$s%' OR 83 comment_author_url LIKE ('%$s%') OR 84 comment_author_IP LIKE ('%$s%') OR 85 comment_content LIKE ('%$s%') ) AND 86 comment_approved != 'spam' 87 ORDER BY comment_date DESC"); 88 } else { 89 if ( isset( $_GET['apage'] ) ) 90 $page = (int) $_GET['apage']; 91 else 92 $page = 1; 93 $start = $offset = ( $page - 1 ) * 20; 78 if ( isset( $_GET['apage'] ) ) 79 $page = (int) $_GET['apage']; 80 else 81 $page = 1; 82 $start = $offset = ( $page - 1 ) * 20; 94 83 95 $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, 20" ); 96 $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1'" ); 97 } 98 ?> 99 <?php if ( $total > 20 ) { 100 $total_pages = ceil( $total / 20 ); 101 $r = ''; 102 if ( 1 < $page ) { 103 $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; 104 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">« '. __('Previous Page') .'</a>' . "\n"; 105 } 106 if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { 107 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : 108 if ( $page == $page_num ) : 109 $r .= "<span>$page_num</span>\n"; 110 else : 111 $p = false; 112 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : 113 $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; 114 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n"; 115 $in = true; 116 elseif ( $in == true ) : 117 $r .= "...\n"; 118 $in = false; 119 endif; 120 endif; 121 endfor; 122 } 123 if ( ( $page ) * 20 < $total || -1 == $total ) { 124 $args['apage'] = $page + 1; 125 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' »</a>' . "\n"; 126 } 127 echo "<p class='pagenav'>$r</p>"; 128 ?> 84 list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra 129 85 130 <?php } ?> 86 $comments = array_slice($_comments, 0, 20); 87 $extra_comments = array_slice($_comments, 20); 131 88 132 <?php 89 $page_links = paginate_links( array( 90 'base' => clean_url( add_query_arg( 'apage', '%#%' ) ), 91 'format' => '', 92 'total' => ceil($total / 20), 93 'current' => $page 94 )); 95 96 if ( $page_links ) 97 echo "<p class='pagenav'>$page_links</p>"; 98 133 99 if ('view' == $mode) { 134 100 if ($comments) { 135 ?> 136 <?php 137 $offset = $offset + 1; 138 $start = " start='$offset'"; 101 $offset = $offset + 1; 102 $start = " start='$offset'"; 139 103 140 echo "<ol id='the-comment-list' class='commentlist' $start> ";104 echo "<ol id='the-comment-list' class='commentlist' $start>\n"; 141 105 $i = 0; 142 foreach ($comments as $comment) { 143 ++$i; $class = ''; 144 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 145 $comment_status = wp_get_comment_status($comment->comment_ID); 146 if ('unapproved' == $comment_status) 147 $class .= ' unapproved'; 148 if ($i % 2) 149 $class .= ' alternate'; 150 echo "<li id='comment-$comment->comment_ID' class='$class'>"; 151 ?> 152 <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 106 foreach ( $comments as $comment ) { 107 get_comment( $comment ); // Cache it 108 _wp_comment_list_item( $comment->comment_ID, ++$i ); 109 } 110 echo "</ol>\n\n"; 153 111 154 <?php comment_text()?>155 156 < p><?php comment_date(__('M j, g:i A')); ?> — [112 if ( $extra_comments ) : ?> 113 <div id="extra-comments" style="display:none"> 114 <ul id="the-extra-comment-list" class="commentlist"> 157 115 <?php 158 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 159 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 160 echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; 161 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 162 echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; 163 echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 116 foreach ( $extra_comments as $comment ) { 117 get_comment( $comment ); // Cache it 118 _wp_comment_list_item( $comment->comment_ID, ++$i ); 164 119 } 165 echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";166 }167 $post = get_post($comment->comment_post_ID);168 $post_title = wp_specialchars( $post->post_title, 'double' );169 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;170 120 ?> 171 ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> 172 </li> 121 </ul> 122 </div> 123 <?php endif; // $extra_comments ?> 173 124 174 <?php } // end foreach($comment) ?>175 </ol>176 177 125 <div id="ajax-response"></div> 178 126 179 127 <?php … … 242 190 <?php 243 191 } // end if ($comments) 244 192 } 245 ?>246 <?php if ( $total > 20 ) {247 $total_pages = ceil( $total / 20 );248 $r = '';249 if ( 1 < $page ) {250 $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1;251 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">« '. __('Previous Page') .'</a>' . "\n";252 }253 if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) {254 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :255 if ( $page == $page_num ) :256 $r .= "<span>$page_num</span>\n";257 else :258 $p = false;259 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :260 $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num;261 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";262 $in = true;263 elseif ( $in == true ) :264 $r .= "...\n";265 $in = false;266 endif;267 endif;268 endfor;269 }270 if ( ( $page ) * 20 < $total || -1 == $total ) {271 $args['apage'] = $page + 1;272 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' »</a>' . "\n";273 }274 echo "<p class='pagenav'>$r</p>";275 ?>276 193 277 <?php } ?> 194 if ( $page_links ) 195 echo "<p class='pagenav'>$page_links</p>"; 278 196 197 ?> 198 279 199 </div> 280 200 281 201 <?php include('admin-footer.php'); ?> -
wp-admin/admin-ajax.php
151 151 ) ); 152 152 $x->send(); 153 153 break; 154 case 'add-comment' : 155 if ( !current_user_can( 'edit_post', $id ) ) 156 die('-1'); 157 $search = isset($_POST['s']) ? $_POST['s'] : false; 158 $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25; 159 160 list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); 161 162 if ( !$comments ) 163 die('1'); 164 $x = new WP_Ajax_Response(); 165 foreach ( (array) $comments as $comment ) { 166 get_comment( $comment ); 167 ob_start(); 168 _wp_comment_list_item( $comment->comment_ID ); 169 $comment_list_item = ob_get_contents(); 170 ob_end_clean(); 171 $x->add( array( 172 'what' => 'comment', 173 'id' => $comment->comment_ID, 174 'data' => $comment_list_item 175 ) ); 176 } 177 $x->send(); 178 break; 154 179 case 'add-meta' : 155 180 if ( !current_user_can( 'edit_post', $id ) ) 156 181 die('-1'); -
wp-admin/admin-functions.php
909 909 return $r; 910 910 } 911 911 912 function _wp_get_comment_list( $s = false, $start, $num ) { 913 global $wpdb; 914 915 $start = (int) $start; 916 $num = (int) $num; 917 918 if ( $s ) { 919 $s = $wpdb->escape($s); 920 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE 921 (comment_author LIKE '%$s%' OR 922 comment_author_email LIKE '%$s%' OR 923 comment_author_url LIKE ('%$s%') OR 924 comment_author_IP LIKE ('%$s%') OR 925 comment_content LIKE ('%$s%') ) AND 926 comment_approved != 'spam' 927 ORDER BY comment_date DESC LIMIT $start, $num"); 928 } else { 929 $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" ); 930 } 931 932 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); 933 934 return array($comments, $total); 935 } 936 937 function _wp_comment_list_item( $id, $alt = 0 ) { 938 global $authordata, $comment, $wpdb; 939 $id = (int) $id; 940 $comment =& get_comment( $id ); 941 $class = ''; 942 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 943 $comment_status = wp_get_comment_status($comment->comment_ID); 944 if ( 'unapproved' == $comment_status ) 945 $class .= ' unapproved'; 946 if ( $alt % 2 ) 947 $class .= ' alternate'; 948 echo "<li id='comment-$comment->comment_ID' class='$class'>"; 949 ?> 950 <p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 951 952 <?php comment_text() ?> 953 954 <p><?php comment_date(__('M j, g:i A')); ?> — [ 955 <?php 956 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 957 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 958 echo ' | <a href="' . wp_nonce_url('ocomment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; 959 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 960 echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; 961 echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 962 } 963 echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; 964 } 965 $post = get_post($comment->comment_post_ID); 966 $post_title = wp_specialchars( $post->post_title, 'double' ); 967 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 968 ?> 969 ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> 970 </li> 971 <?php 972 } 973 912 974 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { 913 975 global $wpdb; 914 976 if (!$categories )