". $args[2][1] .', '; } if (isset($args[3]) && $args[3][1] != "''" && $args[3][1] != '""' && $args[3][1] != 'NULL') { $options .= "'query' => ". $args[3][1] .', '; } if (isset($args[4]) && $args[4][1] != "''" && $args[4][1] != '""' && $args[4][1] != 'NULL') { $options .= "'fragment' => ". $args[4][1] .', '; } if (isset($args[5]) && $args[5][1] != "FALSE") { $options .= "'absolute' => TRUE, "; } if (isset($args[6]) && $args[6][1] != "FALSE") { $options .= "'html' => TRUE, "; } $options = rtrim($options, ', '); $return = 'l('. $args[0][1] .', '. $args[1][1] .', '. $options .'))'; print 'Before: '. $matches[0] ."\nAfter: " . $return . "\n\n"; return $return; } function fix_url($matches) { $args = get_args($matches[1]); // One argument, no change. if (count($args) <= 1) { return $matches[0]; } // Ignore the url() call from l(). if ($args[1][1] == '$options') return $matches[0]; $options = "array("; if (isset($args[1]) && $args[1][1] != "''" && $args[1][1] != '""' && $args[1][1] != 'NULL') { $options .= "'query' => ". $args[1][1] .', '; } if (isset($args[2]) && $args[2][1] != "''" && $args[2][1] != '""' && $args[2][1] != 'NULL') { $options .= "'fragment' => ". $args[2][1] .', '; } if (isset($args[3]) && $args[3][1] != "FALSE") { $options .= "'absolute' => TRUE, "; } $options = rtrim($options, ', '); $return = 'url('. $args[0][1] .', '. $options .'))'; print 'Before: '. $matches[0] ."\nAfter: " . $return . "\n\n"; return $return; } function get_args($string) { preg_match_all('` *(([^(),]+|\((([^()]*|\((?3)?\))+)\))+) *(,|$)`', $string, $matches, PREG_SET_ORDER); return $matches; } //(([^()]*|\((?2)?\))+)\)*/ dir_replace('@(?