summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls/TTriggeredCallback.php
blob: 076166c9736f4e2c1773aa65c95b003955093ffc (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
49
<?php

abstract class TTriggeredCallback extends TCallback
{
	/**
	 * @return string The ID of the server control the trigger is bounded to.
	 */
	public function getControlID()
	{
		return $this->getViewState('ControlID', '');
	}

	/**
	 * @param string The ID of the server control the trigger is bounded to.
	 */
	public function setControlID($value)
	{
		$this->setViewState('ControlID', $value, '');
	}

	/**
	 * @return string target control client ID or html element ID if
	 * control is not found in hierarchy.
	 */
	protected function getTargetControl()
	{
		$id = $this->getControlID();
		if(($control=$this->findControl($id)) instanceof TControl)
			return $control->getClientID();
		if($id==='')
		{
			throw new TConfigurationException(
				'ttriggeredcallback_invalid_controlid', get_class($this));
		}
		return $id;
	}

	/**
	 * @return array list of trigger callback options.
	 */
	protected function getTriggerOptions()
	{
		$options['ID'] = $this->getClientID();
		$options['ControlID'] = $this->getTargetControl();
		return $options;
	}
}

?>