echo "</pre></div>\n";
}
+ function build_args($params, $key, $value, $description) {
+ $uri = preg_replace('/&args=[^&]+/', '', $_SERVER['REQUEST_URI']);
+ $uri = " <a href=\"$uri&args=";
+ $args = array();
+ foreach ($params as $k => $v) {
+ if ($k == $key) $args[] = "$key:$value";
+ else $args[] = "$k:$v";
+ }
+ $uri .= implode("+", $args);
+ $uri .= "\">$description</a>";
+ return $uri;
+ }
+
function module_race($action, $args) {
if ($_POST['add_race']) {
if (add_race($_POST["name"], $_POST["allotted_time"])) unset($_POST);
foreach (array_keys($methods) as $method) {
$Method = preg_replace('/_/', ' ', ucfirst($method));
if ($method == $sort) $uri = " $Method";
- else {
- $uri = preg_replace('/&args=[^&]+/', '', $_SERVER['REQUEST_URI']);
- /* XXX build_http_str */
- $uri = " <a href=\"$uri&args=sort:$method";
- if ($format) $uri .= "+format:$format";
- $uri .= "\">$Method</a>";
- }
+ else $uri = build_args($params, "sort", $method, $Method);
$uri_list[] = $uri;
}
echo "<p class=\"header\">Sort by: " . implode(" // ", $uri_list) . "</p>\n";
foreach (array_keys($formats) as $fmt) {
$Fmt = ucfirst($formats[$fmt][1]);
if ($fmt == $format) $uri = " $Fmt";
- else {
- $uri = preg_replace('/&args=[^&]+/', '', $_SERVER['REQUEST_URI']);
- $uri = " <a href=\"$uri&args=";
- if ($sort) $uri .= "sort:$sort+";
- $uri .= "format:$fmt";
- $uri .= "\">$Fmt</a>";
- }
+ else $uri = build_args($params, "format", $fmt, $Fmt);
$uri_list[] = $uri;
}
echo "<p class=\"header\">Show: " . implode(" // ", $uri_list) . "</p>\n";