Ignore:
Timestamp:
2011-05-09T14:37:04+12:00 (13 years ago)
Author:
sjm84
Message:

Updating this branch to match the latest Greenstone3 changes

Location:
main/branches/64_bit_Greenstone/greenstone3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/branches/64_bit_Greenstone/greenstone3

  • main/branches/64_bit_Greenstone/greenstone3/web/interfaces/default/transform/service-params.xsl

    r19940 r24007  
    44  xmlns:java="http://xml.apache.org/xslt/java"
    55  extension-element-prefixes="java">
    6 
     6 
    77  <!-- handling of the different types of params on a service form
    8   - these now only output the selection box/text box etc, not the name -->
    9 
     8    - these now only output the selection box/text box etc, not the name -->
     9 
    1010  <!-- the default param list handling -->
    1111  <xsl:template match="paramList">
     
    1313    <ul id="queryitemlist">
    1414      <xsl:for-each select="param">
    15     <xsl:choose>
    16       <xsl:when test="@type='multi'">
    17         <li><xsl:apply-templates select='.'><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></li>
    18       </xsl:when>
    19       <xsl:otherwise>
    20         <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable>
    21         <li><xsl:value-of select="displayItem[@name='name']"/><xsl:apply-templates select="."><xsl:with-param name="default" select="$pvalue"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></li>
    22       </xsl:otherwise>
    23     </xsl:choose>
     15        <xsl:choose>
     16          <xsl:when test="@type='multi'">
     17            <li><xsl:apply-templates select='.'><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></li>
     18          </xsl:when>
     19          <xsl:otherwise>
     20            <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable>
     21            <li><xsl:value-of select="displayItem[@name='name']"/><xsl:apply-templates select="."><xsl:with-param name="default" select="$pvalue"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></li>
     22          </xsl:otherwise>
     23        </xsl:choose>
    2424      </xsl:for-each>
    2525    </ul>
     
    2727 
    2828  <!-- puts all the params into a=p&p=h type form - need to change this if use
    29   multi params  -->
     29    multi params  -->
    3030  <xsl:template match="paramList" mode="cgi">
    3131    <xsl:param name="ns">s1.</xsl:param>
     
    3535    </xsl:for-each>
    3636  </xsl:template>
    37 
     37 
    3838  <xsl:template match="param" mode="calculate-default">
    3939    <xsl:param name="ns">s1.</xsl:param>
     
    4141    <xsl:choose>
    4242      <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
    43     <xsl:choose>
    44       <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
    45         <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
    46           <xsl:value-of select="@value"/>,
    47         </xsl:for-each>
    48       </xsl:when>
    49       <xsl:otherwise>
    50         <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
    51       </xsl:otherwise>
    52     </xsl:choose>
     43        <xsl:choose>
     44          <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
     45            <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
     46              <xsl:value-of select="@value"/>,
     47            </xsl:for-each>
     48          </xsl:when>
     49          <xsl:otherwise>
     50            <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
     51          </xsl:otherwise>
     52        </xsl:choose>
    5353      </xsl:when>
    5454      <xsl:otherwise>
    55     <xsl:value-of select="@default"/>
     55        <xsl:value-of select="@default"/>
    5656      </xsl:otherwise>
    5757    </xsl:choose>
    5858  </xsl:template>
    59 
     59 
    6060  <!-- invisible params - used by other stuff. in the query form, we set to teh default -->
    6161  <xsl:template match="param[@type='invisible']">
    6262    <xsl:param name="ns">s1.</xsl:param>
    63     <input type='hidden' name='{$ns}{@name}' value='{@default}'/>
     63    <input type='hidden' name='concat($ns, @name)' value='{@default}'/>
    6464  </xsl:template>
    6565  <!-- boolean params -->
     
    6767    <xsl:param name="ns">s1.</xsl:param>
    6868    <xsl:param name="default"/>
     69   
    6970    <select name='{$ns}{@name}'>
    7071      <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>
     
    7677  <xsl:template match="param[@type='integer']">
    7778    <xsl:param name="ns">s1.</xsl:param>
    78     <xsl:param name="default"/>
     79    <xsl:param name="default"/>
     80   
    7981    <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
    8082  </xsl:template>
    81 
     83 
    8284  <!-- single selection enum params -->
    8385  <xsl:template match="param[@type='enum_single']">
    8486    <xsl:param name="ns">s1.</xsl:param>
    8587    <xsl:param name="default"/>
     88   
    8689    <xsl:choose>
    8790      <xsl:when test="count(option) = 1">
    88     <xsl:text> </xsl:text><xsl:value-of select="option/displayItem[@name='name']"/>
    89     <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of  select='option/@name'/></xsl:attribute></input>
     91        <xsl:text> </xsl:text><xsl:value-of select="option/displayItem[@name='name']"/>
     92        <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of  select='option/@name'/></xsl:attribute></input>
    9093      </xsl:when>
    9194      <xsl:otherwise>
    92     <select name="{$ns}{@name}">
    93       <xsl:for-each select="option">
    94         <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
    95       </xsl:for-each>
    96     </select>
     95       
     96        <select name="{$ns}{@name}">
     97          <xsl:for-each select="option">
     98            <option value="{@name}"><!--<xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if>--><xsl:value-of select="displayItem[@name='name']"/></option>
     99          </xsl:for-each>
     100        </select>
    97101      </xsl:otherwise>
    98102    </xsl:choose>
    99103  </xsl:template>
    100 
    101 
     104 
     105 
    102106  <!-- multiple selection enum params -->
    103107  <!-- how to do defaults for this?? -->
     108  <!-- Don't need to do anything here, handled automatically in the list -->
    104109  <xsl:template match="param[@type='enum_multi']">
    105110    <xsl:param name="ns">s1.</xsl:param>
     
    107112    <select name="{$ns}{@name}" size='2'><xsl:attribute name="multiple"></xsl:attribute>
    108113      <xsl:for-each select="option">
    109     <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>
     114        <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>
    110115      </xsl:for-each>
    111116    </select>
     
    116121    <xsl:param name="ns">s1.</xsl:param>
    117122    <xsl:param name="default"/>
     123   
    118124    <input type="text" name="{$ns}{@name}" size="50" value="{$default}"/>
    119125  </xsl:template>
     
    122128  <xsl:template match="param[@type='text']">
    123129    <xsl:param name="ns">s1.</xsl:param>
    124     <xsl:param name="default"/>
     130    <xsl:param name="default"/>   
     131   
    125132    <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
    126133  </xsl:template>
    127 
     134 
    128135  <!-- multi params - params that are combinations of other params -->
    129136  <xsl:template match="param[@type='multi']">
     
    132139    <table>
    133140      <tr class="queryfieldheading"><xsl:value-of select="displayItem[@name='name']"/>
    134         <xsl:for-each select="param">
    135       <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
    136     </xsl:for-each>
     141        <xsl:for-each select="param">
     142          <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
     143        </xsl:for-each>
    137144      </tr>
    138145     
     
    140147    </table>
    141148  </xsl:template>
    142 
     149 
    143150  <xsl:template match="param[@type='multi']" mode="contents">
    144151    <xsl:param name="ns">s1.</xsl:param>
     
    146153    <xsl:variable name="pos" select="@occurs - $occurs"/>   
    147154    <tr class="queryfieldrow"><xsl:for-each select="param">
    148     <xsl:variable name="pname" select="@name"/>
    149     <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
    150     <td class="queryfieldcell"><xsl:choose>
    151         <xsl:when test="not(@ignore) or  @ignore != $pos">     
    152           <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>
    153         </xsl:when>
    154         <xsl:otherwise><!-- put in a hidden placeholder -->
    155           <input type="hidden" name='{$ns}{@name}' value=''/>
    156         </xsl:otherwise>
    157       </xsl:choose></td>
    158       </xsl:for-each></tr>
     155      <xsl:variable name="pname" select="@name"/>
     156      <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
     157      <td class="queryfieldcell"><xsl:choose>
     158        <xsl:when test="not(@ignore) or  @ignore != $pos">     
     159          <xsl:apply-templates select='.'><xsl:with-param name="default" select="$values|$pos"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
     160        </xsl:when>
     161        <xsl:otherwise><!-- put in a hidden placeholder -->
     162          <input type="hidden" name='{$ns}{@name}' value=''/>
     163        </xsl:otherwise>
     164      </xsl:choose></td>
     165    </xsl:for-each></tr>
    159166    <!-- recursively call this template to get multiple entries -->
    160167    <xsl:if test="$occurs &gt; 1">
     
    162169    </xsl:if>
    163170  </xsl:template>
    164 
     171 
    165172 
    166173</xsl:stylesheet> 
    167174
    168   <!-- a param list that puts params in pairs- wont work as is with new
     175<!-- a param list that puts params in pairs- wont work as is with new
    169176  param handling stuff -->
    170   <!--
     177<!--
    171178  <xsl:template match="paramList">
    172     <p/><table width="537">
    173       <xsl:choose>
    174         <xsl:when test='count(param)>4'>
    175           <xsl:for-each select="param[position() mod 2 = 1]">
    176             <tr><xsl:apply-templates select="."/>
    177               <xsl:if test="following-sibling::param[1]"><xsl:apply-templates select='following-sibling::param[1]'/></xsl:if></tr>
    178           </xsl:for-each>
    179         </xsl:when>
    180     <xsl:otherwise>
    181       <xsl:for-each select="param">
    182         <tr><xsl:apply-templates select='.'/></tr>
    183       </xsl:for-each>
    184     </xsl:otherwise>
    185       </xsl:choose>
    186     </table>
     179  <p/><table width="537">
     180  <xsl:choose>
     181  <xsl:when test='count(param)>4'>
     182  <xsl:for-each select="param[position() mod 2 = 1]">
     183  <tr><xsl:apply-templates select="."/>
     184  <xsl:if test="following-sibling::param[1]"><xsl:apply-templates select='following-sibling::param[1]'/></xsl:if></tr>
     185  </xsl:for-each>
     186  </xsl:when>
     187  <xsl:otherwise>
     188  <xsl:for-each select="param">
     189  <tr><xsl:apply-templates select='.'/></tr>
     190  </xsl:for-each>
     191  </xsl:otherwise>
     192  </xsl:choose>
     193  </table>
    187194  </xsl:template>
    188   -->
     195-->
Note: See TracChangeset for help on using the changeset viewer.