Dotclear

source: plugins/pages/class.listpage.php @ 3265:fb9870e49400

Revision 3265:fb9870e49400, 4.8 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Optional display of columns in posts and pages lists, closes #1074

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               // Cope with optional columns
51               $this->userColumns('pages',$cols);
52
53               $html_block .= '<tr>'.implode(iterator_to_array($cols)).
54                    '</tr></thead><tbody id="pageslist">%s</tbody></table></div>';
55
56               if ($enclose_block) {
57                    $html_block = sprintf($enclose_block,$html_block);
58               }
59
60               echo $pager->getLinks();
61
62               $blocks = explode('%s',$html_block);
63
64               echo $blocks[0];
65
66               $count = 0;
67               while ($this->rs->fetch())
68               {
69                    echo $this->postLine($count,isset($entries[$this->rs->post_id]));
70                    $count ++;
71               }
72
73               echo $blocks[1];
74
75               echo $pager->getLinks();
76          }
77     }
78
79     private function postLine($count,$checked)
80     {
81          $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
82          $sts_class = '';
83          switch ($this->rs->post_status) {
84               case 1:
85                    $img_status = sprintf($img,__('Published'),'check-on.png');
86                    $sts_class = 'sts-online';
87                    break;
88               case 0:
89                    $img_status = sprintf($img,__('Unpublished'),'check-off.png');
90                    $sts_class = 'sts-offline';
91                    break;
92               case -1:
93                    $img_status = sprintf($img,__('Scheduled'),'scheduled.png');
94                    $sts_class = 'sts-scheduled';
95                    break;
96               case -2:
97                    $img_status = sprintf($img,__('Pending'),'check-wrn.png');
98                    $sts_class = 'sts-pending';
99                    break;
100          }
101
102          $protected = '';
103          if ($this->rs->post_password) {
104               $protected = sprintf($img,__('Protected'),'locker.png');
105          }
106
107          $selected = '';
108          if ($this->rs->post_selected) {
109               $selected = sprintf($img,__('Hidden'),'hidden.png');
110          }
111
112          $attach = '';
113          $nb_media = $this->rs->countMedia();
114          if ($nb_media > 0) {
115               $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
116               $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');
117          }
118
119          $res = '<tr class="line '.($this->rs->post_status != 1 ? 'offline ' : '').$sts_class.'"'.
120          ' id="p'.$this->rs->post_id.'">';
121
122          $cols = array(
123               'position' =>       '<td class="nowrap handle minimal">'.
124                                        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>',
125               'check' =>               '<td class="nowrap">'.
126                                        form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable(),'title="'.__('Select this page').'"').'</td>',
127               'title' =>               '<td class="maximal" scope="row"><a href="'.
128                                        $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'.
129                                        html::escapeHTML($this->rs->post_title).'</a></td>',
130               'date' =>           '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>',
131               'author' =>              '<td class="nowrap">'.$this->rs->user_id.'</td>',
132               'comments' =>       '<td class="nowrap count">'.$this->rs->nb_comment.'</td>',
133               'trackbacks' =>          '<td class="nowrap count">'.$this->rs->nb_trackback.'</td>',
134               'status' =>              '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'
135          );
136
137          $cols = new ArrayObject($cols);
138          $this->core->callBehavior('adminPagesListValue',$this->core,$this->rs,$cols);
139
140          // Cope with optional columns
141          $this->userColumns('pages',$cols);
142
143          $res .= implode(iterator_to_array($cols));
144          $res .= '</tr>';
145
146          return $res;
147     }
148}
Note: See TracBrowser for help on using the repository browser.

Sites map