Commit 6744e340 authored by Dries's avatar Dries

- Fixed the pager.  It might not be 100% correct, but it will work in 95%
  of the cases.
parent 22c3f055
......@@ -719,34 +719,6 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $
return form_select($title, $name, $value, $weights, $description, $extra);
}
/**
* Parse an URL; this function must be follow the changes of a clean url implementation
*
* @param string $url optional, url to parse; default to request_uri()
* @return array $result associative array:
* script => index/node/module/admin
* query => GET variables
*
*/
function drupal_parse_url($url = NULL) {
global $PHP_SELF;
static $cache;
if ($url == NULL) {
$url = $PHP_SELF ."?". getenv("QUERY_STRING");
}
if (!$cache[$url]) {
$parts = parse_url($url);
preg_match("/(\w+?)\.php/", $parts["path"], $found);
$cache[$url]["script"] = $found[1];
parse_str($parts["query"], $cache[$url]["query"]);
$cache[$url]["anchor"] = $parts["fragment"];
}
return $cache[$url];
}
function url($url, $query = NULL) {
if ($url) {
......@@ -766,10 +738,6 @@ function url($url, $query = NULL) {
function l($text, $url, $attributes = array(), $query = NULL) {
if (!is_array($attributes)) {
print "$text - $url";
}
$t = array();
foreach ($attributes as $key => $value) {
$t[] = "$key=\"$value\"";
......
......@@ -282,21 +282,19 @@ function pager_query($query, $limit = 10, $element = 0) {
}
function pager_link($from_new, $attributes = array()) {
$url = drupal_parse_url();
if (count($from_new) == 0 || (count($from_new) == 1 && $from_new[0] == 0)) {
unset($url["query"]["from"]);
}
else {
$url["query"]["from"] = implode(",", $from_new);
foreach($attributes as $key => $value) {
$query[] = "$key=$value";
}
if (count($attributes)) {
$url["query"] = array_merge($url["query"], $attributes);
$url = url("", "from=". $from_new[0] ."&". implode("&", $query));
}
else {
$url = url("", "from=". $from_new[0]);
}
// TODO: should use 'url()':
// return drupal_url($url["query"], $url["script"]);
return $url;
}
function pager_load_array($value, $element, $old_array) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment