You are here

function auto_username_punctuation_chars in Automatic User Names 7

Same name and namespace in other branches
  1. 5 auto_username.module \auto_username_punctuation_chars()
  2. 6 auto_username.module \auto_username_punctuation_chars()

Return an array of arrays for punctuation values.

Returns an array of arrays for punctuation values keyed by a name, including the value and a textual description. Can and should be expanded to include "all" non text punctuation values.

Return value

An array of arrays for punctuation values keyed by a name, including the value and a textual description.

3 calls to auto_username_punctuation_chars()
auto_username_cleanstring in ./auto_username.inc
Clean up a string segment to be used in a username.
auto_username_settings_form in ./auto_username.admin.inc
@file Form builder; displays the auto_username settings form.
auto_username_settings_form_validate in ./auto_username.admin.inc
Validate auto_username_settings_form form submissions.

File

./auto_username.inc, line 217
Miscellaneous functions for auto_username.

Code

function auto_username_punctuation_chars() {
  $punctuation =& drupal_static(__FUNCTION__);
  if (!isset($punctuation)) {
    $cid = 'auto_username:punctuation:' . $GLOBALS['language']->language;
    if ($cache = cache_get($cid)) {
      $punctuation = $cache->data;
    }
    else {
      $punctuation = array();
      $punctuation['double_quotes'] = array(
        'value' => '"',
        'name' => t('Double quotation marks'),
      );
      $punctuation['quotes'] = array(
        'value' => '\'',
        'name' => t("Single quotation marks (apostrophe)"),
      );
      $punctuation['backtick'] = array(
        'value' => '`',
        'name' => t('Back tick'),
      );
      $punctuation['comma'] = array(
        'value' => ',',
        'name' => t('Comma'),
      );
      $punctuation['period'] = array(
        'value' => '.',
        'name' => t('Period'),
      );
      $punctuation['hyphen'] = array(
        'value' => '-',
        'name' => t('Hyphen'),
      );
      $punctuation['underscore'] = array(
        'value' => '_',
        'name' => t('Underscore'),
      );
      $punctuation['colon'] = array(
        'value' => ':',
        'name' => t('Colon'),
      );
      $punctuation['semicolon'] = array(
        'value' => ';',
        'name' => t('Semicolon'),
      );
      $punctuation['pipe'] = array(
        'value' => '|',
        'name' => t('Vertical bar (pipe)'),
      );
      $punctuation['left_curly'] = array(
        'value' => '{',
        'name' => t('Left curly bracket'),
      );
      $punctuation['left_square'] = array(
        'value' => '[',
        'name' => t('Left square bracket'),
      );
      $punctuation['right_curly'] = array(
        'value' => '}',
        'name' => t('Right curly bracket'),
      );
      $punctuation['right_square'] = array(
        'value' => ']',
        'name' => t('Right square bracket'),
      );
      $punctuation['plus'] = array(
        'value' => '+',
        'name' => t('Plus sign'),
      );
      $punctuation['equal'] = array(
        'value' => '=',
        'name' => t('Equal sign'),
      );
      $punctuation['asterisk'] = array(
        'value' => '*',
        'name' => t('Asterisk'),
      );
      $punctuation['ampersand'] = array(
        'value' => '&',
        'name' => t('Ampersand'),
      );
      $punctuation['percent'] = array(
        'value' => '%',
        'name' => t('Percent sign'),
      );
      $punctuation['caret'] = array(
        'value' => '^',
        'name' => t('Caret'),
      );
      $punctuation['dollar'] = array(
        'value' => '$',
        'name' => t('Dollar sign'),
      );
      $punctuation['hash'] = array(
        'value' => '#',
        'name' => t('Number sign (pound sign, hash)'),
      );
      $punctuation['at'] = array(
        'value' => '@',
        'name' => t('At sign'),
      );
      $punctuation['exclamation'] = array(
        'value' => '!',
        'name' => t('Exclamation mark'),
      );
      $punctuation['tilde'] = array(
        'value' => '~',
        'name' => t('Tilde'),
      );
      $punctuation['left_parenthesis'] = array(
        'value' => '(',
        'name' => t('Left parenthesis'),
      );
      $punctuation['right_parenthesis'] = array(
        'value' => ')',
        'name' => t('Right parenthesis'),
      );
      $punctuation['question_mark'] = array(
        'value' => '?',
        'name' => t('Question mark'),
      );
      $punctuation['less_than'] = array(
        'value' => '<',
        'name' => t('Less-than sign'),
      );
      $punctuation['greater_than'] = array(
        'value' => '>',
        'name' => t('Greater-than sign'),
      );
      $punctuation['slash'] = array(
        'value' => '/',
        'name' => t('Slash'),
      );
      $punctuation['back_slash'] = array(
        'value' => '\\',
        'name' => t('Backslash'),
      );

      // Allow modules to alter the punctuation list and cache the result.
      drupal_alter('auto_username_punctuation_chars', $punctuation);
      cache_set($cid, $punctuation);
    }
  }
  return $punctuation;
}