summaryrefslogtreecommitdiffstats
path: root/xslt/report-templates/Tri-Column.xsl
blob: 3323a2c883b1d66b9de1196cb9ff149b02b08743 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:tc="http://periapsis.org/tellico/"
                xmlns:exsl="http://exslt.org/common"
                extension-element-prefixes="exsl"
                exclude-result-prefixes="tc"
                version="1.0">

<!--
   ===================================================================
   Tellico XSLT file - Tri-Column Report
                       Modified from VideoDB

   Copyright (C) 2005-2006 Robby Stephenson - robby@periapsis.org

   This XSLT stylesheet is designed to be used with the 'Tellico'
   application, which can be found at http://www.periapsis.org/tellico/

   ===================================================================
-->

<!-- import common templates -->
<!-- location depends on being installed correctly -->
<xsl:import href="../tellico-common.xsl"/>

<xsl:output method="html"
            indent="yes"
            doctype-public="-//W3C//DTD HTML 4.01//EN"
            doctype-system="http://www.w3.org/TR/html4/strict.dtd"
            encoding="utf-8"/>

<xsl:param name="filename"/>
<xsl:param name="cdate"/>

<!-- Sort using user's preferred language -->
<xsl:param name="lang"/>

<xsl:variable name="image-field" select="tc:tellico/tc:collection[1]/tc:fields/tc:field[@type=10][1]/@name"/>

<!-- set the maximum image size -->
<xsl:param name="image-height" select="'150'"/>
<xsl:param name="image-width"  select="'150'"/>

<xsl:param name="datadir"/> <!-- dir where Tellico data files are located -->
<xsl:param name="imgdir"/> <!-- dir where field images are located -->

<xsl:key name="imagesById" match="tc:image" use="@id"/>

<xsl:template match="/">
 <xsl:apply-templates select="tc:tellico"/>
</xsl:template>

<xsl:template match="tc:tellico">
 <html>
  <head>
   <style type="text/css">
   body {
        font-family: sans-serif;
        background-color: #fff;
        color: #000;
   }
   #header-left {
        margin-top: 0;
        float: left;
        font-size: 80%;
        font-style: italic;
   }
   #header-right {
        margin-top: 0;
        float: right;
        font-size: 80%;
        font-style: italic;
   }
   h1.colltitle {
        margin: 0px;
        padding-bottom: 5px;
        font-size: 2em;
        text-align: center;
  }
   tr.r0 {
        border: 1px inset #666;
        background-color: #eee;
   }
   tr.r1 {
        border: 1px inset #666;
        background-color: #ddd;
   }
   img.float {
        float: left;
        margin-right: 10px;
        margin-bottom: 10px;
        border: 2px outset #ccc;
   }
   td {
        vertical-align: top;
   }
   span.title {
       font-size: 1.2em;
       font-weight: bold;
   }
   span.info {
       font-size: 1.1em;
       font-style italic;
       color: #006;
   }
   span.plot {
       font-size: 1em;
   }
   </style>
   <title>Tellico</title>
  </head>
  <body>
   <xsl:apply-templates select="tc:collection"/>
  </body>
 </html>
</xsl:template>

<xsl:template match="tc:collection[@type!=3]">
 <h1 class="colltitle">
  <i18n>This template is meant for video collections only.</i18n>
 </h1>
</xsl:template>

<xsl:template match="tc:collection[@type=3]">
 <p id="header-left"><xsl:value-of select="$filename"/></p>
 <p id="header-right"><xsl:value-of select="$cdate"/></p>
 <h1 class="colltitle">
  <xsl:value-of select="@title"/>
 </h1>
 
 <!-- first, build sorted list -->
 <xsl:variable name="sorted-entries">
  <xsl:for-each select="tc:entry">
   <xsl:sort lang="$lang" select=".//tc:title[1]"/>
   <xsl:copy-of select="."/>
  </xsl:for-each>
 </xsl:variable>
 
 <!-- needed for key context -->
 <xsl:variable name="coll" select="."/>
 
 <table class="tablelist" cellpadding="0" cellspacing="0" width="100%">
   <colgroup width="33%"/>
   <colgroup width="34%"/>
   <colgroup width="33%"/>
  <tbody>
   <!-- three columns -->
   <!-- have to pass in image width and height because
        context changes inside the exsl:node-set -->
   <xsl:variable name="entries" select="exsl:node-set($sorted-entries)/tc:entry"/>
   
   <xsl:for-each select="$entries[position() mod 3 = 1]">
    <xsl:variable name="e1" select="."/>
    <xsl:variable name="e2" select="$e1/following-sibling::tc:entry[position() = 1]"/>
    <xsl:variable name="e3" select="$e2/following-sibling::tc:entry[position() = 1]"/>
    
    <tr class="r{position() mod 2}">
     
     <!-- switch context back to document -->
     <xsl:for-each select="$coll">
      
      <td>
       <xsl:apply-templates select="$e1">
        <xsl:with-param name="img" select="key('imagesById', $e1/*[local-name() = $image-field])"/>
       </xsl:apply-templates>
      </td>
      <td>
       <xsl:apply-templates select="$e2">
        <xsl:with-param name="img" select="key('imagesById', $e2/*[local-name() = $image-field])"/>
       </xsl:apply-templates>
      </td>
      <td>
       <xsl:apply-templates select="$e3">
        <xsl:with-param name="img" select="key('imagesById', $e3/*[local-name() = $image-field])"/>
       </xsl:apply-templates>
      </td>
     </xsl:for-each>
    </tr>
   </xsl:for-each>
   
  </tbody>
 </table>
 
</xsl:template>

<xsl:template match="tc:entry">
 <xsl:param name="img"/>
 <table>
  <tbody>
   <tr>
    <td>
     <xsl:variable name="id" select="./*[local-name() = $image-field]"/>
     <xsl:if test="$id">
      <img class="float" alt=" ">
       <xsl:attribute name="src">
        <xsl:call-template name="image-link">
         <xsl:with-param name="image" select="key('imagesById', $id)"/>
         <xsl:with-param name="dir" select="$imgdir"/>
        </xsl:call-template>
       </xsl:attribute>
       <xsl:call-template name="image-size">
        <xsl:with-param name="limit-width" select="$image-width"/>
        <xsl:with-param name="limit-height" select="$image-height"/>
        <xsl:with-param name="image" select="$img"/>
       </xsl:call-template>
      </img>
     </xsl:if>
    </td>
    <td>
     <span class="title">
      <xsl:value-of select=".//tc:title[1]"/>
     </span>
     <br/>
     <span class="info">
      <xsl:text>[</xsl:text>
      <xsl:value-of select=".//tc:year[1]"/>
      <xsl:text>; </xsl:text>
      <xsl:value-of select=".//tc:director[1]"/>
      <xsl:text>]</xsl:text>
     </span>
     <br/>
     <span class="plot">
      <xsl:value-of select="normalize-space(substring(./tc:plot, 1, 150))" disable-output-escaping="yes"/>
      <xsl:text>&#xa0;&#x2026;</xsl:text>
     </span>
    </td>
   </tr>
  </tbody>
 </table>
</xsl:template>

</xsl:stylesheet>

<!-- Local Variables: -->
<!-- sgml-indent-step: 1 -->
<!-- sgml-indent-data: 1 -->
<!-- End: -->