| 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 | $comment_list = new adminCommentList($core); |
|---|
| 30 | |
|---|
| 31 | $params = new ArrayObject(); |
|---|
| 32 | $params['no_content'] = true; |
|---|
| 33 | |
|---|
| 34 | # - Limit, sortby and order filter |
|---|
| 35 | $params = $comment_list->applyFilters($params); |
|---|
| 36 | |
|---|
| 37 | # Actions combo box |
|---|
| 38 | $combo_action = array(); |
|---|
| 39 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
|---|
| 40 | { |
|---|
| 41 | $combo_action[__('publish')] = 'publish'; |
|---|
| 42 | $combo_action[__('unpublish')] = 'unpublish'; |
|---|
| 43 | $combo_action[__('mark as pending')] = 'pending'; |
|---|
| 44 | $combo_action[__('mark as junk')] = 'junk'; |
|---|
| 45 | } |
|---|
| 46 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
|---|
| 47 | { |
|---|
| 48 | $combo_action[__('delete')] = 'delete'; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | # --BEHAVIOR-- adminCommentsActionsCombo |
|---|
| 52 | $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); |
|---|
| 53 | |
|---|
| 54 | $filterSet = new dcFilterSet('comments','comments.php'); |
|---|
| 55 | |
|---|
| 56 | $authorFilter = new textFilter( |
|---|
| 57 | 'author',__('Author'), __('Author'),'q_author',20,255); |
|---|
| 58 | $filterSet |
|---|
| 59 | ->addFilter(new comboFilter( |
|---|
| 60 | 'status',__('Status'), __('Status'), 'comment_status', $status_combo)) |
|---|
| 61 | ->addFilter(new booleanFilter( |
|---|
| 62 | 'type',__('Type'), __('Type'), 'comment_trackback', $type_combo)) |
|---|
| 63 | ->addFilter($authorFilter) |
|---|
| 64 | ->addFilter(new textFilter( |
|---|
| 65 | 'ip',__('IP address'), __('IP address'), 'comment_ip',20,39)); |
|---|
| 66 | |
|---|
| 67 | $core->callBehavior('adminCommentsFilters',$filterSet); |
|---|
| 68 | |
|---|
| 69 | $filterSet->setFormValues($_GET); |
|---|
| 70 | if (isset($_GET['author'])) { |
|---|
| 71 | $authorFilter->add(); |
|---|
| 72 | $authorFilter->setValue($_GET['author']); |
|---|
| 73 | } |
|---|
| 74 | /* Get comments |
|---|
| 75 | -------------------------------------------------------- */ |
|---|
| 76 | try { |
|---|
| 77 | $nfparams = $params->getArrayCopy(); |
|---|
| 78 | $filtered = $filterSet->applyFilters($params); |
|---|
| 79 | $core->callBehavior('adminCommentsParams',$params); |
|---|
| 80 | $comments = $core->blog->getComments($params); |
|---|
| 81 | $counter = $core->blog->getComments($params,true); |
|---|
| 82 | if ($filtered) { |
|---|
| 83 | $totalcounter = $core->blog->getComments($nfparams,true); |
|---|
| 84 | $page_title = sprintf(__('Comments and Trackacks / %s filtered out of %s'),$counter->f(0),$totalcounter->f(0)); |
|---|
| 85 | } else { |
|---|
| 86 | $page_title = __('Comments and Trackacks'); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | $comment_list->setItems($comments,$counter->f(0)); |
|---|
| 90 | } catch (Exception $e) { |
|---|
| 91 | $core->error->add($e->getMessage()); |
|---|
| 92 | } |
|---|
| 93 | $filterSet->setColumnsForm($comment_list->getColumnsForm()); |
|---|
| 94 | |
|---|
| 95 | /* DISPLAY |
|---|
| 96 | -------------------------------------------------------- */ |
|---|
| 97 | $starting_script = dcPage::jsLoad('js/_comments.js').$filterSet->header();; |
|---|
| 98 | |
|---|
| 99 | # --BEHAVIOR-- adminCommentsHeaders |
|---|
| 100 | $starting_script .= $core->callBehavior('adminCommentsHeaders'); |
|---|
| 101 | |
|---|
| 102 | dcPage::open(__('Comments and trackbacks'),$starting_script); |
|---|
| 103 | |
|---|
| 104 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.$page_title.'</h2>'; |
|---|
| 105 | |
|---|
| 106 | if (!$core->error->flag()) |
|---|
| 107 | { |
|---|
| 108 | # Filters |
|---|
| 109 | $filterSet->display(); |
|---|
| 110 | |
|---|
| 111 | if (!$with_spam) { |
|---|
| 112 | $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0); |
|---|
| 113 | if ($spam_count == 1) { |
|---|
| 114 | echo '<p>'.sprintf(__('You have one spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
|---|
| 115 | '<a href="comments.php?status=-2">'.__('Show it.').'</a></p>'; |
|---|
| 116 | } elseif ($spam_count > 1) { |
|---|
| 117 | echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
|---|
| 118 | '<a href="comments.php?status=-2">'.__('Show them.').'</a></p>'; |
|---|
| 119 | } |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | # Show comments |
|---|
| 123 | $comment_list->display('<form action="comments_actions.php" method="post" id="form-comments">'. |
|---|
| 124 | |
|---|
| 125 | '%s'. |
|---|
| 126 | |
|---|
| 127 | '<div class="two-cols">'. |
|---|
| 128 | '<p class="col checkboxes-helpers"></p>'. |
|---|
| 129 | |
|---|
| 130 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
|---|
| 131 | form::combo('action',$combo_action,'','','','','title="'.__('action: ').'"'). |
|---|
| 132 | $core->formNonce(). |
|---|
| 133 | '<input type="submit" value="'.__('ok').'" /></p>'. |
|---|
| 134 | form::hidden(array('type'),$type). |
|---|
| 135 | form::hidden(array('author'),preg_replace('/%/','%%',$author)). |
|---|
| 136 | form::hidden(array('status'),$status). |
|---|
| 137 | form::hidden(array('ip'),preg_replace('/%/','%%',$ip)). |
|---|
| 138 | $comment_list->getFormFieldsAsHidden(). |
|---|
| 139 | '</div>'. |
|---|
| 140 | |
|---|
| 141 | '</form>' |
|---|
| 142 | ); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | dcPage::helpBlock('core_comments'); |
|---|
| 146 | dcPage::close(); |
|---|
| 147 | ?> |
|---|