summaryrefslogtreecommitdiffstats
path: root/codebase/base_connector.php
diff options
context:
space:
mode:
authorDmitry <dmitry@dhtmlx.com>2012-05-08 16:54:28 +0200
committerDmitry <dmitry@dhtmlx.com>2012-05-08 16:54:28 +0200
commitc5783990b8d84d764584dd8893397ddc181022ad (patch)
treeeb73a0748d3ba1439b7924abc0a62dd3d4f4ea6d /codebase/base_connector.php
parentc0efba59747a13bd79af22b70d9c0d055118598c (diff)
downloadconnector-php-c5783990b8d84d764584dd8893397ddc181022ad.zip
connector-php-c5783990b8d84d764584dd8893397ddc181022ad.tar.gz
connector-php-c5783990b8d84d764584dd8893397ddc181022ad.tar.bz2
minimize code duplicating for GroupConnectors
Diffstat (limited to 'codebase/base_connector.php')
-rw-r--r--codebase/base_connector.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php
index fb3152f..48039a6 100644
--- a/codebase/base_connector.php
+++ b/codebase/base_connector.php
@@ -315,7 +315,7 @@ class Connector {
if (!class_exists($this->names["db_class"],false))
throw new Exception("DB class not found: ".$this->names["db_class"]);
$this->sql = new $this->names["db_class"]($db,$this->config);
- $this->render = new $this->names["render_class"]();
+ $this->render = new $this->names["render_class"]($this);
$this->db=$db;//saved for options connectors, if any
@@ -419,6 +419,7 @@ class Connector {
EventMaster::trigger_static("connectorInit",$this);
$this->parse_request();
+ $this->set_relation();
if ($this->live_update !== false && $this->updating!==false) {
$this->live_update->get_updates();
@@ -426,8 +427,7 @@ class Connector {
if ($this->editing){
$dp = new $this->names["data_class"]($this,$this->config,$this->request);
$dp->process($this->config,$this->request);
- }
- else {
+ } else {
if (!$this->access->check("read")){
LogMaster::log("Access control: read operation blocked");
echo "Access denied";
@@ -441,12 +441,25 @@ class Connector {
$this->event->trigger("beforeFilter",$wrap);
$wrap->store();
- $this->output_as_xml( $this->sql->select($this->request) );
+ $this->output_as_xml($this->get_resource());
}
}
$this->end_run();
}
-
+
+
+ /*! empty call which used for tree-logic
+ * to prevent code duplicating
+ */
+ protected function set_relation() {}
+
+ /*! gets resource for rendering
+ */
+ protected function get_resource() {
+ return $this->sql->select($this->request);
+ }
+
+
/*! prevent SQL injection through column names
replace dangerous chars in field names
@param str
@@ -555,7 +568,7 @@ class Connector {
process commands, output requested data as XML
*/
protected function render_set($res){
- return $this->render->render_set($res, $this, $this->names["item_class"], $this->dload, $this->data_separator);
+ return $this->render->render_set($res, $this->names["item_class"], $this->dload, $this->data_separator);
}
/*! output fetched data as XML