source: main/trunk/greenstone3/web/interfaces/default/transform/layouts/usercomments.xsl@ 31540

Last change on this file since 31540 was 31540, checked in by ak19, 7 years ago

Some commits ahead of further changes: 1. Kathy came up with better name for GS2Construct.java method (to be refactored) that's more descriptive of the multiple tasks it performs. Removed unused paramter. 2. Javascript user_comments.js displays the heading for the comments section only when appropriate, which is when there is a comment history or when the form to add a comment is shown. Otherwise only the Add Comment link will be shown. 3. Changed core.css colours of links and headings in comments section to better match GS3. 4. document.xsl needs to display usercomments section not just for simple docs but also for wrapped docs.

File size: 4.4 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util gsf">
10
11<xsl:template name="userCommentsSection">
12
13 <!-- 1. Make some variables available to javascript that the usercomments related js functions need -->
14 <gsf:variable name="d"><xsl:value-of select="/page/pageRequest/paramList/param[@name='d']/@value"/></gsf:variable>
15 <gsf:variable name="c"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></gsf:variable>
16 <gsf:variable name="site"><xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name='site_name']/@value"/></gsf:variable>
17
18 <gsf:variable name="textusercommentssection"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.heading')"/></gsf:variable>
19 <gsf:variable name="textisempty"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.isempty')"/></gsf:variable>
20 <gsf:variable name="textcommentsubmitted"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.submitted')"/></gsf:variable>
21
22 <!-- 2. Load the javascript, which will do stuff on window load/ready for which it needs the above gs.variables -->
23 <script type="text/javascript" src="interfaces/{$interface_name}/js/user_comments.js"><xsl:text> </xsl:text></script>
24
25
26 <!-- 3. Set up the User comments section in the HTML -->
27 <div id="commentssection" class="centrediv">
28 <div id="usercomments">
29 <!-- A heading for the comment section will be added here dynamically either if
30 previously submitted comments exist, or if the form#usercommentform to add
31 a new comment is displayed. Otherwise only the "Add Comments" link is shown. -->
32 <xsl:comment>Existing comments will be loaded dynamically loaded into this div#usercomments</xsl:comment>
33 </div>
34
35 <!-- If the user's logged in, show the comment form, else show the link to the login page -->
36 <xsl:choose>
37 <xsl:when test="/page/pageRequest/userInformation">
38 <!-- Logged in, allow user to add a comment by displaying a form -->
39 <form name="AddUserCommentForm" id="usercommentform">
40 <input type="hidden" name="username"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/userInformation/@username"/></xsl:attribute></input>
41 <div>
42 <p><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.add')"/></p>
43 <!-- The textarea will be added in by javascript into div#commentarea to avoid the problem of XML turning empty tags into self-closing ones and a self-closing text-area becomes invalid HTML -->
44 <!--<textarea required="required" name="comment" rows="10" cols="64" placeholder="Add your comment here..."></textarea>-->
45 <div id="commentarea">Comment area to appear here</div>
46 <input type="hidden" name="d"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/paramList/param[@name='d']/@value"/></xsl:attribute></input>
47 </div>
48
49 <input type="submit" onclick="addUserComment(document.AddUserCommentForm.username.value, document.AddUserCommentForm.comment.value, document.AddUserCommentForm.d.value, document); return false;"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.submit')"/></xsl:attribute></input>
50 <label id="usercommentfeedback"><xsl:comment>Text to prevent empty tags from becoming self-closing tags</xsl:comment></label>
51
52 <div id="usercommentlogoutlink">
53 <a><xsl:attribute name="href"><xsl:call-template name="generateLogoutURL"/></xsl:attribute>
54 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'menu.logout')"/></a>
55 </div>
56 </form>
57 </xsl:when>
58
59 <!-- User not logged in, "add comment" link allows user to login first -->
60 <xsl:otherwise>
61 <div id="usercommentlink">
62 <a><xsl:attribute name="href"><xsl:call-template name="generateLoginURL"/></xsl:attribute>
63 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.add')"/></a>
64 </div>
65 </xsl:otherwise>
66 </xsl:choose>
67
68 </div>
69
70</xsl:template>
71
72</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.