On 09/09/2010 01:59 PM, cjdelisle (SVN) wrote:
> Author: cjdelisle
> Date: 2010-09-09 13:59:55 +0200 (Thu, 09 Sep 2010)
> New Revision: 31022
>
> Modified:
>     platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm
> Log:
> XWIKI-2110: Made comments be rendered in the context of the document 
> "XWiki.XWikiComments"
>
> Modified: 
> platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm
> ===================================================================
> --- platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm   
> 2010-09-09 08:37:05 UTC (rev 31021)
> +++ platform/web/trunk/standard/src/main/webapp/templates/commentsinline.vm   
> 2010-09-09 11:59:55 UTC (rev 31022)
> @@ -110,7 +110,7 @@
>   ##
>   ##
>   ##
> -#macro(displayThread $key $commentThreads)
> +#macro(displayThread $key $commentThreads, $commentDoc)
>     ## If request parameter replyto is specified then we show the form under 
> that comment.
>     #if($replyTo == "$key")
>       #displayCommentForm()
> @@ -134,7 +134,7 @@
>   ##
>   ##
>   ##
> -#macro(displayComment $comment)
> +#macro(displayComment $comment, $commentDoc)
>     <div id="xwikicomment_${comment.number}" 
> class="xwikicomment#if($comment.getProperty('author').value == $doc.creator) 
> commentByCreator#end">
>       ##<div class="commentavatar">#useravatar($comment.author)</div>
>       <div class="commentheader">
> @@ -156,7 +156,7 @@
>         #end
>         </span>## commenttools
>       </div>## commentheader
> -<div class="commentcontent">$doc.display('comment', 'view', $comment)</div>
> +<div 
> class="commentcontent">$commentDoc.getRenderedContent($comment.getProperty('comment').getValue(),
>  $doc.getSyntax().toIdString())</div>
>     </div>## xwikicomment
>   #end
>   ##
> @@ -302,7 +302,11 @@
>     #foreach($comment in $comments)
>       #addCommentToThreads($comment, $commentThreads, $rootKey)
>     #end
> -  #displayThread($rootKey, $commentThreads)
> +  ##
> +  ## Comments will be rendered in the context of this document.
> +  #set($commentDoc = $xwiki.getDocument('XWiki.XWikiComments'))

What if the user does not have the right to view XWiki.XWikiComments? 
$commentDoc will be null, and the display will fail. You should fall 
back to $doc in this case. Note that this is not so absurd, since it's a 
good practice to forbid access to the XWiki space.

One incompatible use case is that all code using $doc will show 
different results now, but I don't think this is a very valid use case.

> +  ##
> +  #displayThread($rootKey, $commentThreads, $commentDoc)
>   #else
>     <p class="noitems">$msg.get('core.viewers.comments.noComments')</p>
>   #end


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to