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

Last change on this file since 32832 was 32832, checked in by ak19, 5 years ago

Zeddy map work. 1. Now supports saving when map editor is selected and key s is pressed.. The saved shapes are now reloaded on page (re)load. 2. If you make a change and didn't save it and try to leave the page, there's now a default warning (can't yet control the warning message, but it's helpful enough at this stage). 3. Some more fixes. 4. Some cleaning up of unused code. 5. Still some debugging statements left in, check for console.log() for instance. 6. Gone back to using javascript instead of jQuery for keyboard shortcuts so it will work for PDF docs too, but kept some additional changes made earlier so that things still work on Firefox besides Chrome.

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