| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2010 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 | # Creating filter combo boxes |
|---|
| 18 | # Filter form we'll put in html_block |
|---|
| 19 | $status_combo = array(); |
|---|
| 20 | foreach ($core->blog->getAllCommentStatus() as $k => $v) { |
|---|
| 21 | $status_combo[$v] = (string) $k; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | $type_combo = array( |
|---|
| 25 | __('comment') => '0', |
|---|
| 26 | __('trackback') => '1' |
|---|
| 27 | ); |
|---|
| 28 | |
|---|
| 29 | $sortby_combo = array( |
|---|
| 30 | __('Date') => 'comment_dt', |
|---|
| 31 | __('Entry title') => 'post_title', |
|---|
| 32 | __('Author') => 'comment_author', |
|---|
| 33 | __('Status') => 'comment_status' |
|---|
| 34 | ); |
|---|
| 35 | |
|---|
| 36 | $order_combo = array( |
|---|
| 37 | __('Descending') => 'desc', |
|---|
| 38 | __('Ascending') => 'asc' |
|---|
| 39 | ); |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
|---|
| 44 | $nb_per_page = 30; |
|---|
| 45 | |
|---|
| 46 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
|---|
| 47 | if ($nb_per_page != $_GET['nb']) { |
|---|
| 48 | $show_filters = true; |
|---|
| 49 | } |
|---|
| 50 | $nb_per_page = (integer) $_GET['nb']; |
|---|
| 51 | } |
|---|
| 52 | $params = new ArrayObject(); |
|---|
| 53 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
|---|
| 54 | $params['no_content'] = true; |
|---|
| 55 | |
|---|
| 56 | # Actions combo box |
|---|
| 57 | $combo_action = array(); |
|---|
| 58 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
|---|
| 59 | { |
|---|
| 60 | $combo_action[__('publish')] = 'publish'; |
|---|
| 61 | $combo_action[__('unpublish')] = 'unpublish'; |
|---|
| 62 | $combo_action[__('mark as pending')] = 'pending'; |
|---|
| 63 | $combo_action[__('mark as junk')] = 'junk'; |
|---|
| 64 | } |
|---|
| 65 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
|---|
| 66 | { |
|---|
| 67 | $combo_action[__('delete')] = 'delete'; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | # --BEHAVIOR-- adminCommentsActionsCombo |
|---|
| 71 | $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); |
|---|
| 72 | |
|---|
| 73 | $filterSet = new dcFilterSet('comments','comments.php'); |
|---|
| 74 | |
|---|
| 75 | $authorFilter = new textFilter( |
|---|
| 76 | 'author',__('Author'), __('Author'),'q_author',20,255); |
|---|
| 77 | $filterSet |
|---|
| 78 | ->addFilter(new comboFilter( |
|---|
| 79 | 'status',__('Status'), __('Status'), 'comment_status', $status_combo)) |
|---|
| 80 | ->addFilter(new booleanFilter( |
|---|
| 81 | 'type',__('Type'), __('Type'), 'comment_trackback', $type_combo)) |
|---|
| 82 | ->addFilter($authorFilter) |
|---|
| 83 | ->addFilter(new textFilter( |
|---|
| 84 | 'ip',__('IP address'), __('IP address'), 'comment_ip',20,39)); |
|---|
| 85 | |
|---|
| 86 | $core->callBehavior('adminCommentsFilters',$filterSet); |
|---|
| 87 | |
|---|
| 88 | $filterSet->setFormValues($_GET); |
|---|
| 89 | if (isset($_GET['author'])) { |
|---|
| 90 | $authorFilter->add(); |
|---|
| 91 | $authorFilter->setValue($_GET['author']); |
|---|
| 92 | } |
|---|
| 93 | /* Get comments |
|---|
| 94 | -------------------------------------------------------- */ |
|---|
| 95 | try { |
|---|
| 96 | $nfparams = $params->getArrayCopy(); |
|---|
| 97 | $filtered = $filterSet->applyFilters($params); |
|---|
| 98 | $core->callBehavior('adminCommentsParams',$params); |
|---|
| 99 | $comments = $core->blog->getComments($params); |
|---|
| 100 | $counter = $core->blog->getComments($params,true); |
|---|
| 101 | if ($filtered) { |
|---|
| 102 | $totalcounter = $core->blog->getComments($nfparams,true); |
|---|
| 103 | $page_title = sprintf(__('Comments and Trackacks / %s filtered out of %s'),$counter->f(0),$totalcounter->f(0)); |
|---|
| 104 | } else { |
|---|
| 105 | $page_title = __('Comments and Trackacks'); |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | $comment_list = new adminCommentList($core,$comments,$counter->f(0)); |
|---|
| 109 | } catch (Exception $e) { |
|---|
| 110 | $core->error->add($e->getMessage()); |
|---|
| 111 | } |
|---|
| 112 | $filterSet->setColumnsForm($comment_list->getColumnsForm()); |
|---|
| 113 | |
|---|
| 114 | /* DISPLAY |
|---|
| 115 | -------------------------------------------------------- */ |
|---|
| 116 | $starting_script = dcPage::jsLoad('js/_comments.js').$filterSet->header();; |
|---|
| 117 | |
|---|
| 118 | # --BEHAVIOR-- adminCommentsHeaders |
|---|
| 119 | $starting_script .= $core->callBehavior('adminCommentsHeaders'); |
|---|
| 120 | |
|---|
| 121 | dcPage::open(__('Comments and trackbacks'),$starting_script); |
|---|
| 122 | |
|---|
| 123 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.$page_title.'</h2>'; |
|---|
| 124 | |
|---|
| 125 | if (!$core->error->flag()) |
|---|
| 126 | { |
|---|
| 127 | # Filters |
|---|
| 128 | if (!$show_filters) { |
|---|
| 129 | echo '<p><a id="filter-control" class="form-control" href="#">'. |
|---|
| 130 | __('Filters').'</a></p>'; |
|---|
| 131 | } |
|---|
| 132 | $filterSet->display(); |
|---|
| 133 | |
|---|
| 134 | if (!$with_spam) { |
|---|
| 135 | $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0); |
|---|
| 136 | if ($spam_count == 1) { |
|---|
| 137 | echo '<p>'.sprintf(__('You have one spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
|---|
| 138 | '<a href="comments.php?status=-2">'.__('Show it.').'</a></p>'; |
|---|
| 139 | } elseif ($spam_count > 1) { |
|---|
| 140 | echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
|---|
| 141 | '<a href="comments.php?status=-2">'.__('Show them.').'</a></p>'; |
|---|
| 142 | } |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | # Show comments |
|---|
| 146 | $comment_list->display($page,$nb_per_page, |
|---|
| 147 | '<form action="comments_actions.php" method="post" id="form-comments">'. |
|---|
| 148 | |
|---|
| 149 | '%s'. |
|---|
| 150 | |
|---|
| 151 | '<div class="two-cols">'. |
|---|
| 152 | '<p class="col checkboxes-helpers"></p>'. |
|---|
| 153 | |
|---|
| 154 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
|---|
| 155 | form::combo('action',$combo_action,'','','','','title="'.__('action: ').'"'). |
|---|
| 156 | $core->formNonce(). |
|---|
| 157 | '<input type="submit" value="'.__('ok').'" /></p>'. |
|---|
| 158 | form::hidden(array('type'),$type). |
|---|
| 159 | form::hidden(array('sortby'),$sortby). |
|---|
| 160 | form::hidden(array('order'),$order). |
|---|
| 161 | form::hidden(array('author'),preg_replace('/%/','%%',$author)). |
|---|
| 162 | form::hidden(array('status'),$status). |
|---|
| 163 | form::hidden(array('ip'),preg_replace('/%/','%%',$ip)). |
|---|
| 164 | form::hidden(array('page'),$page). |
|---|
| 165 | form::hidden(array('nb'),$nb_per_page). |
|---|
| 166 | '</div>'. |
|---|
| 167 | |
|---|
| 168 | '</form>' |
|---|
| 169 | ); |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | dcPage::helpBlock('core_comments'); |
|---|
| 173 | dcPage::close(); |
|---|
| 174 | ?> |
|---|