Blame view

php/classes/TimeTableCacheIntervalObject.php 2.36 KB
d18b535d   elena   catalog draft + c...
1
<?php
2f1cd444   Benjamin Renard   Apply convention ...
2
class TimeTableCacheIntervalObject
d18b535d   elena   catalog draft + c...
3
4
5
6
7
8
9
10
{
	protected $id         = -1;
	protected $index      = -1;
	protected $start      = 0;
	protected $stop       = 0;
	protected $isNew      = false;
	protected $isModified = false;

e57cb025   Benjamin Renard   Fix most of error...
11
	function __construct($id, $index = -1) {
d18b535d   elena   catalog draft + c...
12
13
14
15
16
17
18
		$this->id = $id;
		$this->index = $index;
	}

	public function getId() {
		return $this->id;
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
19

d18b535d   elena   catalog draft + c...
20
21
22
	public function getIndex() {
		return $this->index;
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
23

d18b535d   elena   catalog draft + c...
24
25
26
27
28
29
30
	public function setIndex($index) {
		$this->index = $index;
	}

	public function getStartToStamp() {
		return $this->start;
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
31

d18b535d   elena   catalog draft + c...
32
	public function getStartToISO() {
5446b8f0   Benjamin Renard   Move CacheTools i...
33
		return TimeUtils::stamp2iso($this->start);
d18b535d   elena   catalog draft + c...
34
35
36
37
38
	}

	public function setStartFromStamp($stamp) {
		$this->start = $stamp;
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
39

d18b535d   elena   catalog draft + c...
40
	public function setStartFromISO($iso) {
5446b8f0   Benjamin Renard   Move CacheTools i...
41
		$this->start = TimeUtils::iso2stamp($iso);
d18b535d   elena   catalog draft + c...
42
43
44
45
46
	}

	public function getStopToStamp() {
		return $this->stop;
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
47

d18b535d   elena   catalog draft + c...
48
	public function getStopToISO() {
5446b8f0   Benjamin Renard   Move CacheTools i...
49
		return TimeUtils::stamp2iso($this->stop);
d18b535d   elena   catalog draft + c...
50
51
52
53
54
	}

	public function setStopFromStamp($stamp) {
		$this->stop = $stamp;
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
55

d18b535d   elena   catalog draft + c...
56
	public function setStopFromISO($iso) {
5446b8f0   Benjamin Renard   Move CacheTools i...
57
		$this->stop = TimeUtils::iso2stamp($iso);
d18b535d   elena   catalog draft + c...
58
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
59

d18b535d   elena   catalog draft + c...
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	public function getDuration() {
		return ($this->stop-$this->start);
	}

	public function isModified() {
		return $this->isModified;
	}

	public function setIsModified($isModified) {
		$this->isModified = $isModified;
	}

	public function isNew() {
		return $this->isNew;
	}

	public function setIsNew($isNew) {
		$this->isNew = $isNew;
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
79

d18b535d   elena   catalog draft + c...
80
81
82
83
84
85
86
87
88
89
	public function toArray() {
		$result = array(
			"cacheId" => $this->id,
			"start"   => $this->getStartToISO(),
			"stop"    => $this->getStopToISO()
		);
		if ($this->isNew)
			$result["isNew"] = true;
		if ($this->isModified)
			$result["isModified"] = true;
5446b8f0   Benjamin Renard   Move CacheTools i...
90

d18b535d   elena   catalog draft + c...
91
92
93
		return $result;
	}

5446b8f0   Benjamin Renard   Move CacheTools i...
94
95


d18b535d   elena   catalog draft + c...
96
97
98
	public function writeBin($handle) {
		fwrite($handle,pack('L6',$this->id,$this->index,$this->start,$this->stop,$this->isNew,$this->isModified));
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
99

d18b535d   elena   catalog draft + c...
100
101
102
103
104
105
106
107
108
	public function loadBin($handle) {
		$array = unpack('L6int',fread($handle,6*4));
		$this->id         = $array['int1'];
		$this->index      = $array['int2'];
		$this->start      = $array['int3'];
		$this->stop       = $array['int4'];
		$this->isNew      = $array['int5'];
		$this->isModified = $array['int6'];
	}
5446b8f0   Benjamin Renard   Move CacheTools i...
109

d18b535d   elena   catalog draft + c...
110
111
112
113
	public function dump() {
		echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".$this->start.", stop = ".$this->stop.", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL;
	}
}
e57cb025   Benjamin Renard   Fix most of error...
114
?>