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

Revision 27029, 12.6 KB (checked in by sjm84, 7 years ago)

Adding a new image

  • 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:for-each select="/page/pageResponse/classifier/documentNode">
96                {
97                <xsl:text disable-output-escaping="yes">var nodeID = "</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">";</xsl:text>
98                <xsl:text disable-output-escaping="yes">var emptyLang = "";</xsl:text>
99                <xsl:text disable-output-escaping="yes">var metaList = new Array();</xsl:text>
100                <xsl:for-each select="metadataList/metadata">
101                    <xsl:text disable-output-escaping="yes">name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
102                    <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>
103                    <xsl:text disable-output-escaping="yes">lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
104                    addMetadataToList(name, value, metaList, lang);
105                </xsl:for-each>
106                addMetadataToList(nodeID, metaList, gs.documentMetadata, emptyLang);
107                }
108            </xsl:for-each>
109           
110            <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>
111        </script>
112    </xsl:template>
113   
114    <xsl:template name="populate-image-url-values">
115        <script type="text/javascript">
116            <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>
117            <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>
118            <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>
119            <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>
120            <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>
121            <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>
122            <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>
123            <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>
124            <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>
125            <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>
126            <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>
127            <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>
128            <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>
129            <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>
130            <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>
131            <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>
132        </script>
133    </xsl:template>
134   
135    <xsl:template name="populate-request-information-values">
136        <script type="text/javascript">
137            <xsl:text disable-output-escaping="yes">
138                gs.requestInformation.fullURL = "</xsl:text><xsl:value-of select="/page/pageRequest/@fullURL"/><xsl:text disable-output-escaping="yes">";
139            </xsl:text>
140        </script>
141    </xsl:template>
142   
143    <xsl:template name="include-global-javascript-functions">
144        <script type="text/javascript" src="interfaces/default/js/javascript-global-functions.js"><xsl:text> </xsl:text></script>
145        <script type="text/javascript" src="interfaces/default/js/GSMetadata.js"><xsl:text> </xsl:text></script>
146    </xsl:template>
147</xsl:stylesheet>
148
149    <!-- CAN WE FIND SOME WAY TO MAKE THIS WORK?
150    <xsl:call-template name="populate-metadata-values">
151        <xsl:with-param name="path">/page/pageResponse/metadataList/metadata</xsl:with-param>
152        <xsl:with-param name="metadataListName">siteMetadata</xsl:with-param>
153    </xsl:call-template>
154   
155    <xsl:call-template name="populate-metadata-values">
156        <xsl:with-param name="path">/page/pageResponse/collection/metadataList/metadata</xsl:with-param>
157        <xsl:with-param name="metadataListName">collectionMetadata</xsl:with-param>
158    </xsl:call-template>
159   
160    <xsl:call-template name="populate-metadata-values">
161        <xsl:with-param name="path">/page/pageResponse/document/metadataList/metadata</xsl:with-param>
162        <xsl:with-param name="metadataListName">documentMetadata</xsl:with-param>
163    </xsl:call-template>
164    -->
165
166    <!-- NOT WORKING BUT IT WOULD BE TIDIER IF IT DID
167    <xsl:template name="populate-metadata-values">
168        <xsl:param name="path"/>
169        <xsl:param name="metadataListName"/>
170       
171        <xsl:for-each select="$path">
172            <script type="text/javascript">
173                <xsl:text disable-output-escaping="yes">var name = "</xsl:text><xsl:value-of select="@name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
174                <xsl:text disable-output-escaping="yes">var value = "</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">";</xsl:text>
175                <xsl:text disable-output-escaping="yes">var lang = "</xsl:text><xsl:value-of select="@lang"/><xsl:text disable-output-escaping="yes">";</xsl:text>
176                <xsl:text disable-output-escaping="yes">var metadataListName = "</xsl:text><xsl:value-of select="$metadataListName"/><xsl:text disable-output-escaping="yes">";</xsl:text>
177                var list = gs[metadataListName];
178                if(lang == "")
179                {
180                    list[name] = value;
181                }
182                else
183                {
184                    if (list[lang] == undefined)
185                    {
186                        list[lang] = new Array();
187                    }
188                    var langList = list[lang];
189                    langList[name] = value;
190                }
191            </script>
192        </xsl:for-each>
193    </xsl:template>
194    -->
Note: See TracBrowser for help on using the browser.