root/main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl @ 32473

Revision 32473, 37.6 KB (checked in by kjdon, 22 months ago)

AllowDocumentEditing? is true by default. Also, if we disable edit mode, then if we were currently in edit mode, then add docEdit=0 & ed=0 to url to take us out of editing.

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