| 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 | -------------------------------------------------------- */ |
|---|
| 15 | class adminPageList 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 | '<th colspan="3">'.__('Title').'</th>'. |
|---|
| 36 | '<th>'.__('Date').'</th>'. |
|---|
| 37 | '<th>'.__('Author').'</th>'. |
|---|
| 38 | '<th>'.__('Comments').'</th>'. |
|---|
| 39 | '<th>'.__('Trackbacks').'</th>'. |
|---|
| 40 | '<th>'.__('Status').'</th>'. |
|---|
| 41 | '</tr></thead><tbody id="pageslist">%s</tbody></table></div>'; |
|---|
| 42 | |
|---|
| 43 | if ($enclose_block) { |
|---|
| 44 | $html_block = sprintf($enclose_block,$html_block); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | echo $pager->getLinks(); |
|---|
| 48 | |
|---|
| 49 | $blocks = explode('%s',$html_block); |
|---|
| 50 | |
|---|
| 51 | echo $blocks[0]; |
|---|
| 52 | |
|---|
| 53 | $count = 0; |
|---|
| 54 | while ($this->rs->fetch()) |
|---|
| 55 | { |
|---|
| 56 | echo $this->postLine($count,isset($entries[$this->rs->post_id])); |
|---|
| 57 | $count ++; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | echo $blocks[1]; |
|---|
| 61 | |
|---|
| 62 | echo $pager->getLinks(); |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 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 | } |
|---|
| 83 | |
|---|
| 84 | $protected = ''; |
|---|
| 85 | if ($this->rs->post_password) { |
|---|
| 86 | $protected = sprintf($img,__('Protected'),'locker.png'); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | $selected = ''; |
|---|
| 90 | if ($this->rs->post_selected) { |
|---|
| 91 | $selected = sprintf($img,__('Hidden'),'hidden.png'); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 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 | } |
|---|
| 100 | |
|---|
| 101 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
|---|
| 102 | ' id="p'.$this->rs->post_id.'">'; |
|---|
| 103 | |
|---|
| 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>'. |
|---|
| 108 | '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
|---|
| 109 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
|---|
| 110 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
|---|
| 111 | |
|---|
| 112 | '<td class="nowrap">'.$this->rs->user_id.'</td>'. |
|---|
| 113 | '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. |
|---|
| 114 | '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. |
|---|
| 115 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
|---|
| 116 | '</tr>'; |
|---|
| 117 | |
|---|
| 118 | return $res; |
|---|
| 119 | } |
|---|
| 120 | } |
|---|