1 | <?php
|
---|
2 | require_once("base_connector.php");
|
---|
3 |
|
---|
4 | /*! DataItem class for Scheduler component
|
---|
5 | **/
|
---|
6 | class SchedulerDataItem extends DataItem{
|
---|
7 | /*! return self as XML string
|
---|
8 | */
|
---|
9 | function to_xml(){
|
---|
10 | if ($this->skip) return "";
|
---|
11 |
|
---|
12 | $str="<event id='".$this->get_id()."' >";
|
---|
13 | $str.="<start_date><![CDATA[".$this->data[$this->config->text[0]["name"]]."]]></start_date>";
|
---|
14 | $str.="<end_date><![CDATA[".$this->data[$this->config->text[1]["name"]]."]]></end_date>";
|
---|
15 | $str.="<text><![CDATA[".$this->data[$this->config->text[2]["name"]]."]]></text>";
|
---|
16 | for ($i=3; $i<sizeof($this->config->text); $i++){
|
---|
17 | $extra = $this->config->text[$i]["name"];
|
---|
18 | $str.="<".$extra."><![CDATA[".$this->data[$extra]."]]></".$extra.">";
|
---|
19 | }
|
---|
20 | return $str."</event>";
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 |
|
---|
25 | /*! Connector class for dhtmlxScheduler
|
---|
26 | **/
|
---|
27 | class SchedulerConnector extends Connector{
|
---|
28 |
|
---|
29 | protected $extra_output="";//!< extra info which need to be sent to client side
|
---|
30 | private $options=array();//!< hash of OptionsConnector
|
---|
31 |
|
---|
32 |
|
---|
33 | /*! assign options collection to the column
|
---|
34 |
|
---|
35 | @param name
|
---|
36 | name of the column
|
---|
37 | @param options
|
---|
38 | array or connector object
|
---|
39 | */
|
---|
40 | public function set_options($name,$options){
|
---|
41 | if (is_array($options)){
|
---|
42 | $str="";
|
---|
43 | foreach($options as $k => $v)
|
---|
44 | $str.="<item value='".$this->xmlentities($k)."' label='".$this->xmlentities($v)."' />";
|
---|
45 | $options=$str;
|
---|
46 | }
|
---|
47 | $this->options[$name]=$options;
|
---|
48 | }
|
---|
49 | /*! generates xml description for options collections
|
---|
50 |
|
---|
51 | @param list
|
---|
52 | comma separated list of column names, for which options need to be generated
|
---|
53 | */
|
---|
54 | protected function fill_collections(){
|
---|
55 | foreach ($this->options as $k=>$v) {
|
---|
56 | $name = $k;
|
---|
57 | $this->extra_output.="<coll_options for='{$name}'>";
|
---|
58 | if (!is_string($this->options[$name]))
|
---|
59 | $this->extra_output.=$this->options[$name]->render();
|
---|
60 | else
|
---|
61 | $this->extra_output.=$this->options[$name];
|
---|
62 | $this->extra_output.="</coll_options>";
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | /*! renders self as xml, ending part
|
---|
67 | */
|
---|
68 | protected function xml_end(){
|
---|
69 | $this->fill_collections();
|
---|
70 | return $this->extra_output."</data>";
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | /*! constructor
|
---|
75 |
|
---|
76 | Here initilization of all Masters occurs, execution timer initialized
|
---|
77 | @param res
|
---|
78 | db connection resource
|
---|
79 | @param type
|
---|
80 | string , which hold type of database ( MySQL or Postgre ), optional, instead of short DB name, full name of DataWrapper-based class can be provided
|
---|
81 | @param item_type
|
---|
82 | name of class, which will be used for item rendering, optional, DataItem will be used by default
|
---|
83 | @param data_type
|
---|
84 | name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default.
|
---|
85 | */
|
---|
86 | public function __construct($res,$type=false,$item_type=false,$data_type=false){
|
---|
87 | if (!$item_type) $item_type="SchedulerDataItem";
|
---|
88 | if (!$data_type) $data_type="SchedulerDataProcessor";
|
---|
89 | parent::__construct($res,$type,$item_type,$data_type);
|
---|
90 | }
|
---|
91 |
|
---|
92 | //parse GET scoope, all operations with incoming request must be done here
|
---|
93 | function parse_request(){
|
---|
94 | parent::parse_request();
|
---|
95 | if (count($this->config->text)){
|
---|
96 | if (isset($_GET["to"]))
|
---|
97 | $this->request->set_filter($this->config->text[0]["name"],$_GET["to"],"<");
|
---|
98 | if (isset($_GET["from"]))
|
---|
99 | $this->request->set_filter($this->config->text[1]["name"],$_GET["from"],">");
|
---|
100 | }
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 | /*! DataProcessor class for Scheduler component
|
---|
105 | **/
|
---|
106 | class SchedulerDataProcessor extends DataProcessor{
|
---|
107 | function name_data($data){
|
---|
108 | if ($data=="start_date")
|
---|
109 | return $this->config->text[0]["db_name"];
|
---|
110 | if ($data=="id")
|
---|
111 | return $this->config->id["db_name"];
|
---|
112 | if ($data=="end_date")
|
---|
113 | return $this->config->text[1]["db_name"];
|
---|
114 | if ($data=="text")
|
---|
115 | return $this->config->text[2]["db_name"];
|
---|
116 |
|
---|
117 | return $data;
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 | ?> |
---|