[2055] | 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 | -------------------------------------------------------- */ |
---|
[2232] | 15 | class adminPagesList extends adminGenericList |
---|
[2055] | 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 | } |
---|
[2566] | 31 | } |
---|
[2055] | 32 | $html_block = |
---|
| 33 | '<div class="table-outer">'. |
---|
[3089] | 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 | |
---|
[3265] | 50 | // Cope with optional columns |
---|
| 51 | $this->userColumns('pages',$cols); |
---|
| 52 | |
---|
[3089] | 53 | $html_block .= '<tr>'.implode(iterator_to_array($cols)). |
---|
| 54 | '</tr></thead><tbody id="pageslist">%s</tbody></table></div>'; |
---|
[2566] | 55 | |
---|
[2055] | 56 | if ($enclose_block) { |
---|
| 57 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 58 | } |
---|
[2566] | 59 | |
---|
[2055] | 60 | echo $pager->getLinks(); |
---|
[2566] | 61 | |
---|
[2055] | 62 | $blocks = explode('%s',$html_block); |
---|
[2566] | 63 | |
---|
[2055] | 64 | echo $blocks[0]; |
---|
[2566] | 65 | |
---|
[2055] | 66 | $count = 0; |
---|
| 67 | while ($this->rs->fetch()) |
---|
| 68 | { |
---|
| 69 | echo $this->postLine($count,isset($entries[$this->rs->post_id])); |
---|
| 70 | $count ++; |
---|
| 71 | } |
---|
[2566] | 72 | |
---|
[2055] | 73 | echo $blocks[1]; |
---|
[2566] | 74 | |
---|
[2055] | 75 | echo $pager->getLinks(); |
---|
| 76 | } |
---|
| 77 | } |
---|
[2566] | 78 | |
---|
[2055] | 79 | private function postLine($count,$checked) |
---|
| 80 | { |
---|
| 81 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
[3118] | 82 | $sts_class = ''; |
---|
[2055] | 83 | switch ($this->rs->post_status) { |
---|
| 84 | case 1: |
---|
| 85 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
[3118] | 86 | $sts_class = 'sts-online'; |
---|
[2055] | 87 | break; |
---|
| 88 | case 0: |
---|
| 89 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
[3118] | 90 | $sts_class = 'sts-offline'; |
---|
[2055] | 91 | break; |
---|
| 92 | case -1: |
---|
| 93 | $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); |
---|
[3118] | 94 | $sts_class = 'sts-scheduled'; |
---|
[2055] | 95 | break; |
---|
| 96 | case -2: |
---|
| 97 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
[3118] | 98 | $sts_class = 'sts-pending'; |
---|
[2055] | 99 | break; |
---|
| 100 | } |
---|
[2566] | 101 | |
---|
[2055] | 102 | $protected = ''; |
---|
| 103 | if ($this->rs->post_password) { |
---|
| 104 | $protected = sprintf($img,__('Protected'),'locker.png'); |
---|
| 105 | } |
---|
[2566] | 106 | |
---|
[2055] | 107 | $selected = ''; |
---|
| 108 | if ($this->rs->post_selected) { |
---|
| 109 | $selected = sprintf($img,__('Hidden'),'hidden.png'); |
---|
| 110 | } |
---|
[2566] | 111 | |
---|
[2055] | 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 | } |
---|
[2566] | 118 | |
---|
[3118] | 119 | $res = '<tr class="line '.($this->rs->post_status != 1 ? 'offline ' : '').$sts_class.'"'. |
---|
[2055] | 120 | ' id="p'.$this->rs->post_id.'">'; |
---|
[2566] | 121 | |
---|
[3089] | 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 | |
---|
[3265] | 140 | // Cope with optional columns |
---|
| 141 | $this->userColumns('pages',$cols); |
---|
| 142 | |
---|
[3089] | 143 | $res .= implode(iterator_to_array($cols)); |
---|
| 144 | $res .= '</tr>'; |
---|
[2566] | 145 | |
---|
[2055] | 146 | return $res; |
---|
| 147 | } |
---|
| 148 | } |
---|