Dotclear

source: inc/admin/lib.pager.php @ 1905:d72d24250853

Revision 1905:d72d24250853, 12.9 KB checked in by Dsls, 12 years ago (diff)

RIP admin/comments_actions.php

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

Sites map