diff -rupN auto_nodetitle/auto_nodetitle.module auto_nodetitle_new/auto_nodetitle.module --- auto_nodetitle/auto_nodetitle.module 2009-02-10 21:31:34.000000000 +1100 +++ auto_nodetitle.module 2009-02-26 09:25:03.000000000 +1100 @@ -64,15 +64,25 @@ function auto_nodetitle_is_needed($node) return empty($node->auto_nodetitle_applied) && ($setting = auto_nodetitle_get_setting($node->type)) && !($setting == AUTO_NODETITLE_OPTIONAL && !empty($node->title)); } -/* +/** * Sets the automatically generated nodetitle for the node + * + * @param node + * The node for which an auto node title is to be created. + * @param flush + * A flag that gets passed to the token module if the auto + * node title is created by the use of tokens. + * It indicates whether or not to flush the token cache. + * If you are creating auto node titles for multiple nodes + * in one go you should pass TRUE here to prevent incorrect + * title creation. The default is FALSE. */ -function auto_nodetitle_set_title(&$node) { +function auto_nodetitle_set_title(&$node, $flush_tokens = FALSE) { $types = node_get_types(); $pattern = variable_get('ant_pattern_'. $node->type, ''); if (trim($pattern)) { $node->changed = time(); - $node->title = _auto_nodetitle_patternprocessor($pattern, $node); + $node->title = _auto_nodetitle_patternprocessor($pattern, $node, $flush_tokens); } else if ($node->nid) { $node->title = t('@type @node-id', array('@type' => $types[$node->type]->name, '@node-id' => $node->nid)); @@ -117,11 +127,22 @@ function auto_nodetitle_operations_updat /** * Helper function to generate the title according to the PHP code. * Right now its only a wrapper, but if this is to be expanded, here is the place to be. + * + * @param node + * The node for which an auto node title is to be created. + * @param flush + * A flag that gets passed to the token module if the auto + * node title is created by the use of tokens. + * It indicates whether or not to flush the token cache. + * If you are creating auto node titles for multiple nodes + * in one go you should pass TRUE here to prevent incorrect + * title creation. The default is FALSE. + * * @return a title string */ -function _auto_nodetitle_patternprocessor($output, $node) { +function _auto_nodetitle_patternprocessor($output, $node, $flush_tokens = FALSE) { if (module_exists('token')) { - $output = token_replace($output, 'node', $node); + $output = token_replace($output, 'node', $node, '[', ']', array(), $flush_tokens); } if (variable_get('ant_php_'. $node->type, 0)) { $output = auto_nodetitle_eval($output, $node);