summaryrefslogtreecommitdiffstats
path: root/codebase
diff options
context:
space:
mode:
authorDmitry <dmitry@dhtmlx.com>2012-05-03 18:54:56 +0200
committerDmitry <dmitry@dhtmlx.com>2012-05-03 18:54:56 +0200
commitd8a3192f9e0c09f3bec11eb5a7aa79dee81294c2 (patch)
tree71d635d40812bfa3977114aca4a3b45c58f7b000 /codebase
parent5ae7d2ddf7e980ddc9ad51817f7e694f2efae1e5 (diff)
downloadconnector-php-d8a3192f9e0c09f3bec11eb5a7aa79dee81294c2.zip
connector-php-d8a3192f9e0c09f3bec11eb5a7aa79dee81294c2.tar.gz
connector-php-d8a3192f9e0c09f3bec11eb5a7aa79dee81294c2.tar.bz2
usage collections in scheduler json connector
Diffstat (limited to 'codebase')
-rw-r--r--codebase/scheduler_connector.php49
1 files changed, 45 insertions, 4 deletions
diff --git a/codebase/scheduler_connector.php b/codebase/scheduler_connector.php
index 5b39c25..4ee0bd1 100644
--- a/codebase/scheduler_connector.php
+++ b/codebase/scheduler_connector.php
@@ -31,7 +31,7 @@ class SchedulerDataItem extends DataItem{
class SchedulerConnector extends Connector{
protected $extra_output="";//!< extra info which need to be sent to client side
- private $options=array();//!< hash of OptionsConnector
+ protected $options=array();//!< hash of OptionsConnector
/*! assign options collection to the column
@@ -186,13 +186,54 @@ class JSONSchedulerConnector extends SchedulerConnector {
}
protected function xml_start() {
- return "";
+ return '{ "data":';
}
protected function xml_end() {
- return "";
+ $this->fill_collections();
+ return ', "collections": {'.$this->extra_output.'} }';
}
-
+
+
+ /*! 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(){
+ $options = array();
+ foreach ($this->options as $k=>$v) {
+ $name = $k;
+ $option="\"{$name}\":[";
+ if (!is_string($this->options[$name]))
+ $option.=substr($this->options[$name]->render(),0,-2);
+ 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