diff options
author | Dmitry <dmitry@dhtmlx.com> | 2012-07-10 17:19:45 +0200 |
---|---|---|
committer | Dmitry <dmitry@dhtmlx.com> | 2012-07-10 17:19:45 +0200 |
commit | 39a85a6361a2de94c5528344ec88eaed614d743b (patch) | |
tree | eb93300681ec90adee33a4838e662965d26abea3 /codebase/base_connector.php | |
parent | fb37b3dc462d73faead66b6c3d16cf5541bde57a (diff) | |
download | connector-php-39a85a6361a2de94c5528344ec88eaed614d743b.zip connector-php-39a85a6361a2de94c5528344ec88eaed614d743b.tar.gz connector-php-39a85a6361a2de94c5528344ec88eaed614d743b.tar.bz2 |
easy sort api
Diffstat (limited to 'codebase/base_connector.php')
-rw-r--r-- | codebase/base_connector.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php index 9f0bb85..b3dddb9 100644 --- a/codebase/base_connector.php +++ b/codebase/base_connector.php @@ -109,7 +109,10 @@ class SortInterface extends EventInterface{ direction of sorting */ public function add($name,$dir){ - $this->request->set_sort($name,$dir); + if ($dir === false) + $this->request->set_sort($name); + else + $this->request->set_sort($name,$dir); } public function store(){ $this->request->set_sort_by($this->rules); @@ -303,6 +306,7 @@ class Connector { protected $options=array();//!< hash of OptionsConnector protected $as_string = false; protected $filters; + protected $sorts; /*! constructor @@ -333,6 +337,7 @@ class Connector { ); $this->attributes = array(); $this->filters = array(); + $this->sorts = array(); $this->config = new DataConfig(); $this->request = new DataRequestConfig(); @@ -480,6 +485,7 @@ class Connector { die(); } $wrap = new SortInterface($this->request); + $this->apply_sorts($wrap); $this->event->trigger("beforeSort",$wrap); $wrap->store(); @@ -811,6 +817,17 @@ class Connector { $wrap->add($f['name'], $f['value'], $f['operation']); } } + + public function sort($name, $direction = false) { + $this->sorts[] = array('name' => $name, 'direction' => $direction); + } + + protected function apply_sorts($wrap) { + for ($i = 0; $i < count($this->sorts); $i++) { + $s = $this->sorts[$i]; + $wrap->add($s['name'], $s['direction']); + } + } } |