summaryrefslogtreecommitdiffstats
path: root/codebase/Event
diff options
context:
space:
mode:
authorKirylka <kirylanoshko@gmail.com>2015-03-31 17:56:47 +0300
committerKirylka <kirylanoshko@gmail.com>2015-03-31 17:56:47 +0300
commitf5f99c335707d9b11d40f1eb0f6ddb5a993fd31a (patch)
treed9c0d3532ec9f0f2fb68e31d2611282ae0642181 /codebase/Event
parent458f0aead573842f1df00ce2ae00334c27f66585 (diff)
downloadconnector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.zip
connector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.tar.gz
connector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.tar.bz2
Creating a new connector for yii2.
Diffstat (limited to 'codebase/Event')
-rw-r--r--codebase/Event/EventInterface.php37
-rw-r--r--codebase/Event/FilterInterface.php32
-rw-r--r--codebase/Event/SortInterface.php31
3 files changed, 100 insertions, 0 deletions
diff --git a/codebase/Event/EventInterface.php b/codebase/Event/EventInterface.php
new file mode 100644
index 0000000..645d89b
--- /dev/null
+++ b/codebase/Event/EventInterface.php
@@ -0,0 +1,37 @@
+<?php
+namespace DHTMLX\Connector\Event;
+
+class EventInterface{
+ protected $request; ////!< DataRequestConfig instance
+ public $rules=array(); //!< array of sorting rules
+
+ /*! constructor
+ creates a new interface based on existing request
+ @param request
+ DataRequestConfig object
+ */
+ public function __construct($request){
+ $this->request = $request;
+ }
+
+ /*! remove all elements from collection
+ */
+ public function clear(){
+ array_splice($rules,0);
+ }
+ /*! get index by name
+
+ @param name
+ name of field
+ @return
+ index of named field
+ */
+ public function index($name){
+ $len = sizeof($this->rules);
+ for ($i=0; $i < $len; $i++) {
+ if ($this->rules[$i]["name"]==$name)
+ return $i;
+ }
+ return false;
+ }
+}
diff --git a/codebase/Event/FilterInterface.php b/codebase/Event/FilterInterface.php
new file mode 100644
index 0000000..e37489d
--- /dev/null
+++ b/codebase/Event/FilterInterface.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace DHTMLX\Connector\Event;
+
+/*! Wrapper for collection of filtering rules
+**/
+class FilterInterface extends EventInterface{
+ /*! constructor
+ creates a new interface based on existing request
+ @param request
+ DataRequestConfig object
+ */
+ public function __construct($request){
+ $this->request = $request;
+ $this->rules = &$request->get_filters_ref();
+ }
+ /*! add new filatering rule
+
+ @param name
+ name of field
+ @param value
+ value to filter by
+ @param rule
+ filtering rule
+ */
+ public function add($name,$value,$rule){
+ $this->request->set_filter($name,$value,$rule);
+ }
+ public function store(){
+ $this->request->set_filters($this->rules);
+ }
+} \ No newline at end of file
diff --git a/codebase/Event/SortInterface.php b/codebase/Event/SortInterface.php
new file mode 100644
index 0000000..5e6aef4
--- /dev/null
+++ b/codebase/Event/SortInterface.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace DHTMLX\Connector\Event;
+
+class SortInterface extends EventInterface{
+ /*! constructor
+ creates a new interface based on existing request
+ @param request
+ DataRequestConfig object
+ */
+ public function __construct($request){
+ parent::__construct($request);
+ $this->rules = &$request->get_sort_by_ref();
+ }
+ /*! add new sorting rule
+
+ @param name
+ name of field
+ @param dir
+ direction of sorting
+ */
+ public function add($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);
+ }
+} \ No newline at end of file