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