Dotclear

source: plugins/periodical/inc/lib.index.pager.php @ 2160

Revision 2160, 6.4 KB checked in by JcDenis, 14 years ago (diff)

periodical 0.1:

  • First lab release
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of periodical, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009-2010 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 adminPeriodicalList extends adminGenericList
16{
17     public function periodDisplay($page,$nb_per_page,$enclose_block='')
18     {
19          $echo = '';
20          if ($this->rs->isEmpty())
21          {
22               $echo .= '<p><strong>'.__('No period').'</strong></p>';
23          }
24          else
25          {
26               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
27               $pager->html_prev = $this->html_prev;
28               $pager->html_next = $this->html_next;
29               $pager->var_page = 'page';
30               
31               $html_block =
32               '<table class="clear">'.
33               '<tr>'.
34               '<th colspan="2" class="nowrap">'.__('Name').'</th>'.
35               '<th class="nowrap">'.__('Next update').'</th>'.
36               '<th class="nowrap">'.__('Frequency').'</th>'.
37               '<th class="nowrap">'.__('Publications').'</th>'.
38               '<th class="nowrap">'.__('Entries').'</th>'.
39               '<th class="nowrap">'.__('End date').'</th>'.
40               '</tr>'.
41               '</tr>%s</table>';
42               
43               if ($enclose_block) {
44                    $html_block = sprintf($enclose_block,$html_block);
45               }
46               
47               $echo .= '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
48               
49               $blocks = explode('%s',$html_block);
50               
51               $echo .= $blocks[0];
52               
53               while ($this->rs->fetch())
54               {
55                    $echo .= $this->periodLine();
56               }
57               
58               $echo .= $blocks[1];
59               
60               $echo .= '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
61          }
62          return $echo;
63     }
64     
65     private function periodLine()
66     {
67          $nb_posts = $this->rs->periodical->getPosts(array('periodical_id'=>$this->rs->periodical_id),true);
68          $nb_posts = $nb_posts->f(0);
69          $style = !$nb_posts ? ' offline' : '';
70          $posts_links = !$nb_posts ? 
71               '0' : 
72               '<a href="plugin.php?p=periodical&amp;part=editperiod&tab=posts&amp;id='.$this->rs->periodical_id.'" title="'.__('view related entries').'">'.$nb_posts.'</a>';
73
74          $pub_int = in_array($this->rs->periodical_pub_int,$this->rs->periodical->getTimesCombo()) ? 
75               __(array_search($this->rs->periodical_pub_int,$this->rs->periodical->getTimesCombo())) : __('Unknow frequence');
76
77          $res = 
78          '<tr class="line'.$style.'">'.
79          '<td class="nowrap">'.form::checkbox(array('periods[]'),$this->rs->periodical_id).'</td>'.
80          '<td class="maximal"><a href="plugin.php?p=periodical&amp;part=editperiod&tab=period&amp;id='.$this->rs->periodical_id.'" title="'.__('edit period').'">'.html::escapeHTML($this->rs->periodical_title).'</a></td>'.
81          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->periodical_curdt).'</td>'.
82          '<td class="nowrap">'.$pub_int.'</td>'.
83          '<td class="nowrap">'.$this->rs->periodical_pub_nb.'</td>'.
84          '<td class="nowrap">'.$posts_links.'</td>'.
85          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->periodical_enddt).'</td>'.
86          '</tr>';
87         
88          return $res;
89     }
90
91     public function postDisplay($page,$nb_per_page,$enclose_block='')
92     {
93          $echo = '';
94          if ($this->rs->isEmpty())
95          {
96               $echo .= '<p><strong>'.__('No entry').'</strong></p>';
97          }
98          else
99          {
100               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
101               $pager->html_prev = $this->html_prev;
102               $pager->html_next = $this->html_next;
103               $pager->var_page = 'page';
104               
105               $html_block =
106               '<table class="clear"><tr>'.
107               '<th colspan="2">'.__('Title').'</th>'.
108               '<th class="nowrap">'.__('Date').'</th>'.
109               '<th class="nowrap">'.__('Category').'</th>'.
110               '<th class="nowrap">'.__('Author').'</th>'.
111               '<th class="nowrap">'.__('Status').'</th>'.
112               '<th class="nowrap">'.__('Create date').'</th>'.
113               '</tr>%s</table>';
114               
115               if ($enclose_block) {
116                    $html_block = sprintf($enclose_block,$html_block);
117               }
118               
119               $echo .= '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
120               
121               $blocks = explode('%s',$html_block);
122               
123               $echo .= $blocks[0];
124               
125               while ($this->rs->fetch())
126               {
127                    $echo .= $this->postLine();
128               }
129               
130               $echo .= $blocks[1];
131               
132               $echo .= '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
133          }
134          return $echo;
135     }
136     
137     private function postLine()
138     {
139          if ($this->core->auth->check('categories',$this->core->blog->id)) {
140               $cat_link = '<a href="category.php?id=%s">%s</a>';
141          } else {
142               $cat_link = '%2$s';
143          }
144          if ($this->rs->cat_title) {
145               $cat_title = sprintf($cat_link,$this->rs->cat_id,
146               html::escapeHTML($this->rs->cat_title));
147          } else {
148               $cat_title = __('None');
149          }
150
151          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
152          switch ($this->rs->post_status) {
153               case 1:
154                    $img_status = sprintf($img,__('published'),'check-on.png');
155                    break;
156               case 0:
157                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
158                    break;
159               case -1:
160                    $img_status = sprintf($img,__('scheduled'),'scheduled.png');
161                    break;
162               case -2:
163                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
164                    break;
165          }
166         
167          $protected = '';
168          if ($this->rs->post_password) {
169               $protected = sprintf($img,__('protected'),'locker.png');
170          }
171         
172          $selected = '';
173          if ($this->rs->post_selected) {
174               $selected = sprintf($img,__('selected'),'selected.png');
175          }
176         
177          $attach = '';
178          $nb_media = $this->rs->countMedia();
179          if ($nb_media > 0) {
180               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
181               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
182          }
183         
184          $res = 
185          '<tr class="line">'.
186          '<td class="minimal">'.form::checkbox(array('periodical_entries[]'),$this->rs->post_id,0).'</td>'.
187          '<td class="maximal"><a href="'.$this->rs->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '.
188          'title="'.html::escapeHTML($this->rs->getURL()).'">'.
189          html::escapeHTML($this->rs->post_title).'</a></td>'.
190          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
191          '<td class="nowrap">'.$cat_title.'</td>'.
192          '<td class="nowrap">'.$this->rs->user_id.'</td>'.
193          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.
194          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_creadt,$this->rs->core->auth->getInfo('user_tz')).'</td>'.
195          '</tr>';
196         
197          return $res;
198     }
199}
200?>
Note: See TracBrowser for help on using the repository browser.

Sites map