--- pathauto.inc 2008-06-18 15:02:40.000000000 -0500 +++ pathauto.inc.new 2009-04-05 14:32:50.000000000 -0500 @@ -139,6 +139,7 @@ function pathauto_cleanstring($string, $ // Replace or drop punctuation based on user settings $separator = variable_get('pathauto_separator', '-'); + $separator_alt = variable_get('pathauto_separator_alt', '--'); $output = $string; $punctuation = pathauto_punctuation_chars(); foreach ($punctuation as $name => $details) { @@ -148,6 +149,10 @@ function pathauto_cleanstring($string, $ // Slightly tricky inline if which either replaces with the separator or nothing $output = str_replace($details['value'], ($action ? $separator : ''), $output); } + else if ($action == 3) { + // 3 is option for using the alternative separator + $output = str_replace($details['value'], ($action ? $separator_alt : ''), $output); + } } // If something is already urlsafe then don't remove slashes @@ -174,7 +179,12 @@ function pathauto_cleanstring($string, $ // Reduce to the subset of ASCII96 letters and numbers if (variable_get('pathauto_reduce_ascii', FALSE)) { $pattern = '/[^a-zA-Z0-9\/]+/ '; + if ($separator_alt) { + $output = preg_replace($pattern, $separator_alt, $output); + } + else { $output = preg_replace($pattern, $separator, $output); + } } // Get rid of words that are on the ignore list @@ -192,18 +202,33 @@ function pathauto_cleanstring($string, $ // In preparation for pattern matching, // escape the separator if and only if it is not alphanumeric. - if (isset($separator)) { - if (preg_match('/^[^'. PREG_CLASS_ALNUM .']+$/uD', $separator)) { - $seppattern = $separator; + if (isset($separator) || isset($separator_alt)) { + if ($separator_alt) { + if (preg_match('/^[^'. PREG_CLASS_ALNUM .']+$/uD', $separator_alt)) { + $seppattern = $separator_alt; + } + else { + $seppattern = '\\'. $separator_alt; + } } else { - $seppattern = '\\'. $separator; + if (preg_match('/^[^'. PREG_CLASS_ALNUM .']+$/uD', $separator)) { + $seppattern = $separator; + } + else { + $seppattern = '\\'. $separator; + } } // Trim any leading or trailing separators (note the need to $output = preg_replace("/^$seppattern+|$seppattern+$/", '', $output); // Replace multiple separators with a single one + if ($separator_alt) { + $output = preg_replace("/$seppattern+/", "$separator_alt", $output); + } + else { $output = preg_replace("/$seppattern+/", "$separator", $output); + } } // Enforce the maximum component length @@ -303,7 +328,11 @@ function pathauto_create_alias($module, // If the alias already exists, generate a new, hopefully unique, variant $separator = variable_get('pathauto_separator', '-'); + $separator_alt = variable_get('pathauto_separator_alt', '--'); if (_pathauto_alias_exists($alias, $src, $language)) { + if (isset($separator_alt)) { + $separator = $separator_alt; + } $original_alias = $alias; for ($i = 0; _pathauto_alias_exists(drupal_substr($alias, 0, $maxlength - strlen($i)) . $separator . $i, $src, $language); $i++) { }