[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 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 | |
---|
| 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()) { |
---|
[158] | 64 | $categories_combo[str_repeat(' ',$categories->level-1).'• '. |
---|
[0] | 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 | |
---|
| 90 | # Actions combo box |
---|
| 91 | $combo_action = array(); |
---|
| 92 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 93 | { |
---|
| 94 | $combo_action[__('Status')] = array( |
---|
| 95 | __('Publish') => 'publish', |
---|
| 96 | __('Unpublish') => 'unpublish', |
---|
| 97 | __('Schedule') => 'schedule', |
---|
| 98 | __('Mark as pending') => 'pending' |
---|
| 99 | ); |
---|
| 100 | } |
---|
| 101 | $combo_action[__('Mark')] = array( |
---|
| 102 | __('Mark as selected') => 'selected', |
---|
| 103 | __('Mark as unselected') => 'unselected' |
---|
| 104 | ); |
---|
| 105 | $combo_action[__('Change')] = array(__('Change category') => 'category'); |
---|
| 106 | if ($core->auth->check('admin',$core->blog->id)) |
---|
| 107 | { |
---|
| 108 | $combo_action[__('Change')] = array_merge($combo_action[__('Change')], |
---|
| 109 | array(__('Change author') => 'author')); |
---|
| 110 | } |
---|
| 111 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 112 | { |
---|
| 113 | $combo_action[__('Delete')] = array(__('Delete') => 'delete'); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | # --BEHAVIOR-- adminPostsActionsCombo |
---|
| 117 | $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); |
---|
| 118 | |
---|
| 119 | /* Get posts |
---|
| 120 | -------------------------------------------------------- */ |
---|
[520] | 121 | $post_list = new adminPostList($core); |
---|
[0] | 122 | |
---|
[225] | 123 | $params = new ArrayObject(); |
---|
[0] | 124 | $params['no_content'] = true; |
---|
| 125 | |
---|
[439] | 126 | $filterSet = new dcFilterSet('posts','posts.php'); |
---|
[225] | 127 | class monthComboFilter extends comboFilter { |
---|
| 128 | public function applyFilter($params) { |
---|
| 129 | $month=$this->values[0]; |
---|
| 130 | $params['post_month'] = substr($month,4,2); |
---|
| 131 | $params['post_year'] = substr($month,0,4); |
---|
[0] | 132 | } |
---|
| 133 | } |
---|
[225] | 134 | $filterSet |
---|
| 135 | ->addFilter(new comboFilter( |
---|
[517] | 136 | 'users',__('Author'), __('Author'), 'user_id', $users_combo)) |
---|
[756] | 137 | ->addFilter(new categoryFilter( |
---|
[517] | 138 | 'category',__('Category'), __('Category'), 'cat_id', $categories_combo)) |
---|
[225] | 139 | ->addFilter(new comboFilter( |
---|
[517] | 140 | 'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) |
---|
[439] | 141 | ->addFilter(new booleanFilter( |
---|
[517] | 142 | 'post_selected',__('Selected'), __('The post : '),'post_selected', $selected_combo)) |
---|
[225] | 143 | ->addFilter(new comboFilter( |
---|
[517] | 144 | 'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) |
---|
[225] | 145 | ->addFilter(new monthComboFilter( |
---|
[756] | 146 | 'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) |
---|
| 147 | ->addFilter(new textFilter( |
---|
| 148 | 'search',__('Contains'),__('The entry contains'), 'search',20,255)); |
---|
[439] | 149 | |
---|
[460] | 150 | $core->callBehavior('adminPostsFilters',$filterSet); |
---|
[764] | 151 | $filterSet->setExtra($post_list); |
---|
[460] | 152 | |
---|
[755] | 153 | $filterSet->setup($_GET,$_POST); |
---|
[0] | 154 | |
---|
| 155 | # Get posts |
---|
| 156 | try { |
---|
[225] | 157 | $nfparams = $params->getArrayCopy(); |
---|
| 158 | $filtered = $filterSet->applyFilters($params); |
---|
[460] | 159 | $core->callBehavior('adminPostsParams',$params); |
---|
[0] | 160 | $posts = $core->blog->getPosts($params); |
---|
| 161 | $counter = $core->blog->getPosts($params,true); |
---|
[225] | 162 | if ($filtered) { |
---|
| 163 | $totalcounter = $core->blog->getPosts($nfparams,true); |
---|
| 164 | $page_title = sprintf(__('Entries / %s filtered out of %s'),$counter->f(0),$totalcounter->f(0)); |
---|
| 165 | } else { |
---|
| 166 | $page_title = __('Entries'); |
---|
[756] | 167 | $filters_info = ''; |
---|
[225] | 168 | } |
---|
[520] | 169 | $post_list->setItems($posts,$counter->f(0)); |
---|
[0] | 170 | } catch (Exception $e) { |
---|
| 171 | $core->error->add($e->getMessage()); |
---|
| 172 | } |
---|
| 173 | |
---|
[242] | 174 | |
---|
[0] | 175 | /* DISPLAY |
---|
| 176 | -------------------------------------------------------- */ |
---|
| 177 | $starting_script = dcPage::jsLoad('js/_posts_list.js'); |
---|
[225] | 178 | |
---|
[276] | 179 | $starting_script .= $filterSet->header(); |
---|
[0] | 180 | |
---|
| 181 | dcPage::open(__('Entries'),$starting_script); |
---|
| 182 | |
---|
| 183 | if (!$core->error->flag()) |
---|
| 184 | { |
---|
[3] | 185 | echo |
---|
[500] | 186 | '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.__('Entries').'</span></h2>'. |
---|
[158] | 187 | '<p class="top-add"><a class="button add" href="post.php">'.__('New entry').'</a></p>'; |
---|
[225] | 188 | |
---|
| 189 | $filterSet->display(); |
---|
[0] | 190 | # Show posts |
---|
[520] | 191 | $post_list->display('<form action="posts_actions.php" method="post" id="form-entries">'. |
---|
[0] | 192 | |
---|
| 193 | '%s'. |
---|
| 194 | |
---|
| 195 | '<div class="two-cols">'. |
---|
| 196 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 197 | |
---|
[96] | 198 | '<p class="col right"><label for="action" class="classic">'.__('Selected entries action:').'</label> '. |
---|
[0] | 199 | form::combo('action',$combo_action). |
---|
| 200 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
[780] | 201 | str_replace('%','%%',$filterSet->getFormFieldsAsHidden()). |
---|
[0] | 202 | $core->formNonce(). |
---|
| 203 | '</div>'. |
---|
| 204 | '</form>' |
---|
| 205 | ); |
---|
[764] | 206 | } |
---|
| 207 | |
---|
[0] | 208 | |
---|
| 209 | dcPage::helpBlock('core_posts'); |
---|
| 210 | dcPage::close(); |
---|
| 211 | ?> |
---|