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

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

Increased the height of the browsing tabs

  • Property svn:executable set to *
File size: 21.4 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 = 'siteURL']">
31 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'siteURL']"/>
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="interfaces/{$interface_name}/images/favicon.ico"/>
54
55 <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery.min.js"><xsl:text> </xsl:text></script>
56 <script type="text/javascript" src="interfaces/{$interface_name}/js/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 <div id="titlesearchcontainer">
99 <xsl:call-template name="page-title-area"/>
100 <xsl:call-template name="quick-search-area"/>
101 <div style="clear:both;"><xsl:text> </xsl:text></div>
102 </div>
103 <xsl:call-template name="browsing-tabs"/>
104 </div>
105 </xsl:template>
106
107 <!-- ***** BROWSING TABS ***** -->
108 <xsl:template name="browsing-tabs">
109 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service">
110 <ul id="gs-nav">
111 <!-- If this collection has a ClassifierBrowse service then add a tab for each classifier-->
112 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='browse' and @name='ClassifierBrowse']">
113 <!-- Loop through each classifier -->
114 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
115 <li>
116 <xsl:choose>
117 <!-- If this tab is selected then colour it differently -->
118 <xsl:when test="util:contains(/page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value, @name)">
119 <xsl:attribute name='class'>ui-state-default ui-corner-top ui-tabs-selected ui-state-active</xsl:attribute>
120 </xsl:when>
121 <xsl:otherwise>
122 <xsl:attribute name='class'>ui-state-default ui-corner-top</xsl:attribute>
123 </xsl:otherwise>
124 </xsl:choose>
125
126 <a>
127 <!-- Add a title element to the <a> tag if a description exists for this classifier -->
128 <xsl:if test="displayItem[@name='description']">
129 <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
130 </xsl:if>
131
132 <!-- Add the href element to the <a> tag -->
133 <xsl:choose>
134 <xsl:when test="@name">
135 <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>
136 </xsl:when>
137 <xsl:otherwise>
138 <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>
139 </xsl:otherwise>
140 </xsl:choose>
141
142 <!-- Add the actual text of the <a> tag -->
143 <xsl:value-of select="displayItem[@name='name']"/>
144 </a>
145 </li>
146 </xsl:for-each>
147 </xsl:if>
148
149 <!-- PhindApplet. Need something similar for the Collage applet too, probably -->
150 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='PhindApplet']">
151 <li>
152 <xsl:choose>
153 <!-- If this tab is selected then colour it differently -->
154 <xsl:when test="/page/pageRequest[@action='a']">
155 <xsl:attribute name='class'>ui-state-default ui-corner-top ui-tabs-selected ui-state-active</xsl:attribute>
156 </xsl:when>
157 <xsl:otherwise>
158 <xsl:attribute name='class'>ui-state-default ui-corner-top</xsl:attribute>
159 </xsl:otherwise>
160 </xsl:choose>
161
162 <a>
163 <xsl:if test="displayItem[@name='description']">
164 <xsl:attribute name="title">
165 <xsl:value-of select="displayItem[@name='description']"/>
166 </xsl:attribute>
167 </xsl:if>
168 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=a&amp;rt=d&amp;s=<xsl:value-of select="@name"/>&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:attribute>
169 <xsl:value-of select="displayItem[@name='name']"/>
170 </a>
171 </li>
172 </xsl:for-each>
173
174 <!-- all other services -->
175 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[not(@type='query') and not(@type='browse') and not (@name='PhindApplet')]">
176 <xsl:call-template name="navigationTab"/>
177 </xsl:for-each>
178 </ul>
179 <div style="clear:both;"><xsl:text> </xsl:text></div>
180 </xsl:if>
181 </xsl:template>
182
183 <!-- ***** HOME HELP PREFERENCES LOGIN ***** -->
184 <xsl:template name="home-help-preferences">
185 <ul id="bannerLinks">
186 <!-- preferences -->
187 <li class="ui-state-default ui-corner-all">
188 <a href="{$library_name}/collection/{$collNameChecked}/page/pref">
189 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/></xsl:attribute>
190 <ul>
191 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/></span></li>
192 <li><span class="ui-icon ui-icon-wrench"><xsl:text> </xsl:text></span></li>
193 </ul>
194 </a>
195 </li>
196
197 <!-- help -->
198 <li class="ui-state-default ui-corner-all">
199 <a href="{$library_name}/collection/{$collNameChecked}/page/help">
200 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_tip')"/></xsl:attribute>
201 <ul>
202 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/></span></li>
203 <li><span class="ui-icon ui-icon-help"><xsl:text> </xsl:text></span></li>
204 </ul>
205 </a>
206 </li>
207
208 <!-- login/logout -->
209 <li class="ui-state-default ui-corner-all" id="userMenuButton">
210 <xsl:choose>
211 <xsl:when test="/page/pageRequest/userInformation/@username">
212 <a>
213 <xsl:attribute name="href">javascript:toggleUserMenu();</xsl:attribute>
214 <script type="text/javascript">
215 <xsl:text disable-output-escaping="yes">
216 function toggleUserMenu()
217 {
218 var button = $("#userMenuButton");
219 var menu;
220
221 if(button.data("userMenu"))
222 {
223 menu = button.data("userMenu");
224 if(menu.css("display") == "block")
225 {
226 menu.hide();
227 }
228 else
229 {
230 menu.show();
231 }
232 }
233 else
234 {
235 menu = $("&lt;UL&gt;")
236 .css("position", "absolute")
237 .css("display", "block")
238 .css("z-index", "100")
239 .css("list-style", "none outside none")
240 .css("margin-left", "0px")
241 .css("padding", "0px")
242 .css("font-size", "90%");
243
244 menu.attr("id", "userMenu");
245
246 button.data("userMenu", menu);
247
248 var settingsLink = $("&lt;a&gt;")
249 .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">");
250 var settingsButton = $("&lt;LI&gt;")
251 .css("padding", "3px")
252 .html("Account settings")
253 .addClass("ui-state-default");
254 settingsLink.append(settingsButton);
255
256 var url = document.URL;
257 var hasQueryString = (url.indexOf("?") != -1);
258 var hashIndex = url.indexOf("#");
259
260 var hashPart;
261 if(hashIndex != -1)
262 {
263 hashPart = url.substring(hashIndex);
264 url = url.substring(0, hashIndex);
265 }
266
267 var logoutLink = $("&lt;a&gt;")
268 .attr("href", url + (hasQueryString ? "&amp;" : "?") + "logout=" + (hashPart ? hashPart : ""));
269 var logoutButton = $("&lt;LI&gt;")
270 .css("padding", "3px")
271 .html("Logout")
272 .addClass("ui-state-default");
273 logoutLink.append(logoutButton);
274
275 menu.append(settingsLink);
276 menu.append(logoutLink);
277
278 var buttonLeft = button.offset().left;
279 var buttonTop = button.offset().top;
280 var buttonHeight = button.height();
281
282 menu.offset({top: buttonTop + buttonHeight + 4, left: buttonLeft});
283 $("#topArea").append(menu);
284 }
285 }
286 </xsl:text>
287 </script>
288 <ul>
289 <li><span><xsl:value-of select="/page/pageRequest/userInformation/@username"/></span></li>
290 <li><span class="ui-icon ui-icon-unlocked"><xsl:text> </xsl:text></span></li>
291 </ul>
292 </a>
293 </xsl:when>
294 <xsl:otherwise>
295 <a>
296 <xsl:attribute name="href">
297 <xsl:value-of select="$library_name"/>
298 <xsl:text>?a=p&amp;sa=login&amp;redirectURL=</xsl:text>
299 <xsl:value-of select="$library_name"/>
300 <xsl:text>%3F</xsl:text>
301 <xsl:if test="/page/pageRequest/@action">
302 <xsl:text>a=</xsl:text>
303 <xsl:value-of select="/page/pageRequest/@action"/>
304 </xsl:if>
305 <xsl:if test="/page/pageRequest/@subaction">
306 <xsl:text>%26sa=</xsl:text>
307 <xsl:value-of select="/page/pageRequest/@subaction"/>
308 </xsl:if>
309 <xsl:for-each select="/page/pageRequest/paramList/param">
310 <xsl:if test="@name != 'password' and @name != 's1.password' and @name != 's1.newPassword' and @name != 's1.oldPassword'">
311 <xsl:text>%26</xsl:text>
312 <xsl:value-of select="@name"/>
313 <xsl:text>=</xsl:text>
314 <xsl:value-of select="@value"/>
315 </xsl:if>
316 </xsl:for-each>
317 </xsl:attribute>
318 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_tip')"/></xsl:attribute>
319 <ul>
320 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_b')"/></span></li>
321 <li><span class="ui-icon ui-icon-locked"><xsl:text> </xsl:text></span></li>
322 </ul>
323 </a>
324 </xsl:otherwise>
325 </xsl:choose>
326 </li>
327 <!-- debuginfo (doesn't use class="ui-state-error" since the text is not legible due to inherited text-colour) -->
328 <xsl:if test="/page/pageRequest/paramList/param[(@name='debug') and (@value='on' or @value='true' or @value='1')]">
329 <li class="ui-state-default ui-corner-all">
330 <a href="{$library_name}/collection/{$collNameChecked}/page/debug">
331 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'debuginfo_tip')"/></xsl:attribute>
332 <ul>
333 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'debuginfo_b')"/></span></li>
334 <li><span class="ui-icon ui-icon-info"><xsl:text> </xsl:text></span></li>
335 </ul>
336 </a>
337 </li>
338 </xsl:if>
339 </ul>
340 </xsl:template>
341
342 <!-- ***** PAGE TITLE ***** -->
343 <xsl:template name="page-title-area">
344 <xsl:variable name="pageTitleVar"><xsl:call-template name="pageTitle"/></xsl:variable>
345 <div id="titlearea">
346 <h2>
347 <!-- Resize the title based on how long it is (There's probably a better way to do this) -->
348 <xsl:attribute name="style">
349 <xsl:choose>
350 <xsl:when test="string-length($pageTitleVar) &lt; 20">
351 <xsl:text>font-size: 1.5em;</xsl:text>
352 </xsl:when>
353 <xsl:when test="string-length($pageTitleVar) &lt; 30">
354 <xsl:text>font-size: 1.4em;</xsl:text>
355 </xsl:when>
356 <xsl:when test="string-length($pageTitleVar) &lt; 40">
357 <xsl:text>font-size: 1.3em;</xsl:text>
358 </xsl:when>
359 <xsl:when test="string-length($pageTitleVar) &lt; 50">
360 <xsl:text>font-size: 1.2em;</xsl:text>
361 </xsl:when>
362 <xsl:when test="string-length($pageTitleVar) &lt; 60">
363 <xsl:text>font-size: 1.1em;</xsl:text>
364 </xsl:when>
365 <xsl:when test="string-length($pageTitleVar) &lt; 70">
366 <xsl:text>font-size: 1em;</xsl:text>
367 </xsl:when>
368 <xsl:when test="string-length($pageTitleVar) &lt; 80">
369 <xsl:text>font-size: 0.9em;</xsl:text>
370 </xsl:when>
371 <xsl:when test="string-length($pageTitleVar) &lt; 90">
372 <xsl:text>font-size: 0.8em;</xsl:text>
373 </xsl:when>
374 <xsl:otherwise>
375 <xsl:text>font-size: 0.7em;</xsl:text>
376 </xsl:otherwise>
377 </xsl:choose>
378 </xsl:attribute>
379 <!--<xsl:value-of select="string-length($pageTitleVar)" />-->
380 <xsl:value-of select="$pageTitleVar" />
381 </h2><xsl:text> </xsl:text>
382 </div>
383 </xsl:template>
384
385 <!-- ***** QUICK SEARCH AREA ***** -->
386 <!-- Search form should only appear if there's a search (query) service AND it has an index.
387 By default, all collections end up with some query service (default is MGPP) even when they have
388 no search indexes, which is why the extra test for the presence of an index/fq-something is necessary. -->
389 <xsl:template name="quick-search-area">
390 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
391 <xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
392 <div id="quicksearcharea">
393 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
394 <form action="{$library_name}/collection/{$collNameChecked}/search/TextQuery">
395 <!-- This parameter says that we have come from the quick search area -->
396 <input type="hidden" name="qs" value="1"/>
397 <input type="hidden" name="rt" value="rd"/>
398 <input type="hidden" name="s1.level">
399 <xsl:attribute name="value">
400 <xsl:choose>
401 <xsl:when test="/page/pageRequest/paramList/param[@name = 's1.level']">
402 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 's1.level']/@value"/>
403 </xsl:when>
404 <xsl:otherwise>
405 <xsl:text>Sec</xsl:text>
406 </xsl:otherwise>
407 </xsl:choose>
408 </xsl:attribute>
409 </input>
410 <xsl:choose>
411 <xsl:when test="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'startPage']">
412 <input type="hidden" name="s1.startPage" value="1"/>
413 </xsl:when>
414 <xsl:otherwise>
415 <input type="hidden" name="startPage" value="1"/>
416 </xsl:otherwise>
417 </xsl:choose>
418 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.hitsPerPage'])">
419 <input type="hidden" name="s1.hitsPerPage" value="20"/>
420 </xsl:if>
421 <xsl:if test="not(/page/pageRequest/paramList/param[@name = 's1.maxDocs'])">
422 <input type="hidden" name="s1.maxDocs" value="100"/>
423 </xsl:if>
424 <!-- The query text box -->
425 <span class="querybox">
426 <xsl:variable name="qs">
427 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
428 </xsl:variable>
429 <nobr>
430 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
431 <xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs, /page/@lang)"/>
432 </xsl:apply-templates>
433 </nobr>
434 </span>
435 <!-- The index selection list -->
436 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']/@type = 'enum_single'">
437 <span class="textselect">
438 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']">
439 <xsl:with-param name="default">
440 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']" mode="calculate-default"/>
441 </xsl:with-param>
442 <xsl:with-param name="hideSingle">true</xsl:with-param>
443 </xsl:apply-templates>
444 </span>
445 </xsl:if>
446 <!-- The submit button (for TextQuery) -->
447 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
448 <input type="submit" id="quickSearchSubmitButton">
449 <xsl:attribute name="value">
450 <xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/displayItem[@name='submit']"/>
451 </xsl:attribute>
452 </input>
453 <br/>
454 </xsl:if>
455 </form>
456 </xsl:if>
457 <!-- The list of other search types -->
458 <ul>
459 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
460 <li class="ui-state-default ui-corner-all">
461 <a>
462 <xsl:attribute name="href">
463 <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collNameChecked"/>/search/<xsl:value-of select="@name"/>
464 </xsl:attribute>
465 <xsl:value-of select="displayItem[@name='name']"/>
466 </a>
467 </li>
468 </xsl:for-each>
469 </ul>
470 </div>
471 </xsl:if>
472 </xsl:template>
473
474 <xsl:template name="map-scripts">
475 <meta content="initial-scale=1.0, user-scalable=no" name="viewport"/>
476 <script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"><xsl:text> </xsl:text></script>
477 <script src="interfaces/{$interface_name}/js/map-scripts.js" type="text/javascript"><xsl:text> </xsl:text></script>
478 <script type="text/javascript">$(window).load(initializeMapScripts);</script>
479 </xsl:template>
480</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.