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/gsajaxapi.js"><xsl:text> </xsl:text></script>
|
---|
24 | <script type="text/javascript" src="interfaces/{$interface_name}/js/user_comments.js"><xsl:text> </xsl:text></script>
|
---|
25 |
|
---|
26 |
|
---|
27 | <!-- 3. Set up the User comments section in the HTML -->
|
---|
28 | <div id="commentssection" class="centrediv">
|
---|
29 | <div id="usercomments">
|
---|
30 | <!-- A heading for the comment section will be added here dynamically either if
|
---|
31 | previously submitted comments exist, or if the form#usercommentform to add
|
---|
32 | a new comment is displayed. Otherwise only the "Add Comments" link is shown. -->
|
---|
33 | <xsl:comment>Existing comments will be loaded dynamically loaded into this div#usercomments</xsl:comment>
|
---|
34 | </div>
|
---|
35 |
|
---|
36 | <!-- If the user's logged in, show the comment form, else show the link to the login page -->
|
---|
37 | <xsl:choose>
|
---|
38 | <xsl:when test="/page/pageRequest/userInformation">
|
---|
39 | <!-- Logged in, allow user to add a comment by displaying a form -->
|
---|
40 | <form name="AddUserCommentForm" id="usercommentform">
|
---|
41 | <input type="hidden" name="username"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/userInformation/@username"/></xsl:attribute></input>
|
---|
42 | <div>
|
---|
43 | <p><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.add')"/></p>
|
---|
44 | <!-- 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 -->
|
---|
45 | <!--<textarea required="required" name="comment" rows="10" cols="64" placeholder="Add your comment here..."></textarea>-->
|
---|
46 | <div id="commentarea">Comment area to appear here</div>
|
---|
47 | <input type="hidden" name="d"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/paramList/param[@name='d']/@value"/></xsl:attribute></input>
|
---|
48 | </div>
|
---|
49 |
|
---|
50 | <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>
|
---|
51 | <label id="usercommentfeedback"><xsl:comment>Text to prevent empty tags from becoming self-closing tags</xsl:comment></label>
|
---|
52 |
|
---|
53 | <div id="usercommentlogoutlink">
|
---|
54 | <a><xsl:attribute name="href"><xsl:call-template name="generateLogoutURL"/></xsl:attribute>
|
---|
55 | <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'menu.logout')"/></a>
|
---|
56 | </div>
|
---|
57 | </form>
|
---|
58 | </xsl:when>
|
---|
59 |
|
---|
60 | <!-- User not logged in, "add comment" link allows user to login first -->
|
---|
61 | <xsl:otherwise>
|
---|
62 | <div id="usercommentlink">
|
---|
63 | <a><xsl:attribute name="href"><xsl:call-template name="generateLoginURL"/></xsl:attribute>
|
---|
64 | <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'usercomments.add')"/></a>
|
---|
65 | </div>
|
---|
66 | </xsl:otherwise>
|
---|
67 | </xsl:choose>
|
---|
68 |
|
---|
69 | </div>
|
---|
70 |
|
---|
71 | </xsl:template>
|
---|
72 |
|
---|
73 | </xsl:stylesheet>
|
---|