Beispiel #1
0
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Antispam, a plugin for Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
    return;
}
dcPage::check('admin');
dcAntispam::initFilters();
$filters = dcAntispam::$filters->getFilters();
$page_name = __('Antispam');
$filter_gui = false;
$default_tab = null;
try {
    # Show filter configuration GUI
    if (!empty($_GET['f'])) {
        if (!isset($filters[$_GET['f']])) {
            throw new Exception(__('Filter does not exist.'));
        }
        if (!$filters[$_GET['f']]->hasGUI()) {
            throw new Exception(__('Filter has no user interface.'));
        }
        $filter = $filters[$_GET['f']];
        $filter_gui = $filter->gui($filter->guiURL());
Beispiel #2
0
 public function display($page, $nb_per_page, $enclose_block = '', $filter = false, $spam = false)
 {
     if ($this->rs->isEmpty()) {
         if ($filter) {
             echo '<p><strong>' . __('No comments or trackbacks matches the filter') . '</strong></p>';
         } else {
             echo '<p><strong>' . __('No comments') . '</strong></p>';
         }
     } else {
         // Get antispam filters' name
         $filters = array();
         if ($spam) {
             if (class_exists('dcAntispam')) {
                 dcAntispam::initFilters();
                 $fs = dcAntispam::$filters->getFilters();
                 foreach ($fs as $fid => $f) {
                     $filters[$fid] = $f->name;
                 }
             }
         }
         $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
         $comments = array();
         if (isset($_REQUEST['comments'])) {
             foreach ($_REQUEST['comments'] as $v) {
                 $comments[(int) $v] = true;
             }
         }
         $html_block = '<div class="table-outer">' . '<table>';
         if ($filter) {
             $html_block .= '<caption>' . sprintf(__('Comment or trackback matching the filter.', 'List of %s comments or trackbacks matching the filter.', $this->rs_count), $this->rs_count) . '</caption>';
         } else {
             $html_block .= '<caption class="hidden">' . __('Comments and trackbacks list') . '</caption>';
         }
         $cols = array('type' => '<th colspan="2" scope="col" abbr="comm" class="first">' . __('Type') . '</th>', 'author' => '<th scope="col">' . __('Author') . '</th>', 'date' => '<th scope="col">' . __('Date') . '</th>', 'status' => '<th scope="col" class="txt-center">' . __('Status') . '</th>');
         if ($spam) {
             $cols['ip'] = '<th scope="col">' . __('IP') . '</th>';
             $cols['spam_filter'] = '<th scope="col">' . __('Spam filter') . '</th>';
         }
         $cols['entry'] = '<th scope="col" abbr="entry">' . __('Entry') . '</th>';
         $cols = new ArrayObject($cols);
         $this->core->callBehavior('adminCommentListHeader', $this->core, $this->rs, $cols);
         $html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>';
         if ($enclose_block) {
             $html_block = sprintf($enclose_block, $html_block);
         }
         echo $pager->getLinks();
         $blocks = explode('%s', $html_block);
         echo $blocks[0];
         while ($this->rs->fetch()) {
             echo $this->commentLine(isset($comments[$this->rs->comment_id]), $spam, $filters);
         }
         echo $blocks[1];
         echo $pager->getLinks();
     }
 }