You are here

function maxlength_node_type in Maxlength 6.2

Same name and namespace in other branches
  1. 5.2 maxlength.module \maxlength_node_type()
  2. 5 maxlength.module \maxlength_node_type()
  3. 6 maxlength.module \maxlength_node_type()

Implementation of hook_node_type().

File

./maxlength.module, line 86
Enables a max length countdown on node body, title and CCK textfields.

Code

function maxlength_node_type($op, $info) {
  $labels = array(
    'title',
    'js_title',
    'text_title',
    'body',
    'js_body',
    'text_body',
  );
  switch ($op) {
    case 'delete':
      foreach ($labels as $label) {
        variable_del('maxlength_' . $label . $info->type);
      }
      break;
    case 'update':
      if (!empty($info->old_type) && $info->old_type != $info->type) {
        foreach ($labels as $label) {
          $old_var = variable_get('maxlength_' . $label . $info->old_type, '');
          variable_set('maxlength_' . $label . $info->type, $old_var);
          variable_del('maxlength_' . $label . $info->old_type);
        }
      }
      break;
  }
}