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

Last change on this file since 18392 was 18392, checked in by kjdon, 15 years ago

changes to keep in line with default interface. class removed from body tag, main div id changed from page to page-wrapper

  • Property svn:keywords set to Author Date Id Revision
File size: 19.7 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>
25 <xsl:attribute name="dir"><xsl:call-template name="direction"/></xsl:attribute>
26 <div id="page-wrapper">
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 </xsl:template>
42
43 <xsl:template match="pageResponse">
44 <xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
45 <!-- check whether these search modes are supported -->
46 <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>
47 <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>
48 <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>
49
50 <center>
51 <xsl:call-template name="standardPageBanner">
52 <xsl:with-param name="collName" select="$collName"/>
53 <xsl:with-param name="pageType">pref</xsl:with-param>
54 </xsl:call-template>
55 <xsl:call-template name="navigationBar">
56 <xsl:with-param name="collName" select="$collName"/>
57 </xsl:call-template>
58 <form name="PrefForm" method="get" action="{$library_name}" onsubmit="return checkForm();">
59 <input type='hidden' name='a' value='p'/>
60 <input type='hidden' name='sa' value='pref'/>
61 <input type='hidden' name='c' value="{$collName}"/>
62
63 <table width="800">
64 <tr><td><div class="formheading"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.prespref')"/></div></td></tr>
65 <tr><td><xsl:call-template name="pres-prefs"/></td></tr>
66 <tr><td><div class="formheading"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.searchpref')"/></div></td></tr>
67 <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>
68 </table>
69 </form>
70 </center>
71 </xsl:template>
72
73
74 <xsl:template name="pres-prefs">
75 <table>
76 <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>
77 <!--<tr><td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.encoding')"/></td><td align='left'>UTF-8</td></tr> -->
78 </table>
79 </xsl:template>
80
81 <xsl:template name="lang-list">
82 <xsl:variable name="current" select="/page/@lang"/>
83 <select name="l">
84 <xsl:for-each select="/page/pageResponse/languageList/language">
85 <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>
86 </xsl:for-each>
87 </select>
88 </xsl:template>
89
90 <xsl:template name="search-mode-prefs">
91 <xsl:param name="ns">s1.</xsl:param>
92 <!-- variables that indicates whether these mode are supported by current collection -->
93 <xsl:param name="simplestatus"/>
94 <xsl:param name="formstatus"/>
95 <xsl:param name="advancedstatus"/>
96
97 <!-- search type : 0(default, simple); 1(form) -->
98 <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>
99 <!-- search form type : 0(default, simple form); 1(advanced form) -->
100 <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>
101 <!-- search mode: text, form, advanced -->
102 <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>
103
104 <table>
105 <tr><td> </td><td> </td><td align='right'><input type='submit' name="submit"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.set_prefs')"/></xsl:attribute></input></td></tr>
106 <!-- search type -->
107 <!-- values are updated by either xslt or javascript -->
108 <input type="hidden" name="qt" value="{$qt}"/>
109
110 <tr><td valign='baseline' class='col1'><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.search_type')"/></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><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.search_type_text')"/></font>
111
112 <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><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.search_type_simple_form')"/></font></xsl:if>
113
114 <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><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.search_type_advanced_form')"/></font></xsl:if>
115 </td></tr>
116
117 <!-- search options -->
118 <tr><td><div class="formheading"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.search_options')"/></div></td></tr>
119 <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>
120 </table>
121 </xsl:template>
122
123 <xsl:template name="search-options-prefs">
124 <xsl:param name="ns">s1.</xsl:param>
125 <xsl:param name="mode">text</xsl:param>
126 <xsl:param name="simplestatus"/>
127 <xsl:param name="formstatus"/>
128 <xsl:param name="advancedstatus"/>
129
130 <!-- extract service parameters, avoid hard coding params in this xslt -->
131 <!-- mode specific options -->
132 <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>
133 <!-- simple form search mode doesn't have any specific options -->
134 <!-- <xsl:if test="$mode='form'"><xsl:apply-templates select="/page/pageResponse//service[@name='FieldQuery']"/></xsl:if> -->
135 <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>
136
137 <!-- search type specific options -->
138 <xsl:apply-templates select="/page/pageResponse//service[@name='TextQuery']">
139 <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>
140 <xsl:with-param name="prefix">tf</xsl:with-param>
141 </xsl:apply-templates>
142 <xsl:apply-templates select="/page/pageResponse//service[@name='AdvancedFieldQuery']">
143 <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>
144 <xsl:with-param name="prefix">adv</xsl:with-param>
145 </xsl:apply-templates>
146
147 <!-- General options -->
148 <!-- sort order -->
149 <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>
150 <xsl:if test="$sort='y'">
151 <xsl:variable name="sortvar" select="concat($ns,'sortBy')"/>
152 <xsl:variable name="sortparam" select="//param[@name='sortBy']"/>
153 <xsl:variable name="cachedValue" select="/page/pageRequest/paramList/param[@name=$sortvar]/@value"/>
154 <xsl:variable name="defaultValue" select="$sortparam/@default"/>
155 <xsl:variable name="optionVal" select="$sortparam/option[1]/@name"/>
156
157 <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>
158 <td><xsl:value-of select="$sortparam/option[1]/displayItem"/></td></tr>
159
160 <xsl:variable name="optionVal" select="$sortparam/option[2]/@name"/>
161 <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>
162 </xsl:if>
163
164 <!-- hit display -->
165 <!-- normally all the collections support customized number of returned records and displayed records. Just to be consistent with the other two options. -->
166 <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>
167 <xsl:if test="$maxstatus='y'">
168 <xsl:variable name="maxvar" select="concat($ns,'maxDocs')"/>
169 <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>
170 <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>
171 <xsl:variable name="maxdocs_param"><select name="{$ns}maxDocs">
172 <option value="50"><xsl:if test="$maxdocs=50"><xsl:attribute name="selected"></xsl:attribute></xsl:if>50</option>
173 <option value="100"><xsl:if test="$maxdocs=100"><xsl:attribute name="selected"></xsl:attribute></xsl:if>100</option>
174 <option value="200"><xsl:if test="$maxdocs=200"><xsl:attribute name="selected"></xsl:attribute></xsl:if>200</option>
175 <option value="-1"><xsl:if test="$maxdocs=-1"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.all')"/></option>
176 </select></xsl:variable>
177 <xsl:variable name="hits_param"><select name="hitsPerPage">
178 <option value="10"><xsl:if test="$hits=10"><xsl:attribute name="selected"></xsl:attribute></xsl:if>10 </option>
179 <option value="20"><xsl:if test="$hits=20"><xsl:attribute name="selected"></xsl:attribute></xsl:if>20</option>
180 <option value="50"><xsl:if test="$hits=50"><xsl:attribute name="selected"></xsl:attribute></xsl:if>50</option>
181 <option value="-1"><xsl:if test="$hits=-1"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.all')"/></option>
182 </select></xsl:variable>
183 <tr><td colspan='3'><xsl:value-of select="util:getInterfaceTextWithDOM($interface_name, /page/@lang, 'pref.hits', $maxdocs_param, $hits_param)" disable-output-escaping="yes"/></td></tr>
184 </xsl:if>
185 </xsl:template>
186
187 <xsl:template name="advanced-search-prefs">
188 <xsl:param name="display">n</xsl:param>
189 <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>
190 <tr id="adv-qnb"><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if>
191 <td colspan='2'><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.num_fields')"/></td><td><select name="qfn">
192 <option value="2"><xsl:if test="$numbox=2"><xsl:attribute name="selected"></xsl:attribute></xsl:if>2</option>
193 <option value="4"><xsl:if test="$numbox=4"><xsl:attribute name="selected"></xsl:attribute></xsl:if>4</option>
194 <option value="6"><xsl:if test="$numbox=6"><xsl:attribute name="selected"></xsl:attribute></xsl:if>6</option>
195 <option value="8"><xsl:if test="$numbox=8"><xsl:attribute name="selected"></xsl:attribute></xsl:if>8</option>
196 </select></td><td/></tr>
197 </xsl:template>
198
199 <xsl:template name="text-search-prefs">
200 <xsl:param name="display">n</xsl:param>
201 <!-- query mode : 0(default, simple); 1(advanced, boolean)-->
202 <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>
203 <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><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.query_mode_simple')"/></td></tr>
204 <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><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.query_mode_adv')"/></td></tr>
205
206 <!-- query box size -->
207 <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>
208 <tr id="text-qb1"><xsl:if test="$display='n'"><xsl:attribute name="style">display:none</xsl:attribute></xsl:if><td rowspan='2' valign='baseline'><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.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><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.query_box_size_reg')"/></td></tr>
209 <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><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.query_box_size_large')"/></td></tr>
210 </xsl:template>
211
212
213 <xsl:template match="service">
214 <xsl:param name="display">n</xsl:param>
215 <xsl:param name="prefix"/>
216 <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>
217 </xsl:template>
218
219 <xsl:template match="param">
220 <xsl:param name="ns">s1.</xsl:param>
221 <xsl:param name="display">n</xsl:param>
222 <xsl:param name="prefix"/>
223
224 <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>
225 </xsl:template>
226
227 <xsl:template match="param" mode="radio">
228 <xsl:param name="ns">s1.</xsl:param>
229 <xsl:param name="display">n</xsl:param>
230 <xsl:param name="prefix"/>
231 <xsl:param name="paramIdx"/>
232
233 <xsl:variable name="cachedName" select="concat($ns, @name)"/>
234 <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>
235 <!-- number of options, for rowspan attribute -->
236 <xsl:variable name="numOptions" select="count(option)"/>
237 <xsl:variable name="displayName"><xsl:value-of select="displayItem"/></xsl:variable>
238 <xsl:variable name="paramName"><xsl:value-of select="@name"/></xsl:variable>
239
240 <xsl:for-each select="option">
241 <xsl:variable name="value" select="@name"/>
242 <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>
243 <xsl:if test="position()=1"><td rowspan='{$numOptions}' valign='baseline'><xsl:value-of select="../displayItem"/></td></xsl:if>
244 <td><input type='radio' name='{$cachedName}' value="{$value}"><xsl:if test="$cachedValue=$value"><xsl:attribute name="checked">true</xsl:attribute></xsl:if></input></td>
245 <td><xsl:value-of select="displayItem"/></td>
246 </tr>
247 </xsl:for-each>
248 </xsl:template>
249
250</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.