summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor <egor.26.93@gmail.com>2015-06-12 16:06:06 +0300
committerEgor <egor.26.93@gmail.com>2015-06-12 16:06:06 +0300
commit9abd184a386a2594398df9f5cd7bd6d5b9c240fc (patch)
tree6b237196dd4ae8bdee61093308f5c3dcdcc5c79e
parent5fbd0adda5155853e86001fad4c571008f09f01b (diff)
downloadconnector-php-9abd184a386a2594398df9f5cd7bd6d5b9c240fc.zip
connector-php-9abd184a386a2594398df9f5cd7bd6d5b9c240fc.tar.gz
connector-php-9abd184a386a2594398df9f5cd7bd6d5b9c240fc.tar.bz2
Updated structure. Added connectors.
-rw-r--r--codebase/Dhtmlx/Connector/ChartConnector.php10
-rw-r--r--codebase/Dhtmlx/Connector/ComboConnector.php60
-rw-r--r--codebase/Dhtmlx/Connector/Connector.php16
-rw-r--r--codebase/Dhtmlx/Connector/Data/ComboDataItem.php32
-rw-r--r--codebase/Dhtmlx/Connector/Data/CommonDataItem.php4
-rw-r--r--codebase/Dhtmlx/Connector/Data/DataAction.php4
-rw-r--r--codebase/Dhtmlx/Connector/Data/DataConfig.php (renamed from codebase/Dhtmlx/Connector/DataStorage/DataConfig.php)6
-rw-r--r--codebase/Dhtmlx/Connector/Data/DataItem.php4
-rw-r--r--codebase/Dhtmlx/Connector/Data/DataItemUpdate.php4
-rw-r--r--codebase/Dhtmlx/Connector/Data/DataRequestConfig.php (renamed from codebase/Dhtmlx/Connector/DataStorage/DataRequestConfig.php)6
-rw-r--r--codebase/Dhtmlx/Connector/Data/DataUpdate.php3
-rw-r--r--codebase/Dhtmlx/Connector/Data/DataViewDataItem.php19
-rw-r--r--codebase/Dhtmlx/Connector/Data/FormDataItem.php17
-rw-r--r--codebase/Dhtmlx/Connector/Data/GanttDataItem.php27
-rw-r--r--codebase/Dhtmlx/Connector/Data/GridDataItem.php (renamed from codebase/Dhtmlx/Connector/GridDataItem.php)7
-rw-r--r--codebase/Dhtmlx/Connector/Data/JSONCommonDataItem.php2
-rw-r--r--codebase/Dhtmlx/Connector/Data/JSONGanttDataItem.php26
-rw-r--r--codebase/Dhtmlx/Connector/Data/JSONSchedulerDataItem.php28
-rw-r--r--codebase/Dhtmlx/Connector/Data/SchedulerDataItem.php26
-rw-r--r--codebase/Dhtmlx/Connector/Data/TreeDataItem.php4
-rw-r--r--codebase/Dhtmlx/Connector/Data/TreeGridDataItem.php47
-rw-r--r--codebase/Dhtmlx/Connector/DataConnector.php2
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/CommonDataProcessor.php (renamed from codebase/Dhtmlx/Connector/Data/CommonDataProcessor.php)5
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/DataProcessor.php (renamed from codebase/Dhtmlx/Connector/Data/DataProcessor.php)22
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/GanttDataProcessor.php23
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/GridDataProcessor.php (renamed from codebase/Dhtmlx/Connector/Data/GridDataProcessor.php)4
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/KeyGridDataProcessor.php21
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/SchedulerDataProcessor.php21
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/TreeDataProcessor.php (renamed from codebase/Dhtmlx/Connector/Data/TreeDataProcessor.php)4
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/TreeGridDataProcessor.php26
-rw-r--r--codebase/Dhtmlx/Connector/DataProcessor/TreeGridMultitableDataProcessor.php20
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/AdoDBDataWrapper.php69
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/ArrayDBDataWrapper.php5
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/ArrayQueryWrapper.php2
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/DBDataWrapper.php13
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/DataWrapper.php5
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/ExcelDBDataWrapper.php105
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/FileSystemDBDataWrapper.php140
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/MsSQLDBDataWrapper.php5
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/MySQLDBDataWrapper.php5
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/OracleDBDataWrapper.php86
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php8
-rwxr-xr-xcodebase/Dhtmlx/Connector/DataStorage/PHPCI2DBDataWrapper.php1
-rwxr-xr-xcodebase/Dhtmlx/Connector/DataStorage/PHPCIDBDataWrapper.php1
-rwxr-xr-xcodebase/Dhtmlx/Connector/DataStorage/PHPCakeDBDataWrapper.php1
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/PHPYii1DBDataWrapper.php1
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/PHPYiiDBDataWrapper.php1
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/PostgreDBDataWrapper.php5
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/ResultHandler/ExcelResultHandler.php75
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/ResultHandler/FileSystemResultHandler.php76
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/ResultHandler/PDOResultHandler.php (renamed from codebase/Dhtmlx/Connector/DataStorage/PDOResultSet.php)5
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/SQLSrvDBDataWrapper.php95
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/SQLite3DBDataWrapper.php30
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/SQLiteDBDataWrapper.php69
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/SaSQLDBDataWrapper.php86
-rw-r--r--codebase/Dhtmlx/Connector/DataStorage/TypeHandler/FileSystemTypeHandler.php119
-rw-r--r--codebase/Dhtmlx/Connector/DataViewConnector.php49
-rw-r--r--codebase/Dhtmlx/Connector/DistinctOptionsConnector.php2
-rw-r--r--codebase/Dhtmlx/Connector/Event/EventInterface.php2
-rw-r--r--codebase/Dhtmlx/Connector/Event/FilterInterface.php3
-rw-r--r--codebase/Dhtmlx/Connector/Event/SortInterface.php3
-rw-r--r--codebase/Dhtmlx/Connector/FormConnector.php36
-rw-r--r--codebase/Dhtmlx/Connector/GanttConnector.php96
-rw-r--r--codebase/Dhtmlx/Connector/GanttLinksConnector.php19
-rw-r--r--codebase/Dhtmlx/Connector/GridConfiguration.php4
-rw-r--r--codebase/Dhtmlx/Connector/GridConnector.php10
-rw-r--r--codebase/Dhtmlx/Connector/JSONDataConnector.php5
-rw-r--r--codebase/Dhtmlx/Connector/JSONDistinctOptionsConnector.php18
-rw-r--r--codebase/Dhtmlx/Connector/JSONGanttConnector.php163
-rw-r--r--codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php19
-rw-r--r--codebase/Dhtmlx/Connector/JSONOptionsConnector.php21
-rw-r--r--codebase/Dhtmlx/Connector/JSONSchedulerConnector.php99
-rw-r--r--codebase/Dhtmlx/Connector/JSONTreeDataConnector.php80
-rw-r--r--codebase/Dhtmlx/Connector/JSONTreeDataGroupConnector.php40
-rw-r--r--codebase/Dhtmlx/Connector/JSONTreeDataMultitableConnector.php37
-rw-r--r--codebase/Dhtmlx/Connector/KeyGridConnector.php24
-rw-r--r--codebase/Dhtmlx/Connector/MixedConnector.php2
-rw-r--r--codebase/Dhtmlx/Connector/OptionsConnector.php3
-rw-r--r--codebase/Dhtmlx/Connector/Output/JSONRenderStrategy.php1
-rw-r--r--codebase/Dhtmlx/Connector/Output/JSONTreeRenderStrategy.php2
-rw-r--r--codebase/Dhtmlx/Connector/Output/OutputWriter.php3
-rw-r--r--codebase/Dhtmlx/Connector/Output/RenderStrategy.php15
-rw-r--r--codebase/Dhtmlx/Connector/Output/TreeRenderStrategy.php4
-rw-r--r--codebase/Dhtmlx/Connector/SchedulerConnector.php61
-rw-r--r--codebase/Dhtmlx/Connector/Tools/AccessMaster.php3
-rw-r--r--codebase/Dhtmlx/Connector/Tools/ConvertService.php (renamed from codebase/Dhtmlx/Connector/ConvertService.php)6
-rw-r--r--codebase/Dhtmlx/Connector/Tools/EventMaster.php5
-rwxr-xr-xcodebase/Dhtmlx/Connector/Tools/LogMaster.php4
-rw-r--r--codebase/Dhtmlx/Connector/TreeConnector.php4
-rw-r--r--codebase/Dhtmlx/Connector/TreeDataConnector.php53
-rw-r--r--codebase/Dhtmlx/Connector/TreeDataGroupConnector.php40
-rw-r--r--codebase/Dhtmlx/Connector/TreeDataMultitableConnector.php45
-rw-r--r--codebase/Dhtmlx/Connector/TreeGridConnector.php48
-rw-r--r--codebase/Dhtmlx/Connector/TreeGridGroupConnector.php40
-rw-r--r--codebase/Dhtmlx/Connector/TreeGridMultitableConnector.php44
-rw-r--r--codebase/Dhtmlx/Connector/TreeGroupConnector.php40
-rw-r--r--codebase/Dhtmlx/Connector/TreeMultitableConnector.php45
-rw-r--r--codebase/Dhtmlx/Connector/XSSFilter/ConnectorSecurity.php4
98 files changed, 2565 insertions, 145 deletions
diff --git a/codebase/Dhtmlx/Connector/ChartConnector.php b/codebase/Dhtmlx/Connector/ChartConnector.php
new file mode 100644
index 0000000..fd3621f
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/ChartConnector.php
@@ -0,0 +1,10 @@
+<?php
+namespace Dhtmlx\Connector;
+
+/*! Connector class for DataView
+**/
+class ChartConnector extends DataViewConnector {
+ public function __construct($res,$type=false,$item_type=false,$data_type=false){
+ parent::__construct($res,$type,$item_type,$data_type);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/ComboConnector.php b/codebase/Dhtmlx/Connector/ComboConnector.php
new file mode 100644
index 0000000..05962f4
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/ComboConnector.php
@@ -0,0 +1,60 @@
+<?php
+namespace Dhtmlx\Connector;
+use Dhtmlx\Connector\Tools\LogMaster;
+
+/*! Connector for the dhtmlxCombo
+**/
+class ComboConnector extends Connector {
+ private $filter; //!< filtering mask from incoming request
+ private $position; //!< position from incoming request
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false){
+ if (!$item_type) $item_type="ComboDataItem";
+ parent::__construct($res,$type,$item_type,$data_type);
+ }
+
+ //parse GET scoope, all operations with incoming request must be done here
+ function parse_request(){
+ parent::parse_request();
+
+ if (isset($_GET["pos"])){
+ if (!$this->dload) //not critical, so just write a log message
+ LogMaster::log("Dyn loading request received, but server side was not configured to process dyn. loading. ");
+ else
+ $this->request->set_limit($_GET["pos"],$this->dload);
+ }
+
+ if (isset($_GET["mask"]))
+ $this->request->set_filter($this->config->text[0]["db_name"],$_GET["mask"]."%","LIKE");
+
+ LogMaster::log($this->request);
+ }
+
+
+ /*! renders self as xml, starting part
+ */
+ public function xml_start(){
+ if ($this->request->get_start())
+ return "<complete add='true'>";
+ else
+ return "<complete>";
+ }
+
+ /*! renders self as xml, ending part
+ */
+ public function xml_end(){
+ return "</complete>";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Connector.php b/codebase/Dhtmlx/Connector/Connector.php
index 7513906..b537925 100644
--- a/codebase/Dhtmlx/Connector/Connector.php
+++ b/codebase/Dhtmlx/Connector/Connector.php
@@ -1,22 +1,20 @@
<?php
-
namespace Dhtmlx\Connector;
-
+use Dhtmlx\Connector\Data\DataAction;
+use Dhtmlx\Connector\Data\DataConfig;
+use Dhtmlx\Connector\Data\DataRequestConfig;
+use Dhtmlx\Connector\Data\DataUpdate;
+use Dhtmlx\Connector\DataStorage\MySQLDBDataWrapper;
+use Dhtmlx\Connector\DataStorage\ArrayDBDataWrapper;
use Dhtmlx\Connector\Tools\EventMaster;
use Dhtmlx\Connector\Tools\AccessMaster;
use Dhtmlx\Connector\Tools\LogMaster;
use Dhtmlx\Connector\Output\RenderStrategy;
use Dhtmlx\Connector\Output\OutputWriter;
-use Dhtmlx\Connector\DataStorage\DataConfig;
-use Dhtmlx\Connector\DataStorage\DataAction;
-use Dhtmlx\Connector\DataStorage\DataRequestConfig;
-use Dhtmlx\Connector\DataStorage\MySQLDBDataWrapper;
-use Dhtmlx\Connector\DataStorage\ArrayDBDataWrapper;
-use Dhtmlx\Connector\DataStorage\PHPYii2DBDataWrapper;
-use Dhtmlx\Connector\Data\CommonDataProcessor;
use Dhtmlx\Connector\XSSFilter\ConnectorSecurity;
use Dhtmlx\Connector\Event\SortInterface;
use Dhtmlx\Connector\Event\FilterInterface;
+use Dhtmlx\Connector\DataStorage\ArrayQueryWrapper;
class Connector {
protected $config;//DataConfig instance
diff --git a/codebase/Dhtmlx/Connector/Data/ComboDataItem.php b/codebase/Dhtmlx/Connector/Data/ComboDataItem.php
new file mode 100644
index 0000000..4e65676
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/ComboDataItem.php
@@ -0,0 +1,32 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+/*! DataItem class for Combo component
+**/
+class ComboDataItem extends DataItem{
+ private $selected;//!< flag of selected option
+
+ function __construct($data,$config,$index){
+ parent::__construct($data,$config,$index);
+
+ $this->selected=false;
+ }
+ /*! mark option as selected
+ */
+ function select(){
+ $this->selected=true;
+ }
+ /*! return self as XML string, starting part
+ */
+ function to_xml_start(){
+ if ($this->skip) return "";
+
+ return "<option ".($this->selected?"selected='true'":"")."value='".$this->xmlentities($this->get_id())."'><![CDATA[".$this->data[$this->config->text[0]["name"]]."]]>";
+ }
+ /*! return self as XML string, ending part
+ */
+ function to_xml_end(){
+ if ($this->skip) return "";
+ return "</option>";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/CommonDataItem.php b/codebase/Dhtmlx/Connector/Data/CommonDataItem.php
index 56bb817..fac5c9b 100644
--- a/codebase/Dhtmlx/Connector/Data/CommonDataItem.php
+++ b/codebase/Dhtmlx/Connector/Data/CommonDataItem.php
@@ -1,9 +1,9 @@
<?php
-
namespace Dhtmlx\Connector\Data;
+
/*! DataItem class for DataView component
**/
-class CommonDataItem extends DataItem{
+class CommonDataItem extends DataItem {
/*! return self as XML string
*/
function to_xml(){
diff --git a/codebase/Dhtmlx/Connector/Data/DataAction.php b/codebase/Dhtmlx/Connector/Data/DataAction.php
index cc136a6..c5520fb 100644
--- a/codebase/Dhtmlx/Connector/Data/DataAction.php
+++ b/codebase/Dhtmlx/Connector/Data/DataAction.php
@@ -1,10 +1,10 @@
<?php
namespace Dhtmlx\Connector\Data;
-
use Dhtmlx\Connector\Tools\LogMaster;
+
/*! contain all info related to action and controls customizaton
**/
-class DataAction{
+class DataAction {
private $status; //!< cuurent status of record
private $id;//!< id of record
private $data;//!< data hash of record
diff --git a/codebase/Dhtmlx/Connector/DataStorage/DataConfig.php b/codebase/Dhtmlx/Connector/Data/DataConfig.php
index 99af751..86b5e8b 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/DataConfig.php
+++ b/codebase/Dhtmlx/Connector/Data/DataConfig.php
@@ -1,9 +1,11 @@
<?php
+namespace Dhtmlx\Connector\Data;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
-namespace Dhtmlx\Connector\DataStorage;
/*! manager of data configuration
**/
-class DataConfig{
+class DataConfig {
public $id;////!< name of ID field
public $relation_id;//!< name or relation ID field
public $text;//!< array of text fields
diff --git a/codebase/Dhtmlx/Connector/Data/DataItem.php b/codebase/Dhtmlx/Connector/Data/DataItem.php
index 4b28300..09ba8a0 100644
--- a/codebase/Dhtmlx/Connector/Data/DataItem.php
+++ b/codebase/Dhtmlx/Connector/Data/DataItem.php
@@ -1,9 +1,9 @@
<?php
-
namespace Dhtmlx\Connector\Data;
+
/*! base class for component item representation
**/
-class DataItem{
+class DataItem {
protected $data; //!< hash of data
protected $config;//!< DataConfig instance
protected $index;//!< index of element
diff --git a/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php b/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php
index e1a8c21..c77451c 100644
--- a/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php
+++ b/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php
@@ -1,4 +1,6 @@
<?php
+namespace Dhtmlx\Connector\Data;
+use Dhtmlx\Connector\Tools\LogMaster;
/*
@author dhtmlx.com
@@ -11,8 +13,6 @@
Create wrapper for every data item with update information.
*/
-namespace Dhtmlx\Connector\Data;
-
class DataItemUpdate extends DataItem {
diff --git a/codebase/Dhtmlx/Connector/DataStorage/DataRequestConfig.php b/codebase/Dhtmlx/Connector/Data/DataRequestConfig.php
index c9f3913..e2b709c 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/DataRequestConfig.php
+++ b/codebase/Dhtmlx/Connector/Data/DataRequestConfig.php
@@ -1,10 +1,10 @@
<?php
-
-namespace Dhtmlx\Connector\DataStorage;
+namespace Dhtmlx\Connector\Data;
+use \Exception;
/*! manager of data request
**/
-class DataRequestConfig{
+class DataRequestConfig {
private $filters; //!< array of filtering rules
private $relation=false; //!< ID or other element used for linking hierarchy
private $sort_by; //!< sorting field
diff --git a/codebase/Dhtmlx/Connector/Data/DataUpdate.php b/codebase/Dhtmlx/Connector/Data/DataUpdate.php
index 8fc1c46..7db2261 100644
--- a/codebase/Dhtmlx/Connector/Data/DataUpdate.php
+++ b/codebase/Dhtmlx/Connector/Data/DataUpdate.php
@@ -1,6 +1,7 @@
<?php
+namespace Dhtmlx\Connector\Data;
-class DataUpdate{
+class DataUpdate {
protected $table; //!< table , where actions are stored
protected $url; //!< url for notification service, optional
diff --git a/codebase/Dhtmlx/Connector/Data/DataViewDataItem.php b/codebase/Dhtmlx/Connector/Data/DataViewDataItem.php
new file mode 100644
index 0000000..51438c7
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/DataViewDataItem.php
@@ -0,0 +1,19 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+/*! DataItem class for DataView component
+**/
+class DataViewDataItem extends DataItem {
+ /*! return self as XML string
+ */
+ function to_xml(){
+ if ($this->skip) return "";
+
+ $str="<item id='".$this->get_id()."' >";
+ for ($i=0; $i<sizeof($this->config->text); $i++){
+ $extra = $this->config->text[$i]["name"];
+ $str.="<".$extra."><![CDATA[".$this->data[$extra]."]]></".$extra.">";
+ }
+ return $str."</item>";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/FormDataItem.php b/codebase/Dhtmlx/Connector/Data/FormDataItem.php
new file mode 100644
index 0000000..720fe7b
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/FormDataItem.php
@@ -0,0 +1,17 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+/*! DataItem class for dhxForm component
+**/
+class FormDataItem extends DataItem {
+ /*! return self as XML string
+ */
+ function to_xml(){
+ if ($this->skip) return "";
+ $str="";
+ for ($i = 0; $i < count($this->config->data); $i++) {
+ $str .= "<".$this->config->data[$i]['name']."><![CDATA[".$this->data[$this->config->data[$i]['name']]."]]></".$this->config->data[$i]['name'].">";
+ }
+ return $str;
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/GanttDataItem.php b/codebase/Dhtmlx/Connector/Data/GanttDataItem.php
new file mode 100644
index 0000000..61acdc2
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/GanttDataItem.php
@@ -0,0 +1,27 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+/*! DataItem class for Gantt component
+**/
+class GanttDataItem extends DataItem {
+
+ /*! return self as XML string
+ */
+ function to_xml(){
+ if ($this->skip) return "";
+
+ $str="<task id='".$this->get_id()."' >";
+ $str.="<start_date><![CDATA[".$this->data[$this->config->text[0]["name"]]."]]></start_date>";
+ $str.="<".$this->config->text[1]["name"]."><![CDATA[".$this->data[$this->config->text[1]["name"]]."]]></".$this->config->text[1]["name"].">";
+ $str.="<text><![CDATA[".$this->data[$this->config->text[2]["name"]]."]]></text>";
+ for ($i=3; $i<sizeof($this->config->text); $i++){
+ $extra = $this->config->text[$i]["name"];
+ $str.="<".$extra."><![CDATA[".$this->data[$extra]."]]></".$extra.">";
+ }
+ if ($this->userdata !== false)
+ foreach ($this->userdata as $key => $value)
+ $str.="<".$key."><![CDATA[".$value."]]></".$key.">";
+
+ return $str."</task>";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/GridDataItem.php b/codebase/Dhtmlx/Connector/Data/GridDataItem.php
index 29db286..e9a9dc1 100644
--- a/codebase/Dhtmlx/Connector/GridDataItem.php
+++ b/codebase/Dhtmlx/Connector/Data/GridDataItem.php
@@ -1,12 +1,9 @@
<?php
+namespace Dhtmlx\Connector\Data;
-namespace Dhtmlx\Connector;
-
-use Dhtmlx\Connector\Data\DataItem;
/*! DataItem class for Grid component
**/
-
-class GridDataItem extends DataItem{
+class GridDataItem extends DataItem {
protected $row_attrs;//!< hash of row attributes
protected $cell_attrs;//!< hash of cell attributes
diff --git a/codebase/Dhtmlx/Connector/Data/JSONCommonDataItem.php b/codebase/Dhtmlx/Connector/Data/JSONCommonDataItem.php
index 1ee8a07..bc52911 100644
--- a/codebase/Dhtmlx/Connector/Data/JSONCommonDataItem.php
+++ b/codebase/Dhtmlx/Connector/Data/JSONCommonDataItem.php
@@ -1,7 +1,7 @@
<?php
namespace Dhtmlx\Connector\Data;
-class JSONCommonDataItem extends DataItem{
+class JSONCommonDataItem extends DataItem {
/*! return self as XML string
*/
function to_xml(){
diff --git a/codebase/Dhtmlx/Connector/Data/JSONGanttDataItem.php b/codebase/Dhtmlx/Connector/Data/JSONGanttDataItem.php
new file mode 100644
index 0000000..d5886fd
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/JSONGanttDataItem.php
@@ -0,0 +1,26 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+class JSONGanttDataItem extends GanttDataItem {
+ /*! return self as XML string
+ */
+ function to_xml(){
+ if ($this->skip) return "";
+
+ $obj = array();
+ $obj['id'] = $this->get_id();
+ $obj['start_date'] = $this->data[$this->config->text[0]["name"]];
+ $obj[$this->config->text[1]["name"]] = $this->data[$this->config->text[1]["name"]];
+ $obj['text'] = $this->data[$this->config->text[2]["name"]];
+ for ($i=3; $i<sizeof($this->config->text); $i++){
+ $extra = $this->config->text[$i]["name"];
+ $obj[$extra]=$this->data[$extra];
+ }
+
+ if ($this->userdata !== false)
+ foreach ($this->userdata as $key => $value)
+ $obj[$key]=$value;
+
+ return $obj;
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/JSONSchedulerDataItem.php b/codebase/Dhtmlx/Connector/Data/JSONSchedulerDataItem.php
new file mode 100644
index 0000000..5eceb04
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/JSONSchedulerDataItem.php
@@ -0,0 +1,28 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+class JSONSchedulerDataItem extends SchedulerDataItem {
+
+ /*! return self as XML string
+ */
+ function to_xml(){
+ if ($this->skip) return "";
+
+ $obj = array();
+ $obj['id'] = $this->get_id();
+ $obj['start_date'] = $this->data[$this->config->text[0]["name"]];
+ $obj['end_date'] = $this->data[$this->config->text[1]["name"]];
+ $obj['text'] = $this->data[$this->config->text[2]["name"]];
+ for ($i=3; $i<sizeof($this->config->text); $i++){
+ $extra = $this->config->text[$i]["name"];
+ $obj[$extra]=$this->data[$extra];
+ }
+
+ if ($this->userdata !== false)
+ foreach ($this->userdata as $key => $value)
+ $obj[$key]=$value;
+
+ return $obj;
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/SchedulerDataItem.php b/codebase/Dhtmlx/Connector/Data/SchedulerDataItem.php
new file mode 100644
index 0000000..97d9293
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/SchedulerDataItem.php
@@ -0,0 +1,26 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+/*! DataItem class for Scheduler component
+**/
+class SchedulerDataItem extends DataItem {
+ /*! return self as XML string
+ */
+ function to_xml(){
+ if ($this->skip) return "";
+
+ $str="<event id='".$this->get_id()."' >";
+ $str.="<start_date><![CDATA[".$this->data[$this->config->text[0]["name"]]."]]></start_date>";
+ $str.="<end_date><![CDATA[".$this->data[$this->config->text[1]["name"]]."]]></end_date>";
+ $str.="<text><![CDATA[".$this->data[$this->config->text[2]["name"]]."]]></text>";
+ for ($i=3; $i<sizeof($this->config->text); $i++){
+ $extra = $this->config->text[$i]["name"];
+ $str.="<".$extra."><![CDATA[".$this->data[$extra]."]]></".$extra.">";
+ }
+ if ($this->userdata !== false)
+ foreach ($this->userdata as $key => $value)
+ $str.="<".$key."><![CDATA[".$value."]]></".$key.">";
+
+ return $str."</event>";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/TreeDataItem.php b/codebase/Dhtmlx/Connector/Data/TreeDataItem.php
index 3a7c840..bb710aa 100644
--- a/codebase/Dhtmlx/Connector/Data/TreeDataItem.php
+++ b/codebase/Dhtmlx/Connector/Data/TreeDataItem.php
@@ -1,9 +1,7 @@
<?php
-
namespace Dhtmlx\Connector\Data;
-class TreeDataItem extends DataItem
-{
+class TreeDataItem extends DataItem {
private $im0;//!< image of closed folder
private $im1;//!< image of opened folder
private $im2;//!< image of leaf item
diff --git a/codebase/Dhtmlx/Connector/Data/TreeGridDataItem.php b/codebase/Dhtmlx/Connector/Data/TreeGridDataItem.php
new file mode 100644
index 0000000..65a2617
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Data/TreeGridDataItem.php
@@ -0,0 +1,47 @@
+<?php
+namespace Dhtmlx\Connector\Data;
+
+/*! DataItem class for TreeGrid component
+**/
+class TreeGridDataItem extends GridDataItem {
+ private $kids=-1;//!< checked state
+
+ function __construct($data,$config,$index){
+ parent::__construct($data,$config,$index);
+ $this->im0=false;
+ }
+ /*! return id of parent record
+
+ @return
+ id of parent record
+ */
+ function get_parent_id(){
+ return $this->data[$this->config->relation_id["name"]];
+ }
+ /*! assign image to treegrid's item
+ longer description
+ @param img
+ relative path to the image
+ */
+ function set_image($img){
+ $this->set_cell_attribute($this->config->text[0]["name"],"image",$img);
+ }
+
+ /*! return count of child items
+ -1 if there is no info about childs
+ @return
+ count of child items
+ */
+ function has_kids(){
+ return $this->kids;
+ }
+ /*! sets count of child items
+ @param value
+ count of child items
+ */
+ function set_kids($value){
+ $this->kids=$value;
+ if ($value)
+ $this->set_row_attribute("xmlkids",$value);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataConnector.php b/codebase/Dhtmlx/Connector/DataConnector.php
index 2b51c24..9e49645 100644
--- a/codebase/Dhtmlx/Connector/DataConnector.php
+++ b/codebase/Dhtmlx/Connector/DataConnector.php
@@ -3,7 +3,7 @@ namespace Dhtmlx\Connector;
/*! Connector class for DataView
**/
-class DataConnector extends Connector{
+class DataConnector extends Connector {
/*! constructor
diff --git a/codebase/Dhtmlx/Connector/Data/CommonDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/CommonDataProcessor.php
index bb64252..fa16f73 100644
--- a/codebase/Dhtmlx/Connector/Data/CommonDataProcessor.php
+++ b/codebase/Dhtmlx/Connector/DataProcessor/CommonDataProcessor.php
@@ -1,10 +1,9 @@
<?php
-namespace Dhtmlx\Connector\Data;
-
+namespace Dhtmlx\Connector\DataProcessor;
use Dhtmlx\Connector\XSSFilter\ConnectorSecurity;
use Dhtmlx\Connector\Tools\LogMaster;
-class CommonDataProcessor extends DataProcessor{
+class CommonDataProcessor extends DataProcessor {
protected function get_post_values($ids){
if (isset($_GET['action'])){
$data = array();
diff --git a/codebase/Dhtmlx/Connector/Data/DataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/DataProcessor.php
index fa283d4..5da7bef 100644
--- a/codebase/Dhtmlx/Connector/Data/DataProcessor.php
+++ b/codebase/Dhtmlx/Connector/DataProcessor/DataProcessor.php
@@ -1,12 +1,14 @@
<?php
-/*! Base DataProcessor handling
-**/
-namespace Dhtmlx\Connector\Data;
+namespace Dhtmlx\Connector\DataProcessor;
use Dhtmlx\Connector\Tools\LogMaster;
use Dhtmlx\Connector\XSSFilter\ConnectorSecurity;
-use Dhtmlx\Connector\DataStorage\DataConfig;
+use Dhtmlx\Connector\Data\DataConfig;
+use Dhtmlx\Connector\Data\DataAction;
+use \Exception;
-class DataProcessor{
+/*! Base DataProcessor handling
+**/
+class DataProcessor {
protected $connector;//!< Connector instance
protected $config;//!< DataConfig instance
protected $request;//!< DataRequestConfig instance
@@ -61,13 +63,13 @@ class DataProcessor{
}
protected function get_ids(){
if (!isset($_POST["ids"]))
- throw new \Exception("Incorrect incoming data, ID of incoming records not recognized");
+ throw new Exception("Incorrect incoming data, ID of incoming records not recognized");
return explode(",",$_POST["ids"]);
}
protected function get_operation($rid){
if (!isset($_POST[$rid."_".DataProcessor::$action_param]))
- throw new \Exception("Status of record [{$rid}] not found in incoming request");
+ throw new Exception("Status of record [{$rid}] not found in incoming request");
return $_POST[$rid."_".DataProcessor::$action_param];
}
/*! process incoming request ( save|update|delete )
@@ -96,7 +98,7 @@ class DataProcessor{
$this->inner_process($action);
}
- } catch(\Exception $e){
+ } catch(Exception $e){
LogMaster::log($e);
$failed=true;
}
@@ -175,7 +177,7 @@ class DataProcessor{
$check = $this->connector->event->trigger("afterProcessing",$action);
}
- } catch (\Exception $e){
+ } catch (Exception $e){
LogMaster::log($e);
$action->set_status("error");
if ($action)
@@ -224,7 +226,7 @@ class DataProcessor{
$method=array($this->connector->sql,$mode);
if (!is_callable($method))
- throw new \Exception("Unknown dataprocessing action: ".$mode);
+ throw new Exception("Unknown dataprocessing action: ".$mode);
call_user_func($method,$action,$this->request);
}
}
diff --git a/codebase/Dhtmlx/Connector/DataProcessor/GanttDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/GanttDataProcessor.php
new file mode 100644
index 0000000..81d0169
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataProcessor/GanttDataProcessor.php
@@ -0,0 +1,23 @@
+<?php
+namespace Dhtmlx\Connector\DataProcessor;
+
+/*! DataProcessor class for Gantt component
+**/
+class GanttDataProcessor extends DataProcessor {
+
+ function name_data($data){
+ if ($data=="start_date")
+ return $this->config->text[0]["name"];
+ if ($data=="id")
+ return $this->config->id["name"];
+ if ($data=="duration" && $this->config->text[1]["name"] == "duration")
+ return $this->config->text[1]["name"];
+ if ($data=="end_date" && $this->config->text[1]["name"] == "end_date")
+ return $this->config->text[1]["name"];
+ if ($data=="text")
+ return $this->config->text[2]["name"];
+
+ return $data;
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/GridDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/GridDataProcessor.php
index 57126c8..e1c5ed6 100644
--- a/codebase/Dhtmlx/Connector/Data/GridDataProcessor.php
+++ b/codebase/Dhtmlx/Connector/DataProcessor/GridDataProcessor.php
@@ -1,9 +1,9 @@
<?php
-namespace Dhtmlx\Connector\Data;
+namespace Dhtmlx\Connector\DataProcessor;
/*! DataProcessor class for Grid component
**/
-class GridDataProcessor extends DataProcessor{
+class GridDataProcessor extends DataProcessor {
/*! convert incoming data name to valid db name
converts c0..cN to valid field names
diff --git a/codebase/Dhtmlx/Connector/DataProcessor/KeyGridDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/KeyGridDataProcessor.php
new file mode 100644
index 0000000..939041e
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataProcessor/KeyGridDataProcessor.php
@@ -0,0 +1,21 @@
+<?php
+namespace Dhtmlx\Connector\DataProcessor;
+
+class KeyGridDataProcessor extends DataProcessor {
+
+ /*! convert incoming data name to valid db name
+ converts c0..cN to valid field names
+ @param data
+ data name from incoming request
+ @return
+ related db_name
+ */
+ function name_data($data){
+ if ($data == "gr_id") return "__dummy__id__"; //ignore ID
+ $parts=explode("c",$data);
+ if ($parts[0]=="" && intval($parts[1])==$parts[1])
+ return $this->config->text[intval($parts[1])]["name"];
+ return $data;
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataProcessor/SchedulerDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/SchedulerDataProcessor.php
new file mode 100644
index 0000000..69a8345
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataProcessor/SchedulerDataProcessor.php
@@ -0,0 +1,21 @@
+<?php
+namespace Dhtmlx\Connector\DataProcessor;
+
+/*! DataProcessor class for Scheduler component
+**/
+class SchedulerDataProcessor extends DataProcessor {
+
+ function name_data($data){
+ if ($data=="start_date")
+ return $this->config->text[0]["db_name"];
+ if ($data=="id")
+ return $this->config->id["db_name"];
+ if ($data=="end_date")
+ return $this->config->text[1]["db_name"];
+ if ($data=="text")
+ return $this->config->text[2]["db_name"];
+
+ return $data;
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Data/TreeDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/TreeDataProcessor.php
index 47d5a8b..eb608d5 100644
--- a/codebase/Dhtmlx/Connector/Data/TreeDataProcessor.php
+++ b/codebase/Dhtmlx/Connector/DataProcessor/TreeDataProcessor.php
@@ -1,7 +1,7 @@
<?php
-namespace Dhtmlx\Connector\Data;
+namespace Dhtmlx\Connector\DataProcessor;
-class TreeDataProcessor extends DataProcessor{
+class TreeDataProcessor extends DataProcessor {
function __construct($connector,$config,$request){
parent::__construct($connector,$config,$request);
diff --git a/codebase/Dhtmlx/Connector/DataProcessor/TreeGridDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/TreeGridDataProcessor.php
new file mode 100644
index 0000000..acb35fa
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataProcessor/TreeGridDataProcessor.php
@@ -0,0 +1,26 @@
+<?php
+namespace Dhtmlx\Connector\DataProcessor;
+
+/*! DataProcessor class for Grid component
+**/
+class TreeGridDataProcessor extends GridDataProcessor {
+
+ function __construct($connector,$config,$request){
+ parent::__construct($connector,$config,$request);
+ $request->set_relation(false);
+ }
+
+ /*! convert incoming data name to valid db name
+ converts c0..cN to valid field names
+ @param data
+ data name from incoming request
+ @return
+ related db_name
+ */
+ function name_data($data){
+
+ if ($data=="gr_pid")
+ return $this->config->relation_id["name"];
+ else return parent::name_data($data);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataProcessor/TreeGridMultitableDataProcessor.php b/codebase/Dhtmlx/Connector/DataProcessor/TreeGridMultitableDataProcessor.php
new file mode 100644
index 0000000..5b2b23f
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataProcessor/TreeGridMultitableDataProcessor.php
@@ -0,0 +1,20 @@
+<?php
+namespace Dhtmlx\Connector\DataProcessor;
+
+class TreeGridMultitableDataProcessor extends DataProcessor {
+
+ function name_data($data){
+ if ($data=="gr_pid")
+ return $this->config->relation_id["name"];
+ if ($data=="gr_id")
+ return $this->config->id["name"];
+ preg_match('/^c([%\d]+)$/', $data, $data_num);
+ if (!isset($data_num[1])) return $data;
+ $data_num = $data_num[1];
+ if (isset($this->config->data[$data_num]["db_name"])) {
+ return $this->config->data[$data_num]["db_name"];
+ }
+ return $data;
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/AdoDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/AdoDBDataWrapper.php
new file mode 100644
index 0000000..b1e1e3b
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/AdoDBDataWrapper.php
@@ -0,0 +1,69 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
+
+/*! Implementation of DataWrapper for ADO
+**/
+class AdoDBDataWrapper extends DBDataWrapper {
+ protected $last_result;
+ public function query($sql){
+ LogMaster::log($sql);
+ if (is_array($sql)) {
+ $res = $this->connection->SelectLimit($sql['sql'], $sql['numrows'], $sql['offset']);
+ } else {
+ $res = $this->connection->Execute($sql);
+ }
+
+ if ($res===false) throw new Exception("ADODB operation failed\n".$this->connection->ErrorMsg());
+ $this->last_result = $res;
+ return $res;
+ }
+
+ public function get_next($res){
+ if (!$res)
+ $res = $this->last_result;
+
+ if ($res->EOF)
+ return false;
+
+ $row = $res->GetRowAssoc(false);
+ $res->MoveNext();
+ return $row;
+ }
+
+ public function get_new_id(){
+ return $this->connection->Insert_ID();
+ }
+
+ public function escape($data){
+ return $this->connection->addq($data);
+ }
+
+ /*! escape field name to prevent sql reserved words conflict
+ @param data
+ unescaped data
+ @return
+ escaped data
+ */
+ public function escape_name($data){
+ if ((strpos($data,"`")!==false || is_int($data)) || (strpos($data,".")!==false))
+ return $data;
+ return '`'.$data.'`';
+ }
+
+
+ protected function select_query($select,$from,$where,$sort,$start,$count){
+ if (!$from)
+ return $select;
+
+ $sql="SELECT ".$select." FROM ".$from;
+ if ($where) $sql.=" WHERE ".$where;
+ if ($sort) $sql.=" ORDER BY ".$sort;
+
+ if ($start || $count) {
+ $sql=array("sql"=>$sql,'numrows'=>$count, 'offset'=>$start);
+ }
+ return $sql;
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/ArrayDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/ArrayDBDataWrapper.php
index e5bbae9..b72aec6 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/ArrayDBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/ArrayDBDataWrapper.php
@@ -1,9 +1,8 @@
<?php
-
namespace Dhtmlx\Connector\DataStorage;
+use \Exception;
-class ArrayDBDataWrapper extends DBDataWrapper
-{
+class ArrayDBDataWrapper extends DBDataWrapper {
public function get_next($res)
{
if ($res->index < sizeof($res->data))
diff --git a/codebase/Dhtmlx/Connector/DataStorage/ArrayQueryWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/ArrayQueryWrapper.php
index 5fa079a..f2ba5b5 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/ArrayQueryWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/ArrayQueryWrapper.php
@@ -1,7 +1,7 @@
<?php
namespace Dhtmlx\Connector\DataStorage;
-class ArrayQueryWrapper{
+class ArrayQueryWrapper {
public function __construct($data){
$this->data = $data;
$this->index = 0;
diff --git a/codebase/Dhtmlx/Connector/DataStorage/DBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/DBDataWrapper.php
index bc93fee..6975c5f 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/DBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/DBDataWrapper.php
@@ -1,15 +1,10 @@
<?php
-/**
- * Created by PhpStorm.
- * User: user
- * Date: 26.3.15
- * Time: 15.50
- */
-
namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\Data\DataRequestConfig;
+use Dhtmlx\Connector\Event\SortInterface;
+use \Exception;
-abstract class DBDataWrapper extends DataWrapper
-{
+abstract class DBDataWrapper extends DataWrapper {
private $transaction = false; //!< type of transaction
private $sequence = false;//!< sequence name
private $sqls = array();//!< predefined sql actions
diff --git a/codebase/Dhtmlx/Connector/DataStorage/DataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/DataWrapper.php
index e6b706f..304d0a2 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/DataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/DataWrapper.php
@@ -1,10 +1,11 @@
<?php
-
namespace Dhtmlx\Connector\DataStorage;
+use \Exception;
+
/*! Base abstraction class, used for data operations
Class abstract access to data, it is a base class to all DB wrappers
**/
-abstract class DataWrapper{
+abstract class DataWrapper {
protected $connection;
protected $config;//!< DataConfig instance
/*! constructor
diff --git a/codebase/Dhtmlx/Connector/DataStorage/ExcelDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/ExcelDBDataWrapper.php
new file mode 100644
index 0000000..2626cfd
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/ExcelDBDataWrapper.php
@@ -0,0 +1,105 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\DataStorage\ResultHandler\ExcelResultHandler;
+
+/*! Implementation of DataWrapper for Excel
+**/
+class ExcelDBDataWrapper extends DBDataWrapper {
+ public $emptyLimit = 10;
+ public function excel_data($points){
+ $path = $this->connection;
+ $excel = PHPExcel_IOFactory::createReaderForFile($path);
+ $excel = $excel->load($path);
+ $result = array();
+ $excelWS = $excel->getActiveSheet();
+
+ for ($i=0; $i < sizeof($points); $i++) {
+ $c = array();
+ preg_match("/^([a-zA-Z]+)(\d+)/", $points[$i], $c);
+ if (count($c) > 0) {
+ $col = PHPExcel_Cell::columnIndexFromString($c[1]) - 1;
+ $cell = $excelWS->getCellByColumnAndRow($col, (int)$c[2]);
+ $result[] = $cell->getValue();
+ }
+ }
+
+ return $result;
+ }
+ public function select($source) {
+ $path = $this->connection;
+ $excel = PHPExcel_IOFactory::createReaderForFile($path);
+ $excel->setReadDataOnly(false);
+ $excel = $excel->load($path);
+ $excRes = new ExcelResultHandler();
+ $excelWS = $excel->getActiveSheet();
+ $addFields = true;
+
+ $coords = array();
+ if ($source->get_source() == '*') {
+ $coords['start_row'] = 0;
+ $coords['end_row'] = false;
+ } else {
+ $c = array();
+ preg_match("/^([a-zA-Z]+)(\d+)/", $source->get_source(), $c);
+ if (count($c) > 0) {
+ $coords['start_row'] = (int) $c[2];
+ } else {
+ $coords['start_row'] = 0;
+ }
+ $c = array();
+ preg_match("/:(.+)(\d+)$/U", $source->get_source(), $c);
+ if (count($c) > 0) {
+ $coords['end_row'] = (int) $c[2];
+ } else {
+ $coords['end_row'] = false;
+ }
+ }
+
+ $i = $coords['start_row'];
+ $end = 0;
+ while ((($coords['end_row'] == false)&&($end < $this->emptyLimit))||(($coords['end_row'] !== false)&&($i < $coords['end_row']))) {
+ $r = Array();
+ $emptyNum = 0;
+ for ($j = 0; $j < count($this->config->text); $j++) {
+ $col = PHPExcel_Cell::columnIndexFromString($this->config->text[$j]['name']) - 1;
+ $cell = $excelWS->getCellByColumnAndRow($col, $i);
+ if (PHPExcel_Shared_Date::isDateTime($cell)) {
+ $r[PHPExcel_Cell::stringFromColumnIndex($col)] = PHPExcel_Shared_Date::ExcelToPHP($cell->getValue());
+ } else if ($cell->getDataType() == 'f') {
+ $r[PHPExcel_Cell::stringFromColumnIndex($col)] = $cell->getCalculatedValue();
+ } else {
+ $r[PHPExcel_Cell::stringFromColumnIndex($col)] = $cell->getValue();
+ }
+ if ($r[PHPExcel_Cell::stringFromColumnIndex($col)] == '') {
+ $emptyNum++;
+ }
+ }
+ if ($emptyNum < count($this->config->text)) {
+ $r['id'] = $i;
+ $excRes->addRecord($r);
+ $end = 0;
+ } else {
+ if (DHX_IGNORE_EMPTY_ROWS == false) {
+ $r['id'] = $i;
+ $excRes->addRecord($r);
+ }
+ $end++;
+ }
+ $i++;
+ }
+ return $excRes;
+ }
+
+ public function query($sql) {
+ }
+
+ public function get_new_id() {
+ }
+
+ public function escape($data) {
+ }
+
+ public function get_next($res) {
+ return $res->next();
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/FileSystemDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/FileSystemDBDataWrapper.php
new file mode 100644
index 0000000..b513556
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/FileSystemDBDataWrapper.php
@@ -0,0 +1,140 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\DataStorage\TypeHandler\FileSystemTypeHandler;
+use Dhtmlx\Connector\DataStorage\ResultHandler\FileSystemResultHandler;
+use Dhtmlx\Connector\Tools\LogMaster;
+
+/*! Most execution time is a standart functions for workin with FileSystem: is_dir(), dir(), readdir(), stat()
+**/
+class FileSystemDBDataWrapper extends DBDataWrapper {
+
+ // returns list of files and directories
+ public function select($source) {
+ $relation = $this->getFileName($source->get_relation());
+ // for tree checks relation id and forms absolute path
+ if ($relation == '0') {
+ $relation = '';
+ } else {
+ $path = $source->get_source();
+ }
+ $path = $source->get_source();
+ $path = $this->getFileName($path);
+ $path = realpath($path);
+ if ($path == false) {
+ return new FileSystemResultHandler();
+ }
+
+ if (strpos(realpath($path.'/'.$relation), $path) !== 0) {
+ return new FileSystemResultHandler();
+ }
+ // gets files and directories list
+ $res = $this->getFilesList($path, $relation);
+ // sorts list
+ $res = $res->sort($source->get_sort_by(), $this->config->data);
+ return $res;
+ }
+
+ // gets files and directory list
+ private function getFilesList($path, $relation) {
+ $typeHandlerObj = FileSystemTypeHandler::getInstance();
+ LogMaster::log("Query filesystem: ".$path);
+ $dir = opendir($path.'/'.$relation);
+ $result = new FileSystemResultHandler();
+ // forms fields list
+ for ($i = 0; $i < count($this->config->data); $i++) {
+ $fields[] = $this->config->data[$i]['db_name'];
+ }
+ // for every file and directory of folder
+ while ($file = readdir($dir)) {
+ // . and .. should not be in output list
+ if (($file == '.')||($file == '..')) {
+ continue;
+ }
+ $newFile = array();
+ // parse file name as Array('name', 'ext', 'is_dir')
+ $fileNameExt = $this->parseFileName($path.'/'.$relation, $file);
+ // checks if file should be in output array
+ if (!$typeHandlerObj->checkFile($file, $fileNameExt)) {
+ continue;
+ }
+ // takes file stat if it's need
+ if ((in_array('size', $fields))||(in_array('date', $fields))) {
+ $fileInfo = stat($path.'/'.$file);
+ }
+
+ // for every field forms list of fields
+ for ($i = 0; $i < count($fields); $i++) {
+ $field = $fields[$i];
+ switch ($field) {
+ case 'filename':
+ $newFile['filename'] = $file;
+ break;
+ case 'full_filename':
+ $newFile['full_filename'] = $path."/".$file;
+ break;
+ case 'size':
+ $newFile['size'] = $fileInfo['size'];
+ break;
+ case 'extention':
+ $newFile['extention'] = $fileNameExt['ext'];
+ break;
+ case 'name':
+ $newFile['name'] = $fileNameExt['name'];
+ break;
+ case 'date':
+ $newFile['date'] = date("Y-m-d H:i:s", $fileInfo['ctime']);
+ break;
+ }
+ $newFile['relation_id'] = $relation.'/'.$file;
+ $newFile['safe_name'] = $this->setFileName($relation.'/'.$file);
+ $newFile['is_folder'] = $fileNameExt['is_dir'];
+ }
+ // add file in output list
+ $result->addFile($newFile);
+ }
+ return $result;
+ }
+
+ // replaces '.' and '_' in id
+ private function setFileName($filename) {
+ $filename = str_replace(".", "{-dot-}", $filename);
+ $filename = str_replace("_", "{-nizh-}", $filename);
+ return $filename;
+ }
+
+ // replaces '{-dot-}' and '{-nizh-}' in id
+ private function getFileName($filename) {
+ $filename = str_replace("{-dot-}", ".", $filename);
+ $filename = str_replace("{-nizh-}", "_", $filename);
+ return $filename;
+ }
+
+ // parses file name and checks if is directory
+ private function parseFileName($path, $file) {
+ $result = Array();
+ if (is_dir($path.'/'.$file)) {
+ $result['name'] = $file;
+ $result['ext'] = 'dir';
+ $result['is_dir'] = 1;
+ } else {
+ $pos = strrpos($file, '.');
+ $result['name'] = substr($file, 0, $pos);
+ $result['ext'] = substr($file, $pos + 1);
+ $result['is_dir'] = 0;
+ }
+ return $result;
+ }
+
+ public function query($sql) {
+ }
+
+ public function get_new_id() {
+ }
+
+ public function escape($data) {
+ }
+
+ public function get_next($res) {
+ return $res->next();
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/MsSQLDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/MsSQLDBDataWrapper.php
index 048af60..aabf0f7 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/MsSQLDBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/MsSQLDBDataWrapper.php
@@ -1,11 +1,8 @@
<?php
-
namespace Dhtmlx\Connector\DataStorage;
-
use Dhtmlx\Connector\Tools\LogMaster;
-class MsSQLDBDataWrapper extends DBDataWrapper
-{
+class MsSQLDBDataWrapper extends DBDataWrapper {
private $last_id = ""; //!< ID of previously inserted record
private $insert_operation = false; //!< flag of insert operation
private $start_from = false; //!< index of start position
diff --git a/codebase/Dhtmlx/Connector/DataStorage/MySQLDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/MySQLDBDataWrapper.php
index db68cbc..a23c34e 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/MySQLDBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/MySQLDBDataWrapper.php
@@ -1,10 +1,11 @@
<?php
namespace Dhtmlx\Connector\DataStorage;
-
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
/*! Implementation of DataWrapper for MySQL
**/
-class MySQLDBDataWrapper extends DBDataWrapper{
+class MySQLDBDataWrapper extends DBDataWrapper {
protected $last_result;
public function query($sql){
LogMaster::log($sql);
diff --git a/codebase/Dhtmlx/Connector/DataStorage/OracleDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/OracleDBDataWrapper.php
new file mode 100644
index 0000000..b7505ab
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/OracleDBDataWrapper.php
@@ -0,0 +1,86 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
+
+/*! Implementation of DataWrapper for MySQL
+**/
+class OracleDBDataWrapper extends DBDataWrapper {
+ private $last_id=""; //id of previously inserted record
+ private $insert_operation=false; //flag of insert operation
+
+ public function query($sql){
+ LogMaster::log($sql);
+ $stm = oci_parse($this->connection,$sql);
+ if ($stm===false) throw new Exception("Oracle - sql parsing failed\n".oci_error($this->connection));
+
+ $out = array(0=>null);
+ if($this->insert_operation){
+ oci_bind_by_name($stm,":outID",$out[0],999);
+ $this->insert_operation=false;
+ }
+
+
+ $mode = ($this->is_record_transaction() || $this->is_global_transaction())?OCI_DEFAULT:OCI_COMMIT_ON_SUCCESS;
+ $res = @oci_execute($stm,$mode);
+ if ($res===false) throw new Exception(oci_error($this->connection));
+
+ $this->last_id=$out[0];
+
+ return $stm;
+ }
+
+ public function get_next($res){
+ $data = oci_fetch_assoc($res);
+ if ($data){
+ foreach ($data as $k => $v)
+ $data[strtolower($k)] = $v;
+ }
+ return $data;
+ }
+
+ public function get_new_id(){
+ /*
+ Oracle doesn't support identity or auto-increment fields
+ Insert SQL returns new ID value, which stored in last_id field
+ */
+ return $this->last_id;
+ }
+
+ protected function insert_query($data,$request){
+ $sql = parent::insert_query($data,$request);
+ $this->insert_operation=true;
+ return $sql." returning ".$this->config->id["db_name"]." into :outID";
+ }
+
+ protected function select_query($select,$from,$where,$sort,$start,$count){
+ if (!$from)
+ return $select;
+
+ $sql="SELECT ".$select." FROM ".$from;
+ if ($where) $sql.=" WHERE ".$where;
+ if ($sort) $sql.=" ORDER BY ".$sort;
+ if ($start || $count)
+ $sql="SELECT * FROM ( select /*+ FIRST_ROWS(".$count.")*/dhx_table.*, ROWNUM rnum FROM (".$sql.") dhx_table where ROWNUM <= ".($count+$start)." ) where rnum >".$start;
+ return $sql;
+ }
+
+ public function escape($data){
+ /*
+ as far as I can see the only way to escape data is by using oci_bind_by_name
+ while it is neat solution in common case, it conflicts with existing SQL building logic
+ fallback to simple escaping
+ */
+ return str_replace("'","''",$data);
+ }
+
+ public function begin_transaction(){
+ //auto-start of transaction
+ }
+ public function commit_transaction(){
+ oci_commit($this->connection);
+ }
+ public function rollback_transaction(){
+ oci_rollback($this->connection);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php
index dce146b..8eebe0c 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php
@@ -1,12 +1,14 @@
<?php
-
namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\DataStorage\ResultHandler\PDOResultHandler;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
/*! Implementation of DataWrapper for PDO
if you plan to use it for Oracle - use Oracle connection type instead
**/
-class PDODBDataWrapper extends DBDataWrapper{
+class PDODBDataWrapper extends DBDataWrapper {
private $last_result;//!< store result or last operation
public function query($sql){
@@ -18,7 +20,7 @@ class PDODBDataWrapper extends DBDataWrapper{
throw new Exception("PDO - sql execution failed\n".$message[2]);
}
- return new PDOResultSet($res);
+ return new PDOResultHandler($res);
}
protected function select_query($select,$from,$where,$sort,$start,$count){
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PHPCI2DBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PHPCI2DBDataWrapper.php
index 8819ab5..cd3c13b 100755
--- a/codebase/Dhtmlx/Connector/DataStorage/PHPCI2DBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/PHPCI2DBDataWrapper.php
@@ -2,6 +2,7 @@
namespace Dhtmlx\Connector\DataStorage;
use Dhtmlx\Connector\Connector;
use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
class PHPCI2DBDataWrapper extends DBDataWrapper {
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PHPCIDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PHPCIDBDataWrapper.php
index 3173557..c89786b 100755
--- a/codebase/Dhtmlx/Connector/DataStorage/PHPCIDBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/PHPCIDBDataWrapper.php
@@ -2,6 +2,7 @@
namespace Dhtmlx\Connector\DataStorage;
use Dhtmlx\Connector\Connector;
use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
class PHPCIDBDataWrapper extends DBDataWrapper {
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PHPCakeDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PHPCakeDBDataWrapper.php
index 8297c7f..6c368e3 100755
--- a/codebase/Dhtmlx/Connector/DataStorage/PHPCakeDBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/PHPCakeDBDataWrapper.php
@@ -1,6 +1,7 @@
<?php
namespace Dhtmlx\Connector\DataStorage;
use Cake\ORM\TableRegistry;
+use \Exception;
class PHPCakeDBDataWrapper extends ArrayDBDataWrapper {
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PHPYii1DBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PHPYii1DBDataWrapper.php
index d585ac2..d22afa5 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/PHPYii1DBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/PHPYii1DBDataWrapper.php
@@ -1,5 +1,6 @@
<?php
namespace Dhtmlx\Connector\DataStorage;
+use \Exception;
class PHPYii1DBDataWrapper extends ArrayDBDataWrapper {
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PHPYiiDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PHPYiiDBDataWrapper.php
index 6a02d11..f76ce0f 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/PHPYiiDBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/PHPYiiDBDataWrapper.php
@@ -1,5 +1,6 @@
<?php
namespace Dhtmlx\Connector\DataStorage;
+use \Exception;
class PHPYiiDBDataWrapper extends ArrayDBDataWrapper {
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PostgreDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PostgreDBDataWrapper.php
index ef5b92d..c3ed69d 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/PostgreDBDataWrapper.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/PostgreDBDataWrapper.php
@@ -1,10 +1,9 @@
<?php
-
namespace Dhtmlx\Connector\DataStorage;
-
use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
-class PostgreDBDataWrapper extends DBDataWrapper{
+class PostgreDBDataWrapper extends DBDataWrapper {
public function query($sql){
LogMaster::log($sql);
diff --git a/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/ExcelResultHandler.php b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/ExcelResultHandler.php
new file mode 100644
index 0000000..d8b51fc
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/ExcelResultHandler.php
@@ -0,0 +1,75 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage\ResultHandler;
+
+class ExcelResultHandler {
+ private $rows;
+ private $currentRecord = 0;
+
+ // add record to output list
+ public function addRecord($file) {
+ $this->rows[] = $file;
+ }
+
+
+ // return next record
+ public function next() {
+ if ($this->currentRecord < count($this->rows)) {
+ $row = $this->rows[$this->currentRecord];
+ $this->currentRecord++;
+ return $row;
+ } else {
+ return false;
+ }
+ }
+
+
+ // sorts records under $sort array
+ public function sort($sort, $data) {
+ if (count($this->files) == 0) {
+ return $this;
+ }
+ // defines fields list if it's need
+ for ($i = 0; $i < count($sort); $i++) {
+ $fieldname = $sort[$i]['name'];
+ if (!isset($this->files[0][$fieldname])) {
+ if (isset($data[$fieldname])) {
+ $fieldname = $data[$fieldname]['db_name'];
+ $sort[$i]['name'] = $fieldname;
+ } else {
+ $fieldname = false;
+ }
+ }
+ }
+
+ // for every sorting field will sort
+ for ($i = 0; $i < count($sort); $i++) {
+ // if field, setted in sort parameter doesn't exist, continue
+ if ($sort[$i]['name'] == false) {
+ continue;
+ }
+ // sorting by current field
+ $flag = true;
+ while ($flag == true) {
+ $flag = false;
+ // checks if previous sorting fields are equal
+ for ($j = 0; $j < count($this->files) - 1; $j++) {
+ $equal = true;
+ for ($k = 0; $k < $i; $k++) {
+ if ($this->files[$j][$sort[$k]['name']] != $this->files[$j + 1][$sort[$k]['name']]) {
+ $equal = false;
+ }
+ }
+ // compares two records in list under current sorting field and sorting direction
+ if (((($this->files[$j][$sort[$i]['name']] > $this->files[$j + 1][$sort[$i]['name']])&&($sort[$i]['direction'] == 'ASC'))||(($this->files[$j][$sort[$i]['name']] < $this->files[$j + 1][$sort[$i]['name']])&&($sort[$i]['direction'] == 'DESC')))&&($equal == true)) {
+ $c = $this->files[$j];
+ $this->files[$j] = $this->files[$j+1];
+ $this->files[$j+1] = $c;
+ $flag = true;
+ }
+ }
+ }
+ }
+ return $this;
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/FileSystemResultHandler.php b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/FileSystemResultHandler.php
new file mode 100644
index 0000000..f71f421
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/FileSystemResultHandler.php
@@ -0,0 +1,76 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage\ResultHandler;
+
+class FileSystemResultHandler {
+ private $files;
+ private $currentRecord = 0;
+
+
+ // add record to output list
+ public function addFile($file) {
+ $this->files[] = $file;
+ }
+
+
+ // return next record
+ public function next() {
+ if ($this->currentRecord < count($this->files)) {
+ $file = $this->files[$this->currentRecord];
+ $this->currentRecord++;
+ return $file;
+ } else {
+ return false;
+ }
+ }
+
+
+ // sorts records under $sort array
+ public function sort($sort, $data) {
+ if (count($this->files) == 0) {
+ return $this;
+ }
+ // defines fields list if it's need
+ for ($i = 0; $i < count($sort); $i++) {
+ $fieldname = $sort[$i]['name'];
+ if (!isset($this->files[0][$fieldname])) {
+ if (isset($data[$fieldname])) {
+ $fieldname = $data[$fieldname]['db_name'];
+ $sort[$i]['name'] = $fieldname;
+ } else {
+ $fieldname = false;
+ }
+ }
+ }
+
+ // for every sorting field will sort
+ for ($i = 0; $i < count($sort); $i++) {
+ // if field, setted in sort parameter doesn't exist, continue
+ if ($sort[$i]['name'] == false) {
+ continue;
+ }
+ // sorting by current field
+ $flag = true;
+ while ($flag == true) {
+ $flag = false;
+ // checks if previous sorting fields are equal
+ for ($j = 0; $j < count($this->files) - 1; $j++) {
+ $equal = true;
+ for ($k = 0; $k < $i; $k++) {
+ if ($this->files[$j][$sort[$k]['name']] != $this->files[$j + 1][$sort[$k]['name']]) {
+ $equal = false;
+ }
+ }
+ // compares two records in list under current sorting field and sorting direction
+ if (((($this->files[$j][$sort[$i]['name']] > $this->files[$j + 1][$sort[$i]['name']])&&($sort[$i]['direction'] == 'ASC'))||(($this->files[$j][$sort[$i]['name']] < $this->files[$j + 1][$sort[$i]['name']])&&($sort[$i]['direction'] == 'DESC')))&&($equal == true)) {
+ $c = $this->files[$j];
+ $this->files[$j] = $this->files[$j+1];
+ $this->files[$j+1] = $c;
+ $flag = true;
+ }
+ }
+ }
+ }
+ return $this;
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/PDOResultSet.php b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/PDOResultHandler.php
index 1221d05..d2b13ec 100644
--- a/codebase/Dhtmlx/Connector/DataStorage/PDOResultSet.php
+++ b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/PDOResultHandler.php
@@ -1,8 +1,7 @@
<?php
+namespace Dhtmlx\Connector\DataStorage\ResultHandler;
-namespace Dhtmlx\Connector\DataStorage;
-
-class PDOResultSet{
+class PDOResultHandler {
private $res;
public function __construct($res){
$this->res = $res;
diff --git a/codebase/Dhtmlx/Connector/DataStorage/SQLSrvDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/SQLSrvDBDataWrapper.php
new file mode 100644
index 0000000..a6d13a2
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/SQLSrvDBDataWrapper.php
@@ -0,0 +1,95 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
+
+/*! SQLSrv implementation of DataWrapper
+**/
+class SQLSrvDBDataWrapper extends DBDataWrapper {
+ private $last_id=""; //!< ID of previously inserted record
+ private $insert_operation=false; //!< flag of insert operation
+ private $start_from=false; //!< index of start position
+
+ public function query($sql){
+ LogMaster::log($sql);
+ if ($this->start_from)
+ $res = sqlsrv_query($this->connection,$sql, array(), array("Scrollable" => SQLSRV_CURSOR_STATIC));
+ else
+ $res = sqlsrv_query($this->connection,$sql);
+
+ if ($res === false){
+ $errors = sqlsrv_errors();
+ $message = Array();
+ foreach($errors as $error)
+ $message[]=$error["SQLSTATE"].$error["code"].$error["message"];
+ throw new Exception("SQLSrv operation failed\n".implode("\n\n", $message));
+ }
+
+ if ($this->insert_operation){
+ sqlsrv_next_result($res);
+ $last = sqlsrv_fetch_array($res);
+ $this->last_id = $last["dhx_id"];
+ sqlsrv_free_stmt($res);
+ }
+ if ($this->start_from)
+ $data = sqlsrv_fetch($res, SQLSRV_SCROLL_ABSOLUTE, $this->start_from-1);
+ return $res;
+ }
+
+ public function get_next($res){
+ $data = sqlsrv_fetch_array($res, SQLSRV_FETCH_ASSOC);
+ if ($data)
+ foreach ($data as $key => $value)
+ if (is_a($value, "DateTime"))
+ $data[$key] = $value->format("Y-m-d H:i");
+ return $data;
+ }
+
+ public function get_new_id(){
+ /*
+ MSSQL doesn't support identity or auto-increment fields
+ Insert SQL returns new ID value, which stored in last_id field
+ */
+ return $this->last_id;
+ }
+
+ protected function insert_query($data,$request){
+ $sql = parent::insert_query($data,$request);
+ $this->insert_operation=true;
+ return $sql.";SELECT SCOPE_IDENTITY() as dhx_id";
+ }
+
+ protected function select_query($select,$from,$where,$sort,$start,$count){
+ if (!$from)
+ return $select;
+
+ $sql="SELECT " ;
+ if ($count)
+ $sql.=" TOP ".($count+$start);
+ $sql.=" ".$select." FROM ".$from;
+ if ($where) $sql.=" WHERE ".$where;
+ if ($sort) $sql.=" ORDER BY ".$sort;
+ if ($start && $count)
+ $this->start_from=$start;
+ else
+ $this->start_from=false;
+ return $sql;
+ }
+
+ public function escape($data){
+ /*
+ there is no special escaping method for mssql - use common logic
+ */
+ return str_replace("'","''",$data);
+ }
+
+ public function begin_transaction(){
+ sqlsrv_begin_transaction($this->connection);
+ }
+ public function commit_transaction(){
+ sqlsrv_commit($this->connection);
+ }
+ public function rollback_transaction(){
+ sqlsrv_rollback($this->connection);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/SQLite3DBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/SQLite3DBDataWrapper.php
new file mode 100644
index 0000000..c44f296
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/SQLite3DBDataWrapper.php
@@ -0,0 +1,30 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
+
+/*! SQLite implementation of DataWrapper
+**/
+class SQLite3DBDataWrapper extends DBDataWrapper {
+ public function query($sql){
+ LogMaster::log($sql);
+
+ $res = $this->connection->query($sql);
+ if ($res === false)
+ throw new Exception("SQLLite - sql execution failed\n".$this->connection->lastErrorMsg());
+
+ return $res;
+ }
+
+ public function get_next($res){
+ return $res->fetchArray();
+ }
+
+ public function get_new_id(){
+ return $this->connection->lastInsertRowID();
+ }
+
+ public function escape($data){
+ return $this->connection->escapeString($data);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/SQLiteDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/SQLiteDBDataWrapper.php
new file mode 100644
index 0000000..7bbf763
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/SQLiteDBDataWrapper.php
@@ -0,0 +1,69 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
+
+/*! SQLite implementation of DataWrapper
+**/
+class SQLiteDBDataWrapper extends DBDataWrapper {
+ protected $last_result;
+ public function query($sql){
+ LogMaster::log($sql);
+ if (is_array($sql)) {
+ $res = $this->connection->SelectLimit($sql['sql'], $sql['numrows'], $sql['offset']);
+ } else {
+ $res = $this->connection->Execute($sql);
+ }
+
+ if ($res===false) throw new Exception("ADODB operation failed\n".$this->connection->ErrorMsg());
+ $this->last_result = $res;
+ return $res;
+ }
+
+ public function get_next($res){
+ if (!$res)
+ $res = $this->last_result;
+
+ if ($res->EOF)
+ return false;
+
+ $row = $res->GetRowAssoc(false);
+ $res->MoveNext();
+ return $row;
+ }
+
+ public function get_new_id(){
+ return $this->connection->Insert_ID();
+ }
+
+ public function escape($data){
+ return $this->connection->addq($data);
+ }
+
+ /*! escape field name to prevent sql reserved words conflict
+ @param data
+ unescaped data
+ @return
+ escaped data
+ */
+ public function escape_name($data){
+ if ((strpos($data,"`")!==false || is_int($data)) || (strpos($data,".")!==false))
+ return $data;
+ return '`'.$data.'`';
+ }
+
+
+ protected function select_query($select,$from,$where,$sort,$start,$count){
+ if (!$from)
+ return $select;
+
+ $sql="SELECT ".$select." FROM ".$from;
+ if ($where) $sql.=" WHERE ".$where;
+ if ($sort) $sql.=" ORDER BY ".$sort;
+
+ if ($start || $count) {
+ $sql=array("sql"=>$sql,'numrows'=>$count, 'offset'=>$start);
+ }
+ return $sql;
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/SaSQLDBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/SaSQLDBDataWrapper.php
new file mode 100644
index 0000000..5e6c65a
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/SaSQLDBDataWrapper.php
@@ -0,0 +1,86 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage;
+use Dhtmlx\Connector\Tools\LogMaster;
+use \Exception;
+
+/*! SaSQL implementation of DataWrapper
+**/
+class SaSQLDBDataWrapper extends DBDataWrapper {
+ private $last_id=""; //id of previously inserted record
+ private $insert_operation=false; //flag of insert operation
+
+ public function query($sql){
+ LogMaster::log($sql);
+ $stm = oci_parse($this->connection,$sql);
+ if ($stm===false) throw new Exception("Oracle - sql parsing failed\n".oci_error($this->connection));
+
+ $out = array(0=>null);
+ if($this->insert_operation){
+ oci_bind_by_name($stm,":outID",$out[0],999);
+ $this->insert_operation=false;
+ }
+
+
+ $mode = ($this->is_record_transaction() || $this->is_global_transaction())?OCI_DEFAULT:OCI_COMMIT_ON_SUCCESS;
+ $res = @oci_execute($stm,$mode);
+ if ($res===false) throw new Exception(oci_error($this->connection));
+
+ $this->last_id=$out[0];
+
+ return $stm;
+ }
+
+ public function get_next($res){
+ $data = oci_fetch_assoc($res);
+ if ($data){
+ foreach ($data as $k => $v)
+ $data[strtolower($k)] = $v;
+ }
+ return $data;
+ }
+
+ public function get_new_id(){
+ /*
+ Oracle doesn't support identity or auto-increment fields
+ Insert SQL returns new ID value, which stored in last_id field
+ */
+ return $this->last_id;
+ }
+
+ protected function insert_query($data,$request){
+ $sql = parent::insert_query($data,$request);
+ $this->insert_operation=true;
+ return $sql." returning ".$this->config->id["db_name"]." into :outID";
+ }
+
+ protected function select_query($select,$from,$where,$sort,$start,$count){
+ if (!$from)
+ return $select;
+
+ $sql="SELECT ".$select." FROM ".$from;
+ if ($where) $sql.=" WHERE ".$where;
+ if ($sort) $sql.=" ORDER BY ".$sort;
+ if ($start || $count)
+ $sql="SELECT * FROM ( select /*+ FIRST_ROWS(".$count.")*/dhx_table.*, ROWNUM rnum FROM (".$sql.") dhx_table where ROWNUM <= ".($count+$start)." ) where rnum >".$start;
+ return $sql;
+ }
+
+ public function escape($data){
+ /*
+ as far as I can see the only way to escape data is by using oci_bind_by_name
+ while it is neat solution in common case, it conflicts with existing SQL building logic
+ fallback to simple escaping
+ */
+ return str_replace("'","''",$data);
+ }
+
+ public function begin_transaction(){
+ //auto-start of transaction
+ }
+ public function commit_transaction(){
+ oci_commit($this->connection);
+ }
+ public function rollback_transaction(){
+ oci_rollback($this->connection);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataStorage/TypeHandler/FileSystemTypeHandler.php b/codebase/Dhtmlx/Connector/DataStorage/TypeHandler/FileSystemTypeHandler.php
new file mode 100644
index 0000000..d544f6d
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataStorage/TypeHandler/FileSystemTypeHandler.php
@@ -0,0 +1,119 @@
+<?php
+namespace Dhtmlx\Connector\DataStorage\TypeHandler;
+
+// singleton class for setting file types filter
+class FileSystemTypeHandler {
+
+ static private $instance = NULL;
+ private $extentions = Array();
+ private $extentions_not = Array();
+ private $all = true;
+ private $patterns = Array();
+ // predefined types
+ private $types = Array(
+ 'image' => Array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp', 'psd', 'dir'),
+ 'document' => Array('txt', 'doc', 'docx', 'xls', 'xlsx', 'rtf', 'dir'),
+ 'web' => Array('php', 'html', 'htm', 'js', 'css', 'dir'),
+ 'audio' => Array('mp3', 'wav', 'ogg', 'dir'),
+ 'video' => Array('avi', 'mpg', 'mpeg', 'mp4', 'dir'),
+ 'only_dir' => Array('dir')
+ );
+
+
+ static function getInstance() {
+ if (self::$instance == NULL) {
+ self::$instance = new FileSystemTypeHandler();
+ }
+ return self::$instance;
+ }
+
+ // sets array of extentions
+ public function setExtentions($ext) {
+ $this->all = false;
+ $this->extentions = $ext;
+ }
+
+ // adds one extention in array
+ public function addExtention($ext) {
+ $this->all = false;
+ $this->extentions[] = $ext;
+ }
+
+
+ // adds one extention which will not ouputed in array
+ public function addExtentionNot($ext) {
+ $this->extentions_not[] = $ext;
+ }
+
+
+ // returns array of extentions
+ public function getExtentions() {
+ return $this->extentions;
+ }
+
+ // adds regexp pattern
+ public function addPattern($pattern) {
+ $this->all = false;
+ $this->patterns[] = $pattern;
+ }
+
+ // clear extentions array
+ public function clearExtentions() {
+ $this->all = true;
+ $this->extentions = Array();
+ }
+
+ // clear regexp patterns array
+ public function clearPatterns() {
+ $this->all = true;
+ $this->patterns = Array();
+ }
+
+ // clear all filters
+ public function clearAll() {
+ $this->clearExtentions();
+ $this->clearPatterns();
+ }
+
+ // sets predefined type
+ public function setType($type, $clear = false) {
+ $this->all = false;
+ if ($type == 'all') {
+ $this->all = true;
+ return true;
+ }
+ if (isset($this->types[$type])) {
+ if ($clear) {
+ $this->clearExtentions();
+ }
+ for ($i = 0; $i < count($this->types[$type]); $i++) {
+ $this->extentions[] = $this->types[$type][$i];
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ // check file under setted filter
+ public function checkFile($filename, $fileNameExt) {
+ if (in_array($fileNameExt['ext'], $this->extentions_not)) {
+ return false;
+ }
+ if ($this->all) {
+ return true;
+ }
+
+ if ((count($this->extentions) > 0)&&(!in_array($fileNameExt['ext'], $this->extentions))) {
+ return false;
+ }
+
+ for ($i = 0; $i < count($this->patterns); $i++) {
+ if (!preg_match($this->patterns[$i], $filename)) {
+ return false;
+ }
+ }
+ return true;
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DataViewConnector.php b/codebase/Dhtmlx/Connector/DataViewConnector.php
new file mode 100644
index 0000000..167bd3b
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/DataViewConnector.php
@@ -0,0 +1,49 @@
+<?php
+namespace Dhtmlx\Connector;
+
+/*! Connector class for DataView
+**/
+class DataViewConnector extends Connector {
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false){
+ if (!$item_type) $item_type="DataViewDataItem";
+ if (!$data_type) $data_type="DataProcessor";
+ parent::__construct($res,$type,$item_type,$data_type);
+ }
+
+ //parse GET scoope, all operations with incoming request must be done here
+ function parse_request(){
+ parent::parse_request();
+
+ if (isset($_GET["posStart"]) && isset($_GET["count"]))
+ $this->request->set_limit($_GET["posStart"],$_GET["count"]);
+ }
+
+ /*! renders self as xml, starting part
+ */
+ protected function xml_start(){
+ $attributes = "";
+ foreach($this->attributes as $k=>$v)
+ $attributes .= " ".$k."='".$v."'";
+
+ if ($this->dload){
+ if ($pos=$this->request->get_start())
+ return "<data pos='".$pos."'".$attributes.">";
+ else
+ return "<data total_count='".$this->sql->get_size($this->request)."'".$attributes.">";
+ }
+ else
+ return "<data".$attributes.">";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/DistinctOptionsConnector.php b/codebase/Dhtmlx/Connector/DistinctOptionsConnector.php
index a2e794c..463659c 100644
--- a/codebase/Dhtmlx/Connector/DistinctOptionsConnector.php
+++ b/codebase/Dhtmlx/Connector/DistinctOptionsConnector.php
@@ -1,7 +1,7 @@
<?php
namespace Dhtmlx\Connector;
-class DistinctOptionsConnector extends OptionsConnector{
+class DistinctOptionsConnector extends OptionsConnector {
/*! render self
process commands, return data as XML, not output data to stdout, ignore parameters in incoming request
@return
diff --git a/codebase/Dhtmlx/Connector/Event/EventInterface.php b/codebase/Dhtmlx/Connector/Event/EventInterface.php
index b2503fe..60cabf1 100644
--- a/codebase/Dhtmlx/Connector/Event/EventInterface.php
+++ b/codebase/Dhtmlx/Connector/Event/EventInterface.php
@@ -1,7 +1,7 @@
<?php
namespace Dhtmlx\Connector\Event;
-class EventInterface{
+class EventInterface {
protected $request; ////!< DataRequestConfig instance
public $rules=array(); //!< array of sorting rules
diff --git a/codebase/Dhtmlx/Connector/Event/FilterInterface.php b/codebase/Dhtmlx/Connector/Event/FilterInterface.php
index 5be8516..89a257a 100644
--- a/codebase/Dhtmlx/Connector/Event/FilterInterface.php
+++ b/codebase/Dhtmlx/Connector/Event/FilterInterface.php
@@ -1,10 +1,9 @@
<?php
-
namespace Dhtmlx\Connector\Event;
/*! Wrapper for collection of filtering rules
**/
-class FilterInterface extends EventInterface{
+class FilterInterface extends EventInterface {
/*! constructor
creates a new interface based on existing request
@param request
diff --git a/codebase/Dhtmlx/Connector/Event/SortInterface.php b/codebase/Dhtmlx/Connector/Event/SortInterface.php
index f2090eb..7a2b92e 100644
--- a/codebase/Dhtmlx/Connector/Event/SortInterface.php
+++ b/codebase/Dhtmlx/Connector/Event/SortInterface.php
@@ -1,8 +1,7 @@
<?php
-
namespace Dhtmlx\Connector\Event;
-class SortInterface extends EventInterface{
+class SortInterface extends EventInterface {
/*! constructor
creates a new interface based on existing request
@param request
diff --git a/codebase/Dhtmlx/Connector/FormConnector.php b/codebase/Dhtmlx/Connector/FormConnector.php
new file mode 100644
index 0000000..7580f48
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/FormConnector.php
@@ -0,0 +1,36 @@
+<?php
+namespace Dhtmlx\Connector;
+use \Exception;
+
+/*! Connector class for dhtmlxForm
+**/
+class FormConnector extends Connector {
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false){
+ if (!$item_type) $item_type="FormDataItem";
+ if (!$data_type) $data_type="FormDataProcessor";
+ parent::__construct($res,$type,$item_type,$data_type);
+ }
+
+ //parse GET scoope, all operations with incoming request must be done here
+ function parse_request(){
+ parent::parse_request();
+ if (isset($_GET["id"]))
+ $this->request->set_filter($this->config->id["name"],$_GET["id"],"=");
+ else if (!$_POST["ids"])
+ throw new Exception("ID parameter is missed");
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/GanttConnector.php b/codebase/Dhtmlx/Connector/GanttConnector.php
new file mode 100644
index 0000000..b27d453
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/GanttConnector.php
@@ -0,0 +1,96 @@
+<?php
+namespace Dhtmlx\Connector;
+
+/*! Connector class for dhtmlxGantt
+**/
+class GanttConnector extends Connector {
+
+ protected $extra_output="";//!< extra info which need to be sent to client side
+ protected $options=array();//!< hash of OptionsConnector
+ protected $links_mode = false;
+
+
+ /*! assign options collection to the column
+
+ @param name
+ name of the column
+ @param options
+ array or connector object
+ */
+ public function set_options($name,$options){
+ if (is_array($options)){
+ $str="";
+ foreach($options as $k => $v)
+ $str.="<item value='".$this->xmlentities($k)."' label='".$this->xmlentities($v)."' />";
+ $options=$str;
+ }
+ $this->options[$name]=$options;
+ }
+
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ * @param render_type
+ name of class which will be used for rendering.
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="GanttDataItem";
+ if (!$data_type) $data_type="GanttDataProcessor";
+ if (!$render_type) $render_type="RenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+
+ $this->event->attach("afterDelete", array($this, "delete_related_links"));
+ $this->event->attach("afterOrder", array($this, "order_set_parent"));
+ }
+
+ //parse GET scoope, all operations with incoming request must be done here
+ function parse_request(){
+ parent::parse_request();
+
+ if (isset($_GET["gantt_mode"]) && $_GET["gantt_mode"] == "links")
+ $this->links_mode = true;
+
+ if (count($this->config->text)){
+ if (isset($_GET["to"]))
+ $this->request->set_filter($this->config->text[0]["name"],$_GET["to"],"<");
+ if (isset($_GET["from"]))
+ $this->request->set_filter($this->config->text[1]["name"],$_GET["from"],">");
+ }
+ }
+
+ function order_set_parent($action){
+ $value = $action->get_id();
+ $parent = $action->get_value("parent");
+
+ $table = $this->request->get_source();
+ $id = $this->config->id["db_name"];
+
+ $this->sql->query("UPDATE $table SET parent = $parent WHERE $id = $value");
+ }
+
+ function delete_related_links($action){
+ if (isset($this->options["links"])){
+ $links = $this->options["links"];
+ $value = $this->sql->escape($action->get_new_id());
+ $table = $links->get_request()->get_source();
+
+ $this->sql->query("DELETE FROM $table WHERE source = '$value'");
+ $this->sql->query("DELETE FROM $table WHERE target = '$value'");
+ }
+ }
+
+ public function render_links($table,$id="",$fields=false,$extra=false,$relation_id=false) {
+ $links = new GanttLinksConnector($this->get_connection(),$this->names["db_class"]);
+ $links->render_table($table,$id,$fields,$extra);
+ $this->set_options("links", $links);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/GanttLinksConnector.php b/codebase/Dhtmlx/Connector/GanttLinksConnector.php
new file mode 100644
index 0000000..6dcf607
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/GanttLinksConnector.php
@@ -0,0 +1,19 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class GanttLinksConnector extends OptionsConnector {
+ public function render(){
+ if (!$this->init_flag){
+ $this->init_flag=true;
+ return "";
+ }
+
+ $res = $this->sql->select($this->request);
+ return $this->render_set($res);
+ }
+
+ public function save() {
+ $dp = new $this->names["data_class"]($this,$this->config,$this->request);
+ $dp->process($this->config,$this->request);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/GridConfiguration.php b/codebase/Dhtmlx/Connector/GridConfiguration.php
index 094d374..1297711 100644
--- a/codebase/Dhtmlx/Connector/GridConfiguration.php
+++ b/codebase/Dhtmlx/Connector/GridConfiguration.php
@@ -1,8 +1,8 @@
<?php
namespace Dhtmlx\Connector;
+use Dhtmlx\Connector\Data\DataConfig;
-class GridConfiguration
-{
+class GridConfiguration {
/*! attaching header functionality
*/
diff --git a/codebase/Dhtmlx/Connector/GridConnector.php b/codebase/Dhtmlx/Connector/GridConnector.php
index d912f4f..3c2b2f6 100644
--- a/codebase/Dhtmlx/Connector/GridConnector.php
+++ b/codebase/Dhtmlx/Connector/GridConnector.php
@@ -1,9 +1,11 @@
<?php
-
namespace Dhtmlx\Connector;
+use Dhtmlx\Connector\Data\DataConfig;
+use Dhtmlx\Connector\Data\DataRequestConfig;
+
/*! Connector for the dhtmlxgrid
**/
-class GridConnector extends Connector{
+class GridConnector extends Connector {
/*! constructor
@@ -18,8 +20,8 @@ class GridConnector extends Connector{
name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
*/
public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
- if (!$item_type) $item_type="Dhtmlx\\Connector\\GridDataItem";
- if (!$data_type) $data_type="Dhtmlx\\Connector\\Data\\GridDataProcessor";
+ if (!$item_type) $item_type="Dhtmlx\\Connector\\Data\\GridDataItem";
+ if (!$data_type) $data_type="Dhtmlx\\Connector\\DataProcessor\\GridDataProcessor";
if (!$render_type) $render_type="Dhtmlx\\Connector\\Output\\RenderStrategy";
parent::__construct($res,$type,$item_type,$data_type,$render_type);
}
diff --git a/codebase/Dhtmlx/Connector/JSONDataConnector.php b/codebase/Dhtmlx/Connector/JSONDataConnector.php
index 90581f3..2b4b3ca 100644
--- a/codebase/Dhtmlx/Connector/JSONDataConnector.php
+++ b/codebase/Dhtmlx/Connector/JSONDataConnector.php
@@ -1,11 +1,8 @@
<?php
-
namespace Dhtmlx\Connector;
-
use Dhtmlx\Connector\Output\OutputWriter;
-
-class JSONDataConnector extends DataConnector{
+class JSONDataConnector extends DataConnector {
public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
if (!$item_type) $item_type="Dhtmlx\\Connector\\Data\\JSONCommonDataItem";
diff --git a/codebase/Dhtmlx/Connector/JSONDistinctOptionsConnector.php b/codebase/Dhtmlx/Connector/JSONDistinctOptionsConnector.php
new file mode 100644
index 0000000..fed4f95
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/JSONDistinctOptionsConnector.php
@@ -0,0 +1,18 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class JSONDistinctOptionsConnector extends JSONOptionsConnector {
+ /*! render self
+ process commands, return data as XML, not output data to stdout, ignore parameters in incoming request
+ @return
+ data as XML string
+ */
+ public function render(){
+ if (!$this->init_flag){
+ $this->init_flag=true;
+ return "";
+ }
+ $res = $this->sql->get_variants($this->config->text[0]["db_name"],$this->request);
+ return $this->render_set($res);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/JSONGanttConnector.php b/codebase/Dhtmlx/Connector/JSONGanttConnector.php
new file mode 100644
index 0000000..18bdc16
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/JSONGanttConnector.php
@@ -0,0 +1,163 @@
+<?php
+namespace Dhtmlx\Connector;
+use Dhtmlx\Connector\Tools\LogMaster;
+use Dhtmlx\Connector\Tools\EventMaster;
+use Dhtmlx\Connector\Output\OutputWriter;
+use Dhtmlx\Connector\Event\SortInterface;
+use Dhtmlx\Connector\Event\FilterInterface;
+use Dhtmlx\Connector\DataStorage\ArrayDBDataWrapper;
+use Dhtmlx\Connector\DataStorage\ArrayQueryWrapper;
+
+class JSONGanttConnector extends GanttConnector {
+
+ protected $data_separator = ",";
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="JSONGanttDataItem";
+ if (!$data_type) $data_type="GanttDataProcessor";
+ if (!$render_type) $render_type="JSONRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ protected function xml_start() {
+ return '{ "data":';
+ }
+
+ protected function xml_end() {
+ $this->fill_collections();
+ $end = (!empty($this->extra_output)) ? ', "collections": {'.$this->extra_output.'}' : '';
+ foreach ($this->attributes as $k => $v)
+ $end.=", \"".$k."\":\"".$v."\"";
+ $end .= '}';
+ return $end;
+ }
+
+ /*! assign options collection to the column
+
+ @param name
+ name of the column
+ @param options
+ array or connector object
+ */
+ public function set_options($name,$options){
+ if (is_array($options)){
+ $str=array();
+ foreach($options as $k => $v)
+ $str[]='{"id":"'.$this->xmlentities($k).'", "value":"'.$this->xmlentities($v).'"}';
+ $options=implode(",",$str);
+ }
+ $this->options[$name]=$options;
+ }
+
+
+ /*! generates xml description for options collections
+
+ @param list
+ comma separated list of column names, for which options need to be generated
+ */
+ protected function fill_collections($list=""){
+ $options = array();
+ foreach ($this->options as $k=>$v) {
+ $name = $k;
+ $option="\"{$name}\":[";
+ if (!is_string($this->options[$name])){
+ $data = json_encode($this->options[$name]->render());
+ $option.=substr($data,1,-1);
+ } else
+ $option.=$this->options[$name];
+ $option.="]";
+ $options[] = $option;
+ }
+ $this->extra_output .= implode($this->data_separator, $options);
+ }
+
+
+ /*! output fetched data as XML
+ @param res
+ DB resultset
+ */
+ protected function output_as_xml($res){
+ $result = $this->render_set($res);
+ if ($this->simple) return $result;
+
+ $data=$this->xml_start().json_encode($result).$this->xml_end();
+
+ if ($this->as_string) return $data;
+
+ $out = new OutputWriter($data, "");
+ $out->set_type("json");
+ $this->event->trigger("beforeOutput", $this, $out);
+ $out->output("", true, $this->encoding);
+ }
+
+ public function render_links($table,$id="",$fields=false,$extra=false,$relation_id=false) {
+ $links = new JSONGanttLinksConnector($this->get_connection(),$this->names["db_class"]);
+ $links->render_table($table,$id,$fields,$extra);
+ $this->set_options("links", $links);
+ }
+
+
+ /*! render self
+ process commands, output requested data as XML
+ */
+ public function render(){
+ $this->event->trigger("onInit", $this);
+ EventMaster::trigger_static("connectorInit",$this);
+
+ if (!$this->as_string)
+ $this->parse_request();
+ $this->set_relation();
+
+ if ($this->live_update !== false && $this->updating!==false) {
+ $this->live_update->get_updates();
+ } else {
+ if ($this->editing){
+ if ($this->links_mode && isset($this->options["links"])) {
+ $this->options["links"]->save();
+ } else {
+ $dp = new $this->names["data_class"]($this,$this->config,$this->request);
+ $dp->process($this->config,$this->request);
+ }
+ } else {
+ if (!$this->access->check("read")){
+ LogMaster::log("Access control: read operation blocked");
+ echo "Access denied";
+ die();
+ }
+ $wrap = new SortInterface($this->request);
+ $this->apply_sorts($wrap);
+ $this->event->trigger("beforeSort",$wrap);
+ $wrap->store();
+
+ $wrap = new FilterInterface($this->request);
+ $this->apply_filters($wrap);
+ $this->event->trigger("beforeFilter",$wrap);
+ $wrap->store();
+
+ if ($this->model && method_exists($this->model, "get")){
+ $this->sql = new ArrayDBDataWrapper();
+ $result = new ArrayQueryWrapper(call_user_func(array($this->model, "get"), $this->request));
+ $out = $this->output_as_xml($result);
+ } else {
+ $out = $this->output_as_xml($this->get_resource());
+
+ if ($out !== null) return $out;
+ }
+
+ }
+ }
+ $this->end_run();
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php b/codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php
new file mode 100644
index 0000000..c08b451
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php
@@ -0,0 +1,19 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class JSONGanttLinksConnector extends JSONOptionsConnector {
+ public function render(){
+ if (!$this->init_flag){
+ $this->init_flag=true;
+ return "";
+ }
+
+ $res = $this->sql->select($this->request);
+ return $this->render_set($res);
+ }
+
+ public function save() {
+ $dp = new $this->names["data_class"]($this,$this->config,$this->request);
+ $dp->process($this->config,$this->request);
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/JSONOptionsConnector.php b/codebase/Dhtmlx/Connector/JSONOptionsConnector.php
index 1a1b600..8f8fb47 100644
--- a/codebase/Dhtmlx/Connector/JSONOptionsConnector.php
+++ b/codebase/Dhtmlx/Connector/JSONOptionsConnector.php
@@ -1,9 +1,9 @@
<?php
-
namespace Dhtmlx\Connector;
+
/*! wrapper around options collection, used for comboboxes and filters
**/
-class JSONOptionsConnector extends JSONDataConnector{
+class JSONOptionsConnector extends JSONDataConnector {
protected $init_flag=false;//!< used to prevent rendering while initialization
public function __construct($res,$type=false,$item_type=false,$data_type=false){
if (!$item_type) $item_type="JSONCommonDataItem";
@@ -23,21 +23,4 @@ class JSONOptionsConnector extends JSONDataConnector{
$res = $this->sql->select($this->request);
return $this->render_set($res);
}
-}
-
-
-class JSONDistinctOptionsConnector extends JSONOptionsConnector{
- /*! render self
- process commands, return data as XML, not output data to stdout, ignore parameters in incoming request
- @return
- data as XML string
- */
- public function render(){
- if (!$this->init_flag){
- $this->init_flag=true;
- return "";
- }
- $res = $this->sql->get_variants($this->config->text[0]["db_name"],$this->request);
- return $this->render_set($res);
- }
} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/JSONSchedulerConnector.php b/codebase/Dhtmlx/Connector/JSONSchedulerConnector.php
new file mode 100644
index 0000000..c946be7
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/JSONSchedulerConnector.php
@@ -0,0 +1,99 @@
+<?php
+namespace Dhtmlx\Connector;
+use Dhtmlx\Connector\Output\OutputWriter;
+
+class JSONSchedulerConnector extends SchedulerConnector {
+
+ protected $data_separator = ",";
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="JSONSchedulerDataItem";
+ if (!$data_type) $data_type="SchedulerDataProcessor";
+ if (!$render_type) $render_type="JSONRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ protected function xml_start() {
+ return '{ "data":';
+ }
+
+ protected function xml_end() {
+ $this->fill_collections();
+ $end = (!empty($this->extra_output)) ? ', "collections": {'.$this->extra_output.'}' : '';
+ foreach ($this->attributes as $k => $v)
+ $end.=", \"".$k."\":\"".$v."\"";
+ $end .= '}';
+ return $end;
+ }
+
+ /*! assign options collection to the column
+
+ @param name
+ name of the column
+ @param options
+ array or connector object
+ */
+ public function set_options($name,$options){
+ if (is_array($options)){
+ $str=array();
+ foreach($options as $k => $v)
+ $str[]='{"id":"'.$this->xmlentities($k).'", "value":"'.$this->xmlentities($v).'"}';
+ $options=implode(",",$str);
+ }
+ $this->options[$name]=$options;
+ }
+
+
+ /*! generates xml description for options collections
+
+ @param list
+ comma separated list of column names, for which options need to be generated
+ */
+ protected function fill_collections($list=""){
+ $options = array();
+ foreach ($this->options as $k=>$v) {
+ $name = $k;
+ $option="\"{$name}\":[";
+ if (!is_string($this->options[$name])){
+ $data = json_encode($this->options[$name]->render());
+ $option.=substr($data,1,-1);
+ } else
+ $option.=$this->options[$name];
+ $option.="]";
+ $options[] = $option;
+ }
+ $this->extra_output .= implode($this->data_separator, $options);
+ }
+
+
+ /*! output fetched data as XML
+ @param res
+ DB resultset
+ */
+ protected function output_as_xml($res) {
+ $result = $this->render_set($res);
+ if ($this->simple) return $result;
+
+ $data=$this->xml_start().json_encode($result).$this->xml_end();
+
+ if ($this->as_string) return $data;
+
+ $out = new OutputWriter($data, "");
+ $out->set_type("json");
+ $this->event->trigger("beforeOutput", $this, $out);
+ $out->output("", true, $this->encoding);
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/JSONTreeDataConnector.php b/codebase/Dhtmlx/Connector/JSONTreeDataConnector.php
new file mode 100644
index 0000000..aee5aa2
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/JSONTreeDataConnector.php
@@ -0,0 +1,80 @@
+<?php
+namespace Dhtmlx\Connector;
+use Dhtmlx\Connector\Output\OutputWriter;
+
+class JSONTreeDataConnector extends TreeDataConnector {
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="JSONTreeCommonDataItem";
+ if (!$data_type) $data_type="CommonDataProcessor";
+ if (!$render_type) $render_type="JSONTreeRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ protected function output_as_xml($res){
+ $result = $this->render_set($res);
+ if ($this->simple) return $result;
+
+ $data = array();
+ if (!$this->rootId || $this->rootId != $this->request->get_relation())
+ $data["parent"] = $this->request->get_relation();
+
+ $data["data"] = $result;
+
+ $this->fill_collections();
+ if (!empty($this->options))
+ $data["collections"] = $this->options;
+
+
+ foreach($this->attributes as $k=>$v)
+ $data[$k] = $v;
+
+ $data = json_encode($data);
+
+ // return as string
+ if ($this->as_string) return $data;
+
+ // output direct to response
+ $out = new OutputWriter($data, "");
+ $out->set_type("json");
+ $this->event->trigger("beforeOutput", $this, $out);
+ $out->output("", true, $this->encoding);
+ }
+
+ /*! assign options collection to the column
+
+ @param name
+ name of the column
+ @param options
+ array or connector object
+ */
+ public function set_options($name,$options){
+ if (is_array($options)){
+ $str=array();
+ foreach($options as $k => $v)
+ $str[]=Array("id"=>$this->xmlentities($k), "value"=>$this->xmlentities($v));//'{"id":"'.$this->xmlentities($k).'", "value":"'.$this->xmlentities($v).'"}';
+ $options=$str;
+ }
+ $this->options[$name]=$options;
+ }
+
+ /*! generates xml description for options collections
+
+ @param list
+ comma separated list of column names, for which options need to be generated
+ */
+ protected function fill_collections($list=""){
+ $options = array();
+ foreach ($this->options as $k=>$v) {
+ $name = $k;
+ if (!is_array($this->options[$name]))
+ $option=$this->options[$name]->render();
+ else
+ $option=$this->options[$name];
+ $options[$name] = $option;
+ }
+ $this->options = $options;
+ $this->extra_output .= "'collections':".json_encode($options);
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/JSONTreeDataGroupConnector.php b/codebase/Dhtmlx/Connector/JSONTreeDataGroupConnector.php
new file mode 100644
index 0000000..a3f2eb3
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/JSONTreeDataGroupConnector.php
@@ -0,0 +1,40 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class JSONTreeDataGroupConnector extends JSONTreeDataConnector {
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$render_type) $render_type="JSONGroupRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ /*! if not isset $_GET[id] then it's top level
+ */
+ protected function set_relation() {
+ if (!isset($_GET[$this->parent_name])) $this->request->set_relation(false);
+ }
+
+ /*! if it's first level then distinct level
+ * else select by parent
+ */
+ protected function get_resource() {
+ $resource = null;
+ if (isset($_GET[$this->parent_name]))
+ $resource = $this->sql->select($this->request);
+ else
+ $resource = $this->sql->get_variants($this->config->relation_id['name'], $this->request);
+ return $resource;
+ }
+
+
+ /*! renders self as xml, starting part
+ */
+ public function xml_start(){
+ if (isset($_GET[$this->parent_name])) {
+ return "<data parent='".$_GET[$this->parent_name].$this->render->get_postfix()."'>";
+ } else {
+ return "<data parent='0'>";
+ }
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/JSONTreeDataMultitableConnector.php b/codebase/Dhtmlx/Connector/JSONTreeDataMultitableConnector.php
new file mode 100644
index 0000000..a826b8e
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/JSONTreeDataMultitableConnector.php
@@ -0,0 +1,37 @@
+<?php
+namespace Dhtmlx\Connector;
+use Dhtmlx\Connector\Output\OutputWriter;
+
+class JSONTreeDataMultitableConnector extends TreeDataMultitableConnector {
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="JSONTreeCommonDataItem";
+ if (!$data_type) $data_type="CommonDataProcessor";
+ if (!$render_type) $render_type="JSONMultitableTreeRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ protected function output_as_xml($res){
+ $result = $this->render_set($res);
+ if ($this->simple) return $result;
+
+ $data = array();
+ if (isset($_GET['parent']))
+ $data["parent"] = $this->render->level_id($_GET[$this->parent_name], $this->render->get_level() - 1);
+ else
+ $data["parent"] = "0";
+ $data["data"] = $result;
+
+ $result = json_encode($data);
+ if ($this->as_string) return $result;
+
+ $out = new OutputWriter($result, "");
+ $out->set_type("json");
+ $this->event->trigger("beforeOutput", $this, $out);
+ $out->output("", true, $this->encoding);
+ }
+
+ public function xml_start(){
+ return '';
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/KeyGridConnector.php b/codebase/Dhtmlx/Connector/KeyGridConnector.php
new file mode 100644
index 0000000..001cae9
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/KeyGridConnector.php
@@ -0,0 +1,24 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class KeyGridConnector extends GridConnector {
+ public function __construct($res,$type=false,$item_type=false,$data_type=false){
+ if (!$item_type) $item_type="GridDataItem";
+ if (!$data_type) $data_type="KeyGridDataProcessor";
+ parent::__construct($res,$type,$item_type,$data_type);
+
+ $this->event->attach("beforeProcessing",array($this,"before_check_key"));
+ $this->event->attach("afterProcessing",array($this,"after_check_key"));
+ }
+
+ public function before_check_key($action){
+ if ($action->get_value($this->config->id["name"])=="")
+ $action->error();
+ }
+ public function after_check_key($action){
+ if ($action->get_status()=="inserted" || $action->get_status()=="updated"){
+ $action->success($action->get_value($this->config->id["name"]));
+ $action->set_status("inserted");
+ }
+ }
+}; \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/MixedConnector.php b/codebase/Dhtmlx/Connector/MixedConnector.php
index 8912599..1d2c9ff 100644
--- a/codebase/Dhtmlx/Connector/MixedConnector.php
+++ b/codebase/Dhtmlx/Connector/MixedConnector.php
@@ -1,8 +1,6 @@
<?php
namespace Dhtmlx\Connector;
-use Dhtmlx\Connector\Connector;
-
class MixedConnector extends Connector {
protected $connectors = array();
diff --git a/codebase/Dhtmlx/Connector/OptionsConnector.php b/codebase/Dhtmlx/Connector/OptionsConnector.php
index 35b81b0..f8fbea3 100644
--- a/codebase/Dhtmlx/Connector/OptionsConnector.php
+++ b/codebase/Dhtmlx/Connector/OptionsConnector.php
@@ -1,10 +1,9 @@
<?php
-
namespace Dhtmlx\Connector;
/*! wrapper around options collection, used for comboboxes and filters
**/
-class OptionsConnector extends Connector{
+class OptionsConnector extends Connector {
protected $init_flag=false;//!< used to prevent rendering while initialization
public function __construct($res,$type=false,$item_type=false,$data_type=false){
if (!$item_type) $item_type="DataItem";
diff --git a/codebase/Dhtmlx/Connector/Output/JSONRenderStrategy.php b/codebase/Dhtmlx/Connector/Output/JSONRenderStrategy.php
index b351f2e..0ac1f40 100644
--- a/codebase/Dhtmlx/Connector/Output/JSONRenderStrategy.php
+++ b/codebase/Dhtmlx/Connector/Output/JSONRenderStrategy.php
@@ -1,5 +1,4 @@
<?php
-
namespace Dhtmlx\Connector\Output;
class JSONRenderStrategy extends RenderStrategy {
diff --git a/codebase/Dhtmlx/Connector/Output/JSONTreeRenderStrategy.php b/codebase/Dhtmlx/Connector/Output/JSONTreeRenderStrategy.php
index c3edd79..739109a 100644
--- a/codebase/Dhtmlx/Connector/Output/JSONTreeRenderStrategy.php
+++ b/codebase/Dhtmlx/Connector/Output/JSONTreeRenderStrategy.php
@@ -1,5 +1,7 @@
<?php
namespace Dhtmlx\Connector\Output;
+use Dhtmlx\Connector\Data\DataConfig;
+use Dhtmlx\Connector\Data\DataRequestConfig;
class JSONTreeRenderStrategy extends TreeRenderStrategy {
diff --git a/codebase/Dhtmlx/Connector/Output/OutputWriter.php b/codebase/Dhtmlx/Connector/Output/OutputWriter.php
index 9f93cf3..aeedd2a 100644
--- a/codebase/Dhtmlx/Connector/Output/OutputWriter.php
+++ b/codebase/Dhtmlx/Connector/Output/OutputWriter.php
@@ -1,8 +1,7 @@
<?php
-
namespace Dhtmlx\Connector\Output;
-class OutputWriter{
+class OutputWriter {
private $start;
private $end;
private $type;
diff --git a/codebase/Dhtmlx/Connector/Output/RenderStrategy.php b/codebase/Dhtmlx/Connector/Output/RenderStrategy.php
index 07ed39e..24bdf56 100644
--- a/codebase/Dhtmlx/Connector/Output/RenderStrategy.php
+++ b/codebase/Dhtmlx/Connector/Output/RenderStrategy.php
@@ -1,8 +1,9 @@
<?php
namespace Dhtmlx\Connector\Output;
-
use Dhtmlx\Connector\Data\DataItem;
-use Dhtmlx\Connector\GridDataItem;
+use Dhtmlx\Connector\Data\GridDataItem;
+use \Exception;
+
class RenderStrategy {
protected $conn = null;
@@ -98,13 +99,15 @@ class RenderStrategy {
$conn = $this->conn;
$this->mix($config, $mix);
$conn->event->trigger("beforeRenderSet",$conn,$res,$config);
- while ($data=$conn->sql->get_next($res)){
+
+ while($data=$conn->sql->get_next($res)) {
$data = $this->simple_mix($mix, $data);
+ $data = new $name($data, $config, $index);
- $data = new $name($data,$config,$index);
- if ($data->get_id()===false)
+ if($data->get_id()===false)
$data->set_id($conn->uuid());
- $conn->event->trigger("beforeRender",$data);
+
+ $conn->event->trigger("beforeRender", $data);
$output.=$data->to_xml().$sep;
$index++;
}
diff --git a/codebase/Dhtmlx/Connector/Output/TreeRenderStrategy.php b/codebase/Dhtmlx/Connector/Output/TreeRenderStrategy.php
index b5ab642..d1f2329 100644
--- a/codebase/Dhtmlx/Connector/Output/TreeRenderStrategy.php
+++ b/codebase/Dhtmlx/Connector/Output/TreeRenderStrategy.php
@@ -1,7 +1,7 @@
<?php
namespace Dhtmlx\Connector\Output;
-
-use Dhtmlx\Connector\DataStorage\DataConfig;
+use Dhtmlx\Connector\Data\DataConfig;
+use Dhtmlx\Connector\Data\DataRequestConfig;
class TreeRenderStrategy extends RenderStrategy {
diff --git a/codebase/Dhtmlx/Connector/SchedulerConnector.php b/codebase/Dhtmlx/Connector/SchedulerConnector.php
new file mode 100644
index 0000000..7b2a1c4
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/SchedulerConnector.php
@@ -0,0 +1,61 @@
+<?php
+namespace Dhtmlx\Connector;
+
+/*! Connector class for dhtmlxScheduler
+**/
+class SchedulerConnector extends Connector {
+
+ protected $extra_output="";//!< extra info which need to be sent to client side
+ protected $options=array();//!< hash of OptionsConnector
+
+
+ /*! assign options collection to the column
+
+ @param name
+ name of the column
+ @param options
+ array or connector object
+ */
+ public function set_options($name,$options){
+ if (is_array($options)){
+ $str="";
+ foreach($options as $k => $v)
+ $str.="<item value='".$this->xmlentities($k)."' label='".$this->xmlentities($v)."' />";
+ $options=$str;
+ }
+ $this->options[$name]=$options;
+ }
+
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ * @param render_type
+ name of class which will be used for rendering.
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="SchedulerDataItem";
+ if (!$data_type) $data_type="SchedulerDataProcessor";
+ if (!$render_type) $render_type="RenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ //parse GET scoope, all operations with incoming request must be done here
+ function parse_request(){
+ parent::parse_request();
+ if (count($this->config->text)){
+ if (isset($_GET["to"]))
+ $this->request->set_filter($this->config->text[0]["name"],$_GET["to"],"<");
+ if (isset($_GET["from"]))
+ $this->request->set_filter($this->config->text[1]["name"],$_GET["from"],">");
+ }
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/Tools/AccessMaster.php b/codebase/Dhtmlx/Connector/Tools/AccessMaster.php
index ce47c6f..032ce69 100644
--- a/codebase/Dhtmlx/Connector/Tools/AccessMaster.php
+++ b/codebase/Dhtmlx/Connector/Tools/AccessMaster.php
@@ -1,8 +1,9 @@
<?php
namespace Dhtmlx\Connector\Tools;
+
/*! Class which handles access rules.
**/
-class AccessMaster{
+class AccessMaster {
private $rules,$local;
/*! constructor
diff --git a/codebase/Dhtmlx/Connector/ConvertService.php b/codebase/Dhtmlx/Connector/Tools/ConvertService.php
index 8c51289..698d2be 100644
--- a/codebase/Dhtmlx/Connector/ConvertService.php
+++ b/codebase/Dhtmlx/Connector/Tools/ConvertService.php
@@ -1,13 +1,11 @@
<?php
+namespace Dhtmlx\Connector\Tools;
-namespace Dhtmlx\Connector;
-
-use Dhtmlx\Connector\Tools\EventMaster;
/*
@author dhtmlx.com
@license GPL, see license.txt
*/
-class ConvertService{
+class ConvertService {
private $url;
private $type;
private $name;
diff --git a/codebase/Dhtmlx/Connector/Tools/EventMaster.php b/codebase/Dhtmlx/Connector/Tools/EventMaster.php
index d4c6c50..8a0e411 100644
--- a/codebase/Dhtmlx/Connector/Tools/EventMaster.php
+++ b/codebase/Dhtmlx/Connector/Tools/EventMaster.php
@@ -1,9 +1,10 @@
<?php
-
namespace Dhtmlx\Connector\Tools;
+use \Exception;
+
/*! Class which allows to assign|fire events.
*/
-class EventMaster{
+class EventMaster {
private $events;//!< hash of event handlers
private $master;
private static $eventsStatic=array();
diff --git a/codebase/Dhtmlx/Connector/Tools/LogMaster.php b/codebase/Dhtmlx/Connector/Tools/LogMaster.php
index da4dd69..107f7d7 100755
--- a/codebase/Dhtmlx/Connector/Tools/LogMaster.php
+++ b/codebase/Dhtmlx/Connector/Tools/LogMaster.php
@@ -1,10 +1,10 @@
<?php
-
namespace Dhtmlx\Connector\Tools;
+
/*! Controls error and debug logging.
Class designed to be used as static object.
**/
-class LogMaster{
+class LogMaster {
private static $_log=false;//!< logging mode flag
private static $_output=false;//!< output error infor to client flag
private static $session="";//!< all messages generated for current request
diff --git a/codebase/Dhtmlx/Connector/TreeConnector.php b/codebase/Dhtmlx/Connector/TreeConnector.php
index 9788e54..886d68d 100644
--- a/codebase/Dhtmlx/Connector/TreeConnector.php
+++ b/codebase/Dhtmlx/Connector/TreeConnector.php
@@ -1,9 +1,7 @@
<?php
-
namespace Dhtmlx\Connector;
-class TreeConnector extends Connector
-{
+class TreeConnector extends Connector {
protected $parent_name = 'id';
public $rootId = "0";
diff --git a/codebase/Dhtmlx/Connector/TreeDataConnector.php b/codebase/Dhtmlx/Connector/TreeDataConnector.php
new file mode 100644
index 0000000..61c1384
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeDataConnector.php
@@ -0,0 +1,53 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class TreeDataConnector extends DataConnector {
+ protected $parent_name = 'parent';
+ public $rootId = "0";
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ * @param render_type
+ * name of class which will provides data rendering
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="TreeCommonDataItem";
+ if (!$data_type) $data_type="CommonDataProcessor";
+ if (!$render_type) $render_type="TreeRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ //parse GET scoope, all operations with incoming request must be done here
+ protected function parse_request(){
+ parent::parse_request();
+
+ if (isset($_GET[$this->parent_name]))
+ $this->request->set_relation($_GET[$this->parent_name]);
+ else
+ $this->request->set_relation($this->rootId);
+
+ $this->request->set_limit(0,0); //netralize default reaction on dyn. loading mode
+ }
+
+ /*! renders self as xml, starting part
+ */
+ protected function xml_start(){
+ $attributes = " ";
+ if (!$this->rootId || $this->rootId != $this->request->get_relation())
+ $attributes = " parent='".$this->request->get_relation()."' ";
+
+ foreach($this->attributes as $k=>$v)
+ $attributes .= " ".$k."='".$v."'";
+
+ return "<data".$attributes.">";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/TreeDataGroupConnector.php b/codebase/Dhtmlx/Connector/TreeDataGroupConnector.php
new file mode 100644
index 0000000..d830fda
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeDataGroupConnector.php
@@ -0,0 +1,40 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class TreeDataGroupConnector extends TreeDataConnector {
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$render_type) $render_type="GroupRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ /*! if not isset $_GET[id] then it's top level
+ */
+ protected function set_relation() {
+ if (!isset($_GET[$this->parent_name])) $this->request->set_relation(false);
+ }
+
+ /*! if it's first level then distinct level
+ * else select by parent
+ */
+ protected function get_resource() {
+ $resource = null;
+ if (isset($_GET[$this->parent_name]))
+ $resource = $this->sql->select($this->request);
+ else
+ $resource = $this->sql->get_variants($this->config->relation_id['name'], $this->request);
+ return $resource;
+ }
+
+
+ /*! renders self as xml, starting part
+ */
+ public function xml_start(){
+ if (isset($_GET[$this->parent_name])) {
+ return "<data parent='".$_GET[$this->parent_name].$this->render->get_postfix()."'>";
+ } else {
+ return "<data parent='0'>";
+ }
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/TreeDataMultitableConnector.php b/codebase/Dhtmlx/Connector/TreeDataMultitableConnector.php
new file mode 100644
index 0000000..0021e70
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeDataMultitableConnector.php
@@ -0,0 +1,45 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class TreeDataMultitableConnector extends TreeDataConnector {
+
+ protected $parent_name = 'parent';
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$data_type) $data_type="TreeDataProcessor";
+ if (!$render_type) $render_type="MultitableTreeRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ public function render(){
+ $this->dload = true;
+ return parent::render();
+ }
+
+ /*! sets relation for rendering */
+ protected function set_relation() {
+ if (!isset($_GET[$this->parent_name]))
+ $this->request->set_relation(false);
+ }
+
+ public function xml_start(){
+ if (isset($_GET[$this->parent_name])) {
+ return "<data parent='".$this->xmlentities($this->render->level_id($_GET[$this->parent_name], $this->render->get_level() - 1))."'>";
+ } else {
+ return "<data parent='0'>";
+ }
+ }
+
+ /*! set maximum level of tree
+ @param max_level
+ maximum level
+ */
+ public function setMaxLevel($max_level) {
+ $this->render->set_max_level($max_level);
+ }
+
+ public function get_level() {
+ return $this->render->get_level($this->parent_name);
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/TreeGridConnector.php b/codebase/Dhtmlx/Connector/TreeGridConnector.php
new file mode 100644
index 0000000..38db3c4
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeGridConnector.php
@@ -0,0 +1,48 @@
+<?php
+namespace Dhtmlx\Connector;
+
+/*! Connector for dhtmlxTreeGrid
+**/
+class TreeGridConnector extends GridConnector {
+ protected $parent_name = 'id';
+ protected $rootId = "0";
+
+ /*! constructor
+
+ Here initilization of all Masters occurs, execution timer initialized
+ @param res
+ db connection resource
+ @param type
+ string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
+ @param item_type
+ name of class, which will be used for item rendering, optional, DataItem will be used by default
+ @param data_type
+ name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
+ * @param render_type
+ * name of class which will provides data rendering
+ */
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$item_type) $item_type="TreeGridDataItem";
+ if (!$data_type) $data_type="TreeGridDataProcessor";
+ if (!$render_type) $render_type="TreeRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ /*! process treegrid specific options in incoming request */
+ public function parse_request(){
+ parent::parse_request();
+
+ if (isset($_GET[$this->parent_name]))
+ $this->request->set_relation($_GET[$this->parent_name]);
+ else
+ $this->request->set_relation($this->rootId);
+
+ $this->request->set_limit(0,0); //netralize default reaction on dyn. loading mode
+ }
+
+ /*! renders self as xml, starting part
+ */
+ protected function xml_start(){
+ return "<rows parent='".$this->xmlentities( $this->request->get_relation() )."'>";
+ }
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/TreeGridGroupConnector.php b/codebase/Dhtmlx/Connector/TreeGridGroupConnector.php
new file mode 100644
index 0000000..771b579
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeGridGroupConnector.php
@@ -0,0 +1,40 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class TreeGridGroupConnector extends TreeGridConnector {
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$render_type) $render_type="GroupRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ /*! if not isset $_GET[id] then it's top level
+ */
+ protected function set_relation() {
+ if (!isset($_GET[$this->parent_name])) $this->request->set_relation(false);
+ }
+
+ /*! if it's first level then distinct level
+ * else select by parent
+ */
+ protected function get_resource() {
+ $resource = null;
+ if (isset($_GET[$this->parent_name]))
+ $resource = $this->sql->select($this->request);
+ else
+ $resource = $this->sql->get_variants($this->config->relation_id['name'], $this->request);
+ return $resource;
+ }
+
+
+ /*! renders self as xml, starting part
+ */
+ protected function xml_start(){
+ if (isset($_GET[$this->parent_name])) {
+ return "<rows parent='".$_GET[$this->parent_name].$this->render->get_postfix()."'>";
+ } else {
+ return "<rows parent='0'>";
+ }
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/TreeGridMultitableConnector.php b/codebase/Dhtmlx/Connector/TreeGridMultitableConnector.php
new file mode 100644
index 0000000..7816943
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeGridMultitableConnector.php
@@ -0,0 +1,44 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class TreeGridMultitableConnector extends TreeGridConnector {
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ $data_type="TreeGridMultitableDataProcessor";
+ if (!$render_type) $render_type="MultitableTreeRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ public function render(){
+ $this->dload = true;
+ return parent::render();
+ }
+
+ /*! sets relation for rendering */
+ protected function set_relation() {
+ if (!isset($_GET['id']))
+ $this->request->set_relation(false);
+ }
+
+ public function xml_start(){
+ if (isset($_GET['id'])) {
+ return "<rows parent='".$this->xmlentities($this->render->level_id($_GET['id'], $this->get_level() - 1))."'>";
+ } else {
+ return "<rows parent='0'>";
+ }
+ }
+
+ /*! set maximum level of tree
+ @param max_level
+ maximum level
+ */
+ public function setMaxLevel($max_level) {
+ $this->render->set_max_level($max_level);
+ }
+
+ public function get_level() {
+ return $this->render->get_level($this->parent_name);
+ }
+
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/TreeGroupConnector.php b/codebase/Dhtmlx/Connector/TreeGroupConnector.php
new file mode 100644
index 0000000..ae836fd
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeGroupConnector.php
@@ -0,0 +1,40 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class TreeGroupConnector extends TreeConnector {
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$render_type) $render_type="GroupRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ /*! if not isset $_GET[id] then it's top level
+ */
+ protected function set_relation() {
+ if (!isset($_GET[$this->parent_name])) $this->request->set_relation(false);
+ }
+
+ /*! if it's first level then distinct level
+ * else select by parent
+ */
+ protected function get_resource() {
+ $resource = null;
+ if (isset($_GET[$this->parent_name]))
+ $resource = $this->sql->select($this->request);
+ else
+ $resource = $this->sql->get_variants($this->config->relation_id['name'], $this->request);
+ return $resource;
+ }
+
+
+ /*! renders self as xml, starting part
+ */
+ public function xml_start(){
+ if (isset($_GET[$this->parent_name])) {
+ return "<tree id='".$_GET[$this->parent_name].$this->render->get_postfix()."'>";
+ } else {
+ return "<tree id='0'>";
+ }
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/TreeMultitableConnector.php b/codebase/Dhtmlx/Connector/TreeMultitableConnector.php
new file mode 100644
index 0000000..7cc0851
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/TreeMultitableConnector.php
@@ -0,0 +1,45 @@
+<?php
+namespace Dhtmlx\Connector;
+
+class TreeMultitableConnector extends TreeConnector {
+
+ protected $parent_name = 'id';
+
+ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
+ if (!$data_type) $data_type="TreeDataProcessor";
+ if (!$render_type) $render_type="MultitableTreeRenderStrategy";
+ parent::__construct($res,$type,$item_type,$data_type,$render_type);
+ }
+
+ public function render(){
+ $this->dload = true;
+ return parent::render();
+ }
+
+ /*! sets relation for rendering */
+ protected function set_relation() {
+ if (!isset($_GET[$this->parent_name]))
+ $this->request->set_relation(false);
+ }
+
+ public function xml_start(){
+ if (isset($_GET[$this->parent_name])) {
+ return "<tree id='".$this->xmlentities($this->render->level_id($_GET[$this->parent_name], $this->get_level() - 1))."'>";
+ } else {
+ return "<tree id='0'>";
+ }
+ }
+
+ /*! set maximum level of tree
+ @param max_level
+ maximum level
+ */
+ public function setMaxLevel($max_level) {
+ $this->render->set_max_level($max_level);
+ }
+
+ public function get_level() {
+ return $this->render->get_level($this->parent_name);
+ }
+
+} \ No newline at end of file
diff --git a/codebase/Dhtmlx/Connector/XSSFilter/ConnectorSecurity.php b/codebase/Dhtmlx/Connector/XSSFilter/ConnectorSecurity.php
index 582ea0a..fa384e2 100644
--- a/codebase/Dhtmlx/Connector/XSSFilter/ConnectorSecurity.php
+++ b/codebase/Dhtmlx/Connector/XSSFilter/ConnectorSecurity.php
@@ -1,14 +1,12 @@
<?php
namespace Dhtmlx\Connector\XSSFilter;
-
-
use Dhtmlx\Connector\Tools\LogMaster;
define("DHX_SECURITY_SAFETEXT", 1);
define("DHX_SECURITY_SAFEHTML", 2);
define("DHX_SECURITY_TRUSTED", 3);
-class ConnectorSecurity{
+class ConnectorSecurity {
static public $xss = DHX_SECURITY_SAFETEXT;
static public $security_key = false;
static public $security_var = "dhx_security";