summaryrefslogtreecommitdiffstats
path: root/codebase/Dhtmlx/Connector/JSONOptionsConnector.php
blob: 1a1b60015857db67bc0cc673c7876f97d645adc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

namespace Dhtmlx\Connector;
/*! wrapper around options collection, used for comboboxes and filters
**/
class JSONOptionsConnector extends JSONDataConnector{
    protected $init_flag=false;//!< used to prevent rendering while initialization
    public function __construct($res,$type=false,$item_type=false,$data_type=false){
        if (!$item_type) $item_type="JSONCommonDataItem";
        if (!$data_type) $data_type=""; //has not sense, options not editable
        parent::__construct($res,$type,$item_type,$data_type);
    }
    /*! render self
        process commands, return data as XML, not output data to stdout, ignore parameters in incoming request
        @return
            data as XML string
    */
    public function render(){
        if (!$this->init_flag){
            $this->init_flag=true;
            return "";
        }
        $res = $this->sql->select($this->request);
        return $this->render_set($res);
    }
}


class JSONDistinctOptionsConnector extends JSONOptionsConnector{
    /*! render self
        process commands, return data as XML, not output data to stdout, ignore parameters in incoming request
        @return
            data as XML string
    */
    public function render(){
        if (!$this->init_flag){
            $this->init_flag=true;
            return "";
        }
        $res = $this->sql->get_variants($this->config->text[0]["db_name"],$this->request);
        return $this->render_set($res);
    }
}