Dotclear

source: plugins/pages/class.listpage.php @ 3089:c9d317ee8619

Revision 3089:c9d317ee8619, 4.5 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

Add behaviors for posts/pages/comments/users lists' column, addresses #2133

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 -----------------------------------------
12
13/* Pager class
14-------------------------------------------------------- */
15class adminPagesList extends adminGenericList
16{
17     public function display($page,$nb_per_page,$enclose_block='')
18     {
19          if ($this->rs->isEmpty())
20          {
21               echo '<p><strong>'.__('No page').'</strong></p>';
22          }
23          else
24          {
25               $pager = new dcPager($page,$this->rs_count,$nb_per_page,10);
26               $entries = array();
27               if (isset($_REQUEST['entries'])) {
28                    foreach ($_REQUEST['entries'] as $v) {
29                         $entries[(integer)$v]=true;
30                    }
31               }
32               $html_block =
33               '<div class="table-outer">'.
34               '<table class="maximal dragable"><thead><tr>';
35
36               $cols = array(
37                    'title' =>               '<th colspan="3" scope="col" class="first">'.__('Title').'</th>',
38                    'date' =>           '<th scope="col">'.__('Date').'</th>',
39                    'author' =>              '<th scope="col">'.__('Author').'</th>',
40                    'comments' =>       '<th scope="col"><img src="images/comments.png" alt="" title="'.__('Comments').
41                                             '" /><span class="hidden">'.__('Comments').'</span></th>',
42                    'trackbacks' =>          '<th scope="col"><img src="images/trackbacks.png" alt="" title="'.__('Trackbacks').
43                                             '" /><span class="hidden">'.__('Trackbacks').'</span></th>',
44                    'status' =>              '<th scope="col">'.__('Status').'</th>'
45               );
46
47               $cols = new ArrayObject($cols);
48               $this->core->callBehavior('adminPagesListHeader',$this->core,$this->rs,$cols);
49
50               $html_block .= '<tr>'.implode(iterator_to_array($cols)).
51                    '</tr></thead><tbody id="pageslist">%s</tbody></table></div>';
52
53               if ($enclose_block) {
54                    $html_block = sprintf($enclose_block,$html_block);
55               }
56
57               echo $pager->getLinks();
58
59               $blocks = explode('%s',$html_block);
60
61               echo $blocks[0];
62
63               $count = 0;
64               while ($this->rs->fetch())
65               {
66                    echo $this->postLine($count,isset($entries[$this->rs->post_id]));
67                    $count ++;
68               }
69
70               echo $blocks[1];
71
72               echo $pager->getLinks();
73          }
74     }
75
76     private function postLine($count,$checked)
77     {
78          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
79          switch ($this->rs->post_status) {
80               case 1:
81                    $img_status = sprintf($img,__('Published'),'check-on.png');
82                    break;
83               case 0:
84                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
85                    break;
86               case -1:
87                    $img_status = sprintf($img,__('Scheduled'),'scheduled.png');
88                    break;
89               case -2:
90                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
91                    break;
92          }
93
94          $protected = '';
95          if ($this->rs->post_password) {
96               $protected = sprintf($img,__('Protected'),'locker.png');
97          }
98
99          $selected = '';
100          if ($this->rs->post_selected) {
101               $selected = sprintf($img,__('Hidden'),'hidden.png');
102          }
103
104          $attach = '';
105          $nb_media = $this->rs->countMedia();
106          if ($nb_media > 0) {
107               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
108               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
109          }
110
111          $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
112          ' id="p'.$this->rs->post_id.'">';
113
114          $cols = array(
115               'position' =>       '<td class="nowrap handle minimal">'.
116                                        form::field(array('order['.$this->rs->post_id.']'),2,3,$count+1,'position','',false,'title="'.sprintf(__('position of %s'),html::escapeHTML($this->rs->post_title)).'"').'</td>',
117               'check' =>               '<td class="nowrap">'.
118                                        form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable(),'title="'.__('Select this page').'"').'</td>',
119               'title' =>               '<td class="maximal" scope="row"><a href="'.
120                                        $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.
121                                        html::escapeHTML($this->rs->post_title).'</a></td>',
122               'date' =>           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>',
123               'author' =>              '<td class="nowrap">'.$this->rs->user_id.'</td>',
124               'comments' =>       '<td class="nowrap count">'.$this->rs->nb_comment.'</td>',
125               'trackbacks' =>          '<td class="nowrap count">'.$this->rs->nb_trackback.'</td>',
126               'status' =>              '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'
127          );
128
129          $cols = new ArrayObject($cols);
130          $this->core->callBehavior('adminPagesListValue',$this->core,$this->rs,$cols);
131
132          $res .= implode(iterator_to_array($cols));
133          $res .= '</tr>';
134
135          return $res;
136     }
137}
Note: See TracBrowser for help on using the repository browser.

Sites map