[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 | # Creating filter combo boxes |
---|
| 18 | # Filter form we'll put in html_block |
---|
| 19 | $status_combo = array( |
---|
| 20 | '-' => '' |
---|
| 21 | ); |
---|
| 22 | foreach ($core->blog->getAllCommentStatus() as $k => $v) { |
---|
| 23 | $status_combo[$v] = (string) $k; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | $type_combo = array( |
---|
| 27 | '-' => '', |
---|
| 28 | __('comment') => 'co', |
---|
| 29 | __('trackback') => 'tb' |
---|
| 30 | ); |
---|
| 31 | |
---|
| 32 | $sortby_combo = array( |
---|
| 33 | __('Date') => 'comment_dt', |
---|
| 34 | __('Entry title') => 'post_title', |
---|
| 35 | __('Author') => 'comment_author', |
---|
| 36 | __('Status') => 'comment_status' |
---|
| 37 | ); |
---|
| 38 | |
---|
| 39 | $order_combo = array( |
---|
| 40 | __('Descending') => 'desc', |
---|
| 41 | __('Ascending') => 'asc' |
---|
| 42 | ); |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | /* Get comments |
---|
| 46 | -------------------------------------------------------- */ |
---|
[796] | 47 | $author = isset($_GET['author']) ? $_GET['author'] : ''; |
---|
| 48 | $status = isset($_GET['status']) ? $_GET['status'] : ''; |
---|
| 49 | $type = !empty($_GET['type']) ? $_GET['type'] : ''; |
---|
| 50 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'comment_dt'; |
---|
| 51 | $order = !empty($_GET['order']) ? $_GET['order'] : 'desc'; |
---|
| 52 | $ip = !empty($_GET['ip']) ? $_GET['ip'] : ''; |
---|
[0] | 53 | |
---|
| 54 | $with_spam = $author || $status || $type || $sortby != 'comment_dt' || $order != 'desc' || $ip; |
---|
| 55 | |
---|
| 56 | $show_filters = false; |
---|
| 57 | |
---|
| 58 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
| 59 | $nb_per_page = 30; |
---|
| 60 | |
---|
| 61 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
| 62 | if ($nb_per_page != $_GET['nb']) { |
---|
| 63 | $show_filters = true; |
---|
| 64 | } |
---|
| 65 | $nb_per_page = (integer) $_GET['nb']; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 69 | $params['no_content'] = true; |
---|
| 70 | |
---|
| 71 | # Author filter |
---|
| 72 | if ($author !== '') { |
---|
| 73 | $params['q_author'] = $author; |
---|
| 74 | $show_filters = true; |
---|
[796] | 75 | } else { |
---|
| 76 | $author=''; |
---|
[0] | 77 | } |
---|
| 78 | |
---|
| 79 | # - Type filter |
---|
| 80 | if ($type == 'tb' || $type == 'co') { |
---|
| 81 | $params['comment_trackback'] = ($type == 'tb'); |
---|
| 82 | $show_filters = true; |
---|
[796] | 83 | } else { |
---|
| 84 | $type=''; |
---|
[0] | 85 | } |
---|
| 86 | |
---|
| 87 | # - Status filter |
---|
| 88 | if ($status !== '' && in_array($status,$status_combo)) { |
---|
| 89 | $params['comment_status'] = $status; |
---|
| 90 | $show_filters = true; |
---|
| 91 | } elseif (!$with_spam) { |
---|
| 92 | $params['comment_status_not'] = -2; |
---|
[796] | 93 | $status=''; |
---|
| 94 | } else { |
---|
| 95 | $status=''; |
---|
[0] | 96 | } |
---|
| 97 | |
---|
| 98 | # - IP filter |
---|
| 99 | if ($ip) { |
---|
| 100 | $params['comment_ip'] = $ip; |
---|
| 101 | $show_filters = true; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | # Sortby and order filter |
---|
| 105 | if ($sortby !== '' && in_array($sortby,$sortby_combo)) { |
---|
| 106 | if ($order !== '' && in_array($order,$order_combo)) { |
---|
| 107 | $params['order'] = $sortby.' '.$order; |
---|
[796] | 108 | } else { |
---|
| 109 | $order = 'desc'; |
---|
[0] | 110 | } |
---|
| 111 | |
---|
| 112 | if ($sortby != 'comment_dt' || $order != 'desc') { |
---|
| 113 | $show_filters = true; |
---|
| 114 | } |
---|
[796] | 115 | } else { |
---|
| 116 | $sortby = 'comment_dt'; |
---|
| 117 | $order = 'desc'; |
---|
[0] | 118 | } |
---|
| 119 | |
---|
| 120 | # Actions combo box |
---|
| 121 | $combo_action = array(); |
---|
[476] | 122 | $default = ''; |
---|
[0] | 123 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 124 | { |
---|
| 125 | $combo_action[__('publish')] = 'publish'; |
---|
| 126 | $combo_action[__('unpublish')] = 'unpublish'; |
---|
| 127 | $combo_action[__('mark as pending')] = 'pending'; |
---|
| 128 | $combo_action[__('mark as junk')] = 'junk'; |
---|
| 129 | } |
---|
| 130 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 131 | { |
---|
[747] | 132 | $combo_action[__('Delete')] = 'delete'; |
---|
[476] | 133 | if ($status == -2) { |
---|
| 134 | $default = 'delete'; |
---|
| 135 | } |
---|
[0] | 136 | } |
---|
| 137 | |
---|
| 138 | # --BEHAVIOR-- adminCommentsActionsCombo |
---|
| 139 | $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); |
---|
| 140 | |
---|
| 141 | /* Get comments |
---|
| 142 | -------------------------------------------------------- */ |
---|
| 143 | try { |
---|
| 144 | $comments = $core->blog->getComments($params); |
---|
| 145 | $counter = $core->blog->getComments($params,true); |
---|
| 146 | $comment_list = new adminCommentList($core,$comments,$counter->f(0)); |
---|
| 147 | } catch (Exception $e) { |
---|
| 148 | $core->error->add($e->getMessage()); |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | /* DISPLAY |
---|
| 152 | -------------------------------------------------------- */ |
---|
| 153 | $starting_script = dcPage::jsLoad('js/_comments.js'); |
---|
| 154 | if (!$show_filters) { |
---|
| 155 | $starting_script .= dcPage::jsLoad('js/filter-controls.js'); |
---|
| 156 | } |
---|
| 157 | # --BEHAVIOR-- adminCommentsHeaders |
---|
| 158 | $starting_script .= $core->callBehavior('adminCommentsHeaders'); |
---|
| 159 | |
---|
[178] | 160 | dcPage::open(__('Comments and trackbacks'),$starting_script); |
---|
[0] | 161 | |
---|
[500] | 162 | echo '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.__('Comments and trackbacks').'</span></h2>'; |
---|
[0] | 163 | |
---|
| 164 | if (!$core->error->flag()) |
---|
| 165 | { |
---|
| 166 | # Filters |
---|
| 167 | if (!$show_filters) { |
---|
| 168 | echo '<p><a id="filter-control" class="form-control" href="#">'. |
---|
| 169 | __('Filters').'</a></p>'; |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | echo |
---|
| 173 | '<form action="comments.php" method="get" id="filters-form">'. |
---|
| 174 | '<fieldset><legend>'.__('Filters').'</legend>'. |
---|
| 175 | '<div class="three-cols">'. |
---|
| 176 | '<div class="col">'. |
---|
[45] | 177 | '<label for="type">'.__('Type:').' '. |
---|
[0] | 178 | form::combo('type',$type_combo,$type). |
---|
| 179 | '</label> '. |
---|
[45] | 180 | '<label for="status">'.__('Status:').' '. |
---|
[0] | 181 | form::combo('status',$status_combo,$status). |
---|
| 182 | '</label>'. |
---|
| 183 | '</div>'. |
---|
| 184 | |
---|
| 185 | '<div class="col">'. |
---|
[45] | 186 | '<p><label for="sortby">'.__('Order by:').' '. |
---|
[0] | 187 | form::combo('sortby',$sortby_combo,$sortby). |
---|
| 188 | '</label> '. |
---|
[45] | 189 | '<label for="order">'.__('Sort:').' '. |
---|
[0] | 190 | form::combo('order',$order_combo,$order). |
---|
| 191 | '</label></p>'. |
---|
[45] | 192 | '<p><label for="nb" class="classic">'. form::field('nb',3,3,$nb_per_page).' '. |
---|
[0] | 193 | __('Comments per page').'</label></p>'. |
---|
| 194 | '</div>'. |
---|
| 195 | |
---|
| 196 | '<div class="col">'. |
---|
[45] | 197 | '<p><label for="author">'.__('Comment author:').' '. |
---|
[0] | 198 | form::field('author',20,255,html::escapeHTML($author)). |
---|
| 199 | '</label>'. |
---|
[45] | 200 | '<label for="ip">'.__('IP address:').' '. |
---|
[0] | 201 | form::field('ip',20,39,html::escapeHTML($ip)). |
---|
| 202 | '</label></p>'. |
---|
[3] | 203 | '<p><input type="submit" value="'.__('Apply filters').'" /></p>'. |
---|
[0] | 204 | '</div>'. |
---|
| 205 | |
---|
| 206 | '</div>'. |
---|
| 207 | '<br class="clear" />'. //Opera sucks |
---|
| 208 | '</fieldset>'. |
---|
| 209 | '</form>'; |
---|
| 210 | |
---|
| 211 | if (!$with_spam) { |
---|
| 212 | $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0); |
---|
| 213 | if ($spam_count == 1) { |
---|
| 214 | echo '<p>'.sprintf(__('You have one spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
| 215 | '<a href="comments.php?status=-2">'.__('Show it.').'</a></p>'; |
---|
| 216 | } elseif ($spam_count > 1) { |
---|
| 217 | echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
| 218 | '<a href="comments.php?status=-2">'.__('Show them.').'</a></p>'; |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | # Show comments |
---|
| 223 | $comment_list->display($page,$nb_per_page, |
---|
| 224 | '<form action="comments_actions.php" method="post" id="form-comments">'. |
---|
| 225 | |
---|
| 226 | '%s'. |
---|
| 227 | |
---|
| 228 | '<div class="two-cols">'. |
---|
| 229 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 230 | |
---|
[96] | 231 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[476] | 232 | form::combo('action',$combo_action,$default,'','','','title="'.__('action: ').'"'). |
---|
[0] | 233 | $core->formNonce(). |
---|
| 234 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 235 | form::hidden(array('type'),$type). |
---|
| 236 | form::hidden(array('sortby'),$sortby). |
---|
| 237 | form::hidden(array('order'),$order). |
---|
| 238 | form::hidden(array('author'),preg_replace('/%/','%%',$author)). |
---|
| 239 | form::hidden(array('status'),$status). |
---|
| 240 | form::hidden(array('ip'),preg_replace('/%/','%%',$ip)). |
---|
| 241 | form::hidden(array('page'),$page). |
---|
| 242 | form::hidden(array('nb'),$nb_per_page). |
---|
| 243 | '</div>'. |
---|
| 244 | |
---|
| 245 | '</form>' |
---|
| 246 | ); |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | dcPage::helpBlock('core_comments'); |
---|
| 250 | dcPage::close(); |
---|
[795] | 251 | ?> |
---|