Ignore:
Timestamp:
2012-10-23T14:03:01+13:00 (11 years ago)
Author:
kjdon
Message:

moved param stuff to query-common.xsl so it can be shared. made 'displaying X to Y of Z docs' a single sentence in dictionary, with args passed in. better for translation when word order is different

File:
1 edited

Legend:

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

    r26349 r26368  
    1313    <xsl:import href="layouts/main.xsl"/>
    1414
     15  <xsl:include href="query-common.xsl"/>
    1516    <!-- set page title -->
    1617    <xsl:template name="pageTitle"><gslib:serviceName/></xsl:template>
     
    144145                            </xsl:when>
    145146                            <xsl:otherwise>
    146                                 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable>
    147                                 <div class="paramLabel"><xsl:value-of select="displayItem[@name='name']"/></div>
    148                                 <div class="paramValue">
    149                                     <xsl:apply-templates select=".">
    150                                         <xsl:with-param name="default" select="$pvalue"/>
    151                                         <xsl:with-param name="ns" select="$ns"/>
    152                                     </xsl:apply-templates>
    153                                 </div>
    154                                 <br class="clear"/>
     147                                <xsl:call-template name="param-display"><xsl:with-param name="ns" select="$ns"/></xsl:call-template>
    155148                            </xsl:otherwise>
    156149                        </xsl:choose>
     
    362355            <!-- Search result status bar (in english it reads "Displaying X to Y of Z documents") -->
    363356            <xsl:if test="$docMax &gt; 0">
    364                 <td id="searchResultsStatusBar">
    365                     <!-- "Displaying" -->
    366                     <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.displaying')"/><xsl:text> </xsl:text>
    367                     <!-- "X" -->
    368                     <xsl:value-of select="($currentPage - 1) * $docsPerPage + 1"/>
    369                     <!-- "to" -->
    370                     <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.to')"/><xsl:text> </xsl:text>
    371                     <!-- "Y" -->
    372                     <xsl:choose>
     357      <xsl:variable name="startdoc" select="($currentPage - 1) * $docsPerPage + 1"/>
     358      <xsl:variable name="enddoc"><xsl:choose>
    373359                        <xsl:when test="($currentPage * $docsPerPage + 1) &gt; $docMax">
    374360                            <xsl:value-of select="$docMax"/>
     
    377363                            <xsl:value-of select="$currentPage * $docsPerPage"/>
    378364                        </xsl:otherwise>
    379                     </xsl:choose>
    380                     <!-- "of" -->
    381                     <xsl:text> </xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.of')"/><xsl:text> </xsl:text>
    382                     <!-- "Z" -->
    383                     <xsl:value-of select="$docMax"/>
    384                     <!-- "document[s]/section[s]"-->
    385                     <xsl:choose>
     365                    </xsl:choose></xsl:variable>
     366      <xsl:variable name="level">                   <xsl:choose>
    386367                        <xsl:when test="$docMax = 1">
    387368                            <xsl:text> </xsl:text>
     
    406387                            </xsl:choose>
    407388                        </xsl:otherwise>
    408                     </xsl:choose>
    409                 </td>
     389                    </xsl:choose></xsl:variable>
     390      <td id="searchResultsStatusBar">
     391        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.displayingnumdocs', concat($startdoc,';', $enddoc, ';', $docMax, ';', $level))"/>
     392        </td>
    410393            </xsl:if>
    411394           
     
    436419    </xsl:template>
    437420
    438     <xsl:template match="param" mode="calculate-default">
    439         <xsl:param name="ns">s1.</xsl:param>
    440         <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
    441         <xsl:choose>
    442             <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
    443                 <xsl:choose>
    444                     <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
    445                         <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
    446                             <xsl:value-of select="@value"/>,
    447                         </xsl:for-each>
    448                     </xsl:when>
    449                     <xsl:otherwise>
    450                         <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
    451                     </xsl:otherwise>
    452                 </xsl:choose>
    453             </xsl:when>
    454             <xsl:otherwise>
    455                 <xsl:value-of select="@default"/>
    456             </xsl:otherwise>
    457         </xsl:choose>
    458     </xsl:template>
    459 
    460     <!-- invisible params - used by other stuff. in the query form, we set to the default -->
    461     <xsl:template match="param[@type='invisible']">
    462         <xsl:param name="ns">s1.</xsl:param>
    463         <input type='hidden' name='{$ns}{@name}' value='{@default}'/>
    464     </xsl:template>
    465 
    466     <!-- boolean params -->
    467     <xsl:template match="param[@type='boolean']">
    468         <xsl:param name="ns">s1.</xsl:param>
    469         <xsl:param name="default"/>
    470         <select name='{$ns}{@name}'>
    471             <option value="0"><xsl:if test="$default='0'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="option[@name='0']/displayItem[@name='name']"/></option>
    472             <option value="1"><xsl:if test="$default='1'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="option[@name='1']/displayItem[@name='name']"/></option>
    473         </select>
    474     </xsl:template>
    475 
    476     <!-- integer params -->
    477     <xsl:template match="param[@type='integer']">
    478         <xsl:param name="ns">s1.</xsl:param>
    479         <xsl:param name="default"/>
    480         <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
    481     </xsl:template>
    482 
    483     <!-- single selection enum params -->
    484     <xsl:template match="param[@type='enum_single']">
    485         <xsl:param name="ns">s1.</xsl:param>
    486         <xsl:param name="default"/>
    487         <xsl:choose>
    488             <xsl:when test="count(option) = 1">
    489                 <xsl:value-of select="option/displayItem[@name='name']"/>
    490                 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of  select='option/@name'/></xsl:attribute></input>
    491             </xsl:when>
    492             <xsl:otherwise>
    493                 <select name="{$ns}{@name}">
    494                     <xsl:for-each select="option">
    495                         <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
    496                     </xsl:for-each>
    497                 </select>
    498             </xsl:otherwise>
    499         </xsl:choose>
    500     </xsl:template>
    501 
    502 
    503     <!-- multiple selection enum params -->
    504     <!-- how to do defaults for this?? -->
    505     <xsl:template match="param[@type='enum_multi']">
    506         <xsl:param name="ns">s1.</xsl:param>
    507         <xsl:param name="default"/>
    508         <select name="{$ns}{@name}" size="2">
    509             <xsl:attribute name="multiple"></xsl:attribute>
    510             <xsl:for-each select="option">
    511                 <option value="{@name}"><xsl:if test="contains($default, concat(',', @name, ','))"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
    512             </xsl:for-each>
    513         </select>
    514     </xsl:template>
    515 
    516     <!-- string params -->
    517     <xsl:template match="param[@type='string']">
    518         <xsl:param name="ns">s1.</xsl:param>
    519         <xsl:param name="default"/>
    520         <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
    521     </xsl:template>
    522 
    523     <!-- large string  params -->
    524     <xsl:template match="param[@type='text']">
    525         <xsl:param name="ns">s1.</xsl:param>
    526         <xsl:param name="default"/>
    527         <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
    528     </xsl:template>
    529 
    530     <!-- multi params - params that are combinations of other params -->
    531     <xsl:template match="param[@type='multi']">
    532         <xsl:param name="ns">s1.</xsl:param>
    533         <xsl:variable name="parent" select="@name"/>
    534 
    535         <table>
    536             <tr class="queryfieldheading">
    537                 <xsl:value-of select="displayItem[@name='name']"/>
    538                 <xsl:for-each select="param">
    539                     <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
    540                 </xsl:for-each>
    541             </tr>
    542             <xsl:apply-templates select="." mode="contents">
    543                 <xsl:with-param name="occurs" select="@occurs"/>
    544                 <xsl:with-param name="ns" select="$ns"/>
    545             </xsl:apply-templates>
    546         </table>
    547 
    548     </xsl:template>
    549    
    550     <xsl:template match="param[@type = 'checkbox_list']">
    551         <xsl:param name="ns">s1.</xsl:param>
    552         <ul class="checkboxList">
    553             <xsl:for-each select="option">
    554                 <li><input type="checkbox" name="{$ns}{../@name}" value="{@name}"/><xsl:value-of select="displayItem"/></li>
    555             </xsl:for-each>
    556         </ul>
    557     </xsl:template>
    558 
    559     <xsl:template match="param[@type='multi']" mode="contents">
    560         <xsl:param name="ns">s1.</xsl:param>
    561         <xsl:param name="occurs">1</xsl:param>
    562         <xsl:variable name="pos" select="@occurs - $occurs"/>   
    563         <tr class="queryfieldrow">
    564             <xsl:for-each select="param">
    565                 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
    566                 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
    567                 <td class="queryfieldcell">
    568                     <xsl:choose>
    569                         <xsl:when test="not(@ignore) or  @ignore != $pos">     
    570                             <xsl:apply-templates select="."><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $pos)"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
    571                         </xsl:when>
    572                         <xsl:otherwise><!-- put in a hidden placeholder -->
    573                             <input type="hidden" name='{$ns}{@name}' value=''/>
    574                         </xsl:otherwise>
    575                     </xsl:choose>
    576                 </td>
    577             </xsl:for-each>
    578         </tr>
    579 
    580         <!-- recursively call this template to get multiple entries -->
    581         <xsl:if test="$occurs &gt; 1">
    582             <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
    583         </xsl:if>
    584     </xsl:template>
     421
     422
     423
     424
     425
    585426   
    586427    <xsl:template name="resultsPagePre">
Note: See TracChangeset for help on using the changeset viewer.