source: main/trunk/greenstone3/web/interfaces/oran/transform/layouts/header.xsl@ 25278

Last change on this file since 25278 was 25278, checked in by sjm84, 9 years ago

Added in the drop down menu for the account settings

  • Property svn:executable set to *
File size: 17.4 KB
Line 
1<xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:java="http://xml.apache.org/xslt/java"
4 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
5 xmlns:gslib="http://www.greenstone.org/skinning"
6 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
7 extension-element-prefixes="java util"
8 exclude-result-prefixes="java util gsf">
9
10 <xsl:include href="../query-common.xsl"/>
11 <xsl:include href="../javascript-global-setup.xsl"/>
12
13 <!-- If the c parameter is empty then use the p.c parameter for the collection name-->
14 <xsl:variable name="collNameChecked">
15 <xsl:choose>
16 <xsl:when test="$collName = '' and /page/pageRequest/paramList/param[@name='p.c']/@value">
17 <xsl:value-of select="/page/pageRequest/paramList/param[@name='p.c']/@value"/>
18 </xsl:when>
19 <xsl:otherwise>
20 <xsl:value-of select="$collName"/>
21 </xsl:otherwise>
22 </xsl:choose>
23 </xsl:variable>
24
25 <!-- Creates a header for the html page -->
26 <xsl:template name="create-html-header">
27 <base href="{/page/pageRequest/@baseURL}"/><xsl:comment>[if lte IE 6]&gt;&lt;/base&gt;&lt;![endif]</xsl:comment>
28
29 <title><xsl:call-template name="pageTitle"/> :: <xsl:call-template name="siteName"/></title>
30
31 <xsl:choose>
32 <xsl:when test="/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value">
33 <!-- Get the theme from the interfaceConfig.xml file -->
34 <link rel="stylesheet" href="{/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value}" type="text/css"/>
35 </xsl:when>
36 <xsl:otherwise>
37 <link rel="stylesheet" href="interfaces/{$interface_name}/style/themes/main/jquery-ui-1.8.16.custom.css" type="text/css"/>
38 </xsl:otherwise>
39 </xsl:choose>
40 <link rel="stylesheet" href="interfaces/{$interface_name}/style/core.css" type="text/css"/>
41 <link rel="shortcut icon" href="favicon.ico"/>
42
43 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"><xsl:text> </xsl:text></script>
44 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"><xsl:text> </xsl:text></script>
45 <script type="text/javascript" src="interfaces/{$interface_name}/js/jquery.themeswitcher.min.js"><xsl:text> </xsl:text></script>
46
47 <script type="text/javascript" src="interfaces/{$interface_name}/js/direct-edit.js"><xsl:text> </xsl:text></script>
48 <script type="text/javascript" src="interfaces/{$interface_name}/js/zoomer.js"><xsl:text> </xsl:text></script>
49
50 <xsl:if test="/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='mapEnabled']/@value = 'true'">
51 <xsl:call-template name="map-scripts"/>
52 </xsl:if>
53
54 <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:contains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))">
55 <xsl:call-template name="init-direct-edit"/>
56 </xsl:if>
57 <xsl:call-template name="setup-gs-variable"/>
58 <xsl:call-template name="additionalHeaderContent"/>
59 </xsl:template>
60
61 <xsl:template name="additionalHeaderContent">
62 <!-- This template should be overridden in the collectionConfig.xml file if you want to add extra header content -->
63 </xsl:template>
64
65 <xsl:template name="init-direct-edit">
66 <script type="text/javascript">
67 <xsl:text disable-output-escaping="yes">
68 de.onready(function()
69 {
70 try
71 {
72 de.init();
73 }
74 catch (err)
75 {
76 alert("Seaweed failed to initialise: " + err.message);
77 }
78 });
79 </xsl:text>
80 </script>
81 </xsl:template>
82
83 <!-- ***** HEADER LAYOUT TEMPLATE ***** -->
84 <xsl:template name="create-banner">
85 <div id="gs_banner" class="ui-widget-header ui-corner-bottom">
86 <table id="titlesearchcontainer">
87 <tr>
88 <xsl:call-template name="page-title-area"/>
89 <xsl:call-template name="quick-search-area"/>
90 </tr>
91 </table>
92 <xsl:call-template name="browsing-tabs"/>
93 </div>
94 </xsl:template>
95
96 <!-- ***** BROWSING TABS ***** -->
97 <xsl:template name="browsing-tabs">
98 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service">
99 <ul id="nav">
100 <!-- If this collection has a ClassifierBrowse service then add a tab for each classifier-->
101 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='browse' and @name='ClassifierBrowse']">
102 <!-- Loop through each classifier -->
103 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
104 <li>
105 <xsl:choose>
106 <!-- If this tab is selected then colour it differently -->
107 <xsl:when test="@name = /page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value">
108 <xsl:attribute name='class'>ui-state-default ui-corner-top ui-tabs-selected ui-state-active</xsl:attribute>
109 </xsl:when>
110 <xsl:otherwise>
111 <xsl:attribute name='class'>ui-state-default ui-corner-top</xsl:attribute>
112 </xsl:otherwise>
113 </xsl:choose>
114
115 <a>
116 <!-- Add a title element to the <a> tag if a description exists for this classifier -->
117 <xsl:if test="displayItem[@name='description']">
118 <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
119 </xsl:if>
120
121 <!-- Add the href element to the <a> tag -->
122 <xsl:choose>
123 <xsl:when test="@name">
124 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=b&amp;rt=s&amp;s=ClassifierBrowse&amp;c=<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>&amp;cl=<xsl:value-of select="@name"/></xsl:attribute>
125 </xsl:when>
126 <xsl:otherwise>
127 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=b&amp;rt=d&amp;s=ClassifierBrowse&amp;c=<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/></xsl:attribute>
128 </xsl:otherwise>
129 </xsl:choose>
130
131 <!-- Add the actual text of the <a> tag -->
132 <xsl:value-of select="displayItem[@name='name']"/>
133 </a>
134 </li>
135 </xsl:for-each>
136 </xsl:if>
137
138 <!-- all other services -->
139 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[not(@type='query') and not(@type='browse')]">
140 <xsl:call-template name="navigationTab"/>
141 </xsl:for-each>
142 </ul>
143 </xsl:if>
144 </xsl:template>
145
146 <!-- ***** HOME HELP PREFERENCES LOGIN ***** -->
147 <xsl:template name="home-help-preferences">
148 <ul id="bannerLinks">
149 <!-- preferences -->
150 <li class="ui-state-default ui-corner-all">
151 <a href="{$library_name}?a=p&amp;amp;sa=pref&amp;amp;c={$collNameChecked}">
152 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/></xsl:attribute>
153 <ul>
154 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/></span></li>
155 <li><span class="ui-icon ui-icon-wrench"><xsl:text> </xsl:text></span></li>
156 </ul>
157 </a>
158 </li>
159
160 <!-- help -->
161 <li class="ui-state-default ui-corner-all">
162 <a href="{$library_name}?a=p&amp;amp;sa=help&amp;amp;c={$collNameChecked}">
163 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_tip')"/></xsl:attribute>
164 <ul>
165 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/></span></li>
166 <li><span class="ui-icon ui-icon-help"><xsl:text> </xsl:text></span></li>
167 </ul>
168 </a>
169 </li>
170
171 <!-- login/logout -->
172 <li class="ui-state-default ui-corner-all" id="userMenuButton">
173 <xsl:choose>
174 <xsl:when test="/page/pageRequest/userInformation/@username">
175 <a>
176 <xsl:attribute name="href">javascript:toggleUserMenu();</xsl:attribute>
177 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'logout_tip')"/></xsl:attribute>
178 <script type="text/javascript">
179 <xsl:text disable-output-escaping="yes">
180 function toggleUserMenu()
181 {
182 var button = $("#userMenuButton");
183 var menu;
184
185 if(button.data("userMenu"))
186 {
187 menu = button.data("userMenu");
188 if(menu.css("display") == "block")
189 {
190 menu.hide();
191 }
192 else
193 {
194 menu.show();
195 }
196 }
197 else
198 {
199 menu = $("&lt;UL&gt;")
200 .css("position", "absolute")
201 .css("display", "block")
202 .css("z-index", "100")
203 .css("list-style", "none outside none")
204 .css("margin-left", "0px")
205 .css("padding", "0px")
206 .css("font-size", "90%");
207
208 button.data("userMenu", menu);
209
210 var settingsLink = $("&lt;a&gt;")
211 .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">");
212 var settingsButton = $("&lt;LI&gt;")
213 .css("padding", "3px")
214 .html("Account settings")
215 .addClass("ui-state-default");
216 settingsLink.append(settingsButton);
217
218 var url = document.URL;
219 var hasQueryString = (url.indexOf("?") != -1);
220 var hashIndex = url.indexOf("#");
221
222 var hashPart;
223 if(hashIndex != -1)
224 {
225 hashPart = url.substring(hashIndex);
226 url = url.substring(0, hashIndex);
227 }
228
229 var logoutLink = $("&lt;a&gt;")
230 .attr("href", url + (hasQueryString ? "&amp;" : "?") + "logout=" + (hashPart ? hashPart : ""));
231 var logoutButton = $("&lt;LI&gt;")
232 .css("padding", "3px")
233 .html("Logout")
234 .addClass("ui-state-default");
235 logoutLink.append(logoutButton);
236
237 menu.append(settingsLink);
238 menu.append(logoutLink);
239
240 var buttonLeft = button.offset().left;
241 var buttonTop = button.offset().top;
242 var buttonHeight = button.height();
243
244 menu.offset({top: buttonTop + buttonHeight + 4, left: buttonLeft});
245 $("#topArea").append(menu);
246 }
247 }
248 </xsl:text>
249 </script>
250 <ul>
251 <li><span><xsl:value-of select="/page/pageRequest/userInformation/@username"/></span></li>
252 <li><span class="ui-icon ui-icon-unlocked"><xsl:text> </xsl:text></span></li>
253 </ul>
254 </a>
255 </xsl:when>
256 <xsl:otherwise>
257 <a>
258 <xsl:attribute name="href">
259 <xsl:value-of select="$library_name"/>
260 <xsl:text>?a=p&amp;sa=login&amp;redirectURL=</xsl:text>
261 <xsl:value-of select="$library_name"/>
262 <xsl:text>%3F</xsl:text>
263 <xsl:if test="/page/pageRequest/@action">
264 <xsl:text>a=</xsl:text>
265 <xsl:value-of select="/page/pageRequest/@action"/>
266 </xsl:if>
267 <xsl:if test="/page/pageRequest/@subaction">
268 <xsl:text>%26sa=</xsl:text>
269 <xsl:value-of select="/page/pageRequest/@subaction"/>
270 </xsl:if>
271 <xsl:for-each select="/page/pageRequest/paramList/param">
272 <xsl:if test="@name != 'password' and @name != 's1.password' and @name != 's1.newPassword' and @name != 's1.oldPassword'">
273 <xsl:text>%26</xsl:text>
274 <xsl:value-of select="@name"/>
275 <xsl:text>=</xsl:text>
276 <xsl:value-of select="@value"/>
277 </xsl:if>
278 </xsl:for-each>
279 </xsl:attribute>
280 <xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_tip')"/></xsl:attribute>
281 <ul>
282 <li><span><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_b')"/></span></li>
283 <li><span class="ui-icon ui-icon-locked"><xsl:text> </xsl:text></span></li>
284 </ul>
285 </a>
286 </xsl:otherwise>
287 </xsl:choose>
288 </li>
289 </ul>
290 </xsl:template>
291
292 <!-- ***** PAGE TITLE ***** -->
293 <xsl:template name="page-title-area">
294 <xsl:variable name="pageTitleVar"><xsl:call-template name="pageTitle"/></xsl:variable>
295 <td id="titlearea">
296 <h2>
297 <!-- Resize the title based on how long it is (There's probably a better way to do this) -->
298 <xsl:attribute name="style">
299 <xsl:choose>
300 <xsl:when test="string-length($pageTitleVar) &lt; 20">
301 <xsl:text>font-size: 1.5em;</xsl:text>
302 </xsl:when>
303 <xsl:when test="string-length($pageTitleVar) &lt; 30">
304 <xsl:text>font-size: 1.4em;</xsl:text>
305 </xsl:when>
306 <xsl:when test="string-length($pageTitleVar) &lt; 40">
307 <xsl:text>font-size: 1.3em;</xsl:text>
308 </xsl:when>
309 <xsl:when test="string-length($pageTitleVar) &lt; 50">
310 <xsl:text>font-size: 1.2em;</xsl:text>
311 </xsl:when>
312 <xsl:when test="string-length($pageTitleVar) &lt; 60">
313 <xsl:text>font-size: 1.1em;</xsl:text>
314 </xsl:when>
315 <xsl:when test="string-length($pageTitleVar) &lt; 70">
316 <xsl:text>font-size: 1em;</xsl:text>
317 </xsl:when>
318 <xsl:when test="string-length($pageTitleVar) &lt; 80">
319 <xsl:text>font-size: 0.9em;</xsl:text>
320 </xsl:when>
321 <xsl:when test="string-length($pageTitleVar) &lt; 90">
322 <xsl:text>font-size: 0.8em;</xsl:text>
323 </xsl:when>
324 <xsl:otherwise>
325 <xsl:text>font-size: 0.7em;</xsl:text>
326 </xsl:otherwise>
327 </xsl:choose>
328 </xsl:attribute>
329 <!--<xsl:value-of select="string-length($pageTitleVar)" />-->
330 <xsl:value-of select="$pageTitleVar" />
331 </h2>
332 </td>
333 </xsl:template>
334
335
336 <!-- ***** QUICK SEARCH AREA ***** -->
337 <xsl:template name="quick-search-area">
338 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
339 <xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
340 <td id="quicksearcharea">
341 <form action="{$library_name}">
342 <input type="hidden" name="a" value="q"/>
343 <input type="hidden" name="sa" value="{$subaction}"/>
344 <input type="hidden" name="rt" value="rd"/>
345 <input type="hidden" name="s" value="TextQuery"/>
346 <input type="hidden" name="c" value="{$collNameChecked}"/>
347 <input type="hidden" name="startPage" value="1"/>
348 <!-- The query text box -->
349 <span class="querybox">
350 <xsl:variable name="qs">
351 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
352 </xsl:variable>
353 <nobr>
354 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
355 <xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs)"/>
356 </xsl:apply-templates>
357 </nobr>
358 </span>
359 <!-- The index selection list -->
360 <xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']/@type = 'enum_single'">
361 <span class="textselect">
362 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']">
363 <xsl:with-param name="default">
364 <xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']" mode="calculate-default"/>
365 </xsl:with-param>
366 </xsl:apply-templates>
367 </span>
368 </xsl:if>
369 <!-- The submit button -->
370 <input type="submit" id="quickSearchSubmitButton">
371 <xsl:attribute name="value">
372 <xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/displayItem[@name='submit']"/>
373 </xsl:attribute>
374 </input>
375 <br/>
376 <!-- The list of other search types -->
377 <ul>
378 <xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
379 <li class="ui-state-default ui-corner-all">
380 <a>
381 <xsl:attribute name="href">
382 <xsl:value-of select="$library_name"/>?a=q&amp;rt=d&amp;c=<xsl:value-of select="$collNameChecked"/>&amp;s=<xsl:value-of select="@name"/>
383 </xsl:attribute>
384 <xsl:value-of select="displayItem[@name='name']"/>
385 </a>
386 </li>
387 </xsl:for-each>
388 </ul>
389 </form>
390 </td>
391 </xsl:if>
392 </xsl:template>
393
394 <xsl:template name="map-scripts">
395 <meta content="initial-scale=1.0, user-scalable=no" name="viewport"/>
396 <script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"><xsl:text> </xsl:text></script>
397 <script src="interfaces/{$interface_name}/js/map-scripts.js" type="text/javascript"><xsl:text> </xsl:text></script>
398 <script type="text/javascript">$(window).load(initializeMapScripts);</script>
399 </xsl:template>
400</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.