Ignore:
Timestamp:
2017-03-24T21:37:12+13:00 (7 years ago)
Author:
ak19
Message:

First commit for getting user comments working for GS3. It all works, but there's debugging statements still and haven't cleaned up commented out code. After that, would like to make POST rather than GET AJAX calls, so more refactoring required. 1. config_format.xsl is just minor spelling corrections. 2. header.xsl has a new function generateLogoutURL. 3. document.xsl imports and calls new usercomments.xsl to set up the user comments area. 4. New usercomments.js is imported by new usercomments.xsl, and sets up the interaction of the usercomments area. 5. javascript-global-functions.js now contains setMetadataArray and getMetadataArray functions to parallel what GS2 used in gsajaxapi.js, but for GS3 need to go through GS2Construct.processModifyMetadata() service in java code. 5. GS2Construct.java does different checking for users adding user comments versus users doing document editing. For the latter, the user needs to have editing permissions for the document. But any user is allowed to add comments on any accessible document. But ModifyMetadata should not allow any other metadata to be modified other than meta fields. 6. New language strings for usercomment area and GS2Construct errors in the 2 changed properties files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl

    r31399 r31537  
    409409   
    410410  </xsl:template>
     411
    411412  <xsl:template name="generateLoginURL">
    412413    <xsl:value-of select="$library_name"/>
     
    431432    </xsl:for-each>
    432433   
     434  </xsl:template>
     435
     436  <!-- Writing the reverse of generateLoginURL since the toggleUserMenuScript does a lot more than I want. -->
     437  <!-- https://www.w3schools.com/xml/xsl_functions.asp#string --> 
     438  <xsl:template name="generateLogoutURL">
     439   
     440    <xsl:variable name="url" select="/page/pageRequest/@fullURL"/>
     441    <xsl:variable name="tmpURL" select="substring-before($url, '&amp;amp;logout=')"/>
     442    <xsl:variable name="beforeHash" select="substring-before($url, '#')"/>
     443    <xsl:variable name="afterHash" select="substring-after($url, '#')"/>
     444    <!-- Get rid of any lingering &amp;logout= already in the URL.
     445     Can't use fn:replace() as it's only been defined since XSLT 2.0. We use XSLT 1.x -->
     446    <xsl:variable name="fullURL">
     447      <xsl:choose>
     448    <xsl:when test="$tmpURL != ''"><xsl:value-of select="$tmpURL" /></xsl:when>
     449    <xsl:otherwise><xsl:value-of select="$url" /></xsl:otherwise>
     450      </xsl:choose>
     451    </xsl:variable>
     452
     453    <!-- Output the logout link: the current page's URL (with any lingering logout suffix removed)
     454     followed by ?logout= or &amp;logout= followed by any # portion of the current page's URL -->
     455    <xsl:choose>
     456      <xsl:when test="$beforeHash != ''"><xsl:value-of select="$beforeHash" /></xsl:when>
     457      <xsl:otherwise><xsl:value-of select="$fullURL" /></xsl:otherwise>
     458    </xsl:choose>
     459    <xsl:choose>
     460      <xsl:when test="contains($fullURL, '?')"><xsl:text>&amp;logout=</xsl:text></xsl:when>
     461      <xsl:otherwise>?logout=</xsl:otherwise>
     462    </xsl:choose>
     463    <xsl:if test="$afterHash != ''">#<xsl:value-of select="$afterHash" /></xsl:if>   
    433464  </xsl:template>
    434465 
Note: See TracChangeset for help on using the changeset viewer.