diff --git a/auto_nodetitle.module b/auto_nodetitle.module index dc0d404..9473f1d 100644 --- a/auto_nodetitle.module +++ b/auto_nodetitle.module @@ -84,8 +84,15 @@ function auto_nodetitle_set_title(&$node) { else { $node->title = t('@type', array('@type' => $types[$node->type]->name)); } + + // Clean up double spaces if so configured. + if (variable_get('ant_pattern_cleanup_' . $node->type, FALSE)) { + $node->title = str_replace(' ', ' ', $node->title); + } + // Ensure the generated title isn't too long. $node->title = substr($node->title, 0, 255); + // With that flag we ensure we don't apply the title two times to the same // node. See auto_nodetitle_is_needed(). $node->auto_nodetitle_applied = TRUE; @@ -171,6 +178,12 @@ function auto_nodetitle_form_node_type_form_alter(&$form, &$form_state) { '#description' => t('Leave blank for using the per default generated title. Otherwise this string will be used as title. Use the syntax [token] if you wa '#default_value' => variable_get('ant_pattern_' . $form['#node_type']->type, ''), ); + $form['auto_nodetitle']['ant_pattern_cleanup'] = array( + '#type' => 'checkbox', + '#title' => t('Eliminate double spaces in title.'), + '#description' => t('If a token is empty, it can leave an extra space in the output. Check this box to replace double spaces with single spaces.'), + '#default_value' => variable_get('ant_pattern_cleanup_' . $form['#node_type']->type, ''), + ); // Don't allow editing of the pattern if PHP is used, but the users lacks // permission for PHP. if (variable_get('ant_php_' . $form['#node_type']->type, '') && !user_access('use PHP for title patterns')) {