Added createURL() + bugfix
[AOOS.git] / modules / Paginator / Paginator.php
blob70fdb1e879aba1ea0e100ed8559eb54da2bb3efd
1 <?php
3 class Paginator extends AOOSModule
5 private $_module = null;
6 private $_options = null;
8 public function show()
10 // First we clear options from previous
11 $this->_options = null;
13 $url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
14 $url = str_replace($this->core()->getSetting("server_name"), "", $url);
15 $parts = explode("/", $url);
16 if (strlen($parts[0]) > 0)
18 $this->_module = array_shift($parts);
19 $this->_options = array();
20 foreach ($parts as $f)
22 $this->_options[] = array_shift($parts);
24 if (!$this->core()->isLoaded($this->_module))
26 return false;
28 return $this->core()->getModule($this->_module)->show();
30 $module = $this->core()->getSetting("default_module", __class__);
31 return $this->core()->getModule($module)->show();
34 public function options()
36 return $this->_options;
39 public function createURL($module, $options) {
40 if (!is_array($options)) {
41 throw new AOOSException($this->core(), $this->tr("not_array"), "", true, 1);
42 return false;
44 $url = $this->core()->getSetting("server_name");
45 $url .= $module."/";
46 $opt = implode("/", $options);
47 $url .= $opt;
48 return $url;
51 public function numOptions() {
52 return count($this->options());