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

Last change on this file since 26461 was 26461, checked in by sjm84, 11 years ago

Phase two of commiting the improved debugging system

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