summaryrefslogtreecommitdiffstats
path: root/codebase/treegridgroup_connector.php
blob: 9900bba65fc62358e5b8ff4b50635d7d040991d1 (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
44
45
46
47
48
<?php
/*
	@author dhtmlx.com
	@license GPL, see license.txt
*/
require_once("treegrid_connector.php");

class TreeGridGroupConnector extends TreeGridConnector{

	public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
		if (!$render_type) $render_type="GroupRenderStrategy";
		parent::__construct($res,$type,$item_type,$data_type,$render_type);
		$this->event->attach("beforeProcessing", Array($this->render, 'check_id'));
		$this->event->attach("onInit", Array($this->render, 'replace_postfix'));
	}

	/*! if not isset $_GET[id] then it's top level
	 */
	protected function set_relation() {
		if (!isset($_GET['id'])) $this->request->set_relation(false);
	}

	/*! if it's first level then distinct level
	 *  else select by parent
	 */
	protected function get_resource() {
		$resource = null;
		if (isset($_GET['id']))
			$resource = $this->sql->select($this->request);
		else
			$resource = $this->sql->get_variants($this->config->relation_id['name'], $this->request);
		return $resource;
	}


	/*! renders self as  xml, starting part
	*/	
	protected function xml_start(){
		if (isset($_GET['id'])) {
			return "<rows parent='".$_GET['id'].$this->render->get_postfix()."'>";
		} else {
			return "<rows parent='0'>";
		}
	}

}

?>