1 | <?php |
---|
2 | include_once(PSLI_BINGMAPS_CLASS_ENTITY_PHP); |
---|
3 | class Psli_Zone extends Psli_Entity { |
---|
4 | |
---|
5 | private $points; |
---|
6 | |
---|
7 | function clearZone() { |
---|
8 | $this->points = Array(); |
---|
9 | $this->data_changed = true; |
---|
10 | } |
---|
11 | function addPoint ($lat, $lon) { |
---|
12 | $point = Array(); |
---|
13 | $point["lat"] = $lat; |
---|
14 | $point["lon"] = $lon; |
---|
15 | array_push($this->points,$point); |
---|
16 | $this->data_changed = true; |
---|
17 | } |
---|
18 | |
---|
19 | function generateZoneList($template, $block) { |
---|
20 | parent::generateList($template, $block, "zone"); |
---|
21 | } |
---|
22 | |
---|
23 | function delete() { |
---|
24 | if (parent::delete() == true) |
---|
25 | { |
---|
26 | $q = 'DELETE FROM '.PSLI_DATAPOINT_TABLE.' WHERE id_entity = '.$this->id.';'; |
---|
27 | pwg_query($q); |
---|
28 | return true; |
---|
29 | } |
---|
30 | else |
---|
31 | return false; |
---|
32 | } |
---|
33 | |
---|
34 | function save() { |
---|
35 | if (($this->status == true) && ($this->data_changed == true)) |
---|
36 | { |
---|
37 | parent::save(); |
---|
38 | |
---|
39 | $q = 'DELETE FROM '.PSLI_DATAPOINT_TABLE.' WHERE id_entity = '.$this->id.';'; |
---|
40 | pwg_query($q); |
---|
41 | |
---|
42 | foreach ($this->points as $point) |
---|
43 | { |
---|
44 | $q = ' |
---|
45 | INSERT INTO '.PSLI_DATAPOINT_TABLE.' (id_entity, lat, lon) |
---|
46 | VALUES ('.$this->id.', '.$point["lat"].', '.$point["lon"].');'; |
---|
47 | pwg_query($q); |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | function open ($open) { |
---|
53 | if (parent::open($open) == true) |
---|
54 | { |
---|
55 | $this->points = Array(); |
---|
56 | $query_datapoint = ' |
---|
57 | SELECT lat, lon |
---|
58 | FROM '.PSLI_DATAPOINT_TABLE.' |
---|
59 | WHERE id_entity = '.$this->id.' ORDER BY id;' ; |
---|
60 | $result_datapoint = pwg_query($query_datapoint); |
---|
61 | if (pwg_db_num_rows($result_datapoint) > 0) |
---|
62 | { |
---|
63 | while ($row = pwg_db_fetch_assoc($result_datapoint)) |
---|
64 | { |
---|
65 | $point = Array(); |
---|
66 | $point["lat"] = $row['lat']; |
---|
67 | $point["lon"] = $row['lon']; |
---|
68 | array_push($this->points,$point); |
---|
69 | } |
---|
70 | } |
---|
71 | return true; |
---|
72 | } |
---|
73 | else |
---|
74 | return false; |
---|
75 | } |
---|
76 | |
---|
77 | function create() { |
---|
78 | return parent::create("zone"); |
---|
79 | $this->points = Array(); |
---|
80 | } |
---|
81 | |
---|
82 | function __construct () { |
---|
83 | parent::__construct(); |
---|
84 | $this->type = 2; |
---|
85 | } |
---|
86 | |
---|
87 | function getPoints () { |
---|
88 | return $this->points; |
---|
89 | } |
---|
90 | } |
---|
91 | ?> |
---|