[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
| 13 | dcPage::check('pages,contentadmin'); |
---|
| 14 | |
---|
| 15 | /* Pager class |
---|
| 16 | -------------------------------------------------------- */ |
---|
| 17 | class adminPageList extends adminGenericList |
---|
| 18 | { |
---|
| 19 | public function display($page,$nb_per_page,$enclose_block='') |
---|
| 20 | { |
---|
| 21 | if ($this->rs->isEmpty()) |
---|
| 22 | { |
---|
| 23 | echo '<p><strong>'.__('No page').'</strong></p>'; |
---|
| 24 | } |
---|
| 25 | else |
---|
| 26 | { |
---|
| 27 | $pager = new pager($page,$this->rs_count,$nb_per_page,10); |
---|
| 28 | $pager->html_prev = $this->html_prev; |
---|
| 29 | $pager->html_next = $this->html_next; |
---|
| 30 | $pager->var_page = 'page'; |
---|
| 31 | |
---|
| 32 | $html_block = |
---|
[1882] | 33 | '<table class="maximal dragable"><thead><tr>'. |
---|
| 34 | '<th colspan="3">'.__('Title').'</th>'. |
---|
[0] | 35 | '<th>'.__('Date').'</th>'. |
---|
| 36 | '<th>'.__('Author').'</th>'. |
---|
| 37 | '<th>'.__('Comments').'</th>'. |
---|
| 38 | '<th>'.__('Trackbacks').'</th>'. |
---|
| 39 | '<th>'.__('Status').'</th>'. |
---|
[1882] | 40 | '</tr></thead><tbody id="pageslist">%s</tbody></table>'; |
---|
[0] | 41 | |
---|
| 42 | if ($enclose_block) { |
---|
| 43 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 44 | } |
---|
| 45 | |
---|
[1416] | 46 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 47 | |
---|
| 48 | $blocks = explode('%s',$html_block); |
---|
| 49 | |
---|
| 50 | echo $blocks[0]; |
---|
| 51 | |
---|
[1882] | 52 | $count = 0; |
---|
[0] | 53 | while ($this->rs->fetch()) |
---|
| 54 | { |
---|
[1882] | 55 | echo $this->postLine($count); |
---|
| 56 | $count ++; |
---|
[0] | 57 | } |
---|
| 58 | |
---|
| 59 | echo $blocks[1]; |
---|
| 60 | |
---|
[1416] | 61 | echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 62 | } |
---|
| 63 | } |
---|
| 64 | |
---|
[1882] | 65 | private function postLine($count) |
---|
[0] | 66 | { |
---|
| 67 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 68 | switch ($this->rs->post_status) { |
---|
| 69 | case 1: |
---|
[1464] | 70 | $img_status = sprintf($img,__('Published'),'check-on.png'); |
---|
[0] | 71 | break; |
---|
| 72 | case 0: |
---|
[1464] | 73 | $img_status = sprintf($img,__('Unpublished'),'check-off.png'); |
---|
[0] | 74 | break; |
---|
| 75 | case -1: |
---|
[1464] | 76 | $img_status = sprintf($img,__('Scheduled'),'scheduled.png'); |
---|
[0] | 77 | break; |
---|
| 78 | case -2: |
---|
[1464] | 79 | $img_status = sprintf($img,__('Pending'),'check-wrn.png'); |
---|
[0] | 80 | break; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | $protected = ''; |
---|
| 84 | if ($this->rs->post_password) { |
---|
[1464] | 85 | $protected = sprintf($img,__('Protected'),'locker.png'); |
---|
[0] | 86 | } |
---|
| 87 | |
---|
| 88 | $selected = ''; |
---|
| 89 | if ($this->rs->post_selected) { |
---|
[1464] | 90 | $selected = sprintf($img,__('Hidden'),'hidden.png'); |
---|
[0] | 91 | } |
---|
| 92 | |
---|
| 93 | $attach = ''; |
---|
| 94 | $nb_media = $this->rs->countMedia(); |
---|
| 95 | if ($nb_media > 0) { |
---|
| 96 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
---|
| 97 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
---|
| 101 | ' id="p'.$this->rs->post_id.'">'; |
---|
| 102 | |
---|
| 103 | $res .= |
---|
[1882] | 104 | '<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>'. |
---|
[0] | 105 | '<td class="nowrap">'. |
---|
[1464] | 106 | form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable(),'title="'.__('Select this page').'"').'</td>'. |
---|
[0] | 107 | '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
---|
| 108 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
---|
| 109 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
---|
| 110 | |
---|
| 111 | '<td class="nowrap">'.$this->rs->user_id.'</td>'. |
---|
| 112 | '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. |
---|
| 113 | '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. |
---|
| 114 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
---|
| 115 | '</tr>'; |
---|
| 116 | |
---|
| 117 | return $res; |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | /* Getting pages |
---|
| 122 | -------------------------------------------------------- */ |
---|
| 123 | $params = array( |
---|
| 124 | 'post_type' => 'page' |
---|
| 125 | ); |
---|
| 126 | |
---|
| 127 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
| 128 | $nb_per_page = 30; |
---|
| 129 | |
---|
| 130 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
| 131 | $nb_per_page = (integer) $_GET['nb']; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 135 | $params['no_content'] = true; |
---|
| 136 | $params['order'] = 'post_position ASC, post_title ASC'; |
---|
| 137 | |
---|
| 138 | try { |
---|
| 139 | $pages = $core->blog->getPosts($params); |
---|
| 140 | $counter = $core->blog->getPosts($params,true); |
---|
| 141 | $post_list = new adminPageList($core,$pages,$counter->f(0)); |
---|
| 142 | } catch (Exception $e) { |
---|
| 143 | $core->error->add($e->getMessage()); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | # Actions combo box |
---|
| 147 | $combo_action = array(); |
---|
| 148 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 149 | { |
---|
[1882] | 150 | $combo_action[__('Reorder')] = 'reorder'; |
---|
[1464] | 151 | $combo_action[__('Publish')] = 'publish'; |
---|
| 152 | $combo_action[__('Unpublish')] = 'unpublish'; |
---|
| 153 | $combo_action[__('Schedule')] = 'schedule'; |
---|
| 154 | $combo_action[__('Mark as pending')] = 'pending'; |
---|
[0] | 155 | } |
---|
| 156 | if ($core->auth->check('admin',$core->blog->id)) { |
---|
[1464] | 157 | $combo_action[__('Change author')] = 'author'; |
---|
[0] | 158 | } |
---|
| 159 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 160 | { |
---|
[1464] | 161 | $combo_action[__('Delete')] = 'delete'; |
---|
[0] | 162 | } |
---|
| 163 | |
---|
| 164 | # --BEHAVIOR-- adminPagesActionsCombo |
---|
| 165 | $core->callBehavior('adminPagesActionsCombo',array(&$combo_action)); |
---|
| 166 | |
---|
| 167 | /* Display |
---|
| 168 | -------------------------------------------------------- */ |
---|
| 169 | ?> |
---|
| 170 | <html> |
---|
| 171 | <head> |
---|
| 172 | <title><?php echo __('Pages'); ?></title> |
---|
[1882] | 173 | <?php |
---|
| 174 | echo dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). |
---|
| 175 | dcPage::jsLoad('index.php?pf=pages/list.js'); |
---|
| 176 | ?> |
---|
[0] | 177 | <script type="text/javascript"> |
---|
| 178 | //<![CDATA[ |
---|
| 179 | <?php echo dcPage::jsVar('dotclear.msg.confirm_delete_posts',__("Are you sure you want to delete selected pages?")); ?> |
---|
| 180 | //]]> |
---|
| 181 | </script> |
---|
| 182 | </head> |
---|
| 183 | |
---|
| 184 | <body> |
---|
| 185 | <?php |
---|
[1358] | 186 | echo dcPage::breadcrumb( |
---|
[1339] | 187 | array( |
---|
| 188 | html::escapeHTML($core->blog->name) => '', |
---|
| 189 | '<span class="page-title">'.__('Pages').'</span>' => '' |
---|
| 190 | )); |
---|
| 191 | |
---|
| 192 | echo |
---|
[158] | 193 | '<p class="top-add"><a class="button add" href="'.$p_url.'&act=page">'.__('New page').'</a></p>'; |
---|
[0] | 194 | |
---|
| 195 | if (!$core->error->flag()) |
---|
| 196 | { |
---|
| 197 | # Show pages |
---|
| 198 | $post_list->display($page,$nb_per_page, |
---|
| 199 | '<form action="posts_actions.php" method="post" id="form-entries">'. |
---|
| 200 | |
---|
| 201 | '%s'. |
---|
| 202 | |
---|
| 203 | '<div class="two-cols">'. |
---|
| 204 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 205 | |
---|
[96] | 206 | '<p class="col right"><label for="action" class="classic">'.__('Selected pages action:').'</label> '. |
---|
[0] | 207 | form::combo('action',$combo_action). |
---|
| 208 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 209 | form::hidden(array('post_type'),'page'). |
---|
| 210 | form::hidden(array('redir'),html::escapeHTML($_SERVER['REQUEST_URI'])). |
---|
| 211 | $core->formNonce(). |
---|
| 212 | '</div>'. |
---|
| 213 | '</form>'); |
---|
| 214 | } |
---|
[198] | 215 | dcPage::helpBlock('pages'); |
---|
[0] | 216 | ?> |
---|
| 217 | </body> |
---|
| 218 | </html> |
---|