Changeset 32652


Ignore:
Timestamp:
2018-12-04T13:46:35+13:00 (5 years ago)
Author:
kjdon
Message:

lots of changes. moved facet display code into its own template, just to make containing template easier to follow. for cross colleciton search, snippets now return a colleciton attribute. test on this when looking for the snippet belonging to a doc node, as two docs could have the same id if the same doc was in multiple collections. hierarchy tempalte renamed to ccsParams, to make it clearer what its doing. changes to handling of group names, s1.colleciton, s1.group, in order to make it easier to select the appropriate values in the colleciton param option list.

File:
1 edited

Legend:

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

    r32625 r32652  
    7575
    7676    <xsl:template name="displayResults">
     77      <xsl:if test="/page/pageResponse/facetList/facet">
     78        <xsl:call-template name="displayFacets"/>
     79      </xsl:if>
     80        <div id="resultsArea">
     81            <xsl:attribute name="class">
     82                <xsl:if test="/page/pageResponse/facetList/facet">facetedResults</xsl:if>
     83            </xsl:attribute>
     84            <table id="resultsTable">
     85                <xsl:for-each select="pageResponse/documentNodeList/documentNode">
     86                    <tr id="div{@nodeID}" class="document">
     87                        <xsl:apply-templates select="."/>
     88                        <!-- The berry (optional) -->
     89                        <td>
     90                          <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
     91                        </td>
     92                        <xsl:call-template name="highlightSnippet">
     93                            <xsl:with-param name="nodeHASH">
     94                                <xsl:value-of select="@nodeID"/>
     95                            </xsl:with-param>
     96                            <xsl:with-param name="collection" select="@collection"/>
     97                              <!--<xsl:choose> <xsl:when test="@collection"><xsl:value-of select="@collection"/></xsl:with-param>-->
     98                        </xsl:call-template>
     99                        <xsl:call-template name="documentNodePost"/>
     100                    </tr>
     101                </xsl:for-each>
     102                <br/>
     103            </table>
     104
     105            <!-- Previous/Next buttons-->
     106            <xsl:call-template name="prevNextButtons"/>
     107        </div>
    77108        <xsl:if test="/page/pageResponse/facetList/facet">
     109            <div style="clear:both;">
     110                <xsl:text> </xsl:text>
     111            </div>
     112        </xsl:if>
     113    </xsl:template>
     114
     115    <xsl:template name="displayFacets">
    78116            <script type="text/javascript" src="interfaces/{$interface_name}/js/facet-scripts.js">
    79117                <xsl:text> </xsl:text>
     
    125163                </xsl:for-each>
    126164            </div>
    127         </xsl:if>
    128         <div id="resultsArea">
    129             <xsl:attribute name="class">
    130                 <xsl:if test="/page/pageResponse/facetList/facet">facetedResults</xsl:if>
    131             </xsl:attribute>
    132             <table id="resultsTable">
    133                 <xsl:for-each select="pageResponse/documentNodeList/documentNode">
    134                     <tr id="div{@nodeID}" class="document">
    135                         <xsl:apply-templates select="."/>
    136                         <!-- The berry (optional) -->
    137                         <td>
    138                           <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
    139                         </td>
    140                         <xsl:call-template name="highlightSnippet">
    141                             <xsl:with-param name="nodeHASH">
    142                                 <xsl:value-of select="@nodeID"/>
    143                             </xsl:with-param>
    144                         </xsl:call-template>
    145                         <xsl:call-template name="documentNodePost"/>
    146                     </tr>
    147                 </xsl:for-each>
    148                 <br/>
    149             </table>
    150 
    151             <!-- Previous/Next buttons-->
    152             <xsl:call-template name="prevNextButtons"/>
    153         </div>
    154         <xsl:if test="/page/pageResponse/facetList/facet">
    155             <div style="clear:both;">
    156                 <xsl:text> </xsl:text>
    157             </div>
    158         </xsl:if>
    159     </xsl:template>
    160 
     165
     166    </xsl:template>
    161167    <!-- this usually gets overriden in collectionConfig.xml -->
    162168    <gsf:template match="documentNode">
     
    174180
    175181    <xsl:template name="highlightSnippet">
    176         <xsl:param name="nodeHASH">
    177         </xsl:param>
    178         <xsl:for-each select="/page/pageResponse/highlightSnippetList/highlightSnippet[@nodeID = $nodeHASH]">
     182      <xsl:param name="nodeHASH"/>
     183        <xsl:param name="collection"/>
     184        <xsl:for-each select="/page/pageResponse/highlightSnippetList/highlightSnippet[@nodeID = $nodeHASH]">
     185          <xsl:if test="not($collection) or $collection = @collection]">
    179186                        <tr>
    180187                            <td>
     
    186193                            </td>
    187194                    </tr>
     195          </xsl:if>
    188196            </xsl:for-each>
    189197    </xsl:template>
     198   
    190199    <xsl:template name="queryPage">
    191200        <xsl:for-each select="pageResponse/service">
    192             <form name="QueryForm" method="get" action="{$library_name}/collection/{$collName}/search/{@name}">
    193                 <div>
     201          <xsl:variable name="form_action"><xsl:value-of select="$library_name"/>/<xsl:if test="$collName">collection/<xsl:value-of select="$collName"/>/</xsl:if>search/<xsl:value-of select="@name"/></xsl:variable>
     202              <form name="QueryForm" method="get" action="{$form_action}">
     203              <div>
    194204                    <input type="hidden" name="a" value="q"/>
    195205                    <input type="hidden" name="sa">
     
    203213                    <xsl:choose>
    204214                        <xsl:when test="/page/pageResponse/hierarchy and paramList/param[@name ='collection']">
    205                             <xsl:call-template name="hierarchy">
     215                            <xsl:call-template name="CCSParams"> <!-- cross coll search -->
    206216                                <xsl:with-param name="ns" select="$ns" />
    207217                            </xsl:call-template>
     
    235245    </xsl:template>
    236246
    237     <xsl:template name="hierarchy">
    238         <xsl:param name="ns" />
    239         <div class="paramLabel">
    240             <xsl:value-of
    241                 select="paramList/param[@name='collection']/displayItem[@name='name']/text()" />
     247    <xsl:template name="CCSParams">
     248      <xsl:param name="ns" />
     249      <xsl:variable name="currentSelection"><xsl:value-of select="util:getFormattedCCSSelection(/page/pageRequest/paramList/param[@name='s1.collection']/@value,/page/pageRequest/paramList/param[@name='s1.group']/@value)"/></xsl:variable>
     250      <!-- display the collection param -->
     251      <div class="paramLabel">
     252            <xsl:value-of select="paramList/param[@name='collection']/displayItem[@name='name']/text()" />
    242253        </div>
    243254        <div class="paramValue">
     
    249260                <xsl:for-each select="/page/pageResponse/hierarchy/*">
    250261                    <xsl:call-template name="hierarchy-display">
    251                         <xsl:with-param name="padding">
    252                             0
    253                         </xsl:with-param>
    254                         <xsl:with-param name="path">
    255                             <xsl:text>/</xsl:text>
    256                         </xsl:with-param>
     262                      <xsl:with-param name="padding">0</xsl:with-param>
     263                      <xsl:with-param name="currentSelection" select="$currentSelection"/>
    257264                    </xsl:call-template>
    258265                </xsl:for-each>
     
    260267        </div>
    261268        <br class="clear" />
     269        <!-- display all the other params -->
    262270        <xsl:for-each select="paramList/param[@name !='collection']">
    263271            <xsl:choose>
     
    279287        <xsl:param name="padding" />
    280288        <xsl:param name="path" />
     289        <xsl:param name="currentSelection"/>
    281290        <xsl:choose>
    282             <xsl:when test="name(.) = 'group'">
     291          <xsl:when test="name(.) = 'group'">
     292            <xsl:variable name="group-name">group.<xsl:if test="$path"><xsl:value-of select="$path" />.</xsl:if><xsl:value-of select="@name" /></xsl:variable>
    283293                <option>
    284294                    <xsl:attribute name="style">
     
    286296                        <xsl:value-of select="concat($padding,'px')" />
    287297                    </xsl:attribute>
    288                     <xsl:attribute name="value">
    289                         <xsl:text>group</xsl:text>
    290                         <xsl:value-of select="$path" />
    291                         <xsl:value-of select="@name" />
    292                     </xsl:attribute>
    293                     <xsl:if test="contains(/page/pageRequest/paramList/param[@name='s1.collection']/@value, @name)">
     298                    <xsl:attribute name="value"><xsl:value-of select="$group-name"/></xsl:attribute>
     299                    <xsl:if test="util:csvContains($currentSelection, $group-name)">
    294300                        <xsl:attribute name="selected">selected</xsl:attribute>
    295301                    </xsl:if>
     
    300306                                <xsl:value-of select="$padding + 20" />
    301307                            </xsl:with-param>
    302                             <xsl:with-param name="path">
    303                                 <xsl:value-of select="$path" />
    304                                 <xsl:text>/</xsl:text>
    305                                 <xsl:value-of select="../@name" />
    306                             </xsl:with-param>
     308                            <xsl:with-param name="path"><xsl:if test="$path"><xsl:value-of select="$path" />.</xsl:if><xsl:value-of select="../@name" /></xsl:with-param>
     309                            <xsl:with-param name="currentSelection" select="$currentSelection"/>
    307310                        </xsl:call-template>
    308311                    </xsl:for-each>
     
    316319                        <xsl:text>px</xsl:text>
    317320                    </xsl:attribute>
    318                     <xsl:if test="contains(/page/pageRequest/paramList/param[@name='s1.collection']/@value, @name)">
     321                    <xsl:if test="util:csvContains($currentSelection, @name)">
    319322                        <xsl:attribute name="selected">selected</xsl:attribute>
    320323                    </xsl:if>
Note: See TracChangeset for help on using the changeset viewer.