[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">'. |
---|
| 34 | '<table class="maximal dragable"><thead><tr>'. |
---|
[2126] | 35 | '<th colspan="3" scope="col" class="first">'.__('Title').'</th>'. |
---|
| 36 | '<th scope="col">'.__('Date').'</th>'. |
---|
| 37 | '<th scope="col">'.__('Author').'</th>'. |
---|
[2127] | 38 | '<th scope="col"><img src="images/comments.png" alt="" title="'.__('Comments').'" /><span class="hidden">'.__('Comments').'</span></th>'. |
---|
| 39 | '<th scope="col"><img src="images/trackbacks.png" alt="" title="'.__('Trackbacks').'" /><span class="hidden">'.__('Trackbacks').'</span></th>'. |
---|
[2126] | 40 | '<th scope="col">'.__('Status').'</th>'. |
---|
[2055] | 41 | '</tr></thead><tbody id="pageslist">%s</tbody></table></div>'; |
---|
[2566] | 42 | |
---|
[2055] | 43 | if ($enclose_block) { |
---|
| 44 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 45 | } |
---|
[2566] | 46 | |
---|
[2055] | 47 | echo $pager->getLinks(); |
---|
[2566] | 48 | |
---|
[2055] | 49 | $blocks = explode('%s',$html_block); |
---|
[2566] | 50 | |
---|
[2055] | 51 | echo $blocks[0]; |
---|
[2566] | 52 | |
---|
[2055] | 53 | $count = 0; |
---|
| 54 | while ($this->rs->fetch()) |
---|
| 55 | { |
---|
| 56 | echo $this->postLine($count,isset($entries[$this->rs->post_id])); |
---|
| 57 | $count ++; |
---|
| 58 | } |
---|
[2566] | 59 | |
---|
[2055] | 60 | echo $blocks[1]; |
---|
[2566] | 61 | |
---|
[2055] | 62 | echo $pager->getLinks(); |
---|
| 63 | } |
---|
| 64 | } |
---|
[2566] | 65 | |
---|
[2055] | 66 | private function postLine($count,$checked) |
---|
| 67 | { |
---|
| 68 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 69 | switch ($this->rs->post_status) { |
---|
| 70 | case 1: |
---|
| 71 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
| 72 | break; |
---|
| 73 | case 0: |
---|
| 74 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
| 75 | break; |
---|
| 76 | case -1: |
---|
| 77 | $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); |
---|
| 78 | break; |
---|
| 79 | case -2: |
---|
| 80 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
| 81 | break; |
---|
| 82 | } |
---|
[2566] | 83 | |
---|
[2055] | 84 | $protected = ''; |
---|
| 85 | if ($this->rs->post_password) { |
---|
| 86 | $protected = sprintf($img,__('Protected'),'locker.png'); |
---|
| 87 | } |
---|
[2566] | 88 | |
---|
[2055] | 89 | $selected = ''; |
---|
| 90 | if ($this->rs->post_selected) { |
---|
| 91 | $selected = sprintf($img,__('Hidden'),'hidden.png'); |
---|
| 92 | } |
---|
[2566] | 93 | |
---|
[2055] | 94 | $attach = ''; |
---|
| 95 | $nb_media = $this->rs->countMedia(); |
---|
| 96 | if ($nb_media > 0) { |
---|
| 97 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
---|
| 98 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
---|
| 99 | } |
---|
[2566] | 100 | |
---|
[2055] | 101 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
---|
| 102 | ' id="p'.$this->rs->post_id.'">'; |
---|
[2566] | 103 | |
---|
[2055] | 104 | $res .= |
---|
| 105 | '<td class="nowrap handle minimal">'.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>'. |
---|
| 106 | '<td class="nowrap">'. |
---|
| 107 | form::checkbox(array('entries[]'),$this->rs->post_id,$checked,'','',!$this->rs->isEditable(),'title="'.__('Select this page').'"').'</td>'. |
---|
[2126] | 108 | '<td class="maximal" scope="row"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
---|
[2055] | 109 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
---|
[2566] | 110 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
---|
[2055] | 111 | '<td class="nowrap">'.$this->rs->user_id.'</td>'. |
---|
[2126] | 112 | '<td class="nowrap count">'.$this->rs->nb_comment.'</td>'. |
---|
| 113 | '<td class="nowrap count">'.$this->rs->nb_trackback.'</td>'. |
---|
[2055] | 114 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
---|
| 115 | '</tr>'; |
---|
[2566] | 116 | |
---|
[2055] | 117 | return $res; |
---|
| 118 | } |
---|
| 119 | } |
---|