Changeset 1561

Show
Ignore:
Timestamp:
03/24/08 22:48:47 (7 months ago)
Author:
bchoate
Message:

Applying comment threading support. BugId:70228

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-32/default_templates/comment_detail.mtml

    r1350 r1561  
    33        <div class="comment-header"> 
    44            <div class="asset-meta"> 
    5                 <span class="byline"><__trans phrase="By [_1] on [_2]" params='<span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span><MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty>%%<a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a>'></span> 
     5               <span class="byline"> 
     6                   <__trans phrase="By"> <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span><MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> 
     7                   <MTCommentParent> 
     8                   <__trans phrase="replied to"> <a href="#comment-<$MTCommentID$>"><MTCommentAuthor></a> 
     9                   </MTCommentParent> 
     10                   <__trans phrase="on"> <a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a> 
     11                   <MTIfCommentsAccepted> | <$MTCommentReplyLink$></MTIfCommentsAccepted> 
     12               </span> 
    613            </div> 
    714        </div> 
  • branches/release-32/default_templates/comment_form.mtml

    r1309 r1561  
    1717            <input type="hidden" name="entry_id" value="<$MTEntryID$>" /> 
    1818            <input type="hidden" name="__lang" value="<$MTBlogLanguage$>" /> 
     19            <input type="hidden" name="parent_id" value="<MTIf name="comment_preview_template"><$MTCommentParentID$></MTIf>" id="comment-parent-id" /> 
    1920            <div id="comments-open-data"> 
    2021                <div id="comment-form-name"> 
     
    3334                    <label for="comment-bake-cookie"><input type="checkbox" id="comment-bake-cookie" name="bakecookie" onclick="if (!this.checked) forgetMe(document.comments_form)" value="1" /> 
    3435                        <__trans phrase="Remember personal info?"></label> 
     36                </div> 
     37                <div id="comment-form-reply"> 
     38                    <label for="comment-reply" id="comment-reply-label"><input type="checkbox" id="comment-reply" name="comment_reply" value="" onclick="setCommentParentID();" /> 
     39                        <__trans phrase="Replying to"></label> 
    3540                </div> 
    3641            </div> 
  • branches/release-32/default_templates/javascript.mtml

    r1354 r1561  
    3636 
    3737function individualArchivesOnLoad(commenter_name) { 
     38    hideDocumentElement('comment-form-reply'); 
    3839<MTIfCommentsAccepted> 
    3940<MTElse> 
     
    150151</MTIfRegistrationAllowed> 
    151152 
     153function replyComment(parent_id, author) { 
     154    showDocumentElement('comment-form-reply'); 
     155     
     156    var checkbox = document.getElementById('comment-reply'); 
     157 
     158    // Clear the current label but NOT our checkbox! 
     159    var label = document.getElementById('comment-reply-label'); 
     160    for(var i = 1; i < label.childNodes.length; i++) { 
     161        label.removeChild(label.childNodes[i]); 
     162    } 
     163     
     164    // Populate label with new values 
     165    var reply_text = document.createTextNode(' <__trans phrase="Replying to"> '); 
     166    label.appendChild(reply_text); 
     167 
     168    var anchor = document.createElement('a'); 
     169    anchor.setAttribute('href', '#comment-' + parent_id); 
     170    anchor.innerHTML = author; 
     171    label.appendChild(anchor); 
     172     
     173    checkbox.value = parent_id;  
     174    checkbox.setAttribute('checked', true); 
     175    checkbox.focus(); 
     176     
     177    setCommentParentID(); 
     178} 
     179 
     180function setCommentParentID() { 
     181    var checkbox = document.getElementById('comment-reply'); 
     182    var parent_id_field = document.getElementById('comment-parent-id'); 
     183    var pid = 0; 
     184     
     185    if(checkbox.checked == true) 
     186        pid = checkbox.value; 
     187     
     188    parent_id_field.value = pid; 
     189} 
     190 
    152191 
    153192// Copyright (c) 1996-1997 Athenia Associates. 
  • branches/release-32/lib/MT/App/Comments.pm

    r1394 r1561  
    12691269        # published for this entry 
    12701270        my $parent_comment = MT::Comment->load( $parent_id ); 
    1271         if ($parent_comment && $parent_comment->entry_id == $entry->id) { 
     1271        if ($parent_comment && $parent->is_published() && $parent_comment->entry_id == $entry->id) { 
    12721272            $comment->parent_id( $parent_id ); 
    12731273        } 
  • branches/release-32/lib/MT/Template/ContextHandlers.pm

    r1554 r1561  
    377377            CommentOrderNumber => \&_hdlr_comment_order_num, 
    378378            CommentDate => \&_hdlr_comment_date, 
     379            CommentParentID => \&_hdlr_comment_parent_id, 
     380            CommentReplyLink => \&_hdlr_comment_reply_link, 
    379381            CommentPreviewAuthor => \&_hdlr_comment_author, 
    380382            CommentPreviewIP => \&_hdlr_comment_ip, 
     
    52805282} 
    52815283 
     5284sub _hdlr_comment_reply_link { 
     5285    my($ctx, $args) = @_; 
     5286    my $comment = $ctx->stash('comment') or 
     5287        return  $ctx->_no_comment_error('MTCommentReplyLink'); 
     5288 
     5289    my $label = $args->{label} || $args->{text} || MT->translate('Reply'); 
     5290    my $comment_author = MT::Util::encode_js($comment->author); 
     5291 
     5292    return sprintf(qq(<a title="%s" href="javascript:void(0);" onclick="replyComment(%d, '%s')">%s</a>), 
     5293                   $label, $comment->id, $comment_author, $label); 
     5294} 
     5295 
     5296sub _hdlr_comment_parent_id { 
     5297    my $args = $_[1]; 
     5298    my $c = $_[0]->stash('comment') 
     5299        or return $_[0]->_no_comment_error('MTCommentParentID'); 
     5300    my $id = $c->parent_id || 0; 
     5301    $args && $args->{pad} ? (sprintf "%06d", $id) : $id; 
     5302} 
     5303 
    52825304sub _hdlr_comment_replies { 
    52835305    my($ctx, $args, $cond) = @_;