Dotclear

source: admin/posts.php @ 1147:2e5cb79e4782

Revision 1147:2e5cb79e4782, 4.4 KB checked in by Dsls <dsls@…>, 13 years ago (diff)

Oops, I did it again (c).

Fist draft of merge from formfilters to dctwig. lists need to be broken up too.

From now all post lists are broken.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2011 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
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14global $_ctx;
15dcPage::check('usage,contentadmin');
16
17# Getting categories
18try {
19     $categories = $core->blog->getCategories(array('post_type'=>'post'));
20} catch (Exception $e) {
21     $core->error->add($e->getMessage());
22}
23
24# Getting authors
25try {
26     $users = $core->blog->getPostsUsers();
27} catch (Exception $e) {
28     $core->error->add($e->getMessage());
29}
30
31# Getting dates
32try {
33     $dates = $core->blog->getDates(array('type'=>'month'));
34} catch (Exception $e) {
35     $core->error->add($e->getMessage());
36}
37
38# Getting langs
39try {
40     $langs = $core->blog->getLangs();
41} catch (Exception $e) {
42     $core->error->add($e->getMessage());
43}
44
45# Creating filter combo boxes
46if (!$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
63# Getting categories
64$categories_combo = array();
65try {
66     $categories = $core->blog->getCategories(array('post_type'=>'post'));
67     while ($categories->fetch()) {
68          $categories_combo[$categories->cat_id] = 
69               str_repeat('&nbsp;&nbsp;',$categories->level-1).
70               ($categories->level-1 == 0 ? '' : '&bull; ').
71               html::escapeHTML($categories->cat_title);
72     }
73} catch (Exception $e) { }
74     $status_combo = array(
75     );
76     foreach ($core->blog->getAllPostStatus() as $k => $v) {
77          $status_combo[(string) $k] = (string)$v;
78     }
79     
80     $selected_combo = array(
81     '1' => __('is selected'),
82     '0' => __('is not selected')
83     );
84     
85     # Months array
86     while ($dates->fetch()) {
87          $dt_m_combo[$dates->year().$dates->month()] = dt::str('%B %Y',$dates->ts());
88     }
89     
90     while ($langs->fetch()) {
91          $lang_combo[$langs->post_lang] = $langs->post_lang;
92     }
93}
94$form = new dcForm($core,'post','post.php');
95
96
97# Actions combo box
98$combo_action = array();
99if ($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'
106     );
107}
108$combo_action[__('Mark')] = array(
109     __('Mark as selected') => 'selected',
110     __('Mark as unselected') => 'unselected'
111);
112$combo_action[__('Change')] = array(__('Change category') => 'category');
113if ($core->auth->check('admin',$core->blog->id))
114{
115     $combo_action[__('Change')] = array_merge($combo_action[__('Change')],
116          array(__('Change author') => 'author'));
117}
118if ($core->auth->check('delete,contentadmin',$core->blog->id))
119{
120     $combo_action[__('Delete')] = array(__('Delete') => 'delete');
121}
122
123# --BEHAVIOR-- adminPostsActionsCombo
124$core->callBehavior('adminPostsActionsCombo',array(&$combo_action));
125
126
127
128class monthComboFilter extends comboFilter {
129     public function applyFilter($params) {
130          $month=$this->avalues['values'][0];
131          $params['post_month'] = substr($month,4,2);
132          $params['post_year'] = substr($month,0,4);
133     }
134}
135/* DISPLAY
136-------------------------------------------------------- */
137$filterSet = new dcFilterSet($core,'fposts','posts.php');
138
139$filterSet
140     ->addFilter(new comboFilter(
141          'users',__('Author'), __('Author'), 'user_id', $users_combo))
142     ->addFilter(new comboFilter(
143          'category',__('Category'), __('Category'), 'cat_id', $categories_combo))
144     ->addFilter(new comboFilter(
145          'post_status',__('Status'), __('Status'), 'post_status', $status_combo))
146     ->addFilter(new comboFilter(
147          'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo))
148     ->addFilter(new booleanFilter(
149          'selected',__('Selected'), __('The post : '),'post_selected', $selected_combo))
150     ->addFilter(new monthComboFilter(
151          'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1)))
152     ->addFilter(new textFilter(
153          'search',__('Contains'),__('The entry contains'), 'search',20,255));
154
155$filterSet->setup();
156
157$_ctx
158     ->fillPageTitle(__('Entries'),'posts.php');
159$params=new ArrayObject();
160$filterSet->applyFilters($params);
161$_ctx->filters = '['.print_r($params->getArrayCopy(),true).']';
162
163$core->tpl->display('posts.html.twig');
164
165
166?>
Note: See TracBrowser for help on using the repository browser.

Sites map