summaryrefslogtreecommitdiffstats
path: root/codebase
diff options
context:
space:
mode:
Diffstat (limited to 'codebase')
-rw-r--r--codebase/base_connector.php18
-rw-r--r--codebase/data_connector.php48
-rw-r--r--codebase/db_common.php20
-rw-r--r--codebase/grid_connector.php3
-rw-r--r--codebase/tree_connector.php3
5 files changed, 79 insertions, 13 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php
index 97e8ac0..ab11cb5 100644
--- a/codebase/base_connector.php
+++ b/codebase/base_connector.php
@@ -445,7 +445,7 @@ class Connector {
public function render_array($data, $id, $fields, $extra=false, $relation_id=false){
$this->configure("-",$id,$fields,$extra,$relation_id);
- $this->sql = new ArrayDBDataWrapper($data, null);
+ $this->sql = new ArrayDBDataWrapper($data, $this->config);
return $this->render();
}
@@ -575,10 +575,14 @@ class Connector {
protected function parse_request(){
//set default dyn. loading params, can be reset in child classes
if ($this->dload)
- $this->request->set_limit(0,$this->dload);
+ $this->request->set_limit(0,$this->dload);
else if ($this->limit)
$this->request->set_limit(0,$this->limit);
-
+
+ if (isset($_GET["posStart"]) && isset($_GET["count"])) {
+ $this->request->set_limit($_GET["posStart"],$_GET["count"]);
+ }
+
$this->parse_request_mode();
if ($this->live_update && ($this->updating || $this->editing)){
@@ -729,6 +733,14 @@ class Connector {
*/
protected function xml_start(){
$attributes = "";
+
+ if ($this->dload){
+ //info for dyn. loadin
+ if ($pos=$this->request->get_start())
+ $attributes .= " pos='".$pos."'";
+ else
+ $attributes .= " total_count='".$this->sql->get_size($this->request)."'";
+ }
foreach($this->attributes as $k=>$v)
$attributes .= " ".$k."='".$v."'";
diff --git a/codebase/data_connector.php b/codebase/data_connector.php
index 2a4e0a3..cf52597 100644
--- a/codebase/data_connector.php
+++ b/codebase/data_connector.php
@@ -145,14 +145,11 @@ class DataConnector extends Connector{
$this->request->set_limit($_GET["start"],$_GET["count"]);
}
-
+
/*! renders self as xml, starting part
*/
protected function xml_start(){
- $start = "<data";
- foreach($this->attributes as $k=>$v)
- $start .= " ".$k."='".$v."'";
- $start.= ">";
+ $start = parent::xml_start();
foreach($this->sections as $k=>$v)
$start .= "<".$k.">".$v."</".$k.">\n";
@@ -418,6 +415,11 @@ class JSONTreeDataConnector extends TreeDataConnector{
$data = array();
$data["parent"] = $this->request->get_relation();
$data["data"] = $result;
+
+ $this->fill_collections();
+ if (!empty($this->options))
+ $data["collections"] = $this->options;
+
$data = json_encode($data);
// return as string
@@ -430,6 +432,42 @@ class JSONTreeDataConnector extends TreeDataConnector{
$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);
+ }
+
}
diff --git a/codebase/db_common.php b/codebase/db_common.php
index 8929631..19365f3 100644
--- a/codebase/db_common.php
+++ b/codebase/db_common.php
@@ -962,7 +962,25 @@ class ArrayDBDataWrapper extends DBDataWrapper{
return $res->data[$res->index++];
}
public function select($sql){
- return new ArrayQueryWrapper($this->connection);
+ if ($this->config->relation_id["db_name"] == "") {
+ if ($sql->get_relation() == "0" || $sql->get_relation() == "") {
+ return new ArrayQueryWrapper($this->connection);
+ } else {
+ return new ArrayQueryWrapper(array());
+ }
+ }
+
+ $relation_id = $this->config->relation_id["db_name"];
+
+ for ($i = 0; $i < count($this->connection); $i++) {
+ $item = $this->connection[$i];
+ if (!isset($item[$relation_id])) continue;
+ if ($item[$relation_id] == $sql->get_relation())
+ $result[] = $item;
+
+ }
+
+ return new ArrayQueryWrapper($result);
}
public function query($sql){
throw new Exception("Not implemented");
diff --git a/codebase/grid_connector.php b/codebase/grid_connector.php
index 1244e0b..9748dee 100644
--- a/codebase/grid_connector.php
+++ b/codebase/grid_connector.php
@@ -145,9 +145,6 @@ class GridConnector extends Connector{
if (isset($_GET["dhx_colls"]))
$this->fill_collections($_GET["dhx_colls"]);
-
- if (isset($_GET["posStart"]) && isset($_GET["count"]))
- $this->request->set_limit($_GET["posStart"],$_GET["count"]);
}
protected function resolve_parameter($name){
if (intval($name).""==$name)
diff --git a/codebase/tree_connector.php b/codebase/tree_connector.php
index d94206a..f8985e2 100644
--- a/codebase/tree_connector.php
+++ b/codebase/tree_connector.php
@@ -198,7 +198,8 @@ class TreeConnector extends Connector{
/*! renders self as xml, ending part
*/
public function xml_end(){
- return "</tree>";
+ $this->fill_collections();
+ return $this->extra_output."</tree>";
}
}