[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 | |
---|
| 13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
| 14 | |
---|
| 15 | dcPage::check('usage,contentadmin'); |
---|
| 16 | |
---|
| 17 | # Getting categories |
---|
| 18 | try { |
---|
| 19 | $categories = $core->blog->getCategories(array('post_type'=>'post')); |
---|
| 20 | } catch (Exception $e) { |
---|
| 21 | $core->error->add($e->getMessage()); |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | # Getting authors |
---|
| 25 | try { |
---|
| 26 | $users = $core->blog->getPostsUsers(); |
---|
| 27 | } catch (Exception $e) { |
---|
| 28 | $core->error->add($e->getMessage()); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | # Getting dates |
---|
| 32 | try { |
---|
| 33 | $dates = $core->blog->getDates(array('type'=>'month')); |
---|
| 34 | } catch (Exception $e) { |
---|
| 35 | $core->error->add($e->getMessage()); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | # Getting langs |
---|
| 39 | try { |
---|
| 40 | $langs = $core->blog->getLangs(); |
---|
| 41 | } catch (Exception $e) { |
---|
| 42 | $core->error->add($e->getMessage()); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | # Creating filter combo boxes |
---|
| 46 | if (!$core->error->flag()) |
---|
| 47 | { |
---|
| 48 | # Filter form we'll put in html_block |
---|
| 49 | $users_combo = $categories_combo = array(); |
---|
| 50 | while ($users->fetch()) |
---|
| 51 | { |
---|
| 52 | $user_cn = dcUtils::getUserCN($users->user_id,$users->user_name, |
---|
| 53 | $users->user_firstname,$users->user_displayname); |
---|
| 54 | |
---|
| 55 | if ($user_cn != $users->user_id) { |
---|
| 56 | $user_cn .= ' ('.$users->user_id.')'; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | $users_combo[$user_cn] = $users->user_id; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | $categories_combo[__('None')] = 'NULL'; |
---|
| 63 | while ($categories->fetch()) { |
---|
| 64 | $categories_combo[str_repeat(' ',$categories->level-1).'• '. |
---|
| 65 | html::escapeHTML($categories->cat_title). |
---|
| 66 | ' ('.$categories->nb_post.')'] = $categories->cat_id; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | $status_combo = array( |
---|
| 70 | ); |
---|
| 71 | foreach ($core->blog->getAllPostStatus() as $k => $v) { |
---|
| 72 | $status_combo[$v] = (string) $k; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | $selected_combo = array( |
---|
[439] | 76 | __('is selected') => '1', |
---|
| 77 | __('is not selected') => '0' |
---|
[0] | 78 | ); |
---|
| 79 | |
---|
| 80 | # Months array |
---|
| 81 | while ($dates->fetch()) { |
---|
| 82 | $dt_m_combo[dt::str('%B %Y',$dates->ts())] = $dates->year().$dates->month(); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | while ($langs->fetch()) { |
---|
| 86 | $lang_combo[$langs->post_lang] = $langs->post_lang; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | $sortby_combo = array( |
---|
| 90 | __('Date') => 'post_dt', |
---|
| 91 | __('Title') => 'post_title', |
---|
| 92 | __('Category') => 'cat_title', |
---|
| 93 | __('Author') => 'user_id', |
---|
| 94 | __('Status') => 'post_status', |
---|
| 95 | __('Selected') => 'post_selected' |
---|
| 96 | ); |
---|
| 97 | |
---|
| 98 | $order_combo = array( |
---|
| 99 | __('Descending') => 'desc', |
---|
| 100 | __('Ascending') => 'asc' |
---|
| 101 | ); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | # Actions combo box |
---|
| 105 | $combo_action = array(); |
---|
| 106 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 107 | { |
---|
| 108 | $combo_action[__('Status')] = array( |
---|
| 109 | __('Publish') => 'publish', |
---|
| 110 | __('Unpublish') => 'unpublish', |
---|
| 111 | __('Schedule') => 'schedule', |
---|
| 112 | __('Mark as pending') => 'pending' |
---|
| 113 | ); |
---|
| 114 | } |
---|
| 115 | $combo_action[__('Mark')] = array( |
---|
| 116 | __('Mark as selected') => 'selected', |
---|
| 117 | __('Mark as unselected') => 'unselected' |
---|
| 118 | ); |
---|
| 119 | $combo_action[__('Change')] = array(__('Change category') => 'category'); |
---|
| 120 | if ($core->auth->check('admin',$core->blog->id)) |
---|
| 121 | { |
---|
| 122 | $combo_action[__('Change')] = array_merge($combo_action[__('Change')], |
---|
| 123 | array(__('Change author') => 'author')); |
---|
| 124 | } |
---|
| 125 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 126 | { |
---|
| 127 | $combo_action[__('Delete')] = array(__('Delete') => 'delete'); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | # --BEHAVIOR-- adminPostsActionsCombo |
---|
| 131 | $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); |
---|
| 132 | |
---|
| 133 | /* Get posts |
---|
| 134 | -------------------------------------------------------- */ |
---|
| 135 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
| 136 | $nb_per_page = 30; |
---|
| 137 | |
---|
| 138 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
| 139 | if ($nb_per_page != $_GET['nb']) { |
---|
| 140 | $show_filters = true; |
---|
| 141 | } |
---|
| 142 | $nb_per_page = (integer) $_GET['nb']; |
---|
| 143 | } |
---|
| 144 | |
---|
[225] | 145 | $params = new ArrayObject(); |
---|
[0] | 146 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 147 | $params['no_content'] = true; |
---|
| 148 | |
---|
[439] | 149 | $filterSet = new dcFilterSet('posts','posts.php'); |
---|
[225] | 150 | class monthComboFilter extends comboFilter { |
---|
| 151 | public function applyFilter($params) { |
---|
| 152 | $month=$this->values[0]; |
---|
| 153 | $params['post_month'] = substr($month,4,2); |
---|
| 154 | $params['post_year'] = substr($month,0,4); |
---|
[0] | 155 | } |
---|
| 156 | } |
---|
[225] | 157 | $filterSet |
---|
| 158 | ->addFilter(new comboFilter( |
---|
[417] | 159 | 'users',__('Author'), 'user_id', $users_combo)) |
---|
[225] | 160 | ->addFilter(new comboFilter( |
---|
| 161 | 'category',__('Category'), 'cat_id', $categories_combo)) |
---|
| 162 | ->addFilter(new comboFilter( |
---|
| 163 | 'post_status',__('Status'), 'post_status', $status_combo,array('singleval' => 1))) |
---|
[439] | 164 | ->addFilter(new booleanFilter( |
---|
| 165 | 'post_selected',__('The post :'), 'post_selected', $selected_combo)) |
---|
[225] | 166 | ->addFilter(new comboFilter( |
---|
| 167 | 'lang',__('Lang'), 'post_lang', $lang_combo)) |
---|
| 168 | ->addFilter(new monthComboFilter( |
---|
[228] | 169 | 'month',__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))); |
---|
[439] | 170 | |
---|
[225] | 171 | $filterSet->setValues($_GET); |
---|
[0] | 172 | |
---|
| 173 | # Get posts |
---|
| 174 | try { |
---|
[225] | 175 | $nfparams = $params->getArrayCopy(); |
---|
| 176 | $filtered = $filterSet->applyFilters($params); |
---|
[0] | 177 | $posts = $core->blog->getPosts($params); |
---|
| 178 | $counter = $core->blog->getPosts($params,true); |
---|
[225] | 179 | if ($filtered) { |
---|
| 180 | $totalcounter = $core->blog->getPosts($nfparams,true); |
---|
| 181 | $page_title = sprintf(__('Entries / %s filtered out of %s'),$counter->f(0),$totalcounter->f(0)); |
---|
| 182 | } else { |
---|
| 183 | $page_title = __('Entries'); |
---|
| 184 | } |
---|
[0] | 185 | $post_list = new adminPostList($core,$posts,$counter->f(0)); |
---|
| 186 | } catch (Exception $e) { |
---|
| 187 | $core->error->add($e->getMessage()); |
---|
| 188 | } |
---|
| 189 | |
---|
[242] | 190 | $filterSet->setColumnsForm($post_list->getColumnsForm()); |
---|
| 191 | |
---|
[0] | 192 | /* DISPLAY |
---|
| 193 | -------------------------------------------------------- */ |
---|
| 194 | $starting_script = dcPage::jsLoad('js/_posts_list.js'); |
---|
[225] | 195 | |
---|
[276] | 196 | $starting_script .= $filterSet->header(); |
---|
[0] | 197 | |
---|
| 198 | dcPage::open(__('Entries'),$starting_script); |
---|
| 199 | |
---|
| 200 | if (!$core->error->flag()) |
---|
| 201 | { |
---|
[3] | 202 | echo |
---|
[225] | 203 | '<h2>'.html::escapeHTML($core->blog->name).' › '.$page_title.'</h2>'. |
---|
[158] | 204 | '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>'; |
---|
[225] | 205 | |
---|
| 206 | $filterSet->display(); |
---|
| 207 | |
---|
[0] | 208 | # Show posts |
---|
| 209 | $post_list->display($page,$nb_per_page, |
---|
| 210 | '<form action="posts_actions.php" method="post" id="form-entries">'. |
---|
| 211 | |
---|
| 212 | '%s'. |
---|
| 213 | |
---|
| 214 | '<div class="two-cols">'. |
---|
| 215 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 216 | |
---|
[417] | 217 | '<p class="col right"><span class="filter-title">'.__('Selected entries action:').'</span> '. |
---|
[0] | 218 | form::combo('action',$combo_action). |
---|
| 219 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
[225] | 220 | $filterSet->getFormFieldsAsHidden(). |
---|
[0] | 221 | $core->formNonce(). |
---|
| 222 | '</div>'. |
---|
| 223 | '</form>' |
---|
| 224 | ); |
---|
| 225 | } |
---|
| 226 | |
---|
| 227 | dcPage::helpBlock('core_posts'); |
---|
| 228 | dcPage::close(); |
---|
| 229 | ?> |
---|