1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 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 | $q = !empty($_GET['q']) ? $_GET['q'] : (!empty($_GET['qx']) ? $_GET['qx'] : null); |
---|
18 | $qtype = !empty($_GET['qtype']) ? $_GET['qtype'] : 'p'; |
---|
19 | if ($qtype != 'c' && $qtype != 'p') { |
---|
20 | $qtype = 'p'; |
---|
21 | } |
---|
22 | |
---|
23 | $starting_scripts = ''; |
---|
24 | |
---|
25 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
26 | $nb_per_page = 30; |
---|
27 | |
---|
28 | |
---|
29 | if ($q) |
---|
30 | { |
---|
31 | $params = array(); |
---|
32 | |
---|
33 | # Get posts |
---|
34 | if ($qtype == 'p') |
---|
35 | { |
---|
36 | $starting_scripts .= dcPage::jsLoad('js/_posts_list.js'); |
---|
37 | |
---|
38 | $params['search'] = $q; |
---|
39 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
40 | $params['no_content'] = true; |
---|
41 | $params['order'] = 'post_dt DESC'; |
---|
42 | |
---|
43 | try { |
---|
44 | $posts = $core->blog->getPosts($params); |
---|
45 | $counter = $core->blog->getPosts($params,true); |
---|
46 | $post_list = new adminPostList($core,$posts,$counter->f(0)); |
---|
47 | } catch (Exception $e) { |
---|
48 | $core->error->add($e->getMessage()); |
---|
49 | } |
---|
50 | } |
---|
51 | # Get comments |
---|
52 | elseif ($qtype == 'c') |
---|
53 | { |
---|
54 | $starting_scripts .= dcPage::jsLoad('js/_comments.js'); |
---|
55 | |
---|
56 | $params['search'] = $q; |
---|
57 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
58 | $params['no_content'] = true; |
---|
59 | $params['order'] = 'comment_dt DESC'; |
---|
60 | |
---|
61 | try { |
---|
62 | $comments = $core->blog->getComments($params); |
---|
63 | $counter = $core->blog->getComments($params,true); |
---|
64 | $comment_list = new adminCommentList($core,$comments,$counter->f(0)); |
---|
65 | } catch (Exception $e) { |
---|
66 | $core->error->add($e->getMessage()); |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | dcPage::open(__('Search'),$starting_scripts, |
---|
73 | dcPage::breadcrumb( |
---|
74 | array( |
---|
75 | html::escapeHTML($core->blog->name) => '', |
---|
76 | '<span class="page-title">'.__('Search').'</span>' => '' |
---|
77 | )) |
---|
78 | ); |
---|
79 | |
---|
80 | echo |
---|
81 | '<form action="search.php" method="get">'. |
---|
82 | '<div class="fieldset"><h3>'.__('Search options').'</h3>'. |
---|
83 | '<p><label for="q">'.__('Query:').' </label>'.form::field('q',30,255,html::escapeHTML($q)).'</p>'. |
---|
84 | '<p><label for="qtype1" class="classic">'.form::radio(array('qtype','qtype1'),'p',$qtype == 'p').' '.__('Search in entries').'</label> '. |
---|
85 | '<label for="qtype2" class="classic">'.form::radio(array('qtype','qtype2'),'c',$qtype == 'c').' '.__('Search in comments').'</label></p>'. |
---|
86 | '<p><input type="submit" value="'.__('Search').'" /></p>'. |
---|
87 | '</div>'. |
---|
88 | '</form>'; |
---|
89 | |
---|
90 | if ($q && !$core->error->flag()) |
---|
91 | { |
---|
92 | $redir = html::escapeHTML($_SERVER['REQUEST_URI']); |
---|
93 | |
---|
94 | # Show posts |
---|
95 | if ($qtype == 'p') |
---|
96 | { |
---|
97 | # Actions combo box |
---|
98 | $combo_action = array(); |
---|
99 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
100 | { |
---|
101 | $combo_action[__('publish')] = 'publish'; |
---|
102 | $combo_action[__('unpublish')] = 'unpublish'; |
---|
103 | $combo_action[__('schedule')] = 'schedule'; |
---|
104 | $combo_action[__('mark as pending')] = 'pending'; |
---|
105 | } |
---|
106 | $combo_action[__('change category')] = 'category'; |
---|
107 | if ($core->auth->check('admin',$core->blog->id)) { |
---|
108 | $combo_action[__('change author')] = 'author'; |
---|
109 | } |
---|
110 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
111 | { |
---|
112 | $combo_action[__('Delete')] = 'delete'; |
---|
113 | } |
---|
114 | |
---|
115 | # --BEHAVIOR-- adminPostsActionsCombo |
---|
116 | $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); |
---|
117 | |
---|
118 | if ($counter->f(0) > 0) { |
---|
119 | printf('<h3>'. |
---|
120 | ($counter->f(0) == 1 ? __('%d entry found') : __('%d entries found')). |
---|
121 | '</h3>',$counter->f(0)); |
---|
122 | } |
---|
123 | |
---|
124 | $post_list->display($page,$nb_per_page, |
---|
125 | '<form action="posts_actions.php" method="post" id="form-entries">'. |
---|
126 | |
---|
127 | '%s'. |
---|
128 | |
---|
129 | '<div class="two-cols">'. |
---|
130 | '<p class="col checkboxes-helpers"></p>'. |
---|
131 | |
---|
132 | '<p class="col right"><label for="action1" class="classic">'.__('Selected entries action:').'</label> '. |
---|
133 | form::combo(array('action','action1'),$combo_action). |
---|
134 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
135 | form::hidden('redir',preg_replace('/%/','%%',$redir)). |
---|
136 | $core->formNonce(). |
---|
137 | '</div>'. |
---|
138 | '</form>' |
---|
139 | ); |
---|
140 | } |
---|
141 | # Show posts |
---|
142 | elseif ($qtype == 'c') |
---|
143 | { |
---|
144 | # Actions combo box |
---|
145 | $combo_action = array(); |
---|
146 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
147 | { |
---|
148 | $combo_action[__('publish')] = 'publish'; |
---|
149 | $combo_action[__('unpublish')] = 'unpublish'; |
---|
150 | $combo_action[__('mark as pending')] = 'pending'; |
---|
151 | $combo_action[__('mark as junk')] = 'junk'; |
---|
152 | } |
---|
153 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
154 | { |
---|
155 | $combo_action[__('Delete')] = 'delete'; |
---|
156 | } |
---|
157 | |
---|
158 | if ($counter->f(0) > 0) { |
---|
159 | printf('<h3>'. |
---|
160 | ($counter->f(0) == 1 ? __('%d comment found') : __('%d comments found')). |
---|
161 | '</h3>',$counter->f(0)); |
---|
162 | } |
---|
163 | |
---|
164 | $comment_list->display($page,$nb_per_page, |
---|
165 | '<form action="comments_actions.php" method="post" id="form-comments">'. |
---|
166 | |
---|
167 | '%s'. |
---|
168 | |
---|
169 | '<div class="two-cols">'. |
---|
170 | '<p class="col checkboxes-helpers"></p>'. |
---|
171 | |
---|
172 | '<p class="col right"><label for="action2" class="classic">'.__('Selected comments action:').'</label> '. |
---|
173 | form::combo(array('action','action2'),$combo_action). |
---|
174 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
175 | form::hidden('redir',preg_replace('/%/','%%',$redir)). |
---|
176 | $core->formNonce(). |
---|
177 | '</div>'. |
---|
178 | '</form>' |
---|
179 | ); |
---|
180 | } |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | dcPage::close(); |
---|
185 | ?> |
---|