Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Aug 5th, 2009 | Syntax: HTML | Size: 7.85 KB | Hits: 469 | Expires: Never
Copy text to clipboard
  1. #set($superParentInode = $_commentContentInode)
  2. #set($user = $session.getAttribute("CMS_USER"))
  3. #set($commentForm = $session.getAttribute("commentsForm"))
  4. $session.removeAttribute("commentsForm")
  5. #set ($relatedMatches = $commentsapi.getComments($_commentContentInode))
  6. #if(!$webapi.isSet($emailTemplate))
  7.         #set($emailTemplate = 'static\comments\comments_email_template.html')
  8. #end
  9. #if($pdfExport == false)
  10. <script language="javascript">
  11.  
  12. /*
  13.  * http://jira.dotmarketing.net/browse/DOTCMS-1682
  14.  */
  15.  
  16. //This function deals with the replies and new comments
  17.  
  18.  function _dotReply(commentInode){
  19.  
  20.           document.getElementById('contentInode').value=commentInode;
  21.           document.getElementById('commentForm').style.display="";
  22.           var nameField = document.getElementById('name');
  23.                 if(nameField){
  24.                         nameField.focus();
  25.                 }
  26.         }
  27.        
  28.        
  29.        
  30. //This function creates the form for posting the comments. Output HTML is returned at the end of the function since
  31. //there are different parts on the page that use this HTML to open a form to write a comment. When a link is clicked
  32. //to post a new comment, the div id just following the link is passed as an argument to this function.
  33.  
  34.  function _createPostCommentPlace(activatedDiv){
  35.          //activeDiv is the div which is being worked on. It gets its value from the hidden field selectedDiv which is
  36.          //"" initially
  37.                 var activeDiv = document.getElementById("selectedDiv").value;
  38.  
  39.                 if(activeDiv != "" && activeDiv != activatedDiv){
  40.                         document.getElementById(activeDiv).innerHTML = " ";
  41.                 }      
  42.  
  43.                 var HTML = "<form action=\"/dotCMS/comments\" method=\"post\" id=\"commentsForm\" name=\"commentsForm\">";
  44.  
  45.                 HTML += "<!--<div style=\"text-align: right;\">-->";
  46.                 HTML += "<input type=\"hidden\" id=\"dispatch\" name=\"dispatch\" value=\"saveComments\" />";
  47.                 HTML += "<input type=\"hidden\" id=\"commentAutoPublish\" name=\"commentAutoPublish\" value=\"$!commentAutoPublish\" />";
  48.                 HTML += "<input type=\"hidden\" id=\"commentUseCaptcha\" name=\"commentUseCaptcha\" value=\"$!commentUseCaptcha\" />";
  49.                 HTML += "<input type=\"hidden\" id=\"commentStripHtml\" name=\"commentStripHtml\" value=\"$!commentStripHtml\" />";
  50.                 HTML += "<input type=\"hidden\" id=\"commentForceLogin\" name=\"commentForceLogin\" value=\"$!commentForceLogin\" />";
  51.                 HTML += "<input type=\"hidden\" id=\"commentTitle\" name=\"commentTitle\" value=\"$!commentTitle\" />";
  52.                 HTML += "<input type=\"hidden\" id=\"referrer\" name=\"referrer\" value=\"${VTLSERVLET_URI}?$!{request.getQueryString()}\" />";
  53.                 HTML += "<input type=\"hidden\" id=\"contentInode\" name=\"contentInode\" value=\"$!superParentInode\" />";
  54.                 HTML += "<input type=\"hidden\" id=\"emailTemplate\" name=\"emailTemplate\" value=\"$!emailTemplate\" />";
  55.                 HTML += "<input type=\"hidden\" id=\"commentsModeration\" name=\"commentsModeration\" value=\"$!commentsModeration\" />";
  56.                 HTML += "<input type=\"hidden\" id=\"commentUseAudioCaptcha\" name=\"commentUseAudioCaptcha\" value=\"$!commentUseAudioCaptcha\" />";
  57.  
  58.                 #set($name = $commentForm.getName())
  59.                 #if(!$UtilMethods.isSet($name) && $UtilMethods.isSet($user))
  60.                         #set($name = $user.getFullName())
  61.                 #end
  62.  
  63.                HTML += "<dl>";
  64.                 HTML += "<dt><label for=\"name\">*Name:</label></dt>";
  65.                 HTML += "<dd><input id=\"name\" name=\"name\" type=\"text\" value=\"$!name\" /></dd>";
  66.  
  67.                 #set($commentEmail = $commentForm.getEmail())
  68.                 #if(!$UtilMethods.isSet($commentEmail) && $UtilMethods.isSet($user))
  69.                         #set($commentEmail = $user.getEmailAddress())
  70.                 #end
  71.  
  72.                 HTML += "<dt><label for=\"email\">*Email:</label></dt>";
  73.                 HTML += "<dd><input id=\"email\" name=\"email\" type=\"text\" value=\"$!commentEmail\" /></dd>";
  74.  
  75.                 HTML += "<dt><label for=\"website\">Website:</label></dt>";
  76.                 HTML += "<dd><input id=\"website\" name=\"website\" type=\"text\" value=\"$!commentForm.getWebsite()\" /></dd>";
  77.  
  78.                 HTML += "<dt class=\"wide\">Please notify me of upcoming comments via email.</dt>";
  79.                 #set($checked = '')
  80.                 #if($!commentForm.isNotify())
  81.                         #set($checked = 'checked')
  82.                 #end
  83.                 HTML += "<dd class=\"wide\"><input name=\"notify\" id=\"notify\" value=\"yes\" type=\"checkbox\" $checked /> <label for=\"notify\">Yes</label></dd>";
  84.  
  85.                 HTML += "<dt class=\"wide\">*Type your comments below</dt>";
  86.                 #if($commentStripHtml)
  87.                         HTML += "<span class=\"greyText\">(HTML not permitted)</span>";
  88.                 #end
  89.                 HTML += "<dd class=\"wide\"><textarea name=\"comment\" id=\"commentIdt\">$!commentForm.getComment()</textarea></dd>";
  90.  
  91.                 #if($UtilMethods.isSet($commentUseCaptcha) == false)
  92.                         #set($commentUseCaptcha = false)
  93.                 #end
  94.                 #if($UtilMethods.isSet($commentUseAudioCaptcha) == false)
  95.                         #set($commentUseAudioCaptcha = false)
  96.                 #end
  97.                
  98.  
  99.                 #if($commentUseCaptcha == 'true' || $commentUseCaptcha == true)
  100.                         HTML += "<dt><label for=\"captcha\">*Validation Image:</label></dt>";
  101.                         HTML += "<dd><img src=\"/Captcha.jpg?$math.getRandom()\"><br /><input id=\"captcha\" name=\"captcha\" type=\"text\" /></dd>";
  102.                 #end
  103.                
  104.                 #if($commentUseAudioCaptcha == 'true' || $commentUseAudioCaptcha == true )
  105.                     #if ($UtilMethods.isSet($commentUseAudioCaptchaHeight))
  106.                         #set ($commentUseAudioCaptchaHeight = 30)
  107.                     #end
  108.                     HTML += "<embed height=\"" + ${commentUseAudioCaptchaHeight} + "\" src=\"/audioCaptcha.wav\" autostart=\"false\"/><br>";
  109.                         #if(!$commentUseCaptcha || $commentUseCaptcha == 'false')
  110.                                 HTML += "<dt><label for=\"audioCaptcha\">*Validation Sound:</label></dt>";
  111.                                 HTML += "<dd><input id=\"audioCaptcha\" name=\"audioCaptcha\" type=\"text\" /></dd>";
  112.                         #end
  113.                 #end
  114.  
  115.                 HTML += "<div style=\"padding: 5px 0pt 10px 65px;\">*required fields</div>";
  116.  
  117.                 #set($checked = '')
  118.                 #if($!commentForm.isAccept())
  119.                         #set($checked = 'checked')
  120.                 #end
  121.  
  122.                 HTML += "<input type=\"hidden\" name=\"accept\" value=\"yes\" >";
  123.                 //This hidden field is sent with the form to fill the activeDiv property of CommentsForm
  124.                 HTML += "<input type=\"hidden\" name=\"activeDiv\" value=\"" + activatedDiv + "\" >";
  125.                 HTML += "<div class=\"clear\">&nbsp;</div>";
  126.                 HTML += "<div id=\"commentButton\">";
  127.                 HTML += "<input class=\"post\" name=\"submit\" value=\"Post Comment\" type=\"submit\">";
  128.                 HTML += "</div>";
  129.                 HTML += "</dl>";
  130.                 HTML += "</form>";
  131.  
  132.                 //The inner HTML of the div is set to the output HTML
  133.                 document.getElementById(activatedDiv).innerHTML = HTML;
  134.                
  135.                 document.getElementById("selectedDiv").value = activatedDiv;
  136.  
  137.                 return HTML;
  138.         }
  139.  
  140. #end
  141. <!-- COMMENTS START -->
  142. <div class="comments" id="commentsIdt">
  143.         <input type="hidden" id="selectedDiv" value="$!{commentForm.getActiveDiv()}" >
  144.         #parse('static/messages.html')
  145.         <a  name="comments"></a>
  146.         <div class="replies">
  147.                 #if($commentTitle)
  148.                 <h4>Your View?</h4>
  149.                 <h5>$commentTitle</h5>
  150.                 #end
  151.  
  152.                 <ul>
  153.                 #foreach($match in $relatedMatches)
  154.                         #getContentDetail("$match.inode")
  155.                         <li>
  156.                           <div class="commentImg">
  157.                             <img src="/global/images/avatar.jpg" alt="Comment Author Avatar" />
  158.                           </div>
  159.                           <div class="commentMeta">
  160.                             <span class="commentAuthor">$author</span> |
  161.                             <span class="commentDate">Posted $UtilMethods.dateToHTMLDate($datePublished,'MMM dd, yyyy hh:mm a')</span>
  162.                           </div>
  163.                           <div class="commentText">
  164.                             $comment
  165.                           </div>
  166.                         </li>
  167.                 #end
  168.                 </ul>
  169.                
  170.         </div>
  171.         <div class="commentForm">
  172.           <h4>Submit Your Comment</h4>
  173.           <div class="formBody">
  174.             <div id="formBody">
  175.                        
  176.             </div>
  177.           </div>
  178.         </div>
  179.  
  180.         <div class="clear">&nbsp;</div>
  181. </div>
  182.  
  183. <script language="javascript">
  184.                 #if($UtilMethods.isSet($!{commentForm.getActiveDiv()}))        
  185.                         var sdiv = document.getElementById("selectedDiv").value;               
  186.                         if(sdiv != null){                              
  187.                                 document.getElementById(sdiv).value = _createPostCommentPlace(sdiv);                           
  188.                         }
  189.                 #end           
  190.         </script>
  191.        
  192. <script type="text/javascript">
  193.         _createPostCommentPlace('formBody');
  194. <!--
  195.  
  196. //-->
  197. <!-- COMMENTS ENDS -->