source: branches/2.2.0.1/calendar/js/dhtmlx/codebase/connector/combo_connector.php @ 4001

Revision 4001, 2.6 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1615 - Componente novo para agenda......................................

Line 
1<?php
2require_once("base_connector.php");
3/*! DataItem class for Combo component
4**/
5class ComboDataItem extends DataItem{
6        private $selected;//!< flag of selected option
7
8        function __construct($data,$config,$index){
9                parent::__construct($data,$config,$index);
10               
11                $this->selected=false;
12        }
13        /*! mark option as selected
14        */
15        function select(){
16                $this->selected=true;
17        }
18        /*! return self as XML string, starting part
19        */
20        function to_xml_start(){
21                if ($this->skip) return "";
22               
23                return "<option ".($this->selected?"selected='true'":"")."value='".$this->get_id()."'><![CDATA[".$this->data[$this->config->text[0]["name"]]."]]>";
24        }
25        /*! return self as XML string, ending part
26        */
27        function to_xml_end(){
28                if ($this->skip) return "";
29                return "</option>";
30        }
31}
32
33/*! Connector for the dhtmlxCombo
34**/
35class ComboConnector extends Connector{
36        private $filter; //!< filtering mask from incoming request
37        private $position; //!< position from incoming request
38
39        /*! constructor
40               
41                Here initilization of all Masters occurs, execution timer initialized
42                @param res
43                        db connection resource
44                @param type
45                        string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
46                @param item_type
47                        name of class, which will be used for item rendering, optional, DataItem will be used by default
48                @param data_type
49                        name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
50        */     
51        public function __construct($res,$type=false,$item_type=false,$data_type=false){
52                if (!$item_type) $item_type="ComboDataItem";
53                parent::__construct($res,$type,$item_type,$data_type);
54        }       
55       
56        //parse GET scoope, all operations with incoming request must be done here
57        function parse_request(){
58                parent::parse_request();
59               
60                if (isset($_GET["pos"])){
61                        if (!$this->dload)      //not critical, so just write a log message
62                                LogMaster::log("Dyn loading request received, but server side was not configured to process dyn. loading. ");
63                        else
64                                $this->request->set_limit($_GET["pos"],$this->dload);
65                }
66                       
67                if (isset($_GET["mask"]))
68                        $this->request->set_filter($this->config->text[0]["name"],$_GET["mask"]."%","LIKE");
69                       
70                LogMaster::log($this->request);
71        }
72       
73       
74        /*! renders self as  xml, starting part
75        */
76        public function xml_start(){
77                if ($this->request->get_start())
78                        return "<complete add='true'>";
79                else
80                        return "<complete>";
81        }
82       
83        /*! renders self as  xml, ending part
84        */
85        public function xml_end(){
86                return "</complete>";
87        }               
88}
89?>
Note: See TracBrowser for help on using the repository browser.