Changeset 32504

Show
Ignore:
Timestamp:
09.10.2018 15:49:21 (11 months ago)
Author:
kjdon
Message:

1. need to make sure we are passing round p.s - previous service - needed for search term highlighting. 2. removed displayAnnotations and added displayMarkedUpTextAndAnnotations - this goes through all the child nodes of an element and outputs them. the template change is for better code reuse as I want to do that for metadata elements. 3. new parameter 'force' to documentNodeText - force the text output even if noText is 1. 4. for one of my examples, testing on Image was not good enough to see if the document is an image file - change to ImageType? test instead.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl

    r32133 r32504  
    444444                            var docID = sectionID.replace(/([^.]*)\..*/, "$1"); 
    445445                            var url = gs.xsltParams.library_name + "?a=d&c=" + gs.cgiParams.c + "&excerptid=gs-document&dt=hierarchy&d=" + docID; 
     446                            if(gs.cgiParams.p_s) {  
     447                            url += "&p.s="+gs.cgiParams.p_s; 
     448                            } 
    446449                            loadTopLevelPage(callbackFunction, url); 
    447450                        }); 
     
    530533    </xsl:template> 
    531534     
    532     <!-- Highlight annotations if requested --> 
    533     <xsl:template name="displayAnnotation"> 
    534         <xsl:choose> 
    535             <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'off' or /page/pageResponse/format[@type='display']/gsf:option[@name='disableSearchTermHighlighting']/@value='true'"> 
    536                 <span class="noTermHighlight"><xsl:value-of select="."/></span> 
    537             </xsl:when> 
    538             <xsl:otherwise> 
    539                 <span class="termHighlight"><xsl:value-of select="."/></span> 
    540             </xsl:otherwise> 
    541         </xsl:choose> 
    542     </xsl:template> 
    543          
     535     
    544536    <!-- The default template for displaying section titles --> 
    545537    <xsl:template name="sectionTitle"> 
     
    555547        <xsl:choose> 
    556548            <xsl:when test="metadataList/metadata[@name = 'Screen'] and metadataList/metadata[@name = 'SourceFile'] and ($imageWidth div $screenImageWidth > 1.2) and (not(/page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']) or /page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']/@value='false')"> 
    557                  
    558549                <div id="image{@nodeID}"> 
    559                   <!-- when we ask for an individual section content we set ed=1. putting this test here prevents downloading all the screen and full images for each section of the document when we are just looking at teh contents list --> 
    560                   <xsl:if test="/page/pageRequest/paramList/param[@name = 'ed']/@value='1'"> 
     550                  <!-- when we ask for an individual section content we set ed=1. putting this test here prevents downloading all the screen and full images for each section of the document when we are just looking at the contents list. ed is not set for simple docs, so do this if doctype is simple --> 
     551                  <xsl:if test="/page/pageResponse/document[@docType='simple'] or /document/page/pageRequest/paramList/param[@name = 'ed']/@value='1'"> 
    561552                 
    562553                    <div id="wrap{util:replace(@nodeID, '.', '_')}" class="zoomImage" style="position:relative; width: {$screenImageWidth}px; height: {$screenImageHeight}px;"> 
     
    622613    <!-- equivalent to gsf:text --> 
    623614    <xsl:template name="documentNodeText"> 
     615      <xsl:param name="force">1</xsl:param> 
    624616        <!-- Hides the "This document has no text." message --> 
    625617        <xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable> 
    626618        <xsl:choose> 
    627         <xsl:when test="not($noText = '1')"> 
     619        <xsl:when test="$force = '1' or not($noText = '1')"> 
    628620 
    629621            <!-- Section text --> 
    630622            <xsl:for-each select="nodeContent"> 
    631                 <xsl:for-each select="node()"> 
    632                     <xsl:choose> 
    633                         <xsl:when test="not(name())"> 
    634                           <xsl:value-of select="." disable-output-escaping="yes"/> 
    635                         </xsl:when> 
    636                         <xsl:when test="name() = 'annotation'"> 
    637                             <xsl:call-template name="displayAnnotation"/> 
    638                         </xsl:when> 
    639                         <xsl:otherwise> 
    640                             <xsl:apply-templates/> 
    641                         </xsl:otherwise> 
    642                     </xsl:choose> 
    643                 </xsl:for-each> 
     623              <xsl:call-template name="displayMarkedUpTextAndAnnotations"/> 
    644624            </xsl:for-each> 
    645625        </xsl:when> 
    646         <xsl:when test="$noText = '1' and not(metadataList/metadata[@name='Image'])"> 
     626        <xsl:when test="$noText = '1' and not(metadataList/metadata[@name='ImageType'])"> 
    647627            <gsf:link type="source"><gsf:metadata name="Source"/></gsf:link> 
    648628        </xsl:when> 
     
    651631    </xsl:template> 
    652632 
     633    <!-- display the text content of a node (content node or metadata node), marking up the annotations --> 
     634    <xsl:template name="displayMarkedUpTextAndAnnotations"> 
     635      <xsl:variable name="annotation_class"> 
     636        <xsl:choose> 
     637          <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'off' or /page/pageResponse/format[@type='display']/gsf:option[@name='disableSearchTermHighlighting']/@value='true'">noTermHighlight</xsl:when> 
     638          <xsl:otherwise>termHighlight</xsl:otherwise> 
     639        </xsl:choose> 
     640      </xsl:variable> 
     641      <xsl:for-each select="node()"> 
     642        <xsl:choose> 
     643          <xsl:when test="not(name())"> 
     644        <xsl:value-of select="." disable-output-escaping="yes"/> 
     645          </xsl:when> 
     646          <xsl:when test="name() = 'annotation'"> 
     647        <span class="{$annotation_class}"><xsl:value-of select="."/></span> 
     648          </xsl:when> 
     649          <xsl:otherwise> 
     650        <xsl:apply-templates/> 
     651          </xsl:otherwise> 
     652        </xsl:choose> 
     653      </xsl:for-each> 
     654    </xsl:template> 
     655 
     656     
    653657    <!-- The default template for displaying the document node text in 
    654658    editing mode -->