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

Last change on this file since 16862 was 16862, checked in by kjdon, 16 years ago

fix up paths for the change from classic to gs2

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