Index: patterns.module =================================================================== --- patterns.module (revision 554) +++ patterns.module (working copy) @@ -1307,6 +1307,19 @@ return $pattern; } +function patterns_array_map($function, $array, $params) { + $new_array = array(); + foreach( $array as $key => $value ) { + if (is_array($value)) { + $new_array[$key] = patterns_array_map($function, $value, $params); + } else { + $fullparams = array_merge(array($value), $params); + $new_array[$key] = call_user_func_array($function, $fullparams); + } + } + return $new_array; +} + /** * Return an array with detailed information about the pattern */ @@ -1328,8 +1341,22 @@ foreach($actions as $key => $action) { if ($action['tag'] == 'pattern') { - $p = patterns_get_pattern($action['value']); + if (isset($action['name'])) { + $p = patterns_get_pattern($action['name']); + } else { + $p = patterns_get_pattern($action['value']); + } $a = patterns_get_pattern_details($p, TRUE, $pids); + + // we replace for tokens in the generated pattern + // this is just a proof of concept, so far + if (function_exists('_token_replace_tokens') && !empty($action['parameters'])) { + $tokens = array_keys($action['parameters']); + $values = array_values($action['parameters']); + // using the internal replace function from the token module + $a = patterns_array_map('_token_replace_tokens', $a, array($tokens, $values, '[', ']')); + } + // array_merge doesn't preserve numeric array keys // so we handle 'info' separately $info = $result['info'];