diff options
author | Kirylka <kirylanoshko@gmail.com> | 2015-04-07 12:27:53 +0300 |
---|---|---|
committer | Kirylka <kirylanoshko@gmail.com> | 2015-04-07 12:27:53 +0300 |
commit | f70c0f119d3aeacbb30fa3ad65ed56cda9640d97 (patch) | |
tree | f1769b415e145da3a836a897450c118f4995d05a /codebase/Data | |
parent | 9c5ae1267c676ca235efb8d78a206cb45d0d714c (diff) | |
download | connector-php-f70c0f119d3aeacbb30fa3ad65ed56cda9640d97.zip connector-php-f70c0f119d3aeacbb30fa3ad65ed56cda9640d97.tar.gz connector-php-f70c0f119d3aeacbb30fa3ad65ed56cda9640d97.tar.bz2 |
Webix grid support
Diffstat (limited to 'codebase/Data')
-rw-r--r-- | codebase/Data/CommonDataItem.php | 27 | ||||
-rw-r--r-- | codebase/Data/CommonDataProcessor.php | 55 | ||||
-rw-r--r-- | codebase/Data/JSONCommonDataItem.php | 29 |
3 files changed, 111 insertions, 0 deletions
diff --git a/codebase/Data/CommonDataItem.php b/codebase/Data/CommonDataItem.php new file mode 100644 index 0000000..523cd08 --- /dev/null +++ b/codebase/Data/CommonDataItem.php @@ -0,0 +1,27 @@ +<?php + +namespace DHTMLX\Connector\Data; +/*! DataItem class for DataView component +**/ +class CommonDataItem extends DataItem{ + /*! return self as XML string + */ + function to_xml(){ + if ($this->skip) return ""; + return $this->to_xml_start().$this->to_xml_end(); + } + + function to_xml_start(){ + $str="<item id='".$this->get_id()."' "; + for ($i=0; $i < sizeof($this->config->text); $i++){ + $name=$this->config->text[$i]["name"]; + $str.=" ".$name."='".$this->xmlentities($this->data[$name])."'"; + } + + if ($this->userdata !== false) + foreach ($this->userdata as $key => $value) + $str.=" ".$key."='".$this->xmlentities($value)."'"; + + return $str.">"; + } +}
\ No newline at end of file diff --git a/codebase/Data/CommonDataProcessor.php b/codebase/Data/CommonDataProcessor.php new file mode 100644 index 0000000..8f00b94 --- /dev/null +++ b/codebase/Data/CommonDataProcessor.php @@ -0,0 +1,55 @@ +<?php +namespace DHTMLX\Connector\Data; + +use DHTMLX\Connector\XSSFilter\ConnectorSecurity; +use DHTMLX\Connector\Tools\LogMaster; + +class CommonDataProcessor extends DataProcessor{ + protected function get_post_values($ids){ + if (isset($_GET['action'])){ + $data = array(); + if (isset($_POST["id"])){ + $dataset = array(); + foreach($_POST as $key=>$value) + $dataset[$key] = ConnectorSecurity::filter($value); + + $data[$_POST["id"]] = $dataset; + } + else + $data["dummy_id"] = $_POST; + return $data; + } + return parent::get_post_values($ids); + } + + protected function get_ids(){ + if (isset($_GET['action'])){ + if (isset($_POST["id"])) + return array($_POST['id']); + else + return array("dummy_id"); + } + return parent::get_ids(); + } + + protected function get_operation($rid){ + if (isset($_GET['action'])) + return $_GET['action']; + return parent::get_operation($rid); + } + + public function output_as_xml($results){ + if (isset($_GET['action'])){ + LogMaster::log("Edit operation finished",$results); + ob_clean(); + $type = $results[0]->get_status(); + if ($type == "error" || $type == "invalid"){ + echo "false"; + } else if ($type=="insert"){ + echo "true\n".$results[0]->get_new_id(); + } else + echo "true"; + } else + return parent::output_as_xml($results); + } +};
\ No newline at end of file diff --git a/codebase/Data/JSONCommonDataItem.php b/codebase/Data/JSONCommonDataItem.php new file mode 100644 index 0000000..4a69068 --- /dev/null +++ b/codebase/Data/JSONCommonDataItem.php @@ -0,0 +1,29 @@ +<?php +namespace DHTMLX\Connector\Data; + +class JSONCommonDataItem extends DataItem{ + /*! return self as XML string + */ + function to_xml(){ + if ($this->skip) return false; + + $data = array( + 'id' => $this->get_id() + ); + for ($i=0; $i<sizeof($this->config->text); $i++){ + $extra = $this->config->text[$i]["name"]; + $data[$extra]=$this->data[$extra]; + if (is_null($data[$extra])) + $data[$extra] = ""; + } + + if ($this->userdata !== false) + foreach ($this->userdata as $key => $value){ + if ($value === null) + $data[$key]=""; + $data[$key]=$value; + } + + return $data; + } +} |