Dotclear

source: inc/admin/lib.pager.php @ 848:ad18a33a3cef

Revision 848:ad18a33a3cef, 8.2 KB checked in by Dsls <dsls@…>, 13 years ago (diff)

sexy step 1 : no more comments ...

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14class adminGenericList
15{
16     protected $core;
17     protected $rs;
18     protected $rs_count;
19     
20     public function __construct($core,$rs,$rs_count)
21     {
22          $this->core =& $core;
23          $this->rs =& $rs;
24          $this->rs_count = $rs_count;
25          $this->html_prev = __('&#171;prev.');
26          $this->html_next = __('next&#187;');
27     }
28}
29
30class adminPostList extends adminGenericList
31{
32     public function display($page,$nb_per_page,$enclose_block='')
33     {
34          if ($this->rs->isEmpty())
35          {
36               echo '<p><strong>'.__('No entry').'</strong></p>';
37          }
38          else
39          {
40               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
41               $pager->html_prev = $this->html_prev;
42               $pager->html_next = $this->html_next;
43               $pager->var_page = 'page';
44               
45               $html_block =
46               '<table class="clear"><tr>'.
47               '<th colspan="2">'.__('Title').'</th>'.
48               '<th>'.__('Date').'</th>'.
49               '<th>'.__('Category').'</th>'.
50               '<th>'.__('Author').'</th>'.
51               '<th>'.__('Status').'</th>'.
52               '</tr>%s</table>';
53               
54               if ($enclose_block) {
55                    $html_block = sprintf($enclose_block,$html_block);
56               }
57               
58               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
59               
60               $blocks = explode('%s',$html_block);
61               
62               echo $blocks[0];
63               
64               while ($this->rs->fetch())
65               {
66                    echo $this->postLine();
67               }
68               
69               echo $blocks[1];
70               
71               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
72          }
73     }
74     
75     private function postLine()
76     {
77          if ($this->core->auth->check('categories',$this->core->blog->id)) {
78               $cat_link = '<a href="category.php?id=%s">%s</a>';
79          } else {
80               $cat_link = '%2$s';
81          }
82         
83          if ($this->rs->cat_title) {
84               $cat_title = sprintf($cat_link,$this->rs->cat_id,
85               html::escapeHTML($this->rs->cat_title));
86          } else {
87               $cat_title = __('None');
88          }
89         
90          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
91          switch ($this->rs->post_status) {
92               case 1:
93                    $img_status = sprintf($img,__('published'),'check-on.png');
94                    break;
95               case 0:
96                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
97                    break;
98               case -1:
99                    $img_status = sprintf($img,__('scheduled'),'scheduled.png');
100                    break;
101               case -2:
102                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
103                    break;
104          }
105         
106          $protected = '';
107          if ($this->rs->post_password) {
108               $protected = sprintf($img,__('protected'),'locker.png');
109          }
110         
111          $selected = '';
112          if ($this->rs->post_selected) {
113               $selected = sprintf($img,__('selected'),'selected.png');
114          }
115         
116          $attach = '';
117          $nb_media = $this->rs->countMedia();
118          if ($nb_media > 0) {
119               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
120               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
121          }
122         
123          $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
124          ' id="p'.$this->rs->post_id.'">';
125         
126          $res .=
127          '<td class="nowrap">'.
128          form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'.
129          '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.
130          html::escapeHTML($this->rs->post_title).'</a></td>'.
131          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
132          '<td class="nowrap">'.$cat_title.'</td>'.
133          '<td class="nowrap">'.$this->rs->user_id.'</td>'.
134          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.
135          '</tr>';
136         
137          return $res;
138     }
139}
140
141class adminPostMiniList extends adminGenericList
142{
143     public function display($page,$nb_per_page,$enclose_block='')
144     {
145          if ($this->rs->isEmpty())
146          {
147               echo '<p><strong>'.__('No entry').'</strong></p>';
148          }
149          else
150          {
151               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
152               $pager->html_prev = $this->html_prev;
153               $pager->html_next = $this->html_next;
154               $pager->var_page = 'page';
155               
156               $html_block =
157               '<table class="clear"><tr>'.
158               '<th>'.__('Title').'</th>'.
159               '<th>'.__('Date').'</th>'.
160               '<th>'.__('Author').'</th>'.
161               '<th>'.__('Status').'</th>'.
162               '</tr>%s</table>';
163               
164               if ($enclose_block) {
165                    $html_block = sprintf($enclose_block,$html_block);
166               }
167               
168               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
169               
170               $blocks = explode('%s',$html_block);
171               
172               echo $blocks[0];
173               
174               while ($this->rs->fetch())
175               {
176                    echo $this->postLine();
177               }
178               
179               echo $blocks[1];
180               
181               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
182          }
183     }
184     
185     private function postLine()
186     {
187          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
188          switch ($this->rs->post_status) {
189               case 1:
190                    $img_status = sprintf($img,__('published'),'check-on.png');
191                    break;
192               case 0:
193                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
194                    break;
195               case -1:
196                    $img_status = sprintf($img,__('scheduled'),'scheduled.png');
197                    break;
198               case -2:
199                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
200                    break;
201          }
202         
203          $protected = '';
204          if ($this->rs->post_password) {
205               $protected = sprintf($img,__('protected'),'locker.png');
206          }
207         
208          $selected = '';
209          if ($this->rs->post_selected) {
210               $selected = sprintf($img,__('selected'),'selected.png');
211          }
212         
213          $attach = '';
214          $nb_media = $this->rs->countMedia();
215          if ($nb_media > 0) {
216               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
217               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
218          }
219         
220          $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
221          ' id="p'.$this->rs->post_id.'">';
222         
223          $res .=
224          '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '.
225          'title="'.html::escapeHTML($this->rs->getURL()).'">'.
226          html::escapeHTML($this->rs->post_title).'</a></td>'.
227          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
228          '<td class="nowrap">'.$this->rs->user_id.'</td>'.
229          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.
230          '</tr>';
231         
232          return $res;
233     }
234}
235
236class adminUserList extends adminGenericList
237{
238     public function display($page,$nb_per_page,$enclose_block='')
239     {
240          if ($this->rs->isEmpty())
241          {
242               echo '<p><strong>'.__('No user').'</strong></p>';
243          }
244          else
245          {
246               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
247               $pager->html_prev = $this->html_prev;
248               $pager->html_next = $this->html_next;
249               $pager->var_page = 'page';
250               
251               $html_block =
252               '<table class="clear"><tr>'.
253               '<th colspan="2">'.__('Username').'</th>'.
254               '<th>'.__('First Name').'</th>'.
255               '<th>'.__('Last Name').'</th>'.
256               '<th>'.__('Display name').'</th>'.
257               '<th class="nowrap">'.__('Entries').'</th>'.
258               '</tr>%s</table>';
259               
260               if ($enclose_block) {
261                    $html_block = sprintf($enclose_block,$html_block);
262               }
263               
264               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
265               
266               $blocks = explode('%s',$html_block);
267               
268               echo $blocks[0];
269               
270               while ($this->rs->fetch())
271               {
272                    echo $this->userLine();
273               }
274               
275               echo $blocks[1];
276               
277               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
278          }
279     }
280     
281     private function userLine()
282     {
283          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
284          $img_status = '';
285         
286          $p = $this->core->getUserPermissions($this->rs->user_id);
287         
288          if (isset($p[$this->core->blog->id]['p']['admin'])) {
289               $img_status = sprintf($img,__('admin'),'admin.png');
290          }
291          if ($this->rs->user_super) {
292               $img_status = sprintf($img,__('superadmin'),'superadmin.png');
293          }
294          return
295          '<tr class="line">'.
296          '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post).
297          form::checkbox(array('user_id[]'),$this->rs->user_id).'</td>'.
298          '<td class="maximal"><a href="user.php?id='.$this->rs->user_id.'">'.
299          $this->rs->user_id.'</a>&nbsp;'.$img_status.'</td>'.
300          '<td class="nowrap">'.$this->rs->user_firstname.'</td>'.
301          '<td class="nowrap">'.$this->rs->user_name.'</td>'.
302          '<td class="nowrap">'.$this->rs->user_displayname.'</td>'.
303          '<td class="nowrap"><a href="posts.php?user_id='.$this->rs->user_id.'">'.
304          $this->rs->nb_post.'</a></td>'.
305          '</tr>';
306     }
307}
308?>
Note: See TracBrowser for help on using the repository browser.

Sites map