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

Last change on this file since 33510 was 33510, checked in by kjdon, 5 years ago

isEditingTurnedOn renamed to isEditingAllowed, and added isMapGPSEditingAllowed

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