Dotclear

source: plugins/eventdata/inc/lib.eventdata.list.php @ 1005

Revision 1005, 4.8 KB checked in by JcDenis, 14 years ago (diff)

eventdata: fix conflict with icsFeed plugin

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of eventdata, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009 JC Denis and contributors
6# jcdenis@gdwd.com
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13if (!defined('DC_CONTEXT_ADMIN')) return;
14
15class eventdataExtList
16{
17     protected $core;
18     protected $rs;
19     protected $rs_count;
20
21     public function __construct(&$core,&$rs,$rs_count)
22     {
23          $this->core =& $core;
24          $this->rs =& $rs;
25          $this->rs_count = $rs_count;
26          $this->html_prev = __('&#171;prev.');
27          $this->html_next = __('next&#187;');
28
29          $this->html_none = '<p><strong>'.__('No entry').'</strong></p>';
30          $this->html = '%1$s';
31          $this->html_pager =  '<p>'.__('Page(s)').' : %1$s</p>';
32          $this->html_table = '<table class="clear">%1$s%2$s</table>';
33          $this->html_headline = '<tr %2$s>%1$s</tr>';
34          $this->html_headcell = '<th %2$s>%1$s</th>';
35          $this->html_line = '<tr %2$s>%1$s</tr>';
36          $this->html_cell = '<td %2$s>%1$s</td>';
37          $this->headlines = '';
38          $this->headcells = '';
39          $this->lines = '';
40          $this->cells = '';
41         
42          $this->init();
43     }
44
45     public function headline($cells,$head='')
46     {
47          $line = '';
48          foreach($cells AS $content => $extra) {
49               $line .= sprintf($this->html_headcell,$content,$extra);
50          }
51          $this->headlines .= sprintf($this->html_headline,$line,$head);
52     }
53
54     public function line($cells,$head='')
55     {
56          $line = '';
57          foreach($cells AS $content => $extra) {
58               $line .= sprintf($this->html_cell,$content,$extra);
59          }
60          $this->lines .= sprintf($this->html_line,$line,$head);
61     }
62
63     public function display($page,$nb_per_page,$enclose_block='')
64     {
65          if ($this->rs->isEmpty()) {
66               echo $this->html_none;
67          } else {
68               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
69               $pager->html_prev = $this->html_prev;
70               $pager->html_next = $this->html_next;
71               $pager->var_page = 'page';
72               
73               while ($this->rs->fetch()) {
74                    $this->setLine();
75               }
76
77               echo
78               sprintf($this->html,
79                    sprintf($enclose_block,
80                         sprintf($this->html_pager,$pager->getLinks()).
81                              sprintf($this->html_table,$this->headlines,$this->lines).
82                         sprintf($this->html_pager,$pager->getLinks())));
83          }
84     }
85}
86
87# Display admin posts list class
88class eventdataEventdataList extends eventdataExtList
89{
90     public function init()
91     {
92          self::headline(array(
93               __('Title') => 'colspan="2"',
94               __('Start') => '',
95               __('End') => '',
96               __('Period') => '',
97               __('Published on') => '',
98               __('Category') => '',
99               __('Author') => '',
100               __('Status') => ''));
101     }
102     
103     public function setLine()
104     {
105          if ($this->rs->cat_title)
106               $cat_title = html::escapeHTML($this->rs->cat_title);
107          else
108               $cat_title = __('None');
109
110          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
111          switch ($this->rs->post_status) {
112               case 1:  $img_status = sprintf($img,__('published'),'check-on.png'); break;
113               case 0:  $img_status = sprintf($img,__('unpublished'),'check-off.png'); break;
114               case -1: $img_status = sprintf($img,__('scheduled'),'scheduled.png'); break;
115               case -2: $img_status = sprintf($img,__('pending'),'check-wrn.png'); break;
116          }
117
118          $protected = '';
119          if ($this->rs->post_password)
120               $protected = sprintf($img,__('protected'),'locker.png');
121
122          $selected = '';
123          if ($this->rs->post_selected)
124               $selected = sprintf($img,__('selected'),'selected.png');
125
126          $attach = '';
127          $nb_media = $this->rs->countMedia();
128          if ($nb_media > 0) {
129               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
130               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
131          }
132
133          $img = '<img alt="%1$s" title="%1$s" src="index.php?pf=eventdata/img/%2$s" />';
134          if (time() < strtotime($this->rs->eventdata_start))
135               $img_period = sprintf($img,__('scheduled'),'scheduled.png');
136          elseif (time() > strtotime($this->rs->eventdata_end))
137               $img_period = sprintf($img,__('finished'),'red.png');
138          else
139               $img_period = sprintf($img,__('ongoing'),'green.png');
140
141          self::line(
142               array(
143                    form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()) =>  'class="nowrap"',
144                    '<a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.html::escapeHTML($this->rs->post_title).'</a>' =>  'class="maximal"',
145                    dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->eventdata_start) => 'class="nowrap"',
146                    dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->eventdata_end) => 'class="nowrap"',
147                    $img_period => 'class="nowrap"',
148                    dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt) => 'class="nowrap"',
149                    $cat_title => 'class="nowrap"',
150                    $this->rs->user_id => 'class="nowrap"',
151                    $img_status.' '.$selected.' '.$protected.' '.$attach => 'class="nowrap status"'
152               ),
153               'class="line'.($this->rs->post_status != 1 ? ' offline' : '').'" id="p'.$this->rs->post_id.'"'
154          );
155     }
156}
157
158?>
Note: See TracBrowser for help on using the repository browser.

Sites map