[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 = |
---|
[1875] | 33 | '<table class="maximal dragable"><thead><tr>'. |
---|
| 34 | '<th scope="col"></th>'. |
---|
[0] | 35 | '<th colspan="2">'.__('Title').'</th>'. |
---|
| 36 | '<th>'.__('Date').'</th>'. |
---|
| 37 | '<th>'.__('Author').'</th>'. |
---|
| 38 | '<th>'.__('Comments').'</th>'. |
---|
| 39 | '<th>'.__('Trackbacks').'</th>'. |
---|
| 40 | '<th>'.__('Status').'</th>'. |
---|
[1875] | 41 | '</tr></thead>%s</table>'; |
---|
[0] | 42 | |
---|
| 43 | if ($enclose_block) { |
---|
| 44 | $html_block = sprintf($enclose_block,$html_block); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
| 48 | |
---|
| 49 | $blocks = explode('%s',$html_block); |
---|
| 50 | |
---|
| 51 | echo $blocks[0]; |
---|
| 52 | |
---|
[1875] | 53 | $count = 0; |
---|
[0] | 54 | while ($this->rs->fetch()) |
---|
| 55 | { |
---|
[1875] | 56 | echo $this->postLine($count); |
---|
| 57 | $count++; |
---|
[0] | 58 | } |
---|
| 59 | |
---|
| 60 | echo $blocks[1]; |
---|
| 61 | |
---|
| 62 | echo '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
[1875] | 66 | private function postLine($count) |
---|
[0] | 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) { |
---|
[911] | 91 | $selected = sprintf($img,__('hidden'),'hidden.png'); |
---|
[0] | 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 .= |
---|
[1875] | 105 | '<td class="handle minimal">'.form::field(array('order['.$count.']'),2,3,$count+1,'position','',false,'title="'.sprintf(__('position of %s'),html::escapeHTML($this->rs->post_title)).'"'). |
---|
| 106 | form::hidden(array('dynorder[]','dynorder-'.$count),$count).'</td>'. |
---|
[0] | 107 | '<td class="nowrap">'. |
---|
[91] | 108 | form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable(),'title="'.__('select this page').'"').'</td>'. |
---|
[0] | 109 | '<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
---|
| 110 | html::escapeHTML($this->rs->post_title).'</a></td>'. |
---|
| 111 | '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. |
---|
| 112 | |
---|
| 113 | '<td class="nowrap">'.$this->rs->user_id.'</td>'. |
---|
| 114 | '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. |
---|
| 115 | '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. |
---|
| 116 | '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. |
---|
| 117 | '</tr>'; |
---|
| 118 | |
---|
| 119 | return $res; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | /* Getting pages |
---|
| 124 | -------------------------------------------------------- */ |
---|
| 125 | $params = array( |
---|
| 126 | 'post_type' => 'page' |
---|
| 127 | ); |
---|
| 128 | |
---|
| 129 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
| 130 | $nb_per_page = 30; |
---|
| 131 | |
---|
| 132 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
| 133 | $nb_per_page = (integer) $_GET['nb']; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 137 | $params['no_content'] = true; |
---|
| 138 | $params['order'] = 'post_position ASC, post_title ASC'; |
---|
| 139 | |
---|
| 140 | try { |
---|
| 141 | $pages = $core->blog->getPosts($params); |
---|
| 142 | $counter = $core->blog->getPosts($params,true); |
---|
| 143 | $post_list = new adminPageList($core,$pages,$counter->f(0)); |
---|
| 144 | } catch (Exception $e) { |
---|
| 145 | $core->error->add($e->getMessage()); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | # Actions combo box |
---|
| 149 | $combo_action = array(); |
---|
| 150 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 151 | { |
---|
| 152 | $combo_action[__('publish')] = 'publish'; |
---|
| 153 | $combo_action[__('unpublish')] = 'unpublish'; |
---|
[578] | 154 | $combo_action[__('schedule')] = 'schedule'; |
---|
[0] | 155 | $combo_action[__('mark as pending')] = 'pending'; |
---|
| 156 | } |
---|
| 157 | if ($core->auth->check('admin',$core->blog->id)) { |
---|
| 158 | $combo_action[__('change author')] = 'author'; |
---|
| 159 | } |
---|
| 160 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 161 | { |
---|
| 162 | $combo_action[__('delete')] = 'delete'; |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | # --BEHAVIOR-- adminPagesActionsCombo |
---|
| 166 | $core->callBehavior('adminPagesActionsCombo',array(&$combo_action)); |
---|
| 167 | |
---|
| 168 | /* Display |
---|
| 169 | -------------------------------------------------------- */ |
---|
| 170 | ?> |
---|
| 171 | <html> |
---|
| 172 | <head> |
---|
| 173 | <title><?php echo __('Pages'); ?></title> |
---|
| 174 | <script type="text/javascript" src="js/_posts_list.js"></script> |
---|
| 175 | <script type="text/javascript"> |
---|
| 176 | //<![CDATA[ |
---|
| 177 | <?php echo dcPage::jsVar('dotclear.msg.confirm_delete_posts',__("Are you sure you want to delete selected pages?")); ?> |
---|
| 178 | //]]> |
---|
| 179 | </script> |
---|
| 180 | </head> |
---|
| 181 | |
---|
| 182 | <body> |
---|
| 183 | <?php |
---|
[1358] | 184 | echo dcPage::breadcrumb( |
---|
[1339] | 185 | array( |
---|
| 186 | html::escapeHTML($core->blog->name) => '', |
---|
| 187 | '<span class="page-title">'.__('Pages').'</span>' => '' |
---|
| 188 | )); |
---|
| 189 | |
---|
| 190 | echo |
---|
[158] | 191 | '<p class="top-add"><a class="button add" href="'.$p_url.'&act=page">'.__('New page').'</a></p>'; |
---|
[0] | 192 | |
---|
| 193 | if (!$core->error->flag()) |
---|
| 194 | { |
---|
| 195 | # Show pages |
---|
| 196 | $post_list->display($page,$nb_per_page, |
---|
| 197 | '<form action="posts_actions.php" method="post" id="form-entries">'. |
---|
| 198 | |
---|
| 199 | '%s'. |
---|
| 200 | |
---|
| 201 | '<div class="two-cols">'. |
---|
| 202 | '<p class="col checkboxes-helpers"></p>'. |
---|
[96] | 203 | '<p class="col right"><label for="action" class="classic">'.__('Selected pages action:').'</label> '. |
---|
[0] | 204 | form::combo('action',$combo_action). |
---|
| 205 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
[1875] | 206 | '</div>'. |
---|
| 207 | |
---|
| 208 | '<p>'. |
---|
| 209 | '<input type="submit" name="updateaction" value="'.__('Update menu').'" />'. |
---|
[0] | 210 | form::hidden(array('post_type'),'page'). |
---|
| 211 | form::hidden(array('redir'),html::escapeHTML($_SERVER['REQUEST_URI'])). |
---|
| 212 | $core->formNonce(). |
---|
[1875] | 213 | '</p>'. |
---|
[0] | 214 | '</form>'); |
---|
| 215 | } |
---|
[198] | 216 | dcPage::helpBlock('pages'); |
---|
[0] | 217 | ?> |
---|
| 218 | </body> |
---|
| 219 | </html> |
---|