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

Last change on this file since 35331 was 35331, checked in by davidb, 3 years ago

Further refinement of the Google Signin process from the JS/Web Browser side of things

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