Dotclear

source: inc/admin/lib.pager.php @ 1364:6005ff85f7f5

Revision 1364:6005ff85f7f5, 11.6 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

none value (category's field) in posts' list is now replaced by (none), (aucune) in french, fixes #1464

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 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>'.__('Comments').'</th>'.
52               '<th>'.__('Trackbacks').'</th>'.
53               '<th>'.__('Status').'</th>'.
54               '</tr>%s</table>';
55               
56               if ($enclose_block) {
57                    $html_block = sprintf($enclose_block,$html_block);
58               }
59               
60               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
61               
62               $blocks = explode('%s',$html_block);
63               
64               echo $blocks[0];
65               
66               while ($this->rs->fetch())
67               {
68                    echo $this->postLine();
69               }
70               
71               echo $blocks[1];
72               
73               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
74          }
75     }
76     
77     private function postLine()
78     {
79          if ($this->core->auth->check('categories',$this->core->blog->id)) {
80               $cat_link = '<a href="category.php?id=%s">%s</a>';
81          } else {
82               $cat_link = '%2$s';
83          }
84         
85          if ($this->rs->cat_title) {
86               $cat_title = sprintf($cat_link,$this->rs->cat_id,
87               html::escapeHTML($this->rs->cat_title));
88          } else {
89               $cat_title = __('(No cat)');
90          }
91         
92          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
93          switch ($this->rs->post_status) {
94               case 1:
95                    $img_status = sprintf($img,__('published'),'check-on.png');
96                    break;
97               case 0:
98                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
99                    break;
100               case -1:
101                    $img_status = sprintf($img,__('scheduled'),'scheduled.png');
102                    break;
103               case -2:
104                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
105                    break;
106          }
107         
108          $protected = '';
109          if ($this->rs->post_password) {
110               $protected = sprintf($img,__('protected'),'locker.png');
111          }
112         
113          $selected = '';
114          if ($this->rs->post_selected) {
115               $selected = sprintf($img,__('selected'),'selected.png');
116          }
117         
118          $attach = '';
119          $nb_media = $this->rs->countMedia();
120          if ($nb_media > 0) {
121               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
122               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
123          }
124         
125          $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
126          ' id="p'.$this->rs->post_id.'">';
127         
128          $res .=
129          '<td class="nowrap">'.
130          form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).'</td>'.
131          '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.
132          html::escapeHTML($this->rs->post_title).'</a></td>'.
133          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
134          '<td class="nowrap">'.$cat_title.'</td>'.
135          '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'.
136          '<td class="nowrap">'.$this->rs->nb_comment.'</td>'.
137          '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'.
138          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.
139          '</tr>';
140         
141          return $res;
142     }
143}
144
145class adminPostMiniList extends adminGenericList
146{
147     public function display($page,$nb_per_page,$enclose_block='')
148     {
149          if ($this->rs->isEmpty())
150          {
151               echo '<p><strong>'.__('No entry').'</strong></p>';
152          }
153          else
154          {
155               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
156               $pager->html_prev = $this->html_prev;
157               $pager->html_next = $this->html_next;
158               $pager->var_page = 'page';
159               
160               $html_block =
161               '<table class="clear"><tr>'.
162               '<th>'.__('Title').'</th>'.
163               '<th>'.__('Date').'</th>'.
164               '<th>'.__('Author').'</th>'.
165               '<th>'.__('Status').'</th>'.
166               '</tr>%s</table>';
167               
168               if ($enclose_block) {
169                    $html_block = sprintf($enclose_block,$html_block);
170               }
171               
172               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
173               
174               $blocks = explode('%s',$html_block);
175               
176               echo $blocks[0];
177               
178               while ($this->rs->fetch())
179               {
180                    echo $this->postLine();
181               }
182               
183               echo $blocks[1];
184               
185               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
186          }
187     }
188     
189     private function postLine()
190     {
191          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
192          switch ($this->rs->post_status) {
193               case 1:
194                    $img_status = sprintf($img,__('published'),'check-on.png');
195                    break;
196               case 0:
197                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
198                    break;
199               case -1:
200                    $img_status = sprintf($img,__('scheduled'),'scheduled.png');
201                    break;
202               case -2:
203                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
204                    break;
205          }
206         
207          $protected = '';
208          if ($this->rs->post_password) {
209               $protected = sprintf($img,__('protected'),'locker.png');
210          }
211         
212          $selected = '';
213          if ($this->rs->post_selected) {
214               $selected = sprintf($img,__('selected'),'selected.png');
215          }
216         
217          $attach = '';
218          $nb_media = $this->rs->countMedia();
219          if ($nb_media > 0) {
220               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
221               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
222          }
223         
224          $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
225          ' id="p'.$this->rs->post_id.'">';
226         
227          $res .=
228          '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '.
229          'title="'.html::escapeHTML($this->rs->getURL()).'">'.
230          html::escapeHTML($this->rs->post_title).'</a></td>'.
231          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'.
232          '<td class="nowrap">'.html::escapeHTML($this->rs->user_id).'</td>'.
233          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.
234          '</tr>';
235         
236          return $res;
237     }
238}
239
240class adminCommentList extends adminGenericList
241{
242     public function display($page,$nb_per_page,$enclose_block='')
243     {
244          if ($this->rs->isEmpty())
245          {
246               echo '<p><strong>'.__('No comment').'</strong></p>';
247          }
248          else
249          {
250               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
251               $pager->html_prev = $this->html_prev;
252               $pager->html_next = $this->html_next;
253               $pager->var_page = 'page';
254               
255               $html_block =
256               '<table><tr>'.
257               '<th colspan="2">'.__('Title').'</th>'.
258               '<th>'.__('Date').'</th>'.
259               '<th>'.__('Author').'</th>'.
260               '<th>'.__('Type').'</th>'.
261               '<th>'.__('Status').'</th>'.
262               '<th>&nbsp;</th>'.
263               '</tr>%s</table>';
264               
265               if ($enclose_block) {
266                    $html_block = sprintf($enclose_block,$html_block);
267               }
268               
269               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
270               
271               $blocks = explode('%s',$html_block);
272               
273               echo $blocks[0];
274               
275               while ($this->rs->fetch())
276               {
277                    echo $this->commentLine();
278               }
279               
280               echo $blocks[1];
281               
282               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
283          }
284     }
285     
286     private function commentLine()
287     {
288          global $author, $status, $sortby, $order, $nb_per_page;
289         
290          $author_url =
291          'comments.php?n='.$nb_per_page.
292          '&amp;status='.$status.
293          '&amp;sortby='.$sortby.
294          '&amp;order='.$order.
295          '&amp;author='.rawurlencode($this->rs->comment_author);
296         
297          $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id);
298         
299          $comment_url = 'comment.php?id='.$this->rs->comment_id;
300         
301          $comment_dt =
302          dt::dt2str($this->core->blog->settings->system->date_format.' - '.
303          $this->core->blog->settings->system->time_format,$this->rs->comment_dt);
304         
305          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
306          switch ($this->rs->comment_status) {
307               case 1:
308                    $img_status = sprintf($img,__('published'),'check-on.png');
309                    break;
310               case 0:
311                    $img_status = sprintf($img,__('unpublished'),'check-off.png');
312                    break;
313               case -1:
314                    $img_status = sprintf($img,__('pending'),'check-wrn.png');
315                    break;
316               case -2:
317                    $img_status = sprintf($img,__('junk'),'junk.png');
318                    break;
319          }
320         
321          $comment_author = html::escapeHTML($this->rs->comment_author);
322          if (mb_strlen($comment_author) > 20) {
323               $comment_author = mb_strcut($comment_author,0,17).'...';
324          }
325         
326          $res = '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'.
327          ' id="c'.$this->rs->comment_id.'">';
328         
329          $res .=
330          '<td class="nowrap">'.
331          form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).'</td>'.
332          '<td class="maximal"><a href="'.$post_url.'">'.
333          html::escapeHTML($this->rs->post_title).'</a>'.
334          ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</td>'.
335          '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'.
336          '<td class="nowrap"><a href="'.$author_url.'">'.html::escapeHTML($comment_author).'</a></td>'.
337          '<td class="nowrap">'.($this->rs->comment_trackback ? __('trackback') : __('comment')).'</td>'.
338          '<td class="nowrap status">'.$img_status.'</td>'.
339          '<td class="nowrap status"><a href="'.$comment_url.'">'.
340          '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>';
341         
342          $res .= '</tr>';
343         
344          return $res;
345     }
346}
347
348class adminUserList extends adminGenericList
349{
350     public function display($page,$nb_per_page,$enclose_block='')
351     {
352          if ($this->rs->isEmpty())
353          {
354               echo '<p><strong>'.__('No user').'</strong></p>';
355          }
356          else
357          {
358               $pager = new pager($page,$this->rs_count,$nb_per_page,10);
359               $pager->html_prev = $this->html_prev;
360               $pager->html_next = $this->html_next;
361               $pager->var_page = 'page';
362               
363               $html_block =
364               '<table class="clear"><tr>'.
365               '<th colspan="2">'.__('Username').'</th>'.
366               '<th>'.__('First Name').'</th>'.
367               '<th>'.__('Last Name').'</th>'.
368               '<th>'.__('Display name').'</th>'.
369               '<th class="nowrap">'.__('Entries').'</th>'.
370               '</tr>%s</table>';
371               
372               if ($enclose_block) {
373                    $html_block = sprintf($enclose_block,$html_block);
374               }
375               
376               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
377               
378               $blocks = explode('%s',$html_block);
379               
380               echo $blocks[0];
381               
382               while ($this->rs->fetch())
383               {
384                    echo $this->userLine();
385               }
386               
387               echo $blocks[1];
388               
389               echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>';
390          }
391     }
392     
393     private function userLine()
394     {
395          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
396          $img_status = '';
397         
398          $p = $this->core->getUserPermissions($this->rs->user_id);
399         
400          if (isset($p[$this->core->blog->id]['p']['admin'])) {
401               $img_status = sprintf($img,__('admin'),'admin.png');
402          }
403          if ($this->rs->user_super) {
404               $img_status = sprintf($img,__('superadmin'),'superadmin.png');
405          }
406          return
407          '<tr class="line">'.
408          '<td class="nowrap">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post).
409          form::checkbox(array('users[]'),$this->rs->user_id).'</td>'.
410          '<td class="maximal"><a href="user.php?id='.$this->rs->user_id.'">'.
411          $this->rs->user_id.'</a>&nbsp;'.$img_status.'</td>'.
412          '<td class="nowrap">'.html::escapeHTML($this->rs->user_firstname).'</td>'.
413          '<td class="nowrap">'.html::escapeHTML($this->rs->user_name).'</td>'.
414          '<td class="nowrap">'.html::escapeHTML($this->rs->user_displayname).'</td>'.
415          '<td class="nowrap"><a href="posts.php?user_id='.$this->rs->user_id.'">'.
416          $this->rs->nb_post.'</a></td>'.
417          '</tr>';
418     }
419}
420?>
Note: See TracBrowser for help on using the repository browser.

Sites map