Paginator: Various fixes
[AOOS.git] / modules / SimplePortfolio / SimplePortfolio.php
blobedc7dbfa303ab917a6308861b8bc8b94575d85b3
1 <?php
3 class SimplePortfolio extends AOOSModule
5 private $_count = null;
6 private $_limit = null;
7 private $_offset = null;
8 private $_sortBy = null;
9 private $_order = null; // ASC or DESC
10 private $_entries = null;
12 public function __construct($core)
14 parent::__construct($core);
16 $s = new AOOSStorageDevice($this->core());
17 $s->setStorageType("mysql");
18 $s->setTable("SimplePortfolio");
20 $this->_entries = $s->selectModel("*");
21 $this->_count = $s->numRows();
22 $this->_limit = $this->core()->getSetting("limit", __class__);
23 $this->_offset = $this->core()->getSetting("offset", __class__);
24 $this->_sortBy = $this->core()->getSetting("sortBy", __class__);
25 $this->_order = $this->core()->getSetting("order", __class__);
26 $this->_entries->sort($this->sortBy(), $this->order());
29 public function show()
31 $rows = $this->entries()->getRows($this->offset(), $this->offset()+$this->limit(), true);
32 return "Simple Portfolio";
35 public function setSortBy($field)
37 if (!$this->entries()->inColumnIndex($field))
39 return false;
41 $this->_sortBy = $field;
42 return true;
45 public function sortBy()
47 return $this->_sortBy;
50 public function setOrder($order)
52 $order = strtoupper($order);
53 if ($order != "ASC" && $order != "DESC")
55 $this->core()->log("Not asc or desc");
56 return false;
58 $this->_order = $order;
59 return true;
62 public function order()
64 return $this->_order;
67 public function setOffset($offset)
69 if (!is_integer($offset))
71 throw new AOOSException($this->core(), $this->tr("offset_not_numeric"), "", true, 1);
72 return false;
74 $this->_offset = $offset;
75 return true;
78 public function offset()
80 return $this->_offset;
83 public function setLimit($limit)
85 if (!is_integer($limit))
87 throw new AOOSException($this->core(), $this->tr("limit_not_numeric"), "", true, 1);
88 return false;
90 $this->_limit = $limit;
91 return true;
94 public function limit()
96 return $this->_limit;
98 public function entries()
100 return $this->_entries;