Make WordPress Core

Changeset 887


Ignore:
Timestamp:
02/17/2004 08:35:04 AM (21 years ago)
Author:
saxmatt
Message:

Edit comments improvement, multiple comment delete not implemented yet.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r869 r887  
    11<?php
     2
     3function url_shorten ($url) {
     4    $short_url = str_replace('http://', '', stripslashes($url));
     5    $short_url = str_replace('www.', '', $short_url);
     6    if ('/' == substr($short_url, -1))
     7        $short_url = substr($short_url, 0, -1);
     8    if (strlen($short_url) > 35)
     9        $short_url =  substr($short_url, 0, 32).'...';
     10    return $short_url;
     11}
    212
    313function selected($selected, $current) {
  • trunk/wp-admin/edit-comments.php

    r872 r887  
    33$parent_file = 'edit.php';
    44require_once('admin-header.php');
     5if (empty($_GET['mode'])) $mode = 'view';
     6else $mode = $_GET['mode'];
    57?>
    68<ul id="adminmenu2">
     
    911    <li class="last"><a href="moderation.php">Awaiting Moderation</a></li>
    1012</ul>
    11 
     13<script type="text/javascript">
     14<!--
     15function checkAll(form)
     16{
     17    for (i = 0, n = form.elements.length; i < n; i++) {
     18        if(form.elements[i].type == "checkbox") {
     19            if(form.elements[i].checked == true)
     20                form.elements[i].checked = false;
     21            else
     22                form.elements[i].checked = true;
     23        }
     24    }
     25}
     26//-->
     27</script>
    1228<div class="wrap">
    1329<form name="searchform" action="" method="get">
     
    1531  <legend>Show Comments That Contain...</legend>
    1632  <input type="text" name="s" value="<?php echo $s; ?>" size="17" />
    17   <input type="submit" name="submit" value="Search"  />
     33  <input type="submit" name="submit" value="Search"  /> 
     34  <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
     35   (Searches within comment text, email, URI, and IP address.)
    1836  </fieldset>
    1937</form>
     
    2846        comment_author_IP LIKE ('%$s%') OR
    2947        comment_content LIKE ('%$s%')
    30         ORDER BY comment_date");
     48        ORDER BY comment_date DESC");
    3149} else {
    32     $comments = $wpdb->get_results("SELECT * FROM $tablecomments ORDER BY comment_date $commentorder LIMIT 20");
     50    $comments = $wpdb->get_results("SELECT * FROM $tablecomments ORDER BY comment_date DESC LIMIT 20");
    3351}
     52if ('view' == $mode) {
    3453    if ($comments) {
    3554        echo '<ol>';
     
    6382        ?>
    6483        <p>
     84        <strong>No results found.</strong></p>
     85       
     86        <?php
     87    } // end if ($comments)
     88} elseif ('edit' == $mode) {
     89    if ($comments) {
     90        echo '<form name="deletecomments" id="deletecomments" action="" method="post">
     91        <table width="100%" cellpadding="3" cellspacing="3">
     92  <tr>
     93    <th scope="col">*</th>
     94    <th scope="col">Name</th>
     95    <th scope="col">Email</th>
     96    <th scope="col">IP</th>
     97    <th scope="col">Comment Excerpt</th>
     98    <th scope="col">Edit</th>
     99    <th scope="col">Delete</th>
     100  </tr>';
     101        foreach ($comments as $comment) {
     102        $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee';
     103?>
     104  <tr style='background-color: <?php echo $bgcolor; ?>'>
     105    <td><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /></td>
     106    <th scope="row"><?php comment_author_link() ?></th>
     107    <td><?php comment_author_email_link() ?></td>
     108    <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
     109    <td><?php comment_excerpt(); ?></td>
     110    <td><?php if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
     111                echo "<a href='post.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>Edit</a>"; } ?></td>
     112    <td><?php if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
     113                echo "<a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('You are about to delete this comment by \'".$comment->comment_author."\'\\n  \'Cancel\' to stop, \'OK\' to delete.')\" class='delete'>Delete</a>"; } ?></td>
     114  </tr>
     115        <?php
     116        } // end foreach
     117    ?></table>
     118    <p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; ">Invert Checkbox Selection</a></p>
     119    <p style="text-align: right;"><input type="submit" name="Submit" value="Delete Checked Comments" onclick="return confirm('You are about to delete these comments permanently \n  \'Cancel\' to stop, \'OK\' to delete.')" />    </p>
     120  </form>
     121<?php
     122    } else {
     123
     124        ?>
     125        <p>
    65126        <strong>No results found.</strong>
    66127        </p>
     
    68129        <?php
    69130    } // end if ($comments)
    70 
     131}
    71132    ?>
    72133
  • trunk/wp-admin/moderation.php

    r682 r887  
    9797?>
    9898<ul id="adminmenu2">
    99     <li><a href="edit.php">Latest Posts</a></li>
    100     <li><a href="edit-comments.php">Latest Comments</a></li>
    101     <li class="last"><a href="moderation.php" class="current">Comments Awaiting Moderation</a></li>
     99    <li><a href="edit.php"> Posts</a></li>
     100    <li><a href="edit-comments.php"> Comments</a></li>
     101    <li class="last"><a href="moderation.php" class="current">Awaiting Moderation</a></li>
    102102</ul>
    103103<?php
     
    167167?>
    168168    </ol>
    169     <input type="submit" name="submit" value="Moderate Comments" class="search" />
     169    <input type="submit" name="submit" value="Moderate Comments" />
    170170    </form>
    171171<?php
  • trunk/wp-includes/template-functions-comment.php

    r885 r887  
    77
    88add_filter('comment_email', 'remove_slashes', 5);
    9 add_filter('comment_email', 'antispambot', 5);
     9add_filter('comment_email', 'antispambot');
    1010
    1111add_filter('comment_url', 'clean_url');
    1212
     13add_filter('comment_text', 'remove_slashes', 5);
    1314add_filter('comment_text', 'convert_chars');
    1415add_filter('comment_text', 'make_clickable');
    15 add_filter('comment_text', 'wpautop');
     16add_filter('comment_text', 'wpautop', 30);
    1617add_filter('comment_text', 'balanceTags');
    1718add_filter('comment_text', 'convert_smilies', 20);
    18    
     19
     20add_filter('comment_excerpt', 'remove_slashes', 5);
     21add_filter('comment_excerpt', 'convert_chars');
     22
    1923function clean_url($url) {
    2024    $url = str_replace('http://url', '', $url);
     
    130134        echo $url;
    131135    } else {
    132         echo 'mailto:'.antispambot($email);
     136        echo "mailto:$email";
    133137    }
    134138    echo '" rel="external">' . $author . '</a>';
     
    154158    $email = apply_filters('comment_email', $comment->comment_author_email);
    155159    if ((!empty($email)) && ($email != '@')) {
    156     $display = ($linktext != '') ? $linktext : antispambot(stripslashes($email));
     160    $display = ($linktext != '') ? $linktext : stripslashes($email);
    157161        echo $before;
    158162        echo "<a href='mailto:$email'>$display</a>";
     
    183187    $comment_text = str_replace('<pingback />', '', $comment_text);
    184188    echo apply_filters('comment_text', $comment_text);
     189}
     190
     191function comment_excerpt() {
     192    global $comment;
     193    $comment_text = str_replace('<trackback />', '', $comment->comment_content);
     194    $comment_text = str_replace('<pingback />', '', $comment_text);
     195    $comment_text = strip_tags($comment_text);
     196    $blah = explode(' ', $comment_text);
     197    if (count($blah) > 20) {
     198        $k = 20;
     199        $use_dotdotdot = 1;
     200    } else {
     201        $k = count($blah);
     202        $use_dotdotdot = 0;
     203    }
     204    $excerpt = '';
     205    for ($i=0; $i<$k; $i++) {
     206        $excerpt .= $blah[$i] . ' ';
     207    }
     208    $excerpt .= ($use_dotdotdot) ? '...' : '';
     209    echo apply_filters('comment_excerpt', $excerpt);
    185210}
    186211
Note: See TracChangeset for help on using the changeset viewer.