root/other-projects/tipple-android/i-greenstone-server-files/greenstone/webapps/greenstone3/interfaces/gs2/transform/style.xsl @ 26899

Revision 26899, 11.6 KB (checked in by davidb, 7 years ago)

Tipple reborn after Chris's Summer of Code 2013

  • Property svn:mime-type set to application/xml
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
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  extension-element-prefixes="java util"
8  exclude-result-prefixes="java util">
9 
10  <xsl:include href="icons.xsl"/>
11
12  <!-- some global parameters - these are set by whoever is invoking the transformation -->
13  <xsl:param name="interface_name"/>
14  <xsl:param name="library_name"/>
15
16  <!-- any global style stuff should go in here -->
17  <xsl:template name="response">
18    <xsl:apply-templates select="pageResponse"/>
19    <xsl:if test="descendant::error">
20      <script language="Javascript">
21    <xsl:text disable-output-escaping="yes">
22      function removeAllChildren(node) {
23        while (node.hasChildNodes()) {
24          node.removeChild(node.firstChild);
25        }
26      }
27
28      function toggleHideError(obj) {
29        if (obj.style.display == "none") {
30          obj.style.display = "";
31          hide_link = document.getElementById("hide");
32          removeAllChildren(hide_link);
33          hide_link.appendChild(document.createTextNode("</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'hide_error')"/><xsl:text disable-output-escaping="yes">"));
34        } else {
35          obj.style.display = "none";
36          hide_link = document.getElementById("hide");
37          removeAllChildren(hide_link);
38          hide_link.appendChild(document.createTextNode("</xsl:text><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'show_error')"/><xsl:text disable-output-escaping="yes">"));
39        }
40      }
41    </xsl:text>
42      </script>
43      <p align='right'><a id="hide" href="javascript:toggleHideError(error);"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'show_error')"/></a></p>
44      <div id="error" style="display: none;">
45    <xsl:apply-templates select="descendant::error"/>
46      </div>
47    </xsl:if>
48  </xsl:template>
49
50  <xsl:template name="globalStyle">
51    <link rel="stylesheet" href="interfaces/gs2/style/gs2-style.css" type="text/css"/>
52    <link rel="stylesheet" href="interfaces/gs2/style/gs2-style2.css" type="text/css"/>
53  </xsl:template>
54 
55  <xsl:template name="genericPageBanner">
56    <xsl:param name='text'/>
57    <xsl:variable name="lang" select="/page/@lang"/>
58    <center>
59      <table width="100%">
60    <tr><td align="left"></td>
61      <td align="right">
62        <table>
63          <tr><td class="gsbutton">
64          <a class="gsbutton" href="{$library_name}?a=p&amp;sa=home">
65            <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_b')"/>
66          </a>
67        </td></tr></table>
68      </td>
69    </tr>
70      </table>
71    </center>
72    <xsl:call-template name="dividerBar"><xsl:with-param name='text' select="$text"/></xsl:call-template>
73  </xsl:template>
74 
75  <xsl:template name="standardPageBanner">
76    <xsl:param name="collName"/>
77    <xsl:param name="pageType"/>
78    <xsl:param name="clTop"/>
79    <xsl:variable name="this-element" select="/page/pageResponse/collection"/>
80    <div id="banner">
81      <div class="pageinfo">
82    <xsl:call-template name="top-buttons">
83      <xsl:with-param name="collName" select="$collName"/>
84      <xsl:with-param name="pageType" select="$pageType"/>
85    </xsl:call-template>
86    <xsl:if test="not(/page/pageRequest/@action='d')">
87      <xsl:variable name="text">
88        <xsl:choose>
89          <xsl:when test="$pageType='browse'">
90        <xsl:value-of select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier[@name=$clTop]/displayItem[@name='name']"/>
91          </xsl:when>
92          <xsl:otherwise>
93        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, concat($pageType, '_t'))"/>
94          </xsl:otherwise>
95        </xsl:choose>
96      </xsl:variable>
97      <xsl:if test="$text != '__t_'">
98        <p class="bannertitle"><xsl:value-of select="$text"/></p>
99      </xsl:if>
100    </xsl:if>
101      </div>
102
103      <div class="collectimage">
104    <a href="{$library_name}?a=p&amp;sa=about&amp;c={$collName}">
105      <xsl:choose>
106        <xsl:when test="$this-element/displayItem[@name='icon']">
107          <img border="0">
108        <xsl:attribute name="src">
109          <xsl:value-of select="$this-element/metadataList/metadata[@name='httpPath']"/>/images/<xsl:value-of select="$this-element/displayItem[@name='icon']"/>
110        </xsl:attribute>   
111        <xsl:attribute name="alt">
112          <xsl:value-of select="$this-element/displayItem[@name='name']"/>
113        </xsl:attribute>
114        <xsl:attribute name="title">
115          <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'aboutpage')"/>
116        </xsl:attribute>
117          </img>
118        </xsl:when>
119        <xsl:otherwise>
120          <b><xsl:value-of select="$this-element/displayItem[@name='name']"/></b>
121        </xsl:otherwise>
122      </xsl:choose>
123    </a>
124      </div>
125    </div>
126    <div class="bannerextra"></div>
127  </xsl:template>
128 
129  <xsl:template name="top-buttons">
130    <xsl:param name="collName"/>
131    <xsl:param name="pageType"/>
132    <p class="bannerlinks">
133      <a class="navlink" href="{$library_name}?a=p&amp;sa=home"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_tip')"/></xsl:attribute>
134    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_b')"/>
135      </a>
136      <!--<xsl:choose>
137        <xsl:when test="$pageType='help'">
138      <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/>
139    </xsl:when>
140    <xsl:otherwise>
141      <a class="navlink" href="{$library_name}?a=p&amp;sa=help&amp;c={$collName}"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_tip')"/></xsl:attribute>
142        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/>
143      </a>
144    </xsl:otherwise>
145      </xsl:choose> -->
146      <xsl:choose>
147    <xsl:when test="$pageType='pref'">
148      <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/>
149    </xsl:when>
150    <xsl:otherwise>
151      <a class="navlink" href="{$library_name}?a=p&amp;sa=pref&amp;c={$collName}"><xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/></xsl:attribute>
152        <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/>
153      </a>
154    </xsl:otherwise>
155      </xsl:choose>     
156    </p>
157  </xsl:template>
158 
159  <xsl:template name="navigationBar">
160    <xsl:param name="collName"/>
161    <xsl:param name="clTop"/>
162    <xsl:variable name="this-element" select="/page/pageResponse/collection"/>
163    <xsl:variable name="this-service" select="/page/pageResponse/service/@name"/>
164    <xsl:variable name="classifiers" select="$this-element/serviceList/service[@name='ClassifierBrowse']/classifierList[1]"/>
165
166    <!-- display order, for Arabic etc. languages, display right to left -->
167    <xsl:variable name="dir"><xsl:call-template name="direction"/></xsl:variable>
168    <xsl:variable name="sort_order"><xsl:choose><xsl:when test="$dir='rtl'">descending</xsl:when><xsl:otherwise>ascending</xsl:otherwise></xsl:choose></xsl:variable>       
169
170    <div class="navbar">
171      <p class="navbar">
172    <xsl:choose>
173      <xsl:when test="not($dir='rtl')">
174        <xsl:if test="$this-element/serviceList/service[@type='query']">
175          <xsl:call-template name="navbar-search"><xsl:with-param name="collName" select="$collName"/></xsl:call-template>
176        </xsl:if>
177      </xsl:when>
178      <xsl:otherwise>
179        <xsl:if test="$this-element/serviceList/service[@name='PhindApplet']">
180          <xsl:call-template name="navbar-phind"><xsl:with-param name="collName" select="$collName"/></xsl:call-template>
181        </xsl:if>
182      </xsl:otherwise>
183    </xsl:choose>
184
185    <xsl:for-each select="$classifiers/classifier">
186      <xsl:sort order="{$sort_order}" select="position()" />
187      <xsl:apply-templates select="." mode="navbar">
188        <xsl:with-param name="collName" select="$collName"/>
189        <xsl:with-param name="clTop" select="$clTop"/>
190      </xsl:apply-templates>
191    </xsl:for-each>
192   
193    <xsl:choose>   
194      <xsl:when test="$dir='rtl'">
195        <xsl:if test="$this-element/serviceList/service[@type='query']">
196          <xsl:call-template name="navbar-search"><xsl:with-param name="collName" select="$collName"/></xsl:call-template>
197        </xsl:if>
198      </xsl:when>
199      <xsl:otherwise>
200        <xsl:if test="$this-element/serviceList/service[@name='PhindApplet']">
201          <xsl:call-template name="navbar-phind"><xsl:with-param name="collName" select="$collName"/></xsl:call-template>
202        </xsl:if>
203      </xsl:otherwise>
204    </xsl:choose>
205      </p>
206    </div>
207  </xsl:template>
208
209  <xsl:template name="navbar-search">
210    <xsl:param name="collName"/>
211    <xsl:choose>
212      <xsl:when test="/page/pageRequest/@action='q'">     
213    <span class="narspace">search</span>
214      </xsl:when>
215      <xsl:otherwise>
216    <xsl:variable name="service">
217      <xsl:choose>
218        <xsl:when  test="not(/page/pageRequest/paramList/param[@name='ct'])">TextQuery</xsl:when>
219        <xsl:when test="/page/pageRequest/paramList/param[@name='ct']/@value='0'">TextQuery</xsl:when>
220        <xsl:when test="/page/pageRequest/paramList/param[@name='qt']/@value='1'"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qfm']/@value='1'">AdvancedFieldQuery</xsl:when><xsl:otherwise>FieldQuery</xsl:otherwise></xsl:choose></xsl:when>
221        <xsl:otherwise>TextQuery</xsl:otherwise>
222      </xsl:choose>
223    </xsl:variable>
224    <a class="navlink" href="{$library_name}?a=q&amp;rt=d&amp;s={$service}&amp;c={$collName}"><xsl:attribute name='title'><xsl:value-of select="/page/pageResponse/collection/service[@name=$service]/displayItem[@name='description']"/></xsl:attribute>search</a>
225      </xsl:otherwise>
226    </xsl:choose>
227  </xsl:template>
228 
229  <xsl:template name="navbar-phind">
230    <xsl:param name="collName"/>
231    <xsl:choose>
232      <xsl:when test="/page/pageRequest/paramList/param[@name='s']/@value='PhindApplet'">
233    <span class="narspace">phrases</span>
234      </xsl:when>
235      <xsl:otherwise>
236    <a class="navlink" href="{$library_name}?a=a&amp;rt=d&amp;s=PhindApplet&amp;c={$collName}"><xsl:if test="/page/pageResponse/collection/service[@name='PhindApplet']/displayItem[@name='description']"><xsl:attribute name='title'><xsl:value-of select="/page/pageResponse/collection/service[@name='PhindApplet']/displayItem[@name='description']"/></xsl:attribute></xsl:if>phrases</a>
237      </xsl:otherwise>
238    </xsl:choose>
239  </xsl:template>
240
241  <xsl:template match="classifier" mode="navbar">
242    <xsl:param name="collName"/>
243    <xsl:param name="clTop"/>
244    <xsl:choose>
245      <xsl:when test="/page/pageRequest/@action='b' and $clTop=@name">
246    <span class="narspace"><xsl:value-of select="displayItem[@name='name']"/></span>
247      </xsl:when>
248      <xsl:otherwise>
249    <a class="navlink" href="{$library_name}?a=b&amp;rt=r&amp;s=ClassifierBrowse&amp;c={$collName}&amp;cl={@name}"><xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute><xsl:value-of select="displayItem[@name='name']"/></a>
250      </xsl:otherwise>
251    </xsl:choose>
252  </xsl:template>
253
254  <xsl:template name="dividerBar">   
255    <xsl:param name='text'/>
256    <xsl:choose>
257      <xsl:when test="$text">
258    <div class="divbar"><p class="navbar"><xsl:value-of select="$text"/></p></div>
259      </xsl:when>
260      <xsl:otherwise>
261    <div class="divbar"><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></div>
262      </xsl:otherwise>
263    </xsl:choose>
264  </xsl:template>
265 
266  <xsl:template name="greenstoneFooter">
267    <div class="divbar"><p class="navbar">powered by greenstone3</p>
268    </div>
269  </xsl:template> 
270
271  <xsl:template name="direction">
272    <xsl:if test="/page/@lang='ar' or /page/@lang='fa' or /page/@lang='he' or /page/@lang='ur' or /page/@lang='ps' or /page/@lang='prs'">rtl</xsl:if>
273  </xsl:template>
274
275</xsl:stylesheet> 
Note: See TracBrowser for help on using the browser.