summaryrefslogtreecommitdiffstats
path: root/codebase/Dhtmlx/Connector/Output/GroupRenderStrategy.php
diff options
context:
space:
mode:
authorEgor <egor.26.93@gmail.com>2015-06-16 15:48:31 +0300
committerEgor <egor.26.93@gmail.com>2015-06-16 15:48:31 +0300
commit67129e12d10b77911d9250b38b42b42dd5b601b4 (patch)
tree1cb3555d8e8148a38a4e6701f2f8dddb3f68c21d /codebase/Dhtmlx/Connector/Output/GroupRenderStrategy.php
parent4081482ce6cf1a6c0894a8be02a57d21f3cdc7dd (diff)
downloadconnector-php-67129e12d10b77911d9250b38b42b42dd5b601b4.zip
connector-php-67129e12d10b77911d9250b38b42b42dd5b601b4.tar.gz
connector-php-67129e12d10b77911d9250b38b42b42dd5b601b4.tar.bz2
Added namespaces for dhtmlx components.3.0.0
Diffstat (limited to 'codebase/Dhtmlx/Connector/Output/GroupRenderStrategy.php')
-rwxr-xr-xcodebase/Dhtmlx/Connector/Output/GroupRenderStrategy.php79
1 files changed, 79 insertions, 0 deletions
diff --git a/codebase/Dhtmlx/Connector/Output/GroupRenderStrategy.php b/codebase/Dhtmlx/Connector/Output/GroupRenderStrategy.php
new file mode 100755
index 0000000..ac6996f
--- /dev/null
+++ b/codebase/Dhtmlx/Connector/Output/GroupRenderStrategy.php
@@ -0,0 +1,79 @@
+<?php
+namespace Dhtmlx\Connector\Output;
+use Dhtmlx\Connector\Data\DataRequestConfig;
+
+class GroupRenderStrategy extends RenderStrategy {
+
+ protected $id_postfix = '__{group_param}';
+
+ public function __construct($conn) {
+ parent::__construct($conn);
+ $conn->event->attach("beforeProcessing", Array($this, 'check_id'));
+ $conn->event->attach("onInit", Array($this, 'replace_postfix'));
+ }
+
+ public function render_set($res, $name, $dload, $sep, $config, $mix, $usemix = false){
+ $output="";
+ $index=0;
+ $conn = $this->conn;
+ if ($usemix) $this->mix($config, $mix);
+ while ($data=$conn->sql->get_next($res)){
+ if (isset($data[$config->id['name']])) {
+ $this->simple_mix($mix, $data);
+ $has_kids = false;
+ } else {
+ $data[$config->id['name']] = $data['value'].$this->id_postfix;
+ $data[$config->text[0]['name']] = $data['value'];
+ $has_kids = true;
+ }
+ $data = new $name($data,$config,$index);
+ $conn->event->trigger("beforeRender",$data);
+ if ($has_kids === false) {
+ $data->set_kids(false);
+ }
+
+ if ($data->has_kids()===-1 && $dload)
+ $data->set_kids(true);
+ $output.=$data->to_xml_start();
+ if (($data->has_kids()===-1 || ( $data->has_kids()==true && !$dload))&&($has_kids == true)){
+ $sub_request = new DataRequestConfig($conn->get_request());
+ $sub_request->set_relation(str_replace($this->id_postfix, "", $data->get_id()));
+ $output.=$this->render_set($conn->sql->select($sub_request), $name, $dload, $sep, $config, $mix, true);
+ }
+ $output.=$data->to_xml_end();
+ $index++;
+ }
+ if ($usemix) $this->unmix($config, $mix);
+ return $output;
+ }
+
+ public function check_id($action) {
+ if (isset($_GET['editing'])) {
+ $config = $this->conn->get_config();
+ $id = $action->get_id();
+ $pid = $action->get_value($config->relation_id['name']);
+ $pid = str_replace($this->id_postfix, "", $pid);
+ $action->set_value($config->relation_id['name'], $pid);
+ if (!empty($pid)) {
+ return $action;
+ } else {
+ $action->error();
+ $action->set_response_text("This record can't be updated!");
+ return $action;
+ }
+ } else {
+ return $action;
+ }
+ }
+
+ public function replace_postfix() {
+ if (isset($_GET['id'])) {
+ $_GET['id'] = str_replace($this->id_postfix, "", $_GET['id']);
+ }
+ }
+
+ public function get_postfix() {
+ return $this->id_postfix;
+ }
+
+} \ No newline at end of file