You are here

function spamspan_filter in SpamSpan filter 5

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

Implementation of hook_filter().

File

./spamspan.module, line 52
This module implements the spamspan technique (http://www.spamspan.com ) for hiding email addresses from spambots. If javascript is disabled on the client-side, addresses appear as example [at] example [dot] com.

Code

function spamspan_filter($op, $delta = 0, $format = -1, $text = '') {
  if ($op == 'list') {
    return array(
      0 => t('Hide email addresses'),
    );
  }
  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(spamspan_convertmailto($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.'),
            '#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.'),
          );
          return $form;
      }
      break;
  }
}