- Timestamp:
- 2009-07-14T09:09:40+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/web/interfaces/oran/transform/pages/query.xsl
r19856 r19988 8 8 exclude-result-prefixes="java util"> 9 9 10 <!-- make this pageuse the 'main' layout -->10 <!-- use the 'main' layout --> 11 11 <xsl:include href="layouts/main.xsl"/> 12 12 13 <!-- set page title and subtitle--> 14 <xsl:template name="title"><gslib:aboutCollectionPageTitle/></xsl:template> 15 <xsl:template name="linked-title"><a href=""><gslib:aboutCollectionPageTitle/></a></xsl:template> 16 17 <!-- the main page layout template is here --> 18 <xsl:template match="/page/pageResponse/service"> 19 20 <form name="QueryForm" method="get" action="{$library_name}"> 21 <div> 22 <input type="hidden" name="a" value="q"/> 23 <input type="hidden" name="sa"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/@subaction"/></xsl:attribute></input> 24 <input type="hidden" name="rt" value="rd"/> 25 <input type="hidden" name="s" value="{@name}"/> 26 <input type="hidden" name="c" value="{$collName}"/> 27 <xsl:if test="not(paramList/param[@name='startPage'])"> 28 <input type="hidden" name="startPage" value="1"/> 29 </xsl:if> 30 31 <xsl:apply-templates select="paramList"/> 32 33 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input> 13 <!-- set page title --> 14 <xsl:template name="pageTitle"><gslib:serviceName/></xsl:template> 15 16 <!-- set page breadcrumbs --> 17 <xsl:template name="breadcrumbs"> <gslib:siteLink/><gslib:rightArrow/> <gslib:collectionNameLinked/><gslib:rightArrow/></xsl:template> 18 19 <!-- the page content --> 20 <xsl:template match="/page"> 21 <xsl:choose> 22 <xsl:when test="not(pageResponse/documentNodeList)"> 23 <xsl:for-each select="pageResponse/service"> 24 <form name="QueryForm" method="get" action="{$library_name}"> 25 <div> 26 <input type="hidden" name="a" value="q"/> 27 <input type="hidden" name="sa"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/@subaction"/></xsl:attribute></input> 28 <input type="hidden" name="rt" value="rd"/> 29 <input type="hidden" name="s" value="{@name}"/> 30 <input type="hidden" name="c" value="{$collName}"/> 31 <xsl:if test="not(paramList/param[@name='startPage'])"> 32 <input type="hidden" name="startPage" value="1"/> 33 </xsl:if> 34 35 <xsl:variable name="ns">s1.</xsl:variable> 36 <xsl:for-each select="paramList/param"> 37 <xsl:choose> 38 <xsl:when test="@type='multi'"> 39 <xsl:apply-templates select="."><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates> 40 </xsl:when> 41 <xsl:otherwise> 42 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable> 43 <div class="paramLabel"><xsl:value-of select="displayItem[@name='name']"/></div> 44 <div class="paramValue"> 45 <xsl:apply-templates select="."> 46 <xsl:with-param name="default" select="$pvalue"/> 47 <xsl:with-param name="ns" select="$ns"/> 48 </xsl:apply-templates> 49 </div> 50 <br class="clear"/> 51 </xsl:otherwise> 52 </xsl:choose> 53 </xsl:for-each> 54 55 <br/> 56 57 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input> 34 58 35 </div> 36 </form> 37 38 <xsl:if test="contains(/page/pageRequest/paramList/param[@name='rt']/@value, 'r')"> 39 <xsl:call-template name="query-response"> 40 <xsl:with-param name="collName" select="$collName"/> 41 </xsl:call-template> 59 </div> 60 </form> 61 <xsl:if test="contains(/page/pageRequest/paramList/param[@name='rt']/@value, 'r')"> 62 <xsl:call-template name="query-response"> 63 <xsl:with-param name="collName" select="$collName"/> 64 </xsl:call-template> 65 </xsl:if> 66 67 </xsl:for-each> 68 69 </xsl:when> 70 71 <xsl:otherwise> 72 73 <ul id="results"> 74 <xsl:for-each select="pageResponse/documentNodeList/documentNode"> 75 <li class="document"> 76 <a> 77 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&d=<xsl:value-of select="@nodeID"/>&dt=<xsl:value-of select="@docType"/>&p.a=b&p.s=<xsl:value-of select="/page/pageResponse/service/@name"/></xsl:attribute> 78 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/> 79 </a> 80 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/> 81 </li> 82 </xsl:for-each> 83 </ul> 84 </xsl:otherwise> 85 86 </xsl:choose> 87 88 </xsl:template> 89 90 91 <!-- puts all the params into a=p&p=h type form - need to change this if use 92 multi params --> 93 <xsl:template match="paramList" mode="cgi"> 94 <xsl:param name="ns">s1.</xsl:param> 95 <xsl:for-each select="param"> 96 <xsl:variable name='pname' select="@name"/> 97 <xsl:text>&</xsl:text><xsl:value-of select="$ns"/><xsl:value-of select="@name"/>=<xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name='ns' select='$ns'/></xsl:apply-templates> 98 </xsl:for-each> 99 </xsl:template> 100 101 <xsl:template match="param" mode="calculate-default"> 102 <xsl:param name="ns">s1.</xsl:param> 103 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable> 104 <xsl:choose> 105 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]"> 106 <xsl:choose> 107 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text> 108 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]"> 109 <xsl:value-of select="@value"/>, 110 </xsl:for-each> 111 </xsl:when> 112 <xsl:otherwise> 113 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/> 114 </xsl:otherwise> 115 </xsl:choose> 116 </xsl:when> 117 <xsl:otherwise> 118 <xsl:value-of select="@default"/> 119 </xsl:otherwise> 120 </xsl:choose> 121 </xsl:template> 122 123 <!-- invisible params - used by other stuff. in the query form, we set to teh default --> 124 <xsl:template match="param[@type='invisible']"> 125 <xsl:param name="ns">s1.</xsl:param> 126 <input type='hidden' name='{$ns}{@name}' value='{@default}'/> 127 </xsl:template> 128 129 <!-- boolean params --> 130 <xsl:template match="param[@type='boolean']"> 131 <xsl:param name="ns">s1.</xsl:param> 132 <xsl:param name="default"/> 133 <select name='{$ns}{@name}'> 134 <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> 135 <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> 136 </select> 137 </xsl:template> 138 139 <!-- integer params --> 140 <xsl:template match="param[@type='integer']"> 141 <xsl:param name="ns">s1.</xsl:param> 142 <xsl:param name="default"/> 143 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/> 144 </xsl:template> 145 146 <!-- single selection enum params --> 147 <xsl:template match="param[@type='enum_single']"> 148 <xsl:param name="ns">s1.</xsl:param> 149 <xsl:param name="default"/> 150 <xsl:choose> 151 <xsl:when test="count(option) = 1"> 152 <xsl:value-of select="option/displayItem[@name='name']"/> 153 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input> 154 </xsl:when> 155 <xsl:otherwise> 156 <select name="{$ns}{@name}"> 157 <xsl:for-each select="option"> 158 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option> 159 </xsl:for-each> 160 </select> 161 </xsl:otherwise> 162 </xsl:choose> 163 </xsl:template> 164 165 166 <!-- multiple selection enum params --> 167 <!-- how to do defaults for this?? --> 168 <xsl:template match="param[@type='enum_multi']"> 169 <xsl:param name="ns">s1.</xsl:param> 170 <xsl:param name="default"/> 171 <select name="{$ns}{@name}" size="2"> 172 <xsl:attribute name="multiple"></xsl:attribute> 173 <xsl:for-each select="option"> 174 <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> 175 </xsl:for-each> 176 </select> 177 </xsl:template> 178 179 <!-- string params --> 180 <xsl:template match="param[@type='string']"> 181 <xsl:param name="ns">s1.</xsl:param> 182 <xsl:param name="default"/> 183 <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/> 184 </xsl:template> 185 186 <!-- large string params --> 187 <xsl:template match="param[@type='text']"> 188 <xsl:param name="ns">s1.</xsl:param> 189 <xsl:param name="default"/> 190 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea> 191 </xsl:template> 192 193 <!-- multi params - params that are combinations of other params --> 194 <xsl:template match="param[@type='multi']"> 195 <xsl:param name="ns">s1.</xsl:param> 196 <xsl:variable name="parent" select="@name"/> 197 198 <table> 199 <tr class="queryfieldheading"> 200 <xsl:value-of select="displayItem[@name='name']"/> 201 <xsl:for-each select="param"> 202 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td> 203 </xsl:for-each> 204 </tr> 205 <xsl:apply-templates select="." mode="contents"> 206 <xsl:with-param name="occurs" select="@occurs"/> 207 <xsl:with-param name="ns" select="$ns"/> 208 </xsl:apply-templates> 209 </table> 210 211 </xsl:template> 212 213 <xsl:template match="param[@type='multi']" mode="contents"> 214 <xsl:param name="ns">s1.</xsl:param> 215 <xsl:param name="occurs">1</xsl:param> 216 <xsl:variable name="pos" select="@occurs - $occurs"/> 217 <tr class="queryfieldrow"> 218 <xsl:for-each select="param"> 219 <xsl:variable name="pname" select="@name"/> 220 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/> 221 <td class="queryfieldcell"> 222 <xsl:choose> 223 <xsl:when test="not(@ignore) or @ignore != $pos"> 224 <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> 225 </xsl:when> 226 <xsl:otherwise><!-- put in a hidden placeholder --> 227 <input type="hidden" name='{$ns}{@name}' value=''/> 228 </xsl:otherwise> 229 </xsl:choose> 230 </td> 231 </xsl:for-each> 232 </tr> 233 234 <!-- recursively call this template to get multiple entries --> 235 <xsl:if test="$occurs > 1"> 236 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates> 42 237 </xsl:if> 43 44 </xsl:template> 45 46 <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/service"/></xsl:template> 47 48 49 <!-- the default param list handling --> 50 <xsl:template match="paramList"> 51 <xsl:param name="ns">s1.</xsl:param> 52 <ul id="queryitemlist"> 53 <xsl:for-each select="param"> 54 <xsl:choose> 55 <xsl:when test="@type='multi'"> 56 <li><xsl:apply-templates select='.'><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></li> 57 </xsl:when> 58 <xsl:otherwise> 59 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable> 60 <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> 61 </xsl:otherwise> 62 </xsl:choose> 63 </xsl:for-each> 64 </ul> 65 </xsl:template> 66 67 <!-- puts all the params into a=p&p=h type form - need to change this if use 68 multi params --> 69 <xsl:template match="paramList" mode="cgi"> 70 <xsl:param name="ns">s1.</xsl:param> 71 <xsl:for-each select="param"> 72 <xsl:variable name='pname' select="@name"/> 73 <xsl:text>&</xsl:text><xsl:value-of select="$ns"/><xsl:value-of select="@name"/>=<xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name='ns' select='$ns'/></xsl:apply-templates> 74 </xsl:for-each> 75 </xsl:template> 76 77 <xsl:template match="param" mode="calculate-default"> 78 <xsl:param name="ns">s1.</xsl:param> 79 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable> 80 <xsl:choose> 81 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]"> 82 <xsl:choose> 83 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text> 84 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]"> 85 <xsl:value-of select="@value"/>, 86 </xsl:for-each> 87 </xsl:when> 88 <xsl:otherwise> 89 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/> 90 </xsl:otherwise> 91 </xsl:choose> 92 </xsl:when> 93 <xsl:otherwise> 94 <xsl:value-of select="@default"/> 95 </xsl:otherwise> 96 </xsl:choose> 97 </xsl:template> 98 99 <!-- invisible params - used by other stuff. in the query form, we set to teh default --> 100 <xsl:template match="param[@type='invisible']"> 101 <xsl:param name="ns">s1.</xsl:param> 102 <input type='hidden' name='{$ns}{@name}' value='{@default}'/> 103 </xsl:template> 104 <!-- boolean params --> 105 <xsl:template match="param[@type='boolean']"> 106 <xsl:param name="ns">s1.</xsl:param> 107 <xsl:param name="default"/> 108 <select name='{$ns}{@name}'> 109 <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> 110 <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> 111 </select> 112 </xsl:template> 113 114 <!-- integer params --> 115 <xsl:template match="param[@type='integer']"> 116 <xsl:param name="ns">s1.</xsl:param> 117 <xsl:param name="default"/> 118 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/> 119 </xsl:template> 120 121 <!-- single selection enum params --> 122 <xsl:template match="param[@type='enum_single']"> 123 <xsl:param name="ns">s1.</xsl:param> 124 <xsl:param name="default"/> 125 <xsl:choose> 126 <xsl:when test="count(option) = 1"> 127 <xsl:value-of select="option/displayItem[@name='name']"/> 128 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input> 129 </xsl:when> 130 <xsl:otherwise> 131 <select name="{$ns}{@name}"> 132 <xsl:for-each select="option"> 133 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option> 134 </xsl:for-each> 135 </select> 136 </xsl:otherwise> 137 </xsl:choose> 138 </xsl:template> 139 140 141 <!-- multiple selection enum params --> 142 <!-- how to do defaults for this?? --> 143 <xsl:template match="param[@type='enum_multi']"> 144 <xsl:param name="ns">s1.</xsl:param> 145 <xsl:param name="default"/> 146 <select name="{$ns}{@name}" size='2'><xsl:attribute name="multiple"></xsl:attribute> 147 <xsl:for-each select="option"> 148 <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> 149 </xsl:for-each> 150 </select> 151 </xsl:template> 152 153 <!-- string params --> 154 <xsl:template match="param[@type='string']"> 155 <xsl:param name="ns">s1.</xsl:param> 156 <xsl:param name="default"/> 157 <input type="text" name="{$ns}{@name}" size="50" value="{$default}"/> 158 </xsl:template> 159 160 <!-- large string params --> 161 <xsl:template match="param[@type='text']"> 162 <xsl:param name="ns">s1.</xsl:param> 163 <xsl:param name="default"/> 164 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea> 165 </xsl:template> 166 167 <!-- multi params - params that are combinations of other params --> 168 <xsl:template match="param[@type='multi']"> 169 <xsl:param name="ns">s1.</xsl:param> 170 <xsl:variable name="parent" select="@name"/> 171 <table> 172 <tr class="queryfieldheading"><xsl:value-of select="displayItem[@name='name']"/> 173 <xsl:for-each select="param"> 174 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td> 175 </xsl:for-each> 176 </tr> 177 178 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="@occurs"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates> 179 </table> 180 </xsl:template> 181 182 <xsl:template match="param[@type='multi']" mode="contents"> 183 <xsl:param name="ns">s1.</xsl:param> 184 <xsl:param name="occurs">1</xsl:param> 185 <xsl:variable name="pos" select="@occurs - $occurs"/> 186 <tr class="queryfieldrow"><xsl:for-each select="param"> 187 <xsl:variable name="pname" select="@name"/> 188 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/> 189 <td class="queryfieldcell"><xsl:choose> 190 <xsl:when test="not(@ignore) or @ignore != $pos"> 191 <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> 192 </xsl:when> 193 <xsl:otherwise><!-- put in a hidden placeholder --> 194 <input type="hidden" name='{$ns}{@name}' value=''/> 195 </xsl:otherwise> 196 </xsl:choose></td> 197 </xsl:for-each></tr> 198 <!-- recursively call this template to get multiple entries --> 199 <xsl:if test="$occurs > 1"> 200 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates> 201 </xsl:if> 202 </xsl:template> 203 238 </xsl:template> 204 239 205 240 </xsl:stylesheet>
Note:
See TracChangeset
for help on using the changeset viewer.