summaryrefslogtreecommitdiffstats
path: root/codebase/Data
diff options
context:
space:
mode:
Diffstat (limited to 'codebase/Data')
-rw-r--r--codebase/Data/CommonDataItem.php27
-rw-r--r--codebase/Data/CommonDataProcessor.php55
-rw-r--r--codebase/Data/JSONCommonDataItem.php29
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;
+ }
+}