#* * commentsinline.vm Shows document comments and gives the user an oppertunity to add a comment. * To include this template in a document you may specify: * * $replyTo (Integer) - If set then the comment form will appear ready to make a reply to the comment with the id number given. * If not set and request parameter 'replyto' is set then $replyTo is set to parameter 'replyto', if * no replyto request parameter and $replyTo isn't set, and $fillInFields is true and * 'XWiki.XWikiComments_replyto' is set then $replyTo is set to that. * * $hideCaptcha (boolean) - If true then the captcha is hidden and then shown by javascript when the user focuses on the comment * textarea. If not set and $captchaAnswerWrong is true or 'X-Requested-With' equals 'XMLHttpRequest' then * it is set true. * * $captchaAnswerWrong (boolean) - If true then a message is displayed next to the captcha window telling the user that the captcha * answer is incorrect. If not set then this template will check for a request parameter by the same * name and sets this true if that equals 1. * * $fillInFields (boolean) - If true then author, and comment fields are filled in from request parameters of the same names * as the fields, also if $replyTo is set the form appears under the comment corrisponding to the $replyTo * number. If not set and $captchaAnswerWrong is true then this is set to true. * * $offerGuestsCaptcha (boolean) - If true then users who are not logged in are offered a captcha image to solve, if undefined then * $xwiki.getSpacePreference('guest_comment_requires_captcha') NOTE: this template doesn't have the power * to require the captcha (that is the commentAdd action) only offer it. * *### ## ## These are used when this page is accessed directly but are useless when the page is pulled in with ajax using ## bin/view/Space/Page?xpage=xpart&vm=commentsinline.vm $xwiki.jsfx.use('uicomponents/viewers/comments.js', {'forceSkinAction': true, 'language': ${xcontext.language}}) $xwiki.ssfx.use('uicomponents/viewers/comments.css', true) ## ##--------------------------------------------------------------------- ## Set some 'global' variables ##--------------------------------------------------------------------- ## #set($xCommentClass = 'XWiki.XWikiComments') ## #if(!$replyTo) #set($replyTo = $escapetool.xml($!request.get('replyto'))) #end ## #set($requestedByAjax = ($request.getHeader('X-Requested-With') == 'XMLHttpRequest')) ## #if("$!captchaAnswerWrong" == '') #set($captchaAnswerWrong = ($request.get('captchaAnswerWrong') == '1')) #end ## #if("$!hideCaptcha" == '') #set($hideCaptcha = ($captchaAnswerWrong != true && $requestedByAjax)) #end ## #if("$!fillInFields" == '') #set($fillInFields = ($captchaAnswerWrong == true)) #end ## ## If $fillInFields, then set variables for each field. #if($fillInFields) #set($author = $!escapetool.xml($request.get("${xCommentClass}_author"))) #set($comment = $!escapetool.xml($request.get("${xCommentClass}_comment"))) #if("$!replyTo" == '') #set($replyTo = $escapetool.xml($!request.get("${xCommentClass}_replyto"))) #end #end ## #if("$!author" == '') #set($author = $services.localization.render('core.viewers.comments.add.guestName.default')) #end ## #set($xredirect = $!escapetool.xml($request.get("xredirect"))) #if("$!xredirect" == '') #set($xredirect = "$doc.getURL('view')?$request.getQueryString()") #end ## #if("$!offerGuestsCaptcha" == '') #set($offerGuestsCaptcha = $xwiki.getSpacePreferenceAsInt('guest_comment_requires_captcha', 0) == 1) #end ## ##--------------------------------------------------------------------- ## Macros ##--------------------------------------------------------------------- ## ## If we are viewing this page through the commentAdd or save actions then we should redirect to view ## This doesn't apply if it is being viewed through javascript. #macro(redirectIfActionNotView) #if(!$requestedByAjax && $xcontext.getAction() != 'view' && $xcontext.getAction() != 'get') #if(!$captchaAnswerWrong) $response.sendRedirect("$doc.getURL('view')?viewer=comments"); #else #foreach($name in $request.getParameterNames()) #set($queryString = "$!queryString&$name=$escapetool.url($request.get($name))") #end $response.sendRedirect($doc.getURL('view', "captchaAnswerWrong=1&$queryString")); #end $response.setContentLength(0) #stop #end #end ## ## ## #macro(addCommentToThreads $comment $commentThreads $rootKey) #set($thread = $commentThreads.get("$!{comment.replyto}")) #if("$!{thread}" == '') #set($thread = $commentThreads.get($rootKey)) #end #set($discard = $thread.add($comment.number)) #set($thread = '') #end ## ## ## #macro(displayThread $key $commentThreads, $commentDoc) ## If request parameter replyto is specified then we show the form under that comment. #if($replyTo == "$key") #displayCommentForm() #set($replied = true) #end ## #set($thread = $commentThreads.get("$!key")) #if($thread.size() > 0)
$!escapetool.xml($commentSelection)#end
$services.localization.render('core.viewers.comments.noComments')
#end ## ## #if(!$replied) #displayCommentForm() #end