You are here

function maxlength_get_values in Maxlength 6.2

Load maxlength settings for a certain fieldtype.

Parameters

$field: The field from which the maxlength settings should be loaded.

$type: The nodetype which is used for loading the settings.

Return value

The settings for a certain field.

2 calls to maxlength_get_values()
_maxlength_comment_form_alter in ./maxlength.inc
_maxlength_content_form_alter in ./maxlength.inc
@file Business logic for maxlength

File

./maxlength.inc, line 174
Business logic for maxlength

Code

function maxlength_get_values($field = 'body', $type = '') {
  $values = array();
  $values['limit'] = FALSE;

  // CCK fields
  if (strpos($field, 'field_') === 0) {
    $values['limit'] = variable_get('maxlength_' . $field, MAXLENGTH_DEFAULT_LENGTH);
    $values['use_js'] = variable_get('maxlength_' . $field . '_js', MAXLENGTH_DEFAULT_USE_JS);
    $values['text'] = variable_get('maxlength_' . $field . '_text', MAXLENGTH_DEFAULT_TEXT);
    $values['key'] = 'value';
  }
  elseif ($type != '') {
    $values['limit'] = variable_get('maxlength_' . $field . '_' . $type, MAXLENGTH_DEFAULT_LENGTH);
    $values['use_js'] = variable_get('maxlength_' . $field . '_js_' . $type, MAXLENGTH_DEFAULT_USE_JS);
    $values['text'] = variable_get('maxlength_' . $field . '_text_' . $type, MAXLENGTH_DEFAULT_TEXT);
  }
  else {
    $values['limit'] = variable_get('maxlength_' . $field, MAXLENGTH_DEFAULT_LENGTH);
    $values['use_js'] = variable_get('maxlength_' . $field . '_js', MAXLENGTH_DEFAULT_USE_JS);
    $values['text'] = variable_get('maxlength_' . $field . '_text', MAXLENGTH_DEFAULT_TEXT);
  }
  if ($values['limit']) {
    return $values;
  }
  else {
    return FALSE;
  }
}