summaryrefslogtreecommitdiffstats
path: root/codebase
diff options
context:
space:
mode:
authorDmitry <dmitry@dhtmlx.com>2012-05-14 12:34:29 +0200
committerDmitry <dmitry@dhtmlx.com>2012-05-14 12:34:29 +0200
commite655169a0211d715f0836ea532701c5448ff1833 (patch)
tree1d2880e996606226ce0161122bae3f03d515e442 /codebase
parent66057eb9be37361384ce7aeb273e55e75df0bb75 (diff)
parentcee7dfc2ccf94a1e69377d5f07b8e1473ad66b00 (diff)
downloadconnector-php-e655169a0211d715f0836ea532701c5448ff1833.zip
connector-php-e655169a0211d715f0836ea532701c5448ff1833.tar.gz
connector-php-e655169a0211d715f0836ea532701c5448ff1833.tar.bz2
merge with master
Diffstat (limited to 'codebase')
-rw-r--r--codebase/data_connector.php39
-rw-r--r--codebase/grid_connector.php3
2 files changed, 32 insertions, 10 deletions
diff --git a/codebase/data_connector.php b/codebase/data_connector.php
index ca814a9..130d217 100644
--- a/codebase/data_connector.php
+++ b/codebase/data_connector.php
@@ -90,10 +90,16 @@ class DataConnector extends Connector{
public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
if (!$item_type) $item_type="CommonDataItem";
if (!$data_type) $data_type="CommonDataProcessor";
+ $section = array();
if (!$render_type) $render_type="RenderStrategy";
parent::__construct($res,$type,$item_type,$data_type,$render_type);
}
+ protected $sections;
+ public function add_section($name, $string){
+ $this->sections[$name] = $string;
+ }
+
protected function parse_request_mode(){
//do nothing, at least for now
}
@@ -132,11 +138,15 @@ class DataConnector extends Connector{
/*! renders self as xml, starting part
*/
protected function xml_start(){
- return "<data>";
+ $start = "<data>";
+ foreach($this->sections as $k=>$v)
+ $start .= "<".$k.">".$v."</".$k.">\n";
+ return $start;
}
};
class JSONDataConnector extends DataConnector{
+
public function __construct($res,$type=false,$item_type=false,$data_type=false){
if (!$item_type) $item_type="JSONCommonDataItem";
if (!$data_type) $data_type="CommonDataProcessor";
@@ -195,16 +205,27 @@ class JSONDataConnector extends DataConnector{
protected function output_as_xml($res){
$start = "[\n";
- $end = substr($this->render_set($res),0,-2);
- $end .= "\n]";
- $end .= ', "collections": {'.$this->extra_output.'}';
+ $end = substr($this->render_set($res),0,-2)."\n]";
- if ($this->dload){
+ $is_sections = sizeof($this->sections) && $this->is_first_call();
+ if ($this->dload || $is_sections){
$start = "{ \"data\":".$start.$end;
- if ($pos=$this->request->get_start())
- $end = ", \"pos\":".$pos." }";
- else
- $end = ", \"pos\":0, \"total_count\":".$this->sql->get_size($this->request)." }";
+ $end="";
+
+ if ($is_sections){
+ //extra sections
+ foreach($this->sections as $k=>$v)
+ $end.= ", ".$k.":".$v;
+ }
+
+ if ($this->dload){
+ //info for dyn. loadin
+ if ($pos=$this->request->get_start())
+ $end .= ", \"pos\":".$pos." }";
+ else
+ $end .= ", \"pos\":0, \"total_count\":".$this->sql->get_size($this->request)." }";
+ } else
+ $end .= " }";
}
$out = new OutputWriter($start, $end);
$out->set_type("json");
diff --git a/codebase/grid_connector.php b/codebase/grid_connector.php
index cc56cec..a54799e 100644
--- a/codebase/grid_connector.php
+++ b/codebase/grid_connector.php
@@ -267,7 +267,8 @@ class GridDataProcessor extends DataProcessor{
if ($data == "gr_id") return $this->config->id["name"];
$parts=explode("c",$data);
if ($parts[0]=="" && ((string)intval($parts[1]))==$parts[1])
- return $this->config->text[intval($parts[1])]["name"];
+ if (sizeof($this->config->text)>intval($parts[1]))
+ return $this->config->text[intval($parts[1])]["name"];
return $data;
}
}