X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/ff81ee6e8304a1982a3ec4f5b134764a29d502cf..refs/tags/wordpress-2.9:/wp-admin/edit-comments.php?mode=edit diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index e74ebb49..ee23b3e3 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -1,172 +1,461 @@ +wp_enqueue_script('admin-comments'); +enqueue_comment_hotkeys_js(); + +$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; - + +if ( $post_id ) + $title = sprintf(__('Edit Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50)); +else + $title = __('Edit Comments'); + +require_once('admin-header.php'); + +$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']); + +$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; +if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) ) + $comment_status = 'all'; + +$comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : ''; + +$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : ''; +$search = esc_attr( $search_dirty ); ?> +
-

-
-
- - - - - -
-
-

|

+ +

' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( stripslashes( $_GET['s'] ) ), 50 ) ) . '' ); ?> +

+ get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); - $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); - if ( current_user_can('edit_post', $post_id) ) : - wp_set_comment_status($comment, "delete"); - ++$i; - endif; - endforeach; - echo "

" . sprintf(__('%s comments deleted.'), $i) . "

"; -endif; - -if (isset($_GET['s'])) { - $s = $wpdb->escape($_GET['s']); - $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE - (comment_author LIKE '%$s%' OR - comment_author_email LIKE '%$s%' OR - comment_author_url LIKE ('%$s%') OR - comment_author_IP LIKE ('%$s%') OR - comment_content LIKE ('%$s%') ) AND - comment_approved != 'spam' - ORDER BY comment_date DESC"); -} else { - if ( isset($_GET['offset']) ) - $offset = (int) $_GET['offset'] * 20; - else - $offset = 0; - - $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20"); -} -if ('view' == $mode) { - if ($comments) { - if ($offset) - $start = " start='$offset'"; - else - $start = ''; - - echo "
    "; - $i = 0; - foreach ($comments as $comment) { - ++$i; $class = ''; - $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); - $comment_status = wp_get_comment_status($comment->comment_ID); - if ('unapproved' == $comment_status) - $class .= ' unapproved'; - if ($i % 2) - $class .= ' alternate'; - echo "
  1. "; -?> -

    comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | |

    - - - -

    comment_post_ID) ) { - echo " | comment_ID."\">" . __('Edit Comment') . ""; - echo " | comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Delete Comment') . " — "; - } // end if any comments to show - // Get post title - if ( current_user_can('edit_post', $comment->comment_post_ID) ) { - $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"); - $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; - ?> - - |

    -
  2. - - -
+if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) ) { + $approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0; + $deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0; + $trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0; + $untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0; + $spammed = isset($_GET['spammed']) ? (int) $_GET['spammed'] : 0; + $unspammed = isset($_GET['unspammed']) ? (int) $_GET['unspammed'] : 0; -
+ if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 ) { + echo '

'; - 0 ) { + printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); + echo '
'; + } + if ( $spammed > 0 ) { + printf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ); + $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; + echo ' ' . __('Undo') . '
'; + } + if ( $unspammed > 0 ) { + printf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); + echo '
'; + } + if ( $trashed > 0 ) { + printf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed ); + $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; + echo ' ' . __('Undo') . '
'; + } + if ( $untrashed > 0 ) { + printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed ); + echo '
'; + } + if ( $deleted > 0 ) { + printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); + echo '
'; + } - ?> -

-

- - - - - - - - - - - '; - foreach ($comments as $comment) { - $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); - $class = ('alternate' == $class) ? '' : 'alternate'; + echo '

'; + } +} ?> - - - - - - - - - - -
*' . __('Name') . '' . __('E-mail') . '' . __('IP') . '' . __('Comment Excerpt') . '' . __('Actions') . '
comment_post_ID) ) { ?>comment_post_ID) ) { - echo "" . __('Edit') . ""; } ?>comment_post_ID) ) { - echo "comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\" class='delete'>" . __('Delete') . ""; } ?>
-

-

')" />

- + +
+
    moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), +//, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") +$stati = array( + 'all' => _n_noop('All', 'All'), // singular not used + 'moderated' => _n_noop('Pending (%s)', 'Pending (%s)'), + 'approved' => _n_noop('Approved', 'Approved'), // singular not used + 'spam' => _n_noop('Spam (%s)', 'Spam (%s)'), + 'trash' => _n_noop('Trash (%s)', 'Trash (%s)') + ); + +if ( !EMPTY_TRASH_DAYS ) + unset($stati['trash']); + +$link = 'edit-comments.php'; +if ( !empty($comment_type) && 'all' != $comment_type ) + $link = add_query_arg( 'comment_type', $comment_type, $link ); + +foreach ( $stati as $status => $label ) { + $class = ''; + + if ( $status == $comment_status ) + $class = ' class="current"'; + if ( !isset( $num_comments->$status ) ) + $num_comments->$status = 10; + $link = add_query_arg( 'comment_status', $status, $link ); + if ( $post_id ) + $link = add_query_arg( 'p', absint( $post_id ), $link ); + /* + // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark + if ( !empty( $_GET['s'] ) ) + $link = add_query_arg( 's', esc_attr( stripslashes( $_GET['s'] ) ), $link ); + */ + $status_links[] = "
  • " . sprintf( + _n( $label[0], $label[1], $num_comments->$status ), + number_format_i18n( $num_comments->$status ) + ) . ''; +} + +$status_links = apply_filters( 'comment_status_links', $status_links ); + +echo implode( " |
  • \n", $status_links) . ''; +unset($status_links); ?> -

    - +

+ + + comment_post_ID; } - ?> +$_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids); +foreach ( (array) $_comment_post_ids as $_cpid ) + $_comment_pending_count[$_cpid] = isset( $_comment_pending_count_temp[$_cpid] ) ? $_comment_pending_count_temp[$_cpid] : 0; +if ( empty($_comment_pending_count) ) + $_comment_pending_count = array(); + +$comments = array_slice($_comments, 0, $comments_per_page); +$extra_comments = array_slice($_comments, $comments_per_page); + +$page_links = paginate_links( array( + 'base' => add_query_arg( 'apage', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil($total / $comments_per_page), + 'current' => $page +)); + +?> + + + + + + + + +
+ + +
' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( $start + 1 ), + number_format_i18n( min( $page * $comments_per_page, $total ) ), + '' . number_format_i18n( $total ) . '', + $page_links +); echo $page_links_text; ?>
+ + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + +comment_ID, $mode, $comment_status ); +?> + + +comment_ID, $mode, $comment_status ); +?> + +
+ +
+$page_links_text
"; +?> + +
+ + + + + + + + + +
+ +
+
+ + + + + +
+ + +

+ + + +

+ + +
- +