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

Last change on this file since 32468 was 32468, checked in by kjdon, 2 years ago

finetuning when the ednable/disable edit mode option appears in the user menu. If editing has been enabled for the collection, but is unavailable for the user, now we'll show an 'editing unavailable...' option, clicking on it shows a popup

  • Property svn:executable set to *
File size: 37.1 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="../shared-templates.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 <!-- does this collection have editing turned on -->
27 <xsl:variable name="isEditingTurnedOn">
28 <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='AllowDocumentEditing']/@value='true'">1</xsl:if>
29 </xsl:variable>
30 <!-- is editing available for the collection? eg is there an archives folder? -->
31 <xsl:variable name="isEditingAvailable">1</xsl:variable>
32 <!-- is a user logged in, and do they have editing rights for this collection? -->
33 <xsl:variable name="userHasEditPermission">
34 <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:groupsContains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))">1</xsl:if>
35 </xsl:variable>
36 <xsl:variable name="siteAdmin">
37 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'siteAdmin']"/>
38 </xsl:variable>
39 <!-- Creates a header for the html page -->
40 <xsl:template name="create-html-header">
41 <base>
42 <xsl:attribute name="href">
43 <xsl:choose>
44 <xsl:when test="/page/pageResponse/metadataList/metadata[@name = 'siteURL']">
45 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'siteURL']"/>
46 </xsl:when>
47 <xsl:when test="/page/pageRequest/@baseURL">
48 <xsl:value-of select="/page/pageRequest/@baseURL"/>
49 </xsl:when>
50 </xsl:choose>
51 </xsl:attribute>
52 </base>
53 <xsl:comment>[if lte IE 6]&gt;&lt;/base&gt;&lt;![endif]</xsl:comment>
54
55 <xsl:variable name="page"><xsl:call-template name="pageTitle"/></xsl:variable>
56 <xsl:variable name="collection"><xsl:call-template name="collectionName"/></xsl:variable>
57 <xsl:variable name="site"><xsl:call-template name="siteName"/></xsl:variable>
58 <title><xsl:value-of select="$page"/><xsl:if test="$collection != '' and $page != $collection"> :: <xsl:value-of select="$collection"/></xsl:if><xsl:if test="$page != $site"> :: <xsl:value-of select="$site"/></xsl:if></title>
59
60 <xsl:if test="/page/pageRequest/@action ='d'">
61
62 <xsl:variable name="myMetadataHeader" select="/page/pageResponse/format/gsf:headMetaTags/gsf:metadata"/>
63 <xsl:for-each select="$myMetadataHeader">
64 <xsl:variable name="metaname" select="@name"/>
65
66 <xsl:variable name="metavals"
67 select="/page/pageResponse/document/metadataList/metadata[@name = $metaname]|/page/pageResponse/document/documentNode/metadataList/metadata[@name = $metaname]"/>
68 <xsl:for-each select="$metavals">
69 <META NAME="{$metaname}" CONTENT="{.}"/>
70 </xsl:for-each>
71 </xsl:for-each>
72
73 </xsl:if>
74
75 <!-- <xsl:call-template name="addGoogleTracking"/>-->
76 <xsl:choose>
77 <xsl:when test="/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value">
78 <!-- Get the theme from the interfaceConfig.xml file -->
79 <link rel="stylesheet" href="{/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value}" type="text/css"/>
80 </xsl:when>
81 <xsl:otherwise>
82 <link rel="stylesheet" href="interfaces/{$interface_name}/style/themes/main/jquery-ui-1.8.16.custom.css" type="text/css"/>
83 </xsl:otherwise>
84 </xsl:choose>
85 <link rel="stylesheet" href="interfaces/{$interface_name}/style/core.css" type="text/css"/>
86 <link rel="shortcut icon" href="interfaces/{$interface_name}/images/favicon.ico"/>
87
88 <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery.min.js"><xsl:text> </xsl:text></script>
89 <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.min.js"><xsl:text> </xsl:text></script>
90 <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery.blockUI.js"><xsl:text> </xsl:text></script>
91 <script type="text/javascript" src="interfaces/{$interface_name}/js/ace/ace.js"><xsl:text> </xsl:text></script>
92
93 <script type="text/javascript" src="interfaces/{$interface_name}/js/zoomer.js"><xsl:text> </xsl:text></script>
94
95 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
96 <xsl:call-template name="map-scripts"/>
97 </xsl:if>
98
99 <xsl:if test="/page/pageResponse/format/gsf:option[@name='mapEnabledOpenLayers']/@value = 'true'">
100 <xsl:call-template name="openlayers-map-scripts"/>
101 </xsl:if>
102
103
104 <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'">
105 <xsl:call-template name="panoramaViewer-scripts"/>
106 </xsl:if>
107
108 <xsl:if test="/page/pageRequest/userInformation and /page/pageRequest/userInformation/@editEnabled = 'true' 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))">
109 <xsl:if test="/page/pageRequest/paramList/param[(@name='docEdit') and (@value='on' or @value='true' or @value='1')]">
110 <script type="text/javascript" src="interfaces/{$interface_name}/js/ckeditor/ckeditor.js" defer="true"><xsl:text> </xsl:text></script>
111 <!-- <xsl:call-template name="init-direct-edit"/> -->
112 </xsl:if>
113 <script type="text/javascript" src="interfaces/{$interface_name}/js/debug_scripts.js"><xsl:text> </xsl:text></script>
114 <script type="text/javascript" src="interfaces/{$interface_name}/js/visual-xml-editor.js"><xsl:text> </xsl:text></script>
115 </xsl:if>
116
117 <xsl:call-template name="setup-gs-variable"/>
118 <xsl:if test="/page/pageRequest/@action ='p' and /page/pageRequest/@subaction='pref'">
119 <script type="text/javascript">
120 <xsl:value-of disable-output-escaping="yes" select="util:getInterfaceStringsAsJavascript($interface_name, /page/@lang, 'pref')"/>
121 </script>
122 <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery.themeswitcher.min.js"><xsl:text> </xsl:text></script>
123 </xsl:if>
124 <xsl:call-template name="define-js-macro-variables"/>
125
126 <xsl:call-template name="additionalHeaderContent"/>
127 </xsl:template>
128
129 <xsl:template name="addGoogleTracking">
130 <xsl:variable name="trackid">UA-xxx-1</xsl:variable>
131 <!-- Global site tag (gtag.js) - Google Analytics -->
132 <script async="async" src="https://www.googletagmanager.com/gtag/js?id={$google_tracking_id}"><xsl:text> </xsl:text></script>
133 <script>
134 <xsl:text disable-output-escaping="yes">
135 window.dataLayer = window.dataLayer || [];
136 function gtag(){dataLayer.push(arguments);}
137 gtag('js', new Date());
138
139 gtag('config', '</xsl:text><xsl:value-of select="$google_tracking_id"/><xsl:text disable-output-escaping="yes">');</xsl:text>
140 </script>
141 </xsl:template>
142
143 <!-- This template allows for extra header content to be added by page, interface, site and collection. -->
144 <xsl:template name="additionalHeaderContent">
145 <xsl:call-template name="additionalHeaderContent-page"/>
146 <xsl:call-template name="additionalHeaderContent-interface"/>
147 <xsl:call-template name="additionalHeaderContent-site"/>
148 <xsl:call-template name="additionalHeaderContent-collection"/>
149 </xsl:template>
150
151 <!-- This template should be overridden in a page xsl file to add extra header content just to that page -->
152 <xsl:template name="additionalHeaderContent-page">
153 </xsl:template>
154
155 <!-- This template should be overridden in header.xsl of a new interface file if you want to add extra header content -->
156 <xsl:template name="additionalHeaderContent-interface">
157 </xsl:template>
158 <!-- This template should be overridden in the header.xsl file in a site's transform directory if you want to add site specific headers -->
159 <xsl:template name="additionalHeaderContent-site">
160 </xsl:template>
161 <!-- This template should be overridden in the collectionConfig.xml file if you want to add extra header content -->
162 <xsl:template name="additionalHeaderContent-collection">
163 </xsl:template>
164
165 <xsl:template name="init-direct-edit">
166 <!-- might be worth moving loading the JS file to earlier, to give time to load -->
167 <script type="text/javascript" src="interfaces/{$interface_name}/js/direct-edit.js"><xsl:text> </xsl:text></script>
168 <script type="text/javascript">
169 <xsl:text disable-output-escaping="yes">
170 $(document).ready(function() {
171 de.onready(function()
172 {
173 try
174 {
175 de.init();
176 }
177 catch (err)
178 {
179 alert("Seaweed failed to initialise: " + err.message);
180 }
181 });
182 });
183 </xsl:text>
184 </script>
185 </xsl:template>
186
187
188 <!-- ***** HEADER LAYOUT TEMPLATE ***** -->
189 <xsl:template name="create-banner">
190 <div id="gs_banner" class="ui-widget-header ui-corner-bottom">
191 <div id="titlesearchcontainer">
192 <xsl:call-template name="page-title-area"/>
193 <xsl:call-template name="quick-search-area"/>
194 <div style="clear:both;"><xsl:text> </xsl:text></div>
195 </div>
196 <xsl:call-template name="browsing-tabs"/>
197 </div>
198 </xsl:template>
199
200 <xsl:template name="additionalNavTabs">
201 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/extraInfo/navigationTab">
202 <li>
203 <xsl:choose>
204 <!-- if we are in frame type and this is the current page, colour it differently-->
205 <xsl:when test="@type='frame' and /page/pageRequest[@subaction='html'] and /page/pageRequest/paramList/param[@name='url']/@value = @url">
206 <xsl:attribute name='class'>ui-state-default ui-corner-top ui-tabs-selected ui-state-active</xsl:attribute>
207 </xsl:when>
208 <xsl:otherwise>
209 <xsl:attribute name="class">ui-state-default ui-corner-top</xsl:attribute>
210 </xsl:otherwise>
211 </xsl:choose>
212 <a>
213 <xsl:if test="displayItem[@name='description']">
214 <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
215 </xsl:if>
216 <xsl:choose>
217 <xsl:when test="@type='external-link'">
218 <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
219 </xsl:when>
220 <xsl:when test="@type='frame'">
221 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/page/html?url=<xsl:value-of select="@url"/></xsl:attribute>
222 </xsl:when>
223 </xsl:choose>
224 <xsl:choose>
225 <xsl:when test="displayItem[@name='name']">
226 <xsl:value-of select="displayItem[@name='name']"/>
227 </xsl:when>
228 <xsl:otherwise>link</xsl:otherwise>
229 </xsl:choose>
230 </a>
231 </li>
232 </xsl:for-each>
233
234 </xsl:template>
235 <!-- ***** BROWSING TABS ***** -->
236 <xsl:template name="browsing-tabs">
237 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service or /page/pageResponse/collection[@name=$collNameChecked]/extraInfo/navigationTab">
238 <ul id="gs-nav">
239 <!-- if this collection has additional tabs, add them here -->
240 <xsl:call-template name="additionalNavTabs"/>
241 <!-- If this collection has a ClassifierBrowse service then add a tab for each classifier-->
242 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='browse' and @name='ClassifierBrowse']">
243 <!-- Loop through each classifier -->
244 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
245 <li>
246 <xsl:choose>
247 <!-- If this tab is selected then colour it differently -->
248 <xsl:when test="util:contains(/page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value, @name)">
249 <xsl:attribute name='class'>ui-state-default ui-corner-top ui-tabs-selected ui-state-active</xsl:attribute>
250 </xsl:when>
251 <xsl:otherwise>
252 <xsl:attribute name='class'>ui-state-default ui-corner-top</xsl:attribute>
253 </xsl:otherwise>
254 </xsl:choose>
255
256 <a>
257 <!-- Add a title element to the <a> tag if a description exists for this classifier -->
258 <xsl:if test="displayItem[@name='description']">
259 <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
260 </xsl:if>
261
262 <!-- Add the href element to the <a> tag -->
263 <xsl:choose>
264 <xsl:when test="@name">
265 <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>
266 </xsl:when>
267 <xsl:otherwise>
268 <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>
269 </xsl:otherwise>
270 </xsl:choose>
271
272 <!-- Add the actual text of the <a> tag -->
273 <xsl:value-of select="displayItem[@name='name']"/>
274 </a>
275 </li>
276 </xsl:for-each>
277 </xsl:if>
278
279 <!-- PhindApplet. Need something similar for the Collage applet too, probably -->
280 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='PhindApplet']">
281 <li>
282 <xsl:choose>
283 <!-- If this tab is selected then colour it differently -->
284 <xsl:when test="/page/pageRequest[@action='a']">
285 <xsl:attribute name='class'>ui-state-default ui-corner-top ui-tabs-selected ui-state-active</xsl:attribute>
286 </xsl:when>
287 <xsl:otherwise>
288 <xsl:attribute name='class'>ui-state-default ui-corner-top</xsl:attribute>
289 </xsl:otherwise>
290 </xsl:choose>
291
292 <a>
293 <xsl:if test="displayItem[@name='description']">
294 <xsl:attribute name="title">
295 <xsl:value-of select="displayItem[@name='description']"/>
296 </xsl:attribute>
297 </xsl:if>
298 <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>
299 <xsl:value-of select="displayItem[@name='name']"/>
300 </a>
301 </li>
302 </xsl:for-each>
303
304 <!-- all other services -->
305 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[not(@type='query') and not(@type='browse') and not (@name='PhindApplet')]">
306 <xsl:call-template name="navigationTab"/>
307 </xsl:for-each>
308 </ul>
309 <div style="clear:both;"><xsl:text> </xsl:text></div>
310 </xsl:if>
311 </xsl:template>
312
313 <!-- ***** HOME HELP PREFERENCES LOGIN ***** -->
314 <xsl:template name="home-help-preferences">
315 <ul id="bannerLinks">
316 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search' or not(@type)]/gsf:option[@name='RSS']/@value = 'true'">
317 <li><xsl:call-template name="RSSLink"/></li>
318 </xsl:if>
319 <li><xsl:call-template name="PrefsLink"/></li>
320 <li><xsl:call-template name="HelpLink"/></li>
321 <li id="userMenuButton"><xsl:call-template name="LoginoutLink"/></li>
322 <xsl:if test="/page/pageRequest/paramList/param[(@name='debug') and (@value='on' or @value='true' or @value='1' or @value='yes')]">
323 <li><xsl:call-template name="DebugLink"/></li>
324 </xsl:if>
325 <xsl:call-template name="buttonStyling"/>
326 </ul>
327 </xsl:template>
328
329 <xsl:template name="RSSLink">
330 <!-- RSS feed link can appear in a global format statement (where it has no type attribute)
331 or in section specific format statements, such as browse, search, display.
332 If it's present in any format statement, display the RSS link in the bannerlinks section. -->
333 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search' or not(@type)]/gsf:option[@name='RSS']/@value = 'true'">
334 <gsf:link type="rss"><gsf:icon file="rssicon.png"/></gsf:link>
335 </xsl:if>
336 </xsl:template>
337
338 <xsl:template name="PrefsLink">
339 <a href="{$library_name}/collection/{$collNameChecked}/page/pref">
340 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/></xsl:attribute>
341 <span id="preferencesButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/></span>
342 </a>
343 </xsl:template>
344
345 <xsl:template name="HelpLink">
346 <a href="{$library_name}/collection/{$collNameChecked}/page/help">
347 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_tip')"/></xsl:attribute>
348 <span id="helpButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/></span>
349 </a>
350 </xsl:template>
351
352 <xsl:template name="toggleUserMenuScript">
353
354 <script type="text/javascript">
355 <xsl:text disable-output-escaping="yes">
356 function toggleUserMenu()
357 {
358 var button = $("#userMenuButton");
359 var menu;
360
361 if(button.data("userMenu"))
362 {
363 menu = button.data("userMenu");
364 if(menu.css("display") == "block")
365 {
366 menu.hide();
367 }
368 else
369 {
370 menu.show();
371 }
372 }
373 else
374 {
375 menu = $("&lt;UL&gt;")
376 .css("position", "absolute")
377 .css("display", "block")
378 .css("z-index", "100")
379 .css("list-style", "none outside none")
380 .css("margin", "0px")
381 .css("padding", "0px")
382 .css("font-size", "90%");
383
384 menu.attr("id", "userMenu");
385
386 button.data("userMenu", menu);
387
388 var settingsLink = $("&lt;a&gt;")
389 .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">");
390 var settingsButton = $("&lt;LI&gt;")
391 .css("padding", "3px")
392 .html("</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'menu.account_settings')"/><xsl:text disable-output-escaping="yes">")
393 .addClass("ui-state-default");
394 settingsLink.append(settingsButton);
395 menu.append(settingsLink);
396
397 </xsl:text><xsl:if test="/page/pageRequest/@action = 'd' and $isEditingTurnedOn = '1'"><xsl:text disable-output-escaping="yes">
398 var editingLink = $("&lt;a&gt;")
399 .attr("href", "javascript:;");
400 var editingButton = $("&lt;LI&gt;")
401 .addClass("ui-state-default")
402 .css("padding", "3px")</xsl:text>
403 <xsl:choose>
404 <xsl:when test="$isEditingAvailable = '1' and $userHasEditPermission = '1'"><xsl:text disable-output-escaping="yes">
405 .html((gs.userInformation.editEnabled == "true") ? "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'menu.disable_edit_mode')"/><xsl:text disable-output-escaping="yes">" : "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'menu.enable_edit_mode')"/><xsl:text disable-output-escaping="yes">")
406 .click(function()
407 {
408 var url = gs.xsltParams.library_name + "?a=g&amp;rt=ro&amp;s=ChangeUserEditMode&amp;s1.username=" + gs.userInformation.username + "&amp;s1.enabled=" + ((gs.userInformation.editEnabled == "true") ? "false" : "true");
409 $.ajax(url)
410 .success(function(response)
411 {
412 location.reload(true);
413 });
414 });
415 </xsl:text></xsl:when><xsl:otherwise><xsl:variable name="reason"><xsl:choose><xsl:when test="$isEditingAvailable != '1'"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'de.error.unavailable')"/></xsl:when><xsl:when test="$userHasEditPermission != '1'"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'de.error.wrong_group')"/></xsl:when></xsl:choose><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'de.error.contact_admin', $siteAdmin)"/></xsl:variable><xsl:text disable-output-escaping="yes">
416 .html("</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'de.error')"/><xsl:text disable-output-escaping='yes'>")
417 .click(function()
418 {
419 alert("</xsl:text><xsl:value-of select="$reason"/><xsl:text disable-output-escaping='yes'>");
420 menu.hide();
421 });
422 </xsl:text>
423 </xsl:otherwise></xsl:choose><xsl:text disable-output-escaping="yes">
424 editingLink.append(editingButton);
425 menu.append(editingLink);
426 </xsl:text></xsl:if><xsl:text disable-output-escaping="yes">
427 var url = document.URL;
428 var hasQueryString = (url.indexOf("?") != -1);
429 var hashIndex = url.indexOf("#");
430
431 var hashPart;
432 if(hashIndex != -1)
433 {
434 hashPart = url.substring(hashIndex);
435 url = url.substring(0, hashIndex);
436 }
437
438 var logoutLink = $("&lt;a&gt;")
439 .attr("href", url + (hasQueryString ? "&amp;" : "?") + "logout=" + (hashPart ? hashPart : ""));
440 var logoutButton = $("&lt;LI&gt;")
441 .css("padding", "3px")
442 .html("</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'menu.logout')"/><xsl:text disable-output-escaping="yes">")
443 .addClass("ui-state-default");
444 logoutLink.append(logoutButton);
445 menu.append(logoutLink);
446
447 var buttonLeft = button.offset().left;
448 var buttonTop = button.offset().top;
449
450 var buttonHeight = button.height();
451
452 menu.offset({top: buttonTop + buttonHeight + 4, left: buttonLeft});
453 $("#topArea").append(menu);
454 }
455 }
456 </xsl:text>
457 </script>
458
459 </xsl:template>
460
461 <xsl:template name="generateLoginURL">
462 <xsl:value-of select="$library_name"/>
463 <xsl:text>?a=p&amp;sa=login&amp;redirectURL=</xsl:text>
464 <xsl:value-of select="$library_name"/>
465 <xsl:text>%3F</xsl:text>
466 <xsl:if test="/page/pageRequest/@action">
467 <xsl:text>a=</xsl:text>
468 <xsl:value-of select="/page/pageRequest/@action"/>
469 </xsl:if>
470 <xsl:if test="/page/pageRequest/@subaction">
471 <xsl:text>%26sa=</xsl:text>
472 <xsl:value-of select="/page/pageRequest/@subaction"/>
473 </xsl:if>
474 <xsl:for-each select="/page/pageRequest/paramList/param">
475 <xsl:if test="@name != 'password' and @name != 's1.password' and @name != 's1.newPassword' and @name != 's1.oldPassword'">
476 <xsl:text>%26</xsl:text>
477 <xsl:value-of select="@name"/>
478 <xsl:text>=</xsl:text>
479 <xsl:value-of select="@value"/>
480 </xsl:if>
481 </xsl:for-each>
482
483 </xsl:template>
484
485 <!-- Writing the reverse of generateLoginURL since the toggleUserMenuScript does a lot more than I want. -->
486 <!-- https://www.w3schools.com/xml/xsl_functions.asp#string -->
487 <xsl:template name="generateLogoutURL">
488
489 <xsl:variable name="url" select="/page/pageRequest/@fullURL"/>
490 <xsl:variable name="beforeLogout" select="substring-before($url, '&amp;amp;logout=')"/>
491 <xsl:variable name="tmpAfter" select="substring-after($url, '&amp;amp;logout=')"/>
492 <xsl:variable name="afterLogout" select="substring-after($tmpAfter, '&amp;amp;')"/>
493 <xsl:variable name="beforeHash" select="substring-before($url, '#')"/>
494 <xsl:variable name="afterHash" select="substring-after($url, '#')"/>
495 <!-- Get rid of any lingering &amp;logout= already in the URL.
496 But retain anything before and after it (the after portion would start with &).
497 Can't use fn:replace() as it's only been defined since XSLT 2.0. We use XSLT 1.x -->
498 <xsl:variable name="fullURL">
499 <xsl:choose>
500 <xsl:when test="$beforeLogout != ''"><xsl:value-of select="$beforeLogout" /></xsl:when>
501 <xsl:otherwise><xsl:value-of select="$url" /></xsl:otherwise>
502 </xsl:choose>
503 <xsl:if test="$afterLogout != ''">&amp;<xsl:value-of select="$afterLogout" /></xsl:if>
504 </xsl:variable>
505
506 <!-- Output the logout link: the current page's URL (with any lingering logout suffix removed)
507 followed by ?logout= or &amp;logout= followed by any # portion of the current page's URL -->
508 <xsl:choose>
509 <xsl:when test="$beforeHash != ''"><xsl:value-of select="$beforeHash" /></xsl:when>
510 <xsl:otherwise><xsl:value-of select="$fullURL" /></xsl:otherwise>
511 </xsl:choose>
512 <xsl:choose>
513 <xsl:when test="contains($fullURL, '?')"><xsl:text>&amp;logout=</xsl:text></xsl:when>
514 <xsl:otherwise>?logout=</xsl:otherwise>
515 </xsl:choose>
516 <xsl:if test="$afterHash != ''">#<xsl:value-of select="$afterHash" /></xsl:if>
517 </xsl:template>
518
519 <xsl:template name="LoginoutLink">
520 <!-- login/logout -->
521 <xsl:choose>
522 <xsl:when test="/page/pageRequest/userInformation/@username">
523 <a>
524 <xsl:attribute name="href">javascript:toggleUserMenu();</xsl:attribute>
525 <xsl:call-template name="toggleUserMenuScript"/>
526 <span id="loginButton"><xsl:value-of select="/page/pageRequest/userInformation/@username"/></span>
527 </a>
528 </xsl:when>
529 <xsl:otherwise>
530 <a>
531 <xsl:attribute name="href"><xsl:call-template name="generateLoginURL"/>
532 </xsl:attribute>
533 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_tip')"/></xsl:attribute>
534 <span id="loginButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_b')"/></span>
535 </a>
536 </xsl:otherwise>
537 </xsl:choose>
538 </xsl:template>
539
540 <xsl:template name="DebugLink">
541 <!-- debuginfo (doesn't use class="ui-state-error" since the text is not legible due to inherited text-colour) -->
542 <xsl:if test="/page/pageRequest/paramList/param[(@name='debug') and (@value='on' or @value='true' or @value='1' or @value='yes')]">
543 <a href="{$library_name}/collection/{$collNameChecked}/page/debug">
544 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'debuginfo_tip')"/></xsl:attribute>
545 <span id="debugButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'debuginfo_b')"/></span>
546 </a>
547 </xsl:if>
548 </xsl:template>
549
550 <xsl:template name="buttonStyling">
551 <script type="text/javascript">
552 <xsl:text disable-output-escaping="yes">
553 $("#preferencesButton").button({icons:{primary:"ui-icon-wrench"}});
554 $("#preferencesButton .ui-button-text").css({"padding-top":"0px", "padding-bottom":"3px"});
555 $("#helpButton").button({icons:{primary:"ui-icon-help"}});
556 $("#helpButton .ui-button-text").css({"padding-top":"0px", "padding-bottom":"3px"});
557 $("#debugButton").button({icons:{primary:"ui-icon-info"}});
558 $("#debugButton .ui-button-text").css({"padding-top":"0px", "padding-bottom":"3px"});
559 </xsl:text>
560 <xsl:choose>
561 <xsl:when test="/page/pageRequest/userInformation/@username">
562 <xsl:text disable-output-escaping="yes">$("#loginButton").button({icons:{primary:"ui-icon-unlocked"}});</xsl:text>
563 </xsl:when>
564 <xsl:otherwise>
565 <xsl:text disable-output-escaping="yes">$("#loginButton").button({icons:{primary:"ui-icon-locked"}});</xsl:text>
566 </xsl:otherwise>
567 </xsl:choose>
568 <xsl:text disable-output-escaping="yes">
569 $("#loginButton .ui-button-text").css({"padding-top":"0px", "padding-bottom":"3px"});
570 </xsl:text>
571 </script>
572
573 </xsl:template>
574 <!-- ***** PAGE TITLE ***** -->
575 <xsl:template name="page-title-area">
576 <xsl:variable name="pageTitleVar"><xsl:call-template name="pageTitle"/></xsl:variable>
577 <div id="titlearea">
578 <h2>
579 <!-- Resize the title based on how long it is (There's probably a better way to do this) -->
580 <xsl:attribute name="style">
581 <xsl:choose>
582 <xsl:when test="string-length($pageTitleVar) &lt; 20">
583 <xsl:text>font-size: 1.5em;</xsl:text>
584 </xsl:when>
585 <xsl:when test="string-length($pageTitleVar) &lt; 30">
586 <xsl:text>font-size: 1.4em;</xsl:text>
587 </xsl:when>
588 <xsl:when test="string-length($pageTitleVar) &lt; 40">
589 <xsl:text>font-size: 1.3em;</xsl:text>
590 </xsl:when>
591 <xsl:when test="string-length($pageTitleVar) &lt; 50">
592 <xsl:text>font-size: 1.2em;</xsl:text>
593 </xsl:when>
594 <xsl:when test="string-length($pageTitleVar) &lt; 60">
595 <xsl:text>font-size: 1.1em;</xsl:text>
596 </xsl:when>
597 <xsl:when test="string-length($pageTitleVar) &lt; 70">
598 <xsl:text>font-size: 1em;</xsl:text>
599 </xsl:when>
600 <xsl:when test="string-length($pageTitleVar) &lt; 80">
601 <xsl:text>font-size: 0.9em;</xsl:text>
602 </xsl:when>
603 <xsl:when test="string-length($pageTitleVar) &lt; 90">
604 <xsl:text>font-size: 0.8em;</xsl:text>
605 </xsl:when>
606 <xsl:otherwise>
607 <xsl:text>font-size: 0.7em;</xsl:text>
608 </xsl:otherwise>
609 </xsl:choose>
610 </xsl:attribute>
611 <!--<xsl:value-of select="string-length($pageTitleVar)" />-->
612 <xsl:value-of select="$pageTitleVar" />
613 </h2><xsl:text> </xsl:text>
614 </div>
615 </xsl:template>
616
617 <!-- ***** QUICK SEARCH AREA ***** -->
618 <!-- Search form should only appear if there's a search (query) service AND it has an index.
619 By default, all collections end up with some query service (default is MGPP) even when they have
620 no search indexes, which is why the extra test for the presence of an index/fq-something is necessary. -->
621 <xsl:template name="quick-search-area">
622 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
623 <xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
624 <div id="quicksearcharea">
625 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
626 <xsl:choose>
627 <xsl:when test="not(page/pageRequest[@action='q']) or /page/pageRequest/paramList/param[@name='qs']/@value = '1'">
628 <form action="{$library_name}/collection/{$collNameChecked}/search/TextQuery">
629 <!-- This parameter says that we have come from the quick search area -->
630 <input type="hidden" name="qs" value="1"/>
631 <input type="hidden" name="rt" value="rd"/>
632 <input type="hidden" name="s1.level">
633 <xsl:attribute name="value">
634 <xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name='TextQuery']/paramList/param[@name = 'level']/@default"/>
635 </xsl:attribute>
636 </input>
637 <xsl:choose>
638 <xsl:when test="/page/pageResponse/service[@name = 'TextQuery']/paramList/param[@name = 'startPage']">
639 <input type="hidden" name="s1.startPage" value="1"/>
640 </xsl:when>
641 <xsl:otherwise>
642 <input type="hidden" name="startPage" value="1"/>
643 </xsl:otherwise>
644 </xsl:choose>
645
646 <!-- The query text box -->
647 <span class="querybox">
648 <xsl:variable name="qs">
649 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
650 </xsl:variable>
651 <nobr>
652 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
653 <!--
654 <xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs, /page/@lang)"/>
655 -->
656 <xsl:with-param name="default" select="normalize-space($qs)"/>
657
658 </xsl:apply-templates>
659 </nobr>
660 </span>
661 <!-- The index selection list -->
662 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']/@type = 'enum_single'">
663 <span class="textselect">
664 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']">
665 <xsl:with-param name="default">
666 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']" mode="calculate-default"/>
667 </xsl:with-param>
668 <xsl:with-param name="hideSingle">false</xsl:with-param>
669 <xsl:with-param name="quickSearch">true</xsl:with-param>
670 </xsl:apply-templates>
671 </span>
672 </xsl:if>
673 <!-- The partition selection list -->
674 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']/@type = 'enum_single'">
675 <span class="textselect">
676 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']">
677 <xsl:with-param name="default">
678 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexSubcollection']" mode="calculate-default"/>
679 </xsl:with-param>
680 <xsl:with-param name="hideSingle">true</xsl:with-param>
681 <xsl:with-param name="quickSearch">true</xsl:with-param>
682 </xsl:apply-templates>
683 </span>
684 </xsl:if>
685 <!-- The language selection list -->
686 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']/@type = 'enum_single'">
687 <span class="textselect">
688 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']">
689 <xsl:with-param name="default">
690 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='indexLanguage']" mode="calculate-default"/>
691 </xsl:with-param>
692 <xsl:with-param name="hideSingle">true</xsl:with-param>
693 <xsl:with-param name="quickSearch">true</xsl:with-param>
694 </xsl:apply-templates>
695 </span>
696 </xsl:if>
697 <!-- The submit button (for TextQuery) -->
698 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
699 <input type="submit" id="quickSearchSubmitButton">
700 <xsl:attribute name="value">
701 <xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/displayItem[@name='submit']"/>
702 </xsl:attribute>
703 </input>
704 <br/>
705 </xsl:if>
706 </form>
707 </xsl:when>
708 <xsl:otherwise><br/></xsl:otherwise>
709 </xsl:choose>
710 </xsl:if>
711 <!-- The list of other search types -->
712 <ul>
713 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
714 <xsl:if test="/page/pageRequest/paramList/param[@name='qs']/@value = 1 or not(@name = /page/pageRequest/paramList/param[@name='s']/@value)">
715 <li class="ui-state-default ui-corner-all">
716 <a>
717 <xsl:attribute name="href">
718 <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collNameChecked"/>/search/<xsl:value-of select="@name"/>
719 </xsl:attribute>
720 <xsl:value-of select="displayItem[@name='name']"/>
721 </a>
722 </li>
723 </xsl:if>
724 </xsl:for-each>
725 </ul>
726 </div>
727 </xsl:if>
728 </xsl:template>
729
730 <xsl:template name="map-scripts">
731 <meta content="initial-scale=1.0, user-scalable=no" name="viewport"/>
732 <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCofVTps3xHfMvIcTMHqYMMxe3xXfkAxnI" type="text/javascript"><xsl:text> </xsl:text></script>
733 <script src="interfaces/{$interface_name}/js/map-scripts.js" type="text/javascript"><xsl:text> </xsl:text></script>
734 <script type="text/javascript">$(window).load(initializeMapScripts);</script>
735 </xsl:template>
736
737 <xsl:template name="openlayers-map-scripts">
738 <script src="interfaces/{interface_name}/js/OpenLayers.js" type="text/javascript"><xsl:text> </xsl:text></script>
739 </xsl:template>
740
741 <xsl:template name="panoramaViewer-scripts">
742 <script src="interfaces/{$interface_name}/js/three45.min.js" type="text/javascript"><xsl:text> </xsl:text></script>
743 <script src="interfaces/{$interface_name}/js/Tween.js" type="text/javascript"><xsl:text> </xsl:text></script>
744 <script src="interfaces/{$interface_name}/js/Detector.js" type="text/javascript"><xsl:text> </xsl:text></script>
745 <script src="interfaces/{$interface_name}/js/RequestAnimationFrame.js" type="text/javascript"><xsl:text> </xsl:text></script>
746 <script src="interfaces/{$interface_name}/js/panoramaMarker.js" type="text/javascript"><xsl:text> </xsl:text></script>
747 <script src="interfaces/{$interface_name}/js/panoramaViewer.js" type="text/javascript"><xsl:text> </xsl:text></script>
748 <script type="text/javascript">$(window).load(initPanoramaViewer);$(window).load(_animate);</script>
749 </xsl:template>
750
751 <xsl:template name="choose-title">
752 <gsf:choose-metadata>
753 <gsf:metadata name="dc.Title"/>
754 <gsf:metadata name="exp.Title"/>
755 <gsf:metadata name="ex.dc.Title"/>
756 <gsf:metadata name="Title"/>
757 <gsf:default>Untitled</gsf:default>
758 </gsf:choose-metadata>
759 </xsl:template>
760</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.