[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1102] | 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'; |
---|
[1147] | 14 | global $_ctx; |
---|
[0] | 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 |
---|
[1476] | 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.')'; |
---|
[2312] | 57 | } |
---|
[1476] | 58 | |
---|
| 59 | $users_combo[$user_cn] = $users->user_id; |
---|
[2312] | 60 | } |
---|
| 61 | |
---|
[1147] | 62 | |
---|
| 63 | # Getting categories |
---|
| 64 | $categories_combo = array(); |
---|
| 65 | try { |
---|
| 66 | $categories = $core->blog->getCategories(array('post_type'=>'post')); |
---|
[1476] | 67 | while ($categories->fetch()) { |
---|
[1147] | 68 | $categories_combo[$categories->cat_id] = |
---|
| 69 | str_repeat(' ',$categories->level-1). |
---|
| 70 | ($categories->level-1 == 0 ? '' : '• '). |
---|
| 71 | html::escapeHTML($categories->cat_title); |
---|
[1476] | 72 | } |
---|
[1147] | 73 | } catch (Exception $e) { } |
---|
[1476] | 74 | $status_combo = array( |
---|
[1719] | 75 | ); |
---|
[1476] | 76 | foreach ($core->blog->getAllPostStatus() as $k => $v) { |
---|
[1147] | 77 | $status_combo[(string) $k] = (string)$v; |
---|
[1476] | 78 | } |
---|
| 79 | |
---|
| 80 | $selected_combo = array( |
---|
[1147] | 81 | '1' => __('is selected'), |
---|
| 82 | '0' => __('is not selected') |
---|
[2312] | 83 | ); |
---|
| 84 | |
---|
[1476] | 85 | # Months array |
---|
| 86 | while ($dates->fetch()) { |
---|
[1147] | 87 | $dt_m_combo[$dates->year().$dates->month()] = dt::str('%B %Y',$dates->ts()); |
---|
[1476] | 88 | } |
---|
[2312] | 89 | |
---|
[1476] | 90 | while ($langs->fetch()) { |
---|
| 91 | $lang_combo[$langs->post_lang] = $langs->post_lang; |
---|
| 92 | } |
---|
| 93 | } |
---|
[1147] | 94 | $form = new dcForm($core,'post','post.php'); |
---|
[1719] | 95 | |
---|
[1476] | 96 | |
---|
| 97 | # Actions combo box |
---|
| 98 | $combo_action = array(); |
---|
| 99 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 100 | { |
---|
| 101 | $combo_action[__('Status')] = array( |
---|
| 102 | __('Publish') => 'publish', |
---|
| 103 | __('Unpublish') => 'unpublish', |
---|
| 104 | __('Schedule') => 'schedule', |
---|
| 105 | __('Mark as pending') => 'pending' |
---|
[1719] | 106 | ); |
---|
[2312] | 107 | } |
---|
[1476] | 108 | $combo_action[__('Mark')] = array( |
---|
| 109 | __('Mark as selected') => 'selected', |
---|
| 110 | __('Mark as unselected') => 'unselected' |
---|
| 111 | ); |
---|
| 112 | $combo_action[__('Change')] = array( |
---|
| 113 | __('Change category') => 'category', |
---|
| 114 | __('Change language') => 'lang'); |
---|
| 115 | if ($core->auth->check('admin',$core->blog->id)) |
---|
| 116 | { |
---|
| 117 | $combo_action[__('Change')] = array_merge($combo_action[__('Change')], |
---|
| 118 | array(__('Change author') => 'author')); |
---|
| 119 | } |
---|
| 120 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 121 | { |
---|
| 122 | $combo_action[__('Delete')] = array(__('Delete') => 'delete'); |
---|
[2312] | 123 | } |
---|
| 124 | |
---|
[1476] | 125 | # --BEHAVIOR-- adminPostsActionsCombo |
---|
| 126 | $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); |
---|
[2312] | 127 | |
---|
| 128 | |
---|
| 129 | |
---|
[1152] | 130 | class monthdcFilterCombo extends dcFilterCombo { |
---|
[1147] | 131 | public function applyFilter($params) { |
---|
| 132 | $month=$this->avalues['values'][0]; |
---|
| 133 | $params['post_month'] = substr($month,4,2); |
---|
| 134 | $params['post_year'] = substr($month,0,4); |
---|
[2312] | 135 | } |
---|
| 136 | } |
---|
| 137 | |
---|
[1154] | 138 | class PostsFetcher extends dcListFetcher { |
---|
[2312] | 139 | |
---|
[1154] | 140 | public function getEntries($params,$offset,$limit) { |
---|
| 141 | $params['limit'] = array($offset,$limit); |
---|
| 142 | return $this->core->blog->getPosts($params); |
---|
[0] | 143 | } |
---|
[2566] | 144 | |
---|
[1154] | 145 | public function getEntriesCount($params) { |
---|
| 146 | $count = $this->core->blog->getPosts($params,true); |
---|
| 147 | return $count->f(0); |
---|
[2048] | 148 | } |
---|
[2072] | 149 | } |
---|
| 150 | |
---|
| 151 | /* DISPLAY |
---|
| 152 | -------------------------------------------------------- */ |
---|
[1147] | 153 | $filterSet = new dcFilterSet($core,'fposts','posts.php'); |
---|
[2136] | 154 | |
---|
[1147] | 155 | $filterSet |
---|
[1152] | 156 | ->addFilter(new dcFilterRichCombo( |
---|
| 157 | 'users',__('Author'), __('Author'), 'user_id', $users_combo,array( |
---|
| 158 | 'multiple' => true))) |
---|
| 159 | ->addFilter(new dcFilterRichCombo( |
---|
[1498] | 160 | 'category',__('Category'), __('Category'), 'cat_id', $categories_combo,array( |
---|
| 161 | 'multiple' => true))) |
---|
[1152] | 162 | ->addFilter(new dcFilterRichCombo( |
---|
[1147] | 163 | 'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) |
---|
[1152] | 164 | ->addFilter(new dcFilterRichCombo( |
---|
[1147] | 165 | 'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) |
---|
[1152] | 166 | ->addFilter(new dcFilterCombo( |
---|
[1147] | 167 | 'selected',__('Selected'), __('The post : '),'post_selected', $selected_combo)) |
---|
[1152] | 168 | ->addFilter(new monthdcFilterCombo( |
---|
[1147] | 169 | 'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) |
---|
[1152] | 170 | ->addFilter(new dcFilterText( |
---|
[1147] | 171 | 'search',__('Contains'),__('The entry contains'), 'search',20,255)); |
---|
[2072] | 172 | |
---|
[2048] | 173 | |
---|
[1154] | 174 | $lfetcher = new PostsFetcher($core); |
---|
[1498] | 175 | $lposts = new dcItemList ($core,array('lposts','form-entries'),$lfetcher,'posts_actions.php'); |
---|
| 176 | $lposts->setFilterSet($filterSet); |
---|
[1152] | 177 | $lposts->addTemplate('posts_cols.html.twig'); |
---|
[2566] | 178 | |
---|
[1152] | 179 | $lposts |
---|
| 180 | ->addColumn(new dcColumn('title',__('Title'),'post_title')) |
---|
| 181 | ->addColumn(new dcColumn('cat',__('Category'),'cat_title')) |
---|
| 182 | ->addColumn(new dcColumn('date',__('Date'),'post_date')) |
---|
[1158] | 183 | ->addColumn(new dcColumn('datetime',__('Date and Time'),'post_dt')) |
---|
| 184 | ->addColumn(new dcColumn('author',__('Author'),'user_id')) |
---|
[1152] | 185 | ->addColumn(new dcColumn('status',__('Status'),'post_status')); |
---|
[2566] | 186 | |
---|
[2048] | 187 | |
---|
[1152] | 188 | $lposts->setup(); |
---|
[2566] | 189 | |
---|
[1147] | 190 | $_ctx |
---|
[1414] | 191 | ->setBreadCrumb(array(__('Entries') => 'posts.php')); |
---|
[2566] | 192 | |
---|
| 193 | |
---|
[1147] | 194 | $core->tpl->display('posts.html.twig'); |
---|
[2566] | 195 | |
---|
[2048] | 196 | |
---|
[1147] | 197 | ?> |
---|