source: greenstone3/trunk/web/interfaces/gs2/transform/pref.xsl@ 17019

Last change on this file since 17019 was 17019, checked in by max, 16 years ago

Move the HTML skeleton from style.xsl to the current XSL file.

  • Property svn:keywords set to Author Date Id Revision
File size: 18.6 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <!-- style includes global params interface_name, library_name -->
10 <xsl:include href="style.xsl"/>
11 <xsl:output method="html"/>
12
13 <!-- the main page layout template is here -->
14 <xsl:template match="page">
15 <html>
16 <head>
17 <title>
18 <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
19 <xsl:call-template name="pageTitle"/><xsl:text> </xsl:text>
20 </title>
21 <xsl:call-template name="globalStyle"/>
22 <xsl:call-template name="pageStyle"/>
23 </head>
24 <body class="bgimage">
25 <xsl:attribute name="dir"><xsl:call-template name="direction"/></xsl:attribute>
26 <div id="page">
27 <xsl:apply-templates select="pageResponse"/>
28 <xsl:call-template name="greenstoneFooter"/>
29 </div>
30 </body>
31 </html>
32 </xsl:template>
33
34 <xsl:template name="pageTitle">
35 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/>
36 </xsl:template>
37
38 <!-- page specific style goes here -->
39 <xsl:template name="pageStyle">
40 <script type="text/javascript" src="interfaces/gs2/js/pref.js"><xsl:text disable-output-escaping="yes"> </xsl:text></script>
41 <link rel="stylesheet" href="interfaces/gs2/style/classic.css" type="text/css"/>
42 </xsl:template>
43
44 <xsl:template match="pageResponse">
45 <xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
46 <!-- check whether these search modes are supported -->
47 <xsl:variable name="simplestatus"><xsl:choose><xsl:when test="/page/pageResponse//service[@name='TextQuery']">y</xsl:when><xsl:otherwise>n</xsl:otherwise></xsl:choose></xsl:variable>
48 <xsl:variable name="formstatus"><xsl:choose><xsl:when test="/page/pageResponse//service[@name='FieldQuery']">y</xsl:when><xsl:otherwise>n</xsl:otherwise></xsl:choose></xsl:variable>
49 <xsl:variable name="advancedstatus"><xsl:choose><xsl:when test="/page/pageResponse//service[@name='AdvancedFieldQuery']">y</xsl:when><xsl:otherwise>n</xsl:otherwise></xsl:choose></xsl:variable>
50
51 <center>
52 <xsl:call-template name="standardPageBanner">
53 <xsl:with-param name="collName" select="$collName"/>
54 <xsl:with-param name="pageType">pref</xsl:with-param>
55 </xsl:call-template>
56 <xsl:call-template name="navigationBar">
57 <xsl:with-param name="collName" select="$collName"/>
58 </xsl:call-template>
59 <form name="PrefForm" method="get" action="{$library_name}" onsubmit="return checkForm();">
60 <input type='hidden' name='a' value='p'/>
61 <input type='hidden' name='sa' value='pref'/>
62 <input type='hidden' name='c' value="{$collName}"/>
63
64 <table width="800">
65 <tr><td><div class="formheading"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.prespref')"/></div></td></tr>
66 <tr><td><xsl:call-template name="pres-prefs"/></td></tr>
67 <tr><td><div class="formheading"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.searchpref')"/></div></td></tr>
68 <tr><td><xsl:call-template name="search-mode-prefs"><xsl:with-param name="simplestatus" select="$simplestatus"/><xsl:with-param name="formstatus" select="$formstatus"/><xsl:with-param name="advancedstatus" select="$advancedstatus"/></xsl:call-template></td></tr>
69 </table>
70 </form>
71 </center>
72 </xsl:template>
73
74
75 <xsl:template name="pres-prefs">
76 <table>
77 <tr><td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.interfacelang')"/></td><td align='left'><xsl:call-template name="lang-list"/><!--English--></td></tr>
78 <!--<tr><td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.encoding')"/></td><td align='left'>UTF-8</td></tr> -->
79 </table>
80 </xsl:template>
81
82 <xsl:template name="lang-list">
83 <xsl:variable name="current" select="/page/@lang"/>
84 <select name="l">
85 <xsl:for-each select="/page/pageResponse/languageList/language">
86 <option value="{@name}"><xsl:if test="@name=$current"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:if test="displayItem"><xsl:value-of select="displayItem[@name='name']"/></xsl:if><xsl:if test="not(displayItem)"><xsl:value-of select="@displayname"/></xsl:if></option>
87 </xsl:for-each>
88 </select>
89 </xsl:template>
90
91 <xsl:template name="search-mode-prefs">
92 <xsl:param name="ns">s1.</xsl:param>
93 <!-- variables that indicates whether these mode are supported by current collection -->
94 <xsl:param name="simplestatus"/>
95 <xsl:param name="formstatus"/>
96 <xsl:param name="advancedstatus"/>
97
98 <!-- search type : 0(default, simple); 1(form) -->
99 <xsl:variable name="qt"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qt']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='qt']/@value"/></xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose></xsl:variable>
100 <!-- search form type : 0(default, simple form); 1(advanced form) -->
101 <xsl:variable name="queryfmode"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qfm']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='qfm']/@value"/></xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose></xsl:variable>
102 <!-- search mode: text, form, advanced -->
103 <xsl:variable name="mode"><xsl:choose><xsl:when test="$qt=0">text</xsl:when><xsl:when test="$queryfmode=0">form</xsl:when><xsl:when test="$queryfmode=1">advanced</xsl:when><xsl:otherwise>text</xsl:otherwise></xsl:choose></xsl:variable>
104
105 <table>
106 <tr><td> </td><td> </td><td align='right'><input type='submit' name="submit" value='set prefs'/></td></tr>
107 <!-- search type -->
108 <!-- values are updated by either xslt or javascript -->
109 <input type="hidden" name="qt" value="{$qt}"/>
110
111 <tr><td valign='baseline' class='col1'>Type of search </td><td class='col2'><input type='radio' name='qfm' value='2' onclick="javascript:changePref(2)"><xsl:if test="$qt=0 or $queryfmode=2"><xsl:attribute name="checked"/></xsl:if></input></td><td class='col3'> <font><xsl:if test="$qt=0 or $queryfmode=2"><xsl:attribute name="style">font-weight: bold;</xsl:attribute></xsl:if>simple text</font>
112
113 <xsl:if test="$formstatus='y'"><input name="qfm" onclick="javascript:changePref(0)" type="radio" value="0"><xsl:if test="$mode='form'"><xsl:attribute name="checked"/></xsl:if></input> <font><xsl:if test="$mode='form'"><xsl:attribute name="style">font-weight: bold;</xsl:attribute></xsl:if>simple form</font></xsl:if>
114
115 <xsl:if test="$advancedstatus='y'"><input name="qfm" onclick="javascript:changePref(1)" type="radio" value="1" ><xsl:if test="$mode='advanced'"><xsl:attribute name="checked"/></xsl:if></input> <font><xsl:if test="$mode='advanced'"><xsl:attribute name="style">font-weight: bold;</xsl:attribute></xsl:if>advanced form</font></xsl:if>
116 </td></tr>
117
118 <!-- search options -->
119 <tr><td><div class="formheading">Options</div></td></tr>
120 <xsl:call-template name="search-options-prefs"><xsl:with-param name="mode" select="$mode"/><xsl:with-param name="simplestatus" select="$simplestatus"/><xsl:with-param name="formstatus" select="$formstatus"/><xsl:with-param name="advancedstatus" select="$advancedstatus"/></xsl:call-template>
121 </table>
122 </xsl:template>
123
124 <xsl:template name="search-options-prefs">
125 <xsl:param name="ns">s1.</xsl:param>
126 <xsl:param name="mode">text</xsl:param>
127 <xsl:param name="simplestatus"/>
128 <xsl:param name="formstatus"/>
129 <xsl:param name="advancedstatus"/>
130
131 <!-- extract service parameters, avoid hard coding params in this xslt -->
132 <!-- mode specific options -->
133 <xsl:call-template name="text-search-prefs"><xsl:with-param name="display"><xsl:if test="$mode='text'">y</xsl:if><xsl:if test="$mode='advanced' or $mode='form'">n</xsl:if></xsl:with-param></xsl:call-template>
134 <!-- simple form search mode doesn't have any specific options -->
135 <!-- <xsl:if test="$mode='form'"><xsl:apply-templates select="/page/pageResponse//service[@name='FieldQuery']"/></xsl:if> -->
136 <xsl:call-template name="advanced-search-prefs"><xsl:with-param name="display"><xsl:if test="$mode='advanced'">y</xsl:if><xsl:if test="$mode='text' or $mode='form'">n</xsl:if></xsl:with-param></xsl:call-template>
137
138 <!-- search type specific options -->
139 <xsl:apply-templates select="/page/pageResponse//service[@name='TextQuery']">
140 <xsl:with-param name="display"><xsl:if test="$mode='text' or $mode='form'">y</xsl:if><xsl:if test="$mode='advanced'">n</xsl:if></xsl:with-param>
141 <xsl:with-param name="prefix">tf</xsl:with-param>
142 </xsl:apply-templates>
143 <xsl:apply-templates select="/page/pageResponse//service[@name='AdvancedFieldQuery']">
144 <xsl:with-param name="display"><xsl:if test="$mode='advanced'">y</xsl:if><xsl:if test="$mode='text' or $mode='form'">n</xsl:if></xsl:with-param>
145 <xsl:with-param name="prefix">adv</xsl:with-param>
146 </xsl:apply-templates>
147
148 <!-- General options -->
149 <!-- sort order -->
150 <xsl:variable name="sort"><xsl:choose><xsl:when test="/page/pageResponse//service[@name='TextQuery']//param[@name='sortBy']">y</xsl:when><xsl:otherwise>n</xsl:otherwise></xsl:choose></xsl:variable>
151 <xsl:if test="$sort='y'">
152 <xsl:variable name="sortvar" select="concat($ns,'sortBy')"/>
153 <xsl:variable name="sortparam" select="//param[@name='sortBy']"/>
154 <xsl:variable name="cachedValue" select="/page/pageRequest/paramList/param[@name=$sortvar]/@value"/>
155 <xsl:variable name="defaultValue" select="$sortparam/@default"/>
156 <xsl:variable name="optionVal" select="$sortparam/option[1]/@name"/>
157
158 <tr><td rowspan='2' valign='baseline'><xsl:value-of select="$sortparam/displayItem"/></td><td><input type='radio' name='{$sortvar}' value='{$optionVal}'><xsl:choose><xsl:when test="$cachedValue=$optionVal"><xsl:attribute name="checked"/></xsl:when><xsl:when test="normalize-space($cachedValue)='' and $optionVal=$defaultValue"><xsl:attribute name="checked"/></xsl:when></xsl:choose></input></td>
159 <td><xsl:value-of select="$sortparam/option[1]/displayItem"/></td></tr>
160
161 <xsl:variable name="optionVal" select="$sortparam/option[2]/@name"/>
162 <tr><td><input type='radio' name='{$sortvar}' value='{$optionVal}'><xsl:choose><xsl:when test="$cachedValue=$optionVal"><xsl:attribute name="checked"/></xsl:when><xsl:when test="normalize-space($cachedValue)='' and $optionVal=$defaultValue"><xsl:attribute name="checked"/></xsl:when></xsl:choose></input></td><td><xsl:value-of select="$sortparam/option[2]/displayItem"/></td></tr>
163 </xsl:if>
164
165 <!-- hit display -->
166 <!-- normally all the collections support customized number of returned records and displayed records. Just to be consistent with the other two options. -->
167 <xsl:variable name="maxstatus"><xsl:choose><xsl:when test="/page/pageResponse//service[@name='TextQuery']//param[@name='maxDocs']">y</xsl:when><xsl:otherwise>n</xsl:otherwise></xsl:choose></xsl:variable>
168 <xsl:if test="$maxstatus='y'">
169 <xsl:variable name="maxvar" select="concat($ns,'maxDocs')"/>
170 <xsl:variable name="maxdocs"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name=$maxvar]"><xsl:value-of select="/page/pageRequest/paramList/param[@name=$maxvar]/@value"/></xsl:when><xsl:otherwise>50</xsl:otherwise></xsl:choose></xsl:variable>
171 <xsl:variable name="hits"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='hitsPerPage']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='hitsPerPage']/@value"/></xsl:when><xsl:otherwise>20</xsl:otherwise></xsl:choose></xsl:variable>
172 <tr><td colspan='3'>Return up to
173 <select name="{$ns}maxDocs">
174 <option value="50"><xsl:if test="$maxdocs=50"><xsl:attribute name="selected"></xsl:attribute></xsl:if>50</option>
175 <option value="100"><xsl:if test="$maxdocs=100"><xsl:attribute name="selected"></xsl:attribute></xsl:if>100</option>
176 <option value="200"><xsl:if test="$maxdocs=200"><xsl:attribute name="selected"></xsl:attribute></xsl:if>200</option>
177 <option value="-1"><xsl:if test="$maxdocs=-1"><xsl:attribute name="selected"></xsl:attribute></xsl:if>all</option>
178 </select>
179 hits with
180 <select name="hitsPerPage">
181 <option value="10"><xsl:if test="$hits=10"><xsl:attribute name="selected"></xsl:attribute></xsl:if>10 </option>
182 <option value="20"><xsl:if test="$hits=20"><xsl:attribute name="selected"></xsl:attribute></xsl:if>20</option>
183 <option value="50"><xsl:if test="$hits=50"><xsl:attribute name="selected"></xsl:attribute></xsl:if>50</option>
184 <option value="-1"><xsl:if test="$hits=-1"><xsl:attribute name="selected"></xsl:attribute></xsl:if>all</option>
185 </select>
186 hits per page.
187 </td></tr>
188 </xsl:if>
189 </xsl:template>
190
191 <xsl:template name="advanced-search-prefs">
192 <xsl:param name="display">n</xsl:param>
193 <xsl:variable name="numbox"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qfn']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='qfn']/@value"/></xsl:when><xsl:otherwise>4</xsl:otherwise></xsl:choose></xsl:variable>
194 <tr id="adv-qnb"><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if>
195 <td colspan='2'>Number of fields: </td><td><select name="qfn">
196 <option value="2"><xsl:if test="$numbox=2"><xsl:attribute name="selected"></xsl:attribute></xsl:if>2</option>
197 <option value="4"><xsl:if test="$numbox=4"><xsl:attribute name="selected"></xsl:attribute></xsl:if>4</option>
198 <option value="6"><xsl:if test="$numbox=6"><xsl:attribute name="selected"></xsl:attribute></xsl:if>6</option>
199 <option value="8"><xsl:if test="$numbox=8"><xsl:attribute name="selected"></xsl:attribute></xsl:if>8</option>
200 </select></td><td/></tr>
201 </xsl:template>
202
203 <xsl:template name="text-search-prefs">
204 <xsl:param name="display">n</xsl:param>
205 <!-- query mode : 0(default, simple); 1(advanced, boolean)-->
206 <xsl:variable name="querymode"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qm']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='qm']/@value"/></xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose></xsl:variable>
207 <tr id="text-qm1"><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if><td rowspan='2' valign='baseline'>Query mode </td><td><input type='radio' name='qm' value='0'><xsl:if test="$querymode=0"><xsl:attribute name="checked"></xsl:attribute></xsl:if></input></td><td> simple query mode</td></tr>
208 <tr id="text-qm2"><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if><td><input type='radio' name='qm' value='1'><xsl:if test="$querymode=1"><xsl:attribute name="checked"/></xsl:if></input></td><td> advanced query mode (allows boolean searching using !, &amp;, |, and parentheses)</td></tr>
209
210 <!-- query box size -->
211 <xsl:variable name="boxsize"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qb']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='qb']/@value"/></xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose></xsl:variable>
212 <tr id="text-qb1"><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if><td rowspan='2' valign='baseline'>Query box size</td><td><input type='radio' name='qb' value='0'><xsl:if test="$boxsize=0"><xsl:attribute name="checked"></xsl:attribute></xsl:if></input></td><td> regular query box</td></tr>
213 <tr id="text-qb2"><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if><td><input type='radio' name='qb' value='1'><xsl:if test="$boxsize=1"><xsl:attribute name="checked"></xsl:attribute></xsl:if></input></td><td> large query box</td></tr>
214 </xsl:template>
215
216
217 <xsl:template match="service">
218 <xsl:param name="display">n</xsl:param>
219 <xsl:param name="prefix"/>
220 <xsl:apply-templates select="paramList/param[not(@type='invisible')]"><xsl:with-param name="display" select="$display"/><xsl:with-param name="prefix" select="$prefix"/></xsl:apply-templates>
221 </xsl:template>
222
223 <xsl:template match="param">
224 <xsl:param name="ns">s1.</xsl:param>
225 <xsl:param name="display">n</xsl:param>
226 <xsl:param name="prefix"/>
227
228 <xsl:if test="not(@name='matchMode') and not(@name='level') and not(@name='index') and not(@name='sortBy') and not(@name='indexSubcollection') and not(@name='indexLanguage') and (@type='boolean' or @type='enum_single')"><xsl:apply-templates select="." mode="radio"><xsl:with-param name="display" select="$display"/><xsl:with-param name="prefix" select="$prefix"/><xsl:with-param name="paramIdx" select="position()"/></xsl:apply-templates></xsl:if>
229 </xsl:template>
230
231 <xsl:template match="param" mode="radio">
232 <xsl:param name="ns">s1.</xsl:param>
233 <xsl:param name="display">n</xsl:param>
234 <xsl:param name="prefix"/>
235 <xsl:param name="paramIdx"/>
236
237 <xsl:variable name="cachedName" select="concat($ns, @name)"/>
238 <xsl:variable name="cachedValue"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name=$cachedName]"><xsl:value-of select="/page/pageRequest/paramList/param[@name=$cachedName]/@value"/></xsl:when><xsl:otherwise><xsl:value-of select="@default"/></xsl:otherwise></xsl:choose></xsl:variable>
239 <!-- number of options, for rowspan attribute -->
240 <xsl:variable name="numOptions" select="count(option)"/>
241 <xsl:variable name="displayName"><xsl:value-of select="displayItem"/></xsl:variable>
242 <xsl:variable name="paramName"><xsl:value-of select="@name"/></xsl:variable>
243
244 <xsl:for-each select="option">
245 <xsl:variable name="value" select="@name"/>
246 <tr><xsl:attribute name="id"><xsl:value-of select="concat($prefix, '-', $paramIdx, '-', position())"/></xsl:attribute><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if>
247 <xsl:if test="position()=1"><td rowspan='{$numOptions}' valign='baseline'><xsl:value-of select="../displayItem"/></td></xsl:if>
248 <td><input type='radio' name='{$cachedName}' value="{$value}"><xsl:if test="$cachedValue=$value"><xsl:attribute name="checked">true</xsl:attribute></xsl:if></input></td>
249 <td><xsl:value-of select="displayItem"/></td>
250 </tr>
251 </xsl:for-each>
252 </xsl:template>
253
254</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.