File: group_view.xsl

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (403 lines) | stat: -rw-r--r-- 17,318 bytes parent folder | download | duplicates (2)
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<?xml version="1.0"?>
<!--
 -
 -  $Id$
 -
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -
 -  Copyright (C) 1998-2018 OpenLink Software
 -
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -
-->
<!-- news group list control; two states in main page and on the other pages
     Despite it's name, this is actually the control listing articles in a group, not the groups -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:v="http://www.openlinksw.com/vspx/"
                xmlns:vm="http://www.openlinksw.com/vspx/weblog/"
                version="1.0">
  <xsl:template match="vm:group-view">
    <v:variable name="old_view" type="int" default="10" />
    <v:variable persist="temp" name="r_count" type="integer" default="0"/>
    <v:variable name="art_id" type="varchar"/>
    <v:variable name="order_by_str" type="varchar"/>
    <v:variable name="order_way_str" type="varchar"/>
    <v:variable name="prev_order_way_str" type="varchar"/>
    <v:variable name="order_full_str" type="varchar"/>

    <v:on-init>
      <![CDATA[
       declare order_full_str varchar;
       
       self.order_by_str:='';
       
       self.order_by_str       := get_keyword('order_by', self.vc_event.ve_params,'date');
       self.order_way_str      := get_keyword('order_way', self.vc_event.ve_params,'');
       self.prev_order_way_str := get_keyword('prev_order_way', self.vc_event.ve_params,'');

        if (self.order_way_str='' )
        {
          self.order_way_str:='ASC';
          if (self.order_by_str='date')
            self.order_way_str:='DESC';
       }
        if (self.prev_order_way_str='')
          self.prev_order_way_str:=self.order_way_str;
       self.order_full_str:=' order by ';
       self.order_full_str:=self.order_full_str||(case when self.order_by_str='date'    then '_date'
                                                       when self.order_by_str='creator' then '_from'
                                                       when self.order_by_str='subject' then  '_subj'
                                                       else '_date'
                                                  end);

       self.order_full_str:=self.order_full_str||' '||self.order_way_str;


      ]]>
    </v:on-init>
    <v:before-data-bind>
      <![CDATA[
  self.grp_sel_no_thr := get_keyword ('group', params);
  self.grp_sel_thr := self.grp_sel_no_thr;
  self.article_list_lenght := atoi (get_keyword ('view', params, '10'));
  self.old_view := atoi (get_keyword ('old_view', params, '10'));
  self.cur_art := get_keyword ('disp_artic', params, null);

  declare cancel_article varchar;
  cancel_article := get_keyword ('cancel_artic', params, '');
  if (cancel_article <> '')
    {
      declare h vspx_data_set;
      declare g vspx_data_source;
      ns_delete_message (cancel_article, 1);
      g := udt_get (self, 'dss');
      g.ds_rows_offs := 0;
      g.vc_data_bind (e);
      h := udt_get (self, 'ds_list_message');
      h.vc_reset ();
      h.vc_data_bind (e);
    }
      ]]>
    </v:before-data-bind>
    <v:after-data-bind>
      <![CDATA[
  self.art_id := get_keyword ('disp_artic', self.vc_page.vc_event.ve_params, '-');
      ]]>
    </v:after-data-bind>

  <script type="text/javascript">
    <![CDATA[
    function setOrderParams(orderBy,orderWay,prevOrderWay)
    {

      document.getElementById('order_by').value=orderBy;
      document.getElementById('order_way').value=orderWay;
      document.getElementById('prev_order_way').value=prevOrderWay;
      
      doPost('nntpf','ds_list_message_pager_1');
    }
    ]]>
  </script>

    <v:data-source nrows="--self.article_list_lenght"
                   initial-offset="0"
                   name="dss"
                   data="--nntpf_group_list_v_data (self.grp_sel_no_thr, self.fordate, self.article_list_lenght, self.order_full_str)"
                   meta="--nntpf_group_list_v_meta (self.grp_sel_no_thr, self.fordate, self.article_list_lenght, self.order_full_str)"
                   expression-type="array"
                   control-udt="vspx_data_source">
                   <v:after-data-bind>
                     control.ds_make_statistic();
                   </v:after-data-bind>
    </v:data-source>               
    <v:data-set name="ds_list_message"
                data-source="self.dss"
                scrollable="1"
                width="80"
                cursor-type="keyset">
                >
      <v:template name="template_head"
                  type="simple"
                  name-to-remove="table"
                  set-to-remove="bottom">
        <h2>
          <v:label value="--sprintf ('Group: %s (%s)',
                                     nntpf_get_group_desc (self.grp_sel_no_thr),
                                     nntpf_get_group_name (self.grp_sel_no_thr))"
                   format="%s"
                   width="80"/>
        </h2>
        <p>View
          <v:button style="url" value="10" action="simple">
            <v:on-post>
              <![CDATA[
  if (udt_defines_field (self, 'ds_list_message'))
    {
      declare h vspx_data_set;
      h := udt_get (self, 'ds_list_message');
      self.article_list_lenght := 10;
      h.vc_reset ();
      h.vc_data_bind (e);
    }
  if (udt_defines_field (self, 'dss'))
    {
      declare x vspx_data_source;
      x := udt_get (self, 'dss');
--		       x.ds_rows_offs := 0; -- !?!
      x.vc_data_bind (e);
      declare h vspx_data_set;
      h := udt_get (self, 'ds_list_message');
      self.article_list_lenght := 10;
      h.vc_reset ();
      h.vc_data_bind (e);
    }
              ]]>
            </v:on-post>
          </v:button> |
          <v:button style="url" value="20" action="simple">
            <v:on-post>
              <![CDATA[
  if (udt_defines_field (self, 'ds_list_message'))
    {
      declare h vspx_data_set;
      h := udt_get (self, 'ds_list_message');
      self.article_list_lenght := 20;
      h.vc_reset ();
      h.vc_data_bind (e);
    }
  if (udt_defines_field (self, 'dss'))
    {
      declare x vspx_data_source;
      x := udt_get (self, 'dss');
      x.ds_rows_offs := 0;
      x.vc_data_bind (e);
      declare h vspx_data_set;
      h := udt_get (self, 'ds_list_message');
      self.article_list_lenght := 20;
      h.vc_reset ();
      h.vc_data_bind (e);
    }
              ]]>
            </v:on-post>
          </v:button> |
          <v:button style="url" value="50" action="simple">
            <v:on-post>
              <![CDATA[
  if (udt_defines_field (self, 'ds_list_message'))
    {
      declare h vspx_data_set;
      h := udt_get (self, 'ds_list_message');
      self.article_list_lenght := 50;
      h.vc_reset ();
      h.vc_data_bind (e);
    }
  if (udt_defines_field (self, 'dss'))
    {
      declare x vspx_data_source;
      x := udt_get (self, 'dss');
      x.ds_rows_offs := 0;
      x.vc_data_bind (e);
      declare h vspx_data_set;
      h := udt_get (self, 'ds_list_message');
      self.article_list_lenght := 50;
      h.vc_reset ();
      h.vc_data_bind (e);
    }
              ]]>
            </v:on-post>
          </v:button>
          | last
          <a href="#"
             onclick="javascript: doPostValueN ('nntpf', 'view', 500); return false">
             5 days
          </a>
          | enable
          <v:url value="--'Thread view'"
                 format="%s"
		             url="--'/dataspace/discussion/nntpf_thread_view.vspx?group='||self.grp_sel_no_thr || '&amp;thr=1'" /> |
	        <v:url value="Subscribe" format="%s" url="--sprintf ('/dataspace/discussion/nntpf_subs_group.vspx?group=%s', self.grp_sel_no_thr)" />
          <br/>
        </p>
        <table width="100%" class="news_summary_encapsul" cellspacing="0" cellpadding="0">
          <input type="hidden" id="order_by" name="order_by" value="<?Vself.order_by_str?>"/>
          <input type="hidden" id="order_way" name="order_way" value="<?Vself.order_way_str?>"/>
          <input type="hidden" id="prev_order_way" name="prev_order_way" value="<?Vself.prev_order_way_str?>"/>
          <tr>
            <th align="left">
                <h3>Summary</h3>
            </th>
          </tr>
          <tr>
            <th align="left" style="width:150px;">
            <a href="javascript:void(0)" onClick="setOrderParams('date','<?V(case when self.order_by_str='date' AND self.order_way_str='asc' then 'desc'
                                                                                  when self.order_by_str='date' AND self.order_way_str='desc' then 'asc'
                                                                                  else 'asc' end)?>','<?Vself.prev_order_way_str?>')">Date</a>

            </th>
            <th align="left" style="width:220px;">
            <a href="javascript:void(0)" onClick="setOrderParams('creator','<?V(case when self.order_by_str='creator' AND self.order_way_str='asc' then 'desc'
                                                                                     when self.order_by_str='creator' AND self.order_way_str='desc' then 'asc'
                                                                                     else 'asc' end)?>','<?Vself.prev_order_way_str?>')">From</a>
            </th>
            <th align="left">
            <a href="javascript:void(0)" onClick="setOrderParams('subject','<?V(case when self.order_by_str='subject' AND self.order_way_str='asc' then 'desc'
                                                                                     when self.order_by_str='subject' AND self.order_way_str='desc' then 'asc'
                                                                                     else 'asc' end)?>','<?Vself.prev_order_way_str?>')">Subject</a>
            </th>
            <th align="left">Action</th>
            <th align="left">Tags</th>
	  </tr>
        </table>
      </v:template>
      <v:template name="template2" type="repeat" name-to-remove="" set-to-remove="">
        <v:template name="template7" type="if-not-exists" name-to-remove="table" set-to-remove="both">
          <table width="100%" class="news_summary_encapsul" cellspacing="0" cellpadding="1">
            <tr>
              <td align="center" colspan="5">
                <b>No articles available</b>
              </td>
            </tr>
          </table>
        </v:template>
        <v:template name="template_data" type="browse" name-to-remove="table" set-to-remove="both">
          <?vsp
  if (not self.art_id = control.te_rowset[3])
    {
              http (sprintf ('<tr class="%s">', case when mod (self.r_count, 2) then 'listing_row_odd' else 'listing_row_even' end));
    }
  else
    {
      http (sprintf ('<tr class="article_listing_current">'));
    }
          ?>
          <td>
            <span class="dc-date">
            <v:label value="--(control.vc_parent as vspx_row_template).te_rowset[0]" format="%s" width="80"/>
              </span>
          </td>
          <td>
            <span class="dc-subject">
            <v:label value="--sprintf('%V', (control.vc_parent as vspx_row_template).te_rowset[2])" format="%s" width="80"/>
              </span>
          </td>
          <td>
            <span class="dc-creator">
            <v:label value="--(control.vc_parent as vspx_row_template).te_rowset[1]" format="%s" width="80"/>
              </span>
          </td>
          <td>
            <a href="nntpf_disp_article.vspx?id=<?=sprintf ('%U', encode_base64 (control.te_rowset[3]))?>"
               onclick="javascript: doPostValueN ('nntpf', 'disp_artic', '<?=sprintf ('%s', (control.te_rowset[3]))?>'); return false">
              Read
            </a>
            <?vsp
  if (nntpf_show_cancel_link (control.te_rowset[3]))
    {
                http (sprintf (' | <a href="#" onclick="javascript: doPostValueN (''nntpf'', ''cancel_artic'', ''%s''); return false">Cancel</a>', control.te_rowset[3]));
    }
            ?>
            </td>
           <td align="left">
              <v:url value="--sprintf('tags (%d)', discussions_tagscount(cast (self.grp_sel_no_thr as varchar), sprintf ('%U', encode_base64 (cast ((control.vc_parent as vspx_row_template).te_rowset[3] as varchar))),case when length(self.u_name)>0 then (select U_ID from DB.DBA.SYS_USERS where U_NAME=self.u_name) else '-1' end) )"
                    url="--'javascript:void(0)'"
                    xhtml_class="nntp_group_rss"
                    xhtml_onClick="--concat ('showTagsDiv(\'',cast (self.grp_sel_no_thr as varchar),'\'',
                                                           ',\'', sprintf ('%U', encode_base64 (cast ((control.vc_parent as vspx_row_template).te_rowset[3] as varchar))),'\',this)')"
                     enabled="--(case when length(self.u_name)>0 or discussions_tagscount(cast (self.grp_sel_no_thr as varchar),sprintf ('%U', encode_base64 (cast ((control.vc_parent as vspx_row_template).te_rowset[3] as varchar))),case when length(self.u_name)>0 then (select U_ID from DB.DBA.SYS_USERS where U_NAME=self.u_name) else '-1' end)>0 then 1 else 0 end)"
               />
              <v:label value="--'tags (0)'" enabled="--(case when length(self.u_name)=0 and discussions_tagscount(cast (self.grp_sel_no_thr as varchar),sprintf ('%U', encode_base64 (cast ((control.vc_parent as vspx_row_template).te_rowset[3] as varchar))),case when length(self.u_name)>0 then (select U_ID from DB.DBA.SYS_USERS where U_NAME=self.u_name) else '-1' end)=0 then 1 else 0 end)"/>
           </td>
          <?vsp
  http('</tr>');
  self.r_count := self.r_count + 1;
          ?>
        </v:template>
      </v:template>
      <v:template name="template3" type="simple" name-to-remove="table" set-to-remove="top">
        <table width="100%" class="news_summary_encapsul" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center" colspan="4">
              <![CDATA[&nbsp;]]>
              <v:button name="ds_list_message_prev" style="url" action="simple" value="&lt;"/>
              <![CDATA[&nbsp;]]>
<?vsp
declare _pages integer;
declare _total_rows,_nrows folat;

_total_rows:=cast(self.ds_list_message.ds_data_source.ds_total_rows as float);
_nrows:=cast(self.ds_list_message.ds_data_source.ds_nrows as float);
_pages:=ceiling(_total_rows/_nrows);

if(self.ds_list_message.ds_data_source.ds_total_pages<_pages)
   self.ds_list_message.ds_data_source.ds_total_pages:=_pages;
?>
	      <v:template name="template_pager" type="page-navigator">
<?vsp
declare _enabled integer;

_enabled:=0;
if(self.ds_list_message.ds_data_source.ds_total_pages >= self.ds_list_message.ds_data_source.ds_current_pager_idx)
  _enabled:=1;;
?>
                <v:button name="ds_list_message_pager"
                     style="url"
                     action="simple"
                     value="--cast(self.ds_list_message.ds_data_source.ds_current_pager_idx as varchar)"
                     xhtml_style="--case when self.ds_list_message.ds_data_source.ds_current_pager_idx = self.ds_list_message.ds_data_source.ds_current_page
                                   then 'font-weight: bold' else '' end"              
                     enabled ="_enabled"
                   />
			<?vsp
				if (self.ds_list_message.ds_data_source.ds_total_pages - self.ds_list_message.ds_data_source.ds_current_pager_idx > 0)
				   http ('&nbsp; | &nbsp;');
			?>
                </v:template>
                
              <![CDATA[&nbsp;]]>
              <v:button name="ds_list_message_next" style="url" action="simple" value="&gt;" enabled ="_enabled"/>
              <![CDATA[&nbsp;]]>
	      <input type="hidden" name="group" value="<?= get_keyword ('group', self.vc_page.vc_event.ve_params) ?>"/>
	      <input type="hidden" name="view" value="<?= self.article_list_lenght ?>"/>
	      <input type="hidden" name="old_view" value="<?=self.old_view?>"/>
	      <input type="hidden" name="signin_returl_params" value="group=<?=self.grp_sel_no_thr?>"/>
            </td>
          </tr>
        </table>
      </v:template>
    </v:data-set>
<?vsp
        declare id any;

        id := get_keyword ('disp_artic', self.vc_page.vc_event.ve_params, '-');
        if (id <> '-')
          {
      ?>
      <br/><br/>
      <table>
	  <tr>
	      <td>
       		   <v:url value="Subscribe to the thread" format="%s" url="--sprintf ('/dataspace/discussion/nntpf_subs_group.vspx?group=%s&amp;id=%U', self.grp_sel_thr, self.cur_art)" />
		  <br />
      <?vsp
      nntpf_display_article ((id), NULL, self.sid);
      ?>
            </td>
          </tr>
        </table>
      <?vsp
          }
?>
  </xsl:template>
</xsl:stylesheet>