source: main/trunk/greenstone3/web/interfaces/default/transform/javascript-global-setup.xsl@ 37805

Last change on this file since 37805 was 37805, checked in by anupama, 11 months ago

Another instance where ??= needed replacing, this time in XSLT. Only the 32 bit linux could locate these as the GS3 installation's document view would fail to load the page pointing out such errors. I had assumed all ??= were generated by the XSLTUtil.java java code and had been fixed up with yesterday's commit.

  • Property svn:executable set to *
File size: 15.1 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 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9 <xsl:template name="setup-gs-variable">
10 <script type="text/javascript">
11 <xsl:text disable-output-escaping="yes">
12 if (typeof gs === "undefined" ) {
13 gs={};
14 }
15 if(typeof gs.cgiParams==="undefined"){gs.cgiParams={};} //gs.cgiParams ??= {};
16 if(typeof gs.xsltParams==="undefined"){gs.xsltParams={};} //gs.xsltParams ??= {};
17 if(typeof gs.siteMetadata==="undefined"){gs.siteMetadata={};} //gs.siteMetadata ??= {};
18 if(typeof gs.collectionMetadata==="undefined"){gs.collectionMetadata={};} //gs.collectionMetadata ??= {};
19 if(typeof gs.documentMetadata==="undefined"){gs.documentMetadata={};} //gs.documentMetadata ??= {};
20 if(typeof gs.imageURLs==="undefined"){gs.imageURLs={};} //gs.imageURLs ??= {};
21 if(typeof gs.variables==="undefined"){gs.variables={};} //gs.variables ??= {};
22 if(typeof gs.requestInformation==="undefined"){gs.requestInformation={};} //gs.requestInformation ??= {};
23 </xsl:text>
24 </script>
25 <xsl:call-template name="populate-cgi-param-values"/>
26 <xsl:call-template name="populate-xslt-param-values"/>
27 <xsl:call-template name="populate-image-url-values"/>
28 <xsl:call-template name="populate-metadata-values"/>
29 <xsl:call-template name="populate-request-information-values"/>
30 <xsl:call-template name="populate-user-information-values"/>
31 <xsl:call-template name="include-global-javascript-functions"/>
32 </xsl:template>
33
34 <xsl:template name="populate-cgi-param-values">
35 <script type="text/javascript">
36 var name;
37 var value;
38 <xsl:for-each select="/page/pageRequest/paramList/param">
39 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
40 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesQuotesAngleBracketsForJSString(@value)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
41 <xsl:text disable-output-escaping="yes">name = name.replace(".", "_");</xsl:text>
42 gs.cgiParams[name] = value;
43 </xsl:for-each>
44 </script>
45 </xsl:template>
46
47 <xsl:template name="populate-xslt-param-values">
48 <script type="text/javascript">
49 <xsl:text disable-output-escaping="yes">gs.xsltParams.library_name = "</xsl:text><xsl:value-of select="$library_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
50 <xsl:text disable-output-escaping="yes">gs.xsltParams.interface_name = "</xsl:text><xsl:value-of select="$interface_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
51 <xsl:text disable-output-escaping="yes">gs.xsltParams.site_name = "</xsl:text><xsl:value-of select="$site_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
52 <xsl:text disable-output-escaping="yes">gs.xsltParams.use_client_side_xslt = "</xsl:text><xsl:value-of select="$use_client_side_xslt"/><xsl:text disable-output-escaping="yes">";</xsl:text>
53 <xsl:text disable-output-escaping="yes">gs.xsltParams.filepath = "</xsl:text><xsl:value-of select="$filepath"/><xsl:text disable-output-escaping="yes">";</xsl:text>
54 <xsl:text disable-output-escaping="yes">gs.xsltParams.cookie_path = "</xsl:text><xsl:choose><xsl:when test="$cookie_path"><xsl:value-of select="$cookie_path"/></xsl:when><xsl:otherwise><xsl:value-of select="$servlet_context"/></xsl:otherwise></xsl:choose><xsl:text disable-output-escaping="yes">";</xsl:text>
55 </script>
56 </xsl:template>
57
58 <xsl:template name="populate-metadata-values">
59 <script type="text/javascript">
60 <xsl:text disable-output-escaping="yes">
61 function addMetadataToList(name, value, list, lang)
62 {
63 name = name.replace(".", "_");
64 if(lang == "" || lang == "en")
65 {
66 list[name] = value;
67 }
68 else
69 {
70 if (list[lang] == undefined)
71 {
72 list[lang] = new Array();
73 }
74 var langList = list[lang];
75 langList[name] = value;
76 }
77 }
78 var name;
79 var value;
80 var lang;
81 </xsl:text>
82 <xsl:for-each select="/page/pageResponse/metadataList/metadata">
83 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
84 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesQuotesAngleBracketsForJSString(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
85 <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
86 addMetadataToList(name, value, gs.siteMetadata, lang);
87 </xsl:for-each>
88
89 <xsl:for-each select="/page/pageResponse/collection/metadataList/metadata">
90 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
91 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesQuotesAngleBracketsForJSString(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
92 <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
93 addMetadataToList(name, value, gs.collectionMetadata, lang);
94 </xsl:for-each>
95
96 <xsl:for-each select="/page/pageResponse/document/metadataList/metadata">
97 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
98 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesQuotesAngleBracketsForJSString(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
99 <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
100 addMetadataToList(name, value, gs.documentMetadata, lang);
101 </xsl:for-each>
102
103 <xsl:for-each select="/page/pageResponse/classifier/documentNode">
104 {
105 <xsl:text disable-output-escaping="yes">var nodeID = "</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">";</xsl:text>
106 <xsl:text disable-output-escaping="yes">var emptyLang = "";</xsl:text>
107 <xsl:text disable-output-escaping="yes">var metaList = new Array();</xsl:text>
108 <xsl:for-each select="metadataList/metadata">
109 <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
110 <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesQuotesAngleBracketsForJSString(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
111 <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
112 addMetadataToList(name, value, metaList, lang);
113 </xsl:for-each>
114 addMetadataToList(nodeID, metaList, gs.documentMetadata, emptyLang);
115 }
116 </xsl:for-each>
117
118 <xsl:text disable-output-escaping="yes">addMetadataToList("docType", "</xsl:text><xsl:value-of select="/page/pageResponse/document/@docType"/><xsl:text disable-output-escaping="yes">", gs.documentMetadata, "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">");</xsl:text>
119 </script>
120 </xsl:template>
121
122 <xsl:template name="populate-image-url-values">
123 <script type="text/javascript">
124 <xsl:text disable-output-escaping="yes">gs.imageURLs.expand = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
125 <xsl:text disable-output-escaping="yes">gs.imageURLs.collapse = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
126 <xsl:text disable-output-escaping="yes">gs.imageURLs.page = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
127 <xsl:text disable-output-escaping="yes">gs.imageURLs.chapter = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
128 <xsl:text disable-output-escaping="yes">gs.imageURLs.realisticBook = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
129 <xsl:text disable-output-escaping="yes">gs.imageURLs.highlight = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
130 <xsl:text disable-output-escaping="yes">gs.imageURLs.bookshelf = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
131 <xsl:text disable-output-escaping="yes">gs.imageURLs.book = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
132 <xsl:text disable-output-escaping="yes">gs.imageURLs.loading = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'loading_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
133 <xsl:text disable-output-escaping="yes">gs.imageURLs.pageIcon = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
134 <xsl:text disable-output-escaping="yes">gs.imageURLs.trashFull = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'trash_full_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
135 <xsl:text disable-output-escaping="yes">gs.imageURLs.blank = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'blank_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
136 <xsl:text disable-output-escaping="yes">gs.imageURLs.next = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'next_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
137 <xsl:text disable-output-escaping="yes">gs.imageURLs.prev = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'prev_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
138 <xsl:text disable-output-escaping="yes">gs.imageURLs.trashEmpty = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'trash_empty_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
139 <xsl:text disable-output-escaping="yes">gs.imageURLs.trashFull = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'trash_full_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
140 <xsl:text disable-output-escaping="yes">gs.imageURLs.greenBug = "</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'green_bug_image')"/><xsl:text disable-output-escaping="yes">";</xsl:text>
141 </script>
142 </xsl:template>
143
144 <xsl:template name="populate-request-information-values">
145 <script type="text/javascript">
146 <xsl:text disable-output-escaping="yes">
147 gs.requestInformation.fullURL = "</xsl:text><xsl:value-of select="/page/pageRequest/@fullURL"/><xsl:text disable-output-escaping="yes">";
148 </xsl:text>
149 </script>
150 </xsl:template>
151
152 <xsl:template name="populate-user-information-values">
153 <xsl:if test="/page/pageRequest/userInformation">
154 <script type="text/javascript">
155 <xsl:text disable-output-escaping="yes">
156 gs.userInformation = new Array();
157 gs.userInformation.username = "</xsl:text><xsl:value-of select="/page/pageRequest/userInformation/@username"/><xsl:text disable-output-escaping="yes">";
158 gs.userInformation.groups = "</xsl:text><xsl:value-of select="/page/pageRequest/userInformation/@groups"/><xsl:text disable-output-escaping="yes">";
159 gs.userInformation.editEnabled = "</xsl:text><xsl:value-of select="/page/pageRequest/userInformation/@editEnabled"/><xsl:text disable-output-escaping="yes">";
160 </xsl:text>
161 </script>
162 </xsl:if>
163 </xsl:template>
164
165 <xsl:template name="include-global-javascript-functions">
166 <script type="text/javascript" src="interfaces/{$interface_name}/js/javascript-global-functions.js"><xsl:text> </xsl:text></script>
167 <script type="text/javascript" src="interfaces/{$interface_name}/js/GSMetadata.js"><xsl:text> </xsl:text></script>
168 <script type="text/javascript" src="interfaces/{$interface_name}/js/utility_scripts.js"><xsl:text> </xsl:text></script>
169
170 </xsl:template>
171</xsl:stylesheet>
172
173 <!-- CAN WE FIND SOME WAY TO MAKE THIS WORK?
174 <xsl:call-template name="populate-metadata-values">
175 <xsl:with-param name="path">/page/pageResponse/metadataList/metadata</xsl:with-param>
176 <xsl:with-param name="metadataListName">siteMetadata</xsl:with-param>
177 </xsl:call-template>
178
179 <xsl:call-template name="populate-metadata-values">
180 <xsl:with-param name="path">/page/pageResponse/collection/metadataList/metadata</xsl:with-param>
181 <xsl:with-param name="metadataListName">collectionMetadata</xsl:with-param>
182 </xsl:call-template>
183
184 <xsl:call-template name="populate-metadata-values">
185 <xsl:with-param name="path">/page/pageResponse/document/metadataList/metadata</xsl:with-param>
186 <xsl:with-param name="metadataListName">documentMetadata</xsl:with-param>
187 </xsl:call-template>
188 -->
189
190 <!-- NOT WORKING BUT IT WOULD BE TIDIER IF IT DID
191 <xsl:template name="populate-metadata-values">
192 <xsl:param name="path"/>
193 <xsl:param name="metadataListName"/>
194
195 <xsl:for-each select="$path">
196 <script type="text/javascript">
197 <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
198 <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
199 <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
200 <xsl:text disable-output-escaping="yes">var metadataListName = "</xsl:text><xsl:value-of select="$metadataListName"/><xsl:text disable-output-escaping="yes">";</xsl:text>
201 var list = gs[metadataListName];
202 if(lang == "")
203 {
204 list[name] = value;
205 }
206 else
207 {
208 if (list[lang] == undefined)
209 {
210 list[lang] = new Array();
211 }
212 var langList = list[lang];
213 langList[name] = value;
214 }
215 </script>
216 </xsl:for-each>
217 </xsl:template>
218 -->
Note: See TracBrowser for help on using the repository browser.