From 34964a5604ff234eadeaa238177a082ea97fdaa7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Skej=C3=B8?= Date: Mon, 25 May 2009 11:40:43 +0200 Subject: [PATCH] Paginator: Various fixes --- modules/Paginator/Paginator.php | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/Paginator/Paginator.php b/modules/Paginator/Paginator.php index c51926b..7167733 100644 --- a/modules/Paginator/Paginator.php +++ b/modules/Paginator/Paginator.php @@ -16,9 +16,12 @@ class Paginator extends AOOSModule { $this->_module = array_shift($parts); $this->_options = array(); - foreach ($parts as $f) - { - $this->_options[] = array_shift($parts); + foreach ($parts as $f) { + $p = array_shift($parts); + if ($p == "") { + return false; + } + $this->_options[] = $p; } } else { @@ -29,7 +32,7 @@ class Paginator extends AOOSModule public function show() { $this->start(); - if (!($m = $this->core()->getModule($this->_module))) { + if (!($m = $this->core()->getModule($this->module()))) { return false; } return $m->show(); @@ -40,6 +43,19 @@ class Paginator extends AOOSModule return $this->_options; } + public function getOption($nr) { + $opts = $this->options(); + if ($nr >= count($opts)) { + return false; + } + return $opts[$nr]; + } + + public function module() { + $this->start(); + return $this->_module; + } + public function createURL($module, $options) { $this->start(); if (!is_array($options)) { @@ -56,10 +72,14 @@ class Paginator extends AOOSModule public function currentURL($short = false) { $this->start(); if ($short) { - return $this->_module."/".implode("/",$this->_options); + return $this->options() ? $this->module()."/".implode("/",$this->options()) : $this->module(); } else { - return $this->createURL($this->_module, $this->_options); + $url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; + if (strpos($url, $this->module()) === false) { + return $url.$this->module(); + } + return $url; } } -- 2.11.4.GIT