Dotclear

source: admin/comments.php @ 782:01efbf050a8a

Revision 782:01efbf050a8a, 4.6 KB checked in by Dsls <dsls@…>, 14 years ago (diff)

Merged last default changes with formfilter branch

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';
14
15dcPage::check('usage,contentadmin');
16
17class authorFilter extends textFilter {
18     public function header() {
19          return 
20               dcPage::jqueryUI().
21               dcPage::jsLoad('js/author_filter.js')
22               ;
23     }
24     public function applyFilter($params) {
25          $val = preg_split("/[\s,]+/",$this->values[0]);
26          $params[$this->request_param]=$val;
27     }
28}
29
30
31# Creating filter combo boxes
32# Filter form we'll put in html_block
33$status_combo = array();
34foreach ($core->blog->getAllCommentStatus() as $k => $v) {
35     $status_combo[$v] = (string) $k;
36}
37
38$type_combo = array(
39__('comment') => '0',
40__('trackback') => '1'
41);
42
43$comment_list = new adminCommentList($core);
44
45$params = new ArrayObject();
46$params['no_content'] = true;
47
48# - Limit, sortby and order filter
49
50# Actions combo box
51$combo_action = array();
52if ($core->auth->check('publish,contentadmin',$core->blog->id))
53{
54     $combo_action[__('publish')] = 'publish';
55     $combo_action[__('unpublish')] = 'unpublish';
56     $combo_action[__('mark as pending')] = 'pending';
57     $combo_action[__('mark as junk')] = 'junk';
58}
59if ($core->auth->check('delete,contentadmin',$core->blog->id))
60{
61     $combo_action[__('delete')] = 'delete';
62}
63
64# --BEHAVIOR-- adminCommentsActionsCombo
65$core->callBehavior('adminCommentsActionsCombo',array(&$combo_action));
66
67$filterSet = new dcFilterSet('comments','comments.php');
68
69$authorFilter = new authorFilter(
70          'author',__('Author'), __('Author'),'comment_author',20,255);
71$filterSet
72     ->addFilter(new comboFilter(
73          'status',__('Status'), __('Status'), 'comment_status', $status_combo))
74     ->addFilter(new booleanFilter(
75          'type',__('Type'), __('Type'), 'comment_trackback', $type_combo))
76     ->addFilter($authorFilter)
77     ->addFilter(new textFilter(
78          'ip',__('IP address'), __('IP address'), 'comment_ip',20,39));
79         
80$core->callBehavior('adminCommentsFilters',$filterSet);
81$filterSet->setExtra($comment_list);
82
83$filterSet->setup($_GET,$_POST);
84if (isset($_GET['author'])) {
85     $authorFilter->add();
86     $authorFilter->setValue($_GET['author']);
87}
88$with_spam=true;
89/* Get comments
90-------------------------------------------------------- */
91try {
92     $nfparams = $params->getArrayCopy();
93     $filtered = $filterSet->applyFilters($params);
94     $core->callBehavior('adminCommentsParams',$params);
95     $comments = $core->blog->getComments($params);
96     $counter = $core->blog->getComments($params,true);
97     if ($filtered) {
98          $totalcounter = $core->blog->getComments($nfparams,true);
99          $page_title = sprintf(__('Comments and Trackacks / %s filtered out of %s'),$counter->f(0),$totalcounter->f(0));
100     } else {
101          $page_title = __('Comments and Trackacks');
102     }
103
104     $comment_list->setItems($comments,$counter->f(0));
105} catch (Exception $e) {
106     $core->error->add($e->getMessage());
107}
108
109/* DISPLAY
110-------------------------------------------------------- */
111$starting_script = dcPage::jsLoad('js/_comments.js').$filterSet->header();
112
113# --BEHAVIOR-- adminCommentsHeaders
114$starting_script .= $core->callBehavior('adminCommentsHeaders');
115
116dcPage::open(__('Comments and trackbacks'),$starting_script);
117
118echo '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; <span class="page-title">'.__('Comments and trackbacks').'</span></h2>';
119
120if (!$core->error->flag())
121{
122     # Filters
123     $filterSet->display();
124     
125     if (!$with_spam) {
126          $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0);
127          if ($spam_count == 1) {
128               echo '<p>'.sprintf(__('You have one spam comments.'),'<strong>'.$spam_count.'</strong>').' '.
129               '<a href="comments.php?status=-2">'.__('Show it.').'</a></p>';
130          } elseif ($spam_count > 1) {
131               echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '.
132               '<a href="comments.php?status=-2">'.__('Show them.').'</a></p>';
133          }
134     }
135     
136     # Show comments
137     $comment_list->display('<form action="comments_actions.php" method="post" id="form-comments">'.
138     
139     '%s'.
140     
141     '<div class="two-cols">'.
142     '<p class="col checkboxes-helpers"></p>'.
143     
144     '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '.
145     form::combo('action',$combo_action,'','','','','title="'.__('action: ').'"').
146     $core->formNonce().
147     '<input type="submit" value="'.__('ok').'" /></p>'.
148     str_replace('%','%%',$filterSet->getFormFieldsAsHidden()).
149     '</div>'.
150     
151     '</form>'
152     );
153}
154
155dcPage::helpBlock('core_comments');
156dcPage::close();
157?>
Note: See TracBrowser for help on using the repository browser.

Sites map