root/main/trunk/greenstone3/web/interfaces/default/transform/javascript-global-setup.xsl @ 26211

Revision 26211, 11.0 KB (checked in by sjm84, 8 years ago)

Added back an image that I accidentally removed last time I edited this file

  • Property svn:executable set to *
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            gs = new Array();
12            gs.cgiParams = new Array();
13            gs.xsltParams = new Array();
14            gs.siteMetadata = new Array();
15            gs.collectionMetadata = new Array();
16            gs.documentMetadata = new Array();
17            gs.imageURLs = new Array();
18            gs.variables = new Array();
19            gs.requestInformation = new Array();
20        </script>
21        <xsl:call-template name="populate-cgi-param-values"/>
22        <xsl:call-template name="populate-xslt-param-values"/>
23        <xsl:call-template name="populate-image-url-values"/>
24        <xsl:call-template name="populate-metadata-values"/>
25        <xsl:call-template name="populate-request-information-values"/>
26        <xsl:call-template name="include-global-javascript-functions"/>
27    </xsl:template>
28   
29    <xsl:template name="populate-cgi-param-values">
30        <script type="text/javascript">
31            var name;
32            var value;
33            <xsl:for-each select="/page/pageRequest/paramList/param">
34                <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
35                <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of select="util:escapeNewLinesAndQuotes(@value)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
36                <xsl:text disable-output-escaping="yes">name = name.replace(".", "_");</xsl:text>
37                gs.cgiParams[name] = value;
38            </xsl:for-each>
39        </script>
40    </xsl:template>
41   
42    <xsl:template name="populate-xslt-param-values">
43        <script type="text/javascript">
44            <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>
45            <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>
46            <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>
47        </script>
48    </xsl:template>
49   
50    <xsl:template name="populate-metadata-values">
51        <script type="text/javascript">
52            <xsl:text disable-output-escaping="yes">
53                function addMetadataToList(name, value, list, lang)
54                {
55                    name = name.replace(".", "_");
56                    if(lang == "" || lang == "en")
57                    {
58                        list[name] = value;
59                    }
60                    else
61                    {
62                        if (list[lang] == undefined)
63                        {
64                            list[lang] = new Array();
65                        }
66                        var langList = list[lang];
67                        langList[name] = value;
68                    }
69                }
70                var name;
71                var value;
72                var lang;
73            </xsl:text>
74            <xsl:for-each select="/page/pageResponse/metadataList/metadata">
75                <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
76                <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesAndQuotes(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
77                <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
78                addMetadataToList(name, value, gs.siteMetadata, lang);
79            </xsl:for-each>
80       
81            <xsl:for-each select="/page/pageResponse/collection/metadataList/metadata">
82                <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
83                <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesAndQuotes(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
84                <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
85                addMetadataToList(name, value, gs.collectionMetadata, lang);
86            </xsl:for-each>
87       
88            <xsl:for-each select="/page/pageResponse/document/metadataList/metadata">
89                <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
90                <xsl:text disable-output-escaping="yes">value = "</xsl:text><xsl:value-of disable-output-escaping="yes" select="util:escapeNewLinesAndQuotes(.)"/><xsl:text disable-output-escaping="yes">";</xsl:text>
91                <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
92                addMetadataToList(name, value, gs.documentMetadata, lang);
93            </xsl:for-each>
94           
95            <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>
96        </script>
97    </xsl:template>
98   
99    <xsl:template name="populate-image-url-values">
100        <script type="text/javascript">
101            <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>
102            <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>
103            <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>
104            <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>
105            <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>
106            <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>
107            <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>
108            <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>
109            <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>
110            <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>
111            <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>
112            <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>
113            <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>
114            <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>
115        </script>
116    </xsl:template>
117   
118    <xsl:template name="populate-request-information-values">
119        <script type="text/javascript">
120            <xsl:text disable-output-escaping="yes">
121                gs.requestInformation.fullURL = "</xsl:text><xsl:value-of select="/page/pageRequest/@fullURL"/><xsl:text disable-output-escaping="yes">";
122            </xsl:text>
123        </script>
124    </xsl:template>
125   
126    <xsl:template name="include-global-javascript-functions">
127        <script type="text/javascript" src="interfaces/default/js/javascript-global-functions.js"><xsl:text> </xsl:text></script>
128        <script type="text/javascript" src="interfaces/default/js/GSMetadata.js"><xsl:text> </xsl:text></script>
129    </xsl:template>
130</xsl:stylesheet>
131
132    <!-- CAN WE FIND SOME WAY TO MAKE THIS WORK?
133    <xsl:call-template name="populate-metadata-values">
134        <xsl:with-param name="path">/page/pageResponse/metadataList/metadata</xsl:with-param>
135        <xsl:with-param name="metadataListName">siteMetadata</xsl:with-param>
136    </xsl:call-template>
137   
138    <xsl:call-template name="populate-metadata-values">
139        <xsl:with-param name="path">/page/pageResponse/collection/metadataList/metadata</xsl:with-param>
140        <xsl:with-param name="metadataListName">collectionMetadata</xsl:with-param>
141    </xsl:call-template>
142   
143    <xsl:call-template name="populate-metadata-values">
144        <xsl:with-param name="path">/page/pageResponse/document/metadataList/metadata</xsl:with-param>
145        <xsl:with-param name="metadataListName">documentMetadata</xsl:with-param>
146    </xsl:call-template>
147    -->
148
149    <!-- NOT WORKING BUT IT WOULD BE TIDIER IF IT DID
150    <xsl:template name="populate-metadata-values">
151        <xsl:param name="path"/>
152        <xsl:param name="metadataListName"/>
153       
154        <xsl:for-each select="$path">
155            <script type="text/javascript">
156                <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
157                <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
158                <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
159                <xsl:text disable-output-escaping="yes">var metadataListName = "</xsl:text><xsl:value-of select="$metadataListName"/><xsl:text disable-output-escaping="yes">";</xsl:text>
160                var list = gs[metadataListName];
161                if(lang == "")
162                {
163                    list[name] = value;
164                }
165                else
166                {
167                    if (list[lang] == undefined)
168                    {
169                        list[lang] = new Array();
170                    }
171                    var langList = list[lang];
172                    langList[name] = value;
173                }
174            </script>
175        </xsl:for-each>
176    </xsl:template>
177    -->
Note: See TracBrowser for help on using the browser.