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

Revision 32466, 35.4 KB (checked in by kjdon, 11 months ago)

only show disable/enable editing button in the user menu when we are on a document page, as that is the only place it currently makes sense.

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