You are here

function spamspan_filter in SpamSpan filter 6

Same name and namespace in other branches
  1. 5 spamspan.module \spamspan_filter()

Implementation of hook_filter().

File

./spamspan.module, line 60
This module implements the spamspan technique (http://www.spamspan.com ) for hiding email addresses from spambots.

Code

function spamspan_filter($op, $delta = 0, $format = -1, $text = '') {
  if ($op == 'list') {
    return array(
      0 => t('Hide email addresses using the SpamSpan technique'),
    );
  }
  switch ($delta) {
    case 0:
      switch ($op) {
        case 'description':
          return t('Attempt to hide email addresses from spam-bots.');
        case 'prepare':
          return $text;
        case 'process':
          return spamspan($text);
        case 'settings':

          // field set for the spamspan settings
          $form['spamspan_settings'] = array(
            '#type' => 'fieldset',
            '#title' => t('SpamSpan email address encoding filter'),
            '#description' => t('Warning: these are global settings and not per input format. Changing them here will change them for other input formats too.  You should not normally need to change any of these settings.'),
            '#collapsible' => TRUE,
          );

          // spamspan user name part class name
          $form['spamspan_settings']['spamspan_userclass'] = array(
            '#type' => 'textfield',
            '#title' => t('User name class'),
            '#default_value' => variable_get('spamspan_userclass', 'u'),
            '#required' => TRUE,
            '#description' => t('The class name of the <span> element enclosing the part of the address before the "@".'),
          );

          // spamspan domain part class name
          $form['spamspan_settings']['spamspan_domainclass'] = array(
            '#type' => 'textfield',
            '#title' => t('Domain part class'),
            '#default_value' => variable_get('spamspan_domainclass', 'd'),
            '#required' => TRUE,
            '#description' => t('The class name of the <span> element enclosing the part of the address after the "@".'),
          );

          // spamspan '@' replacement
          $form['spamspan_settings']['spamspan_at'] = array(
            '#type' => 'textfield',
            '#title' => t('Replacement for "@"'),
            '#default_value' => variable_get('spamspan_at', ' [at] '),
            '#required' => TRUE,
            '#description' => t('Replace "@" with this text when javascript is disabled.'),
          );
          $form['spamspan_settings']['spamspan_use_graphic'] = array(
            '#type' => 'checkbox',
            '#title' => t('Use a graphical replacement for "@"'),
            '#default_value' => variable_get('spamspan_use_graphic', 0),
            '#description' => t('Replace "@" with a graphical representation when javascript is disabled (and ignore the setting "Replacement for @" above).'),
          );
          return $form;
      }
      break;
  }
}