summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php
blob: c962850a46cf82b5ccca7e7167ad1984c6508e38 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php

Prado::using('System.Web.UI.IValidatable');

class Ticket284Component extends TTemplateControl implements IValidatable
{
	private $_isValid;
 	public function onPreRender($param)
 	{
		if (!$this->ShowHours && $this->ShowMinutes)
		{
			throw new TConfigurationException(
				'Invalid OPSDatePicker Config: You cannot specify ShowMinutes="true" while ShowHours="false"'
			);
		}
	}

    public function getDatePicker()
    {
        $this->ensureChildControls();
        return $this->getRegisteredObject('datePicker');
    }
    
    public function getHourPicker()
    {
        $this->ensureChildControls();
        return $this->getRegisteredObject('hourPicker');
    }
    
    public function getMinutePicker()
    {
        $this->ensureChildControls();
        return $this->getRegisteredObject('minutePicker');
    }
	
	public function getShowHours()
	{
		return $this->HourPicker->Visible;
	}
	
	public function setShowHours($value)
	{
		$this->HourPicker->Visible = TPropertyValue::ensureBoolean($value);
	}
	
	public function getShowMinutes()
	{
		return $this->MinutePicker->Visible;
	}
	
	public function setShowMinutes($value)
	{
		$this->MinutePicker->Visible = TPropertyValue::ensureBoolean($value);
	}

	public function getTimeStamp()
	{
		return strtotime($this->Date);
	}
	
	public function setTimeStamp($value)
	{
		$ts = TPropertyValue::ensureInteger($value);
		$this->DatePicker->TimeStamp = $ts;
		$this->HourPicker->SelectedValue = date('H', $ts);
		$this->MinutePicker->SelectedValue = date('i', $ts);
	}
	
	public function getDate()
	{
		$dateStr = $this->DatePicker->Date;
		if ($this->ShowHours){
			$dateStr .= ' '.$this->HourPicker->SelectedValue;
		}
		if ($this->ShowMinutes){
			$dateStr .= ':'.$this->MinutePicker->SelectedValue;
		}
		return $dateStr;
	}
	
	public function setDate($value)
	{
		$dateStr = TPropertyValue::ensureString($value);
		$this->TimeStamp = strtotime($dateStr);
	}
	
	public function getValidationPropertyValue()
	{
		if ($this->DatePicker->Date === ''){
			return '';
		}
		else{
			return $this->TimeStamp;
		}
	}
        public function getIsValid()
        {
            return $this->_isValid;
        }
        public function setIsValid($value)
        {
            $this->_isValid=TPropertyValue::ensureBoolean($value);
        }
}