source: main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl@ 25704

Last change on this file since 25704 was 25686, checked in by sjm84, 12 years ago

The correct browse tab will now be shown if the a sub-classifier is being viewed

  • Property svn:executable set to *
File size: 19.2 KB
Line 
1<xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:java="http://xml.apache.org/xslt/java"
4 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
5 xmlns:gslib="http://www.greenstone.org/skinning"
6 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
7 extension-element-prefixes="java util"
8 exclude-result-prefixes="java util gsf">
9
10 <xsl:include href="../query-common.xsl"/>
11 <xsl:include href="../javascript-global-setup.xsl"/>
12
13 <!-- If the c parameter is empty then use the p.c parameter for the collection name-->
14 <xsl:variable name="collNameChecked">
15 <xsl:choose>
16 <xsl:when test="$collName = '' and /page/pageRequest/paramList/param[@name='p.c']/@value">
17 <xsl:value-of select="/page/pageRequest/paramList/param[@name='p.c']/@value"/>
18 </xsl:when>
19 <xsl:otherwise>
20 <xsl:value-of select="$collName"/>
21 </xsl:otherwise>
22 </xsl:choose>
23 </xsl:variable>
24
25 <!-- Creates a header for the html page -->
26 <xsl:template name="create-html-header">
27 <base>
28 <xsl:attribute name="href">
29 <xsl:choose>
30 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'baseURL']">
31 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'baseURL']"/>
32 </xsl:when>
33 <xsl:when test="/page/pageRequest/@baseURL">
34 <xsl:value-of select="/page/pageRequest/@baseURL"/>
35 </xsl:when>
36 </xsl:choose>
37 </xsl:attribute>
38 </base>
39 <xsl:comment>[if lte IE 6]&gt;&lt;/base&gt;&lt;![endif]</xsl:comment>
40
41 <title><xsl:call-template name="pageTitle"/> :: <xsl:call-template name="siteName"/></title>
42
43 <xsl:choose>
44 <xsl:when test="/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value">
45 <!-- Get the theme from the interfaceConfig.xml file -->
46 <link rel="stylesheet" href="{/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value}" type="text/css"/>
47 </xsl:when>
48 <xsl:otherwise>
49 <link rel="stylesheet" href="interfaces/{$interface_name}/style/themes/main/jquery-ui-1.8.16.custom.css" type="text/css"/>
50 </xsl:otherwise>
51 </xsl:choose>
52 <link rel="stylesheet" href="interfaces/{$interface_name}/style/core.css" type="text/css"/>
53 <link rel="shortcut icon" href="favicon.ico"/>
54
55 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"><xsl:text> </xsl:text></script>
56 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"><xsl:text> </xsl:text></script>
57 <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery.themeswitcher.min.js"><xsl:text> </xsl:text></script>
58
59 <script type="text/javascript" src="interfaces/{$interface_name}/js/direct-edit.js"><xsl:text> </xsl:text></script>
60 <script type="text/javascript" src="interfaces/{$interface_name}/js/zoomer.js"><xsl:text> </xsl:text></script>
61
62 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
63 <xsl:call-template name="map-scripts"/>
64 </xsl:if>
65
66 <xsl:if test="/page/pageRequest/userInformation and (util:contains(/page/pageRequest/userInformation/@groups, 'administrator') or util:contains(/page/pageRequest/userInformation/@groups, 'all-collections-editor') or util:contains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))">
67 <xsl:call-template name="init-direct-edit"/>
68 </xsl:if>
69 <xsl:call-template name="setup-gs-variable"/>
70 <xsl:call-template name="additionalHeaderContent"/>
71 </xsl:template>
72
73 <xsl:template name="additionalHeaderContent">
74 <!-- This template should be overridden in the collectionConfig.xml file if you want to add extra header content -->
75 </xsl:template>
76
77 <xsl:template name="init-direct-edit">
78 <script type="text/javascript">
79 <xsl:text disable-output-escaping="yes">
80 de.onready(function()
81 {
82 try
83 {
84 de.init();
85 }
86 catch (err)
87 {
88 alert("Seaweed failed to initialise: " + err.message);
89 }
90 });
91 </xsl:text>
92 </script>
93 </xsl:template>
94
95 <!-- ***** HEADER LAYOUT TEMPLATE ***** -->
96 <xsl:template name="create-banner">
97 <div id="gs_banner" class="ui-widget-header ui-corner-bottom">
98 <table id="titlesearchcontainer">
99 <tr>
100 <xsl:call-template name="page-title-area"/>
101 <xsl:call-template name="quick-search-area"/>
102 </tr>
103 </table>
104 <xsl:call-template name="browsing-tabs"/>
105 </div>
106 </xsl:template>
107
108 <!-- ***** BROWSING TABS ***** -->
109 <xsl:template name="browsing-tabs">
110 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service">
111 <ul id="nav">
112 <!-- If this collection has a ClassifierBrowse service then add a tab for each classifier-->
113 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='browse' and @name='ClassifierBrowse']">
114 <!-- Loop through each classifier -->
115 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
116 <li>
117 <xsl:choose>
118 <!-- If this tab is selected then colour it differently -->
119 <xsl:when test="util:contains(/page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value, @name)">
120 <xsl:attribute name='class'>ui-state-default ui-corner-top ui-tabs-selected ui-state-active</xsl:attribute>
121 </xsl:when>
122 <xsl:otherwise>
123 <xsl:attribute name='class'>ui-state-default ui-corner-top</xsl:attribute>
124 </xsl:otherwise>
125 </xsl:choose>
126
127 <a>
128 <!-- Add a title element to the <a> tag if a description exists for this classifier -->
129 <xsl:if test="displayItem[@name='description']">
130 <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
131 </xsl:if>
132
133 <!-- Add the href element to the <a> tag -->
134 <xsl:choose>
135 <xsl:when test="@name">
136 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/<xsl:value-of select="@name"/></xsl:attribute>
137 </xsl:when>
138 <xsl:otherwise>
139 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/1</xsl:attribute>
140 </xsl:otherwise>
141 </xsl:choose>
142
143 <!-- Add the actual text of the <a> tag -->
144 <xsl:value-of select="displayItem[@name='name']"/>
145 </a>
146 </li>
147 </xsl:for-each>
148 </xsl:if>
149
150 <!-- all other services -->
151 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[not(@type='query') and not(@type='browse')]">
152 <xsl:call-template name="navigationTab"/>
153 </xsl:for-each>
154 </ul>
155 </xsl:if>
156 </xsl:template>
157
158 <!-- ***** HOME HELP PREFERENCES LOGIN ***** -->
159 <xsl:template name="home-help-preferences">
160 <ul id="bannerLinks">
161 <!-- preferences -->
162 <li class="ui-state-default ui-corner-all">
163 <a href="{$library_name}/collection/{$collNameChecked}/page/pref">
164 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/></xsl:attribute>
165 <ul>
166 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/></span></li>
167 <li><span class="ui-icon ui-icon-wrench"><xsl:text> </xsl:text></span></li>
168 </ul>
169 </a>
170 </li>
171
172 <!-- help -->
173 <li class="ui-state-default ui-corner-all">
174 <a href="{$library_name}/collection/{$collNameChecked}/page/help">
175 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_tip')"/></xsl:attribute>
176 <ul>
177 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/></span></li>
178 <li><span class="ui-icon ui-icon-help"><xsl:text> </xsl:text></span></li>
179 </ul>
180 </a>
181 </li>
182
183 <!-- login/logout -->
184 <li class="ui-state-default ui-corner-all" id="userMenuButton">
185 <xsl:choose>
186 <xsl:when test="/page/pageRequest/userInformation/@username">
187 <a>
188 <xsl:attribute name="href">javascript:toggleUserMenu();</xsl:attribute>
189 <script type="text/javascript">
190 <xsl:text disable-output-escaping="yes">
191 function toggleUserMenu()
192 {
193 var button = $("#userMenuButton");
194 var menu;
195
196 if(button.data("userMenu"))
197 {
198 menu = button.data("userMenu");
199 if(menu.css("display") == "block")
200 {
201 menu.hide();
202 }
203 else
204 {
205 menu.show();
206 }
207 }
208 else
209 {
210 menu = $("&lt;UL&gt;")
211 .css("position", "absolute")
212 .css("display", "block")
213 .css("z-index", "100")
214 .css("list-style", "none outside none")
215 .css("margin-left", "0px")
216 .css("padding", "0px")
217 .css("font-size", "90%");
218
219 button.data("userMenu", menu);
220
221 var settingsLink = $("&lt;a&gt;")
222 .attr("href", gs.xsltParams.library_name + "/admin/AccountSettings?s1.username=</xsl:text><xsl:value-of select="/page/pageRequest/userInformation/@username"/><xsl:text disable-output-escaping="yes">");
223 var settingsButton = $("&lt;LI&gt;")
224 .css("padding", "3px")
225 .html("Account settings")
226 .addClass("ui-state-default");
227 settingsLink.append(settingsButton);
228
229 var url = document.URL;
230 var hasQueryString = (url.indexOf("?") != -1);
231 var hashIndex = url.indexOf("#");
232
233 var hashPart;
234 if(hashIndex != -1)
235 {
236 hashPart = url.substring(hashIndex);
237 url = url.substring(0, hashIndex);
238 }
239
240 var logoutLink = $("&lt;a&gt;")
241 .attr("href", url + (hasQueryString ? "&amp;" : "?") + "logout=" + (hashPart ? hashPart : ""));
242 var logoutButton = $("&lt;LI&gt;")
243 .css("padding", "3px")
244 .html("Logout")
245 .addClass("ui-state-default");
246 logoutLink.append(logoutButton);
247
248 menu.append(settingsLink);
249 menu.append(logoutLink);
250
251 var buttonLeft = button.offset().left;
252 var buttonTop = button.offset().top;
253 var buttonHeight = button.height();
254
255 menu.offset({top: buttonTop + buttonHeight + 4, left: buttonLeft});
256 $("#topArea").append(menu);
257 }
258 }
259 </xsl:text>
260 </script>
261 <ul>
262 <li><span><xsl:value-of select="/page/pageRequest/userInformation/@username"/></span></li>
263 <li><span class="ui-icon ui-icon-unlocked"><xsl:text> </xsl:text></span></li>
264 </ul>
265 </a>
266 </xsl:when>
267 <xsl:otherwise>
268 <a>
269 <xsl:attribute name="href">
270 <xsl:value-of select="$library_name"/>
271 <xsl:text>?a=p&amp;sa=login&amp;redirectURL=</xsl:text>
272 <xsl:value-of select="$library_name"/>
273 <xsl:text>%3F</xsl:text>
274 <xsl:if test="/page/pageRequest/@action">
275 <xsl:text>a=</xsl:text>
276 <xsl:value-of select="/page/pageRequest/@action"/>
277 </xsl:if>
278 <xsl:if test="/page/pageRequest/@subaction">
279 <xsl:text>%26sa=</xsl:text>
280 <xsl:value-of select="/page/pageRequest/@subaction"/>
281 </xsl:if>
282 <xsl:for-each select="/page/pageRequest/paramList/param">
283 <xsl:if test="@name != 'password' and @name != 's1.password' and @name != 's1.newPassword' and @name != 's1.oldPassword'">
284 <xsl:text>%26</xsl:text>
285 <xsl:value-of select="@name"/>
286 <xsl:text>=</xsl:text>
287 <xsl:value-of select="@value"/>
288 </xsl:if>
289 </xsl:for-each>
290 </xsl:attribute>
291 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_tip')"/></xsl:attribute>
292 <ul>
293 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_b')"/></span></li>
294 <li><span class="ui-icon ui-icon-locked"><xsl:text> </xsl:text></span></li>
295 </ul>
296 </a>
297 </xsl:otherwise>
298 </xsl:choose>
299 </li>
300 <!-- debuginfo (doesn't use class="ui-state-error" since the text is not legible due to inherited text-colour) -->
301 <xsl:if test="/page/pageRequest/paramList/param[(@name='debug') and (@value='on' or @value='true' or @value='1')]">
302 <li class="ui-state-default ui-corner-all">
303 <a href="{$library_name}/collection/{$collNameChecked}/page/debuginfo">
304 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'debuginfo_tip')"/></xsl:attribute>
305 <ul>
306 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'debuginfo_b')"/></span></li>
307 <li><span class="ui-icon ui-icon-info"><xsl:text> </xsl:text></span></li>
308 </ul>
309 </a>
310 </li>
311 </xsl:if>
312 </ul>
313 </xsl:template>
314
315 <!-- ***** PAGE TITLE ***** -->
316 <xsl:template name="page-title-area">
317 <xsl:variable name="pageTitleVar"><xsl:call-template name="pageTitle"/></xsl:variable>
318 <td id="titlearea">
319 <h2>
320 <!-- Resize the title based on how long it is (There's probably a better way to do this) -->
321 <xsl:attribute name="style">
322 <xsl:choose>
323 <xsl:when test="string-length($pageTitleVar) &lt; 20">
324 <xsl:text>font-size: 1.5em;</xsl:text>
325 </xsl:when>
326 <xsl:when test="string-length($pageTitleVar) &lt; 30">
327 <xsl:text>font-size: 1.4em;</xsl:text>
328 </xsl:when>
329 <xsl:when test="string-length($pageTitleVar) &lt; 40">
330 <xsl:text>font-size: 1.3em;</xsl:text>
331 </xsl:when>
332 <xsl:when test="string-length($pageTitleVar) &lt; 50">
333 <xsl:text>font-size: 1.2em;</xsl:text>
334 </xsl:when>
335 <xsl:when test="string-length($pageTitleVar) &lt; 60">
336 <xsl:text>font-size: 1.1em;</xsl:text>
337 </xsl:when>
338 <xsl:when test="string-length($pageTitleVar) &lt; 70">
339 <xsl:text>font-size: 1em;</xsl:text>
340 </xsl:when>
341 <xsl:when test="string-length($pageTitleVar) &lt; 80">
342 <xsl:text>font-size: 0.9em;</xsl:text>
343 </xsl:when>
344 <xsl:when test="string-length($pageTitleVar) &lt; 90">
345 <xsl:text>font-size: 0.8em;</xsl:text>
346 </xsl:when>
347 <xsl:otherwise>
348 <xsl:text>font-size: 0.7em;</xsl:text>
349 </xsl:otherwise>
350 </xsl:choose>
351 </xsl:attribute>
352 <!--<xsl:value-of select="string-length($pageTitleVar)" />-->
353 <xsl:value-of select="$pageTitleVar" />
354 </h2>
355 </td>
356 </xsl:template>
357
358 <!-- ***** QUICK SEARCH AREA ***** -->
359 <xsl:template name="quick-search-area">
360 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
361 <xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
362 <td id="quicksearcharea">
363 <form action="{$library_name}/collection/{$collNameChecked}/search/TextQuery">
364 <input type="hidden" name="rt" value="rd"/>
365 <input type="hidden" name="s1.level">
366 <xsl:attribute name="value">
367 <xsl:choose>
368 <xsl:when test="/page/pageRequest/paramList/param[@name = 's1.level']">
369 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.level']/@value"/>
370 </xsl:when>
371 <xsl:otherwise>
372 <xsl:text>Sec</xsl:text>
373 </xsl:otherwise>
374 </xsl:choose>
375 </xsl:attribute>
376 </input>
377 <xsl:choose>
378 <xsl:when test="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'startPage']">
379 <input type="hidden" name="s1.startPage" value="1"/>
380 </xsl:when>
381 <xsl:otherwise>
382 <input type="hidden" name="startPage" value="1"/>
383 </xsl:otherwise>
384 </xsl:choose>
385 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.hitsPerPage'])">
386 <input type="hidden" name="s1.hitsPerPage" value="20"/>
387 </xsl:if>
388 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.maxDocs'])">
389 <input type="hidden" name="s1.maxDocs" value="100"/>
390 </xsl:if>
391 <!-- The query text box -->
392 <span class="querybox">
393 <xsl:variable name="qs">
394 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
395 </xsl:variable>
396 <nobr>
397 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
398 <xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs)"/>
399 </xsl:apply-templates>
400 </nobr>
401 </span>
402 <!-- The index selection list -->
403 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']/@type = 'enum_single'">
404 <span class="textselect">
405 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']">
406 <xsl:with-param name="default">
407 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']" mode="calculate-default"/>
408 </xsl:with-param>
409 </xsl:apply-templates>
410 </span>
411 </xsl:if>
412 <!-- The submit button -->
413 <input type="submit" id="quickSearchSubmitButton">
414 <xsl:attribute name="value">
415 <xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/displayItem[@name='submit']"/>
416 </xsl:attribute>
417 </input>
418 <br/>
419 <!-- The list of other search types -->
420 <ul>
421 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
422 <li class="ui-state-default ui-corner-all">
423 <a>
424 <xsl:attribute name="href">
425 <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collNameChecked"/>/search/<xsl:value-of select="@name"/>
426 </xsl:attribute>
427 <xsl:value-of select="displayItem[@name='name']"/>
428 </a>
429 </li>
430 </xsl:for-each>
431 </ul>
432 </form>
433 </td>
434 </xsl:if>
435 </xsl:template>
436
437 <xsl:template name="map-scripts">
438 <meta content="initial-scale=1.0, user-scalable=no" name="viewport"/>
439 <script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"><xsl:text> </xsl:text></script>
440 <script src="interfaces/{$interface_name}/js/map-scripts.js" type="text/javascript"><xsl:text> </xsl:text></script>
441 <script type="text/javascript">$(window).load(initializeMapScripts);</script>
442 </xsl:template>
443</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.