Dotclear


Ignore:
Timestamp:
03/02/18 15:55:06 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Use specialized input fields (color, email, url, number, …) where is relevant

Location:
plugins/antispam
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • plugins/antispam/_admin.php

    r3333 r3725  
    1010# 
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    12 if (!defined('DC_CONTEXT_ADMIN')) { return; } 
     12if (!defined('DC_CONTEXT_ADMIN')) {return;} 
    1313 
    1414if (!defined('DC_ANTISPAM_CONF_SUPER')) { 
    15      define('DC_ANTISPAM_CONF_SUPER',false); 
     15    define('DC_ANTISPAM_CONF_SUPER', false); 
    1616} 
    1717 
    1818$_menu['Plugins']->addItem(__('Antispam'), 
    19      $core->adminurl->get('admin.plugin.antispam'), 
    20      dcPage::getPF('antispam/icon.png'), 
    21      preg_match('/'.preg_quote($core->adminurl->get('admin.plugin.antispam')).'(&.*)?$/',$_SERVER['REQUEST_URI']), 
    22      $core->auth->check('admin',$core->blog->id)); 
     19    $core->adminurl->get('admin.plugin.antispam'), 
     20    dcPage::getPF('antispam/icon.png'), 
     21    preg_match('/' . preg_quote($core->adminurl->get('admin.plugin.antispam')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), 
     22    $core->auth->check('admin', $core->blog->id)); 
    2323 
    24 $core->addBehavior('coreAfterCommentUpdate',array('dcAntispam','trainFilters')); 
    25 $core->addBehavior('adminAfterCommentDesc',array('dcAntispam','statusMessage')); 
    26 $core->addBehavior('adminDashboardIcons',array('dcAntispam','dashboardIcon')); 
     24$core->addBehavior('coreAfterCommentUpdate', array('dcAntispam', 'trainFilters')); 
     25$core->addBehavior('adminAfterCommentDesc', array('dcAntispam', 'statusMessage')); 
     26$core->addBehavior('adminDashboardIcons', array('dcAntispam', 'dashboardIcon')); 
    2727 
    28 $core->addBehavior('adminDashboardFavorites','antispamDashboardFavorites'); 
    29 $core->addBehavior('adminDashboardFavsIcon','antispamDashboardFavsIcon'); 
     28$core->addBehavior('adminDashboardFavorites', 'antispamDashboardFavorites'); 
     29$core->addBehavior('adminDashboardFavsIcon', 'antispamDashboardFavsIcon'); 
    3030 
    31 function antispamDashboardFavorites($core,$favs) 
     31function antispamDashboardFavorites($core, $favs) 
    3232{ 
    33      $favs->register('antispam', array( 
    34           'title' => __('Antispam'), 
    35           'url' => $core->adminurl->get('admin.plugin.antispam'), 
    36           'small-icon' => dcPage::getPF('antispam/icon.png'), 
    37           'large-icon' => dcPage::getPF('antispam/icon-big.png'), 
    38           'permissions' => 'admin') 
    39      ); 
     33    $favs->register('antispam', array( 
     34        'title'      => __('Antispam'), 
     35        'url'        => $core->adminurl->get('admin.plugin.antispam'), 
     36        'small-icon' => dcPage::getPF('antispam/icon.png'), 
     37        'large-icon' => dcPage::getPF('antispam/icon-big.png'), 
     38        'permissions' => 'admin') 
     39    ); 
    4040} 
    4141 
    42 function antispamDashboardFavsIcon($core,$name,$icon) 
     42function antispamDashboardFavsIcon($core, $name, $icon) 
    4343{ 
    44      // Check if it is comments favs 
    45      if ($name == 'comments') { 
    46           // Hack comments title if there is at least one spam 
    47           $str = dcAntispam::dashboardIconTitle($core); 
    48           if ($str != '') { 
    49                $icon[0] .= $str; 
    50           } 
    51      } 
     44    // Check if it is comments favs 
     45    if ($name == 'comments') { 
     46        // Hack comments title if there is at least one spam 
     47        $str = dcAntispam::dashboardIconTitle($core); 
     48        if ($str != '') { 
     49            $icon[0] .= $str; 
     50        } 
     51    } 
    5252} 
    5353 
    5454if (!DC_ANTISPAM_CONF_SUPER || $core->auth->isSuperAdmin()) { 
    55      $core->addBehavior('adminBlogPreferencesForm',array('antispamBehaviors','adminBlogPreferencesForm')); 
    56      $core->addBehavior('adminBeforeBlogSettingsUpdate',array('antispamBehaviors','adminBeforeBlogSettingsUpdate')); 
    57      $core->addBehavior('adminCommentsSpamForm',array('antispamBehaviors','adminCommentsSpamForm')); 
    58      $core->addBehavior('adminPageHelpBlock',array('antispamBehaviors','adminPageHelpBlock')); 
     55    $core->addBehavior('adminBlogPreferencesForm', array('antispamBehaviors', 'adminBlogPreferencesForm')); 
     56    $core->addBehavior('adminBeforeBlogSettingsUpdate', array('antispamBehaviors', 'adminBeforeBlogSettingsUpdate')); 
     57    $core->addBehavior('adminCommentsSpamForm', array('antispamBehaviors', 'adminCommentsSpamForm')); 
     58    $core->addBehavior('adminPageHelpBlock', array('antispamBehaviors', 'adminPageHelpBlock')); 
    5959} 
    6060 
    6161class antispamBehaviors 
    6262{ 
    63      public static function adminPageHelpBlock($blocks) 
    64      { 
    65           $found = false; 
    66           foreach($blocks as $block) { 
    67                if ($block == 'core_comments') { 
    68                     $found = true; 
    69                     break; 
    70                } 
    71           } 
    72           if (!$found) { 
    73                return null; 
    74           } 
    75           $blocks[] = 'antispam_comments'; 
    76      } 
     63    public static function adminPageHelpBlock($blocks) 
     64    { 
     65        $found = false; 
     66        foreach ($blocks as $block) { 
     67            if ($block == 'core_comments') { 
     68                $found = true; 
     69                break; 
     70            } 
     71        } 
     72        if (!$found) { 
     73            return; 
     74        } 
     75        $blocks[] = 'antispam_comments'; 
     76    } 
    7777 
    78      public static function adminCommentsSpamForm($core) 
    79      { 
    80           $ttl = $core->blog->settings->antispam->antispam_moderation_ttl; 
    81           if ($ttl != null && $ttl >=0) { 
    82                echo '<p>'.sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $ttl).' '. 
    83                sprintf(__('You can modify this duration in the %s'),'<a href="'.$core->adminurl->get('admin.blog.pref'). 
    84                     '#antispam_moderation_ttl"> '.__('Blog settings').'</a>'). 
    85                '.</p>'; 
    86           } 
    87      } 
     78    public static function adminCommentsSpamForm($core) 
     79    { 
     80        $ttl = $core->blog->settings->antispam->antispam_moderation_ttl; 
     81        if ($ttl != null && $ttl >= 0) { 
     82            echo '<p>' . sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $ttl) . ' ' . 
     83            sprintf(__('You can modify this duration in the %s'), '<a href="' . $core->adminurl->get('admin.blog.pref') . 
     84                '#antispam_moderation_ttl"> ' . __('Blog settings') . '</a>') . 
     85                '.</p>'; 
     86        } 
     87    } 
    8888 
    89      public static function adminBlogPreferencesForm($core,$settings) 
    90      { 
    91           $ttl = $settings->antispam->antispam_moderation_ttl; 
    92           echo 
    93           '<div class="fieldset"><h4 id="antispam_params">Antispam</h4>'. 
    94           '<p><label for="antispam_moderation_ttl" class="classic">'.__('Delete junk comments older than').' '. 
    95           form::field('antispam_moderation_ttl', 3, 3, $ttl). 
    96           ' '.__('days'). 
    97           '</label></p>'. 
    98           '<p><a href="'.$core->adminurl->get('admin.plugin.antispam').'">'.__('Set spam filters.').'</a></p>'. 
    99           '</div>'; 
    100      } 
     89    public static function adminBlogPreferencesForm($core, $settings) 
     90    { 
     91        $ttl = $settings->antispam->antispam_moderation_ttl; 
     92        echo 
     93        '<div class="fieldset"><h4 id="antispam_params">Antispam</h4>' . 
     94        '<p><label for="antispam_moderation_ttl" class="classic">' . __('Delete junk comments older than') . ' ' . 
     95        form::number('antispam_moderation_ttl', 0, 999, $ttl) . 
     96        ' ' . __('days') . 
     97        '</label></p>' . 
     98        '<p><a href="' . $core->adminurl->get('admin.plugin.antispam') . '">' . __('Set spam filters.') . '</a></p>' . 
     99            '</div>'; 
     100    } 
    101101 
    102      public static function adminBeforeBlogSettingsUpdate($settings) 
    103      { 
    104           $settings->addNamespace('antispam'); 
    105           $settings->antispam->put('antispam_moderation_ttl',(integer)$_POST['antispam_moderation_ttl']); 
    106      } 
     102    public static function adminBeforeBlogSettingsUpdate($settings) 
     103    { 
     104        $settings->addNamespace('antispam'); 
     105        $settings->antispam->put('antispam_moderation_ttl', (integer) $_POST['antispam_moderation_ttl']); 
     106    } 
    107107} 
  • plugins/antispam/index.php

    r3707 r3725  
    204204        echo 
    205205        '<tr class="line' . ($f->active ? '' : ' offline') . '" id="f_' . $fid . '">' . 
    206         '<td class="handle">' . form::field(array('f_order[' . $fid . ']'), 2, 5, (string) $i, 'position', '', false, 'title="' . __('position') . '"') . '</td>' . 
     206        '<td class="handle">' . form::number(array('f_order[' . $fid . ']'), array( 
     207            'min'        => 0, 
     208            'default'    => $i, 
     209            'class'      => 'position', 
     210            'extra_html' => 'title="' . __('position') . '"' 
     211        )) . 
     212        '</td>' . 
    207213        '<td class="nowrap">' . form::checkbox(array('filters_active[]'), $fid, 
    208214            array( 
Note: See TracChangeset for help on using the changeset viewer.

Sites map