You are here

function _auto_nodetitle_patternprocessor in Automatic Nodetitles 7

Same name and namespace in other branches
  1. 8 auto_nodetitle.module \_auto_nodetitle_patternprocessor()
  2. 5 auto_nodetitle.module \_auto_nodetitle_patternprocessor()
  3. 6 auto_nodetitle.module \_auto_nodetitle_patternprocessor()

Helper function to generate the title according to the settings.

Return value

a title string

1 call to _auto_nodetitle_patternprocessor()
auto_nodetitle_set_title in ./auto_nodetitle.module
Sets the automatically generated nodetitle for the node.

File

./auto_nodetitle.module, line 182
Allows hiding of the node title field and automatic title creation.

Code

function _auto_nodetitle_patternprocessor($pattern, $node) {

  // // Replace tokens.
  // $output = token_replace($pattern, array('node' => $node), array('callback' => '_auto_nodetitle_nohtmlentities', 'sanitize' => FALSE, 'clear' => TRUE));
  // // Evaluate PHP.
  if (variable_get('ant_php_' . $node->type, 0)) {

    // Replace tokens.
    $output = token_replace($pattern, array(
      'node' => $node,
    ), array(
      'sanitize' => FALSE,
      'clear' => TRUE,
      'callback' => '_auto_nodetitle_token_replacement_escape',
    ));

    // Evalute PHP.
    $output = auto_nodetitle_eval($output, $node);
  }
  else {

    // Replace tokens.
    $output = token_replace($pattern, array(
      'node' => $node,
    ), array(
      'sanitize' => FALSE,
      'clear' => TRUE,
    ));
  }

  // Strip tags.
  $output = preg_replace('/[\\t\\n\\r\\0\\x0B]/', '', $output);
  return trim($output);
}