Commit 3ed056c4ffb7e0400ddef359e4dc15bad0167f7f
1 parent
1340621c
Exists in
master
and in
111 other branches
redmine #5278
Showing
2 changed files
with
287 additions
and
307 deletions
Show diff stats
js/app/controllers/AmdaModule.js
... | ... | @@ -6,36 +6,33 @@ |
6 | 6 | * @brief Generic Module controller definition for AMDA project |
7 | 7 | * @author CDA |
8 | 8 | * @version $Id: AmdaModule.js 1761 2013-09-13 13:18:03Z myriam $ |
9 | - * @todo define createWindow method for simple applications here ? | |
10 | - ******************************************************************************* | |
11 | - * FT Id : Date : Name - Description | |
12 | - ******************************************************************************* | |
13 | - * : :08/06/2011: CDA - Migration extjs4 | |
14 | - * : :09/06/2011: elena - Init method for Applications without launchers now is defined here | |
15 | 9 | */ |
16 | 10 | |
17 | 11 | Ext.define('amdaDesktop.AmdaModule', { |
18 | 12 | extend: 'Ext.ux.desktop.Module', |
19 | 13 | |
20 | - /** | |
21 | - * @cfg {String} id | |
22 | - * @required | |
23 | - */ | |
14 | + /** | |
15 | + * @cfg {String} id | |
16 | + * @required | |
17 | + */ | |
24 | 18 | id : '', |
25 | - /** | |
26 | - * @cfg {String} icon | |
27 | - * @required | |
28 | - */ | |
19 | + | |
20 | + /** | |
21 | + * @cfg {String} icon | |
22 | + * @required | |
23 | + */ | |
29 | 24 | icon : '', |
30 | - /** | |
31 | - * @cfg {String} title | |
32 | - * @required | |
33 | - */ | |
25 | + | |
26 | + /** | |
27 | + * @cfg {String} title | |
28 | + * @required | |
29 | + */ | |
34 | 30 | title : '', |
35 | - /** | |
36 | - * @cfg {String} contentId | |
37 | - * @required | |
38 | - */ | |
31 | + | |
32 | + /** | |
33 | + * @cfg {String} contentId | |
34 | + * @required | |
35 | + */ | |
39 | 36 | contentId : '', |
40 | 37 | |
41 | 38 | constructor : function(config){ |
... | ... | @@ -45,24 +42,22 @@ Ext.define('amdaDesktop.AmdaModule', { |
45 | 42 | /** |
46 | 43 | * Module without launcher in Start Menu |
47 | 44 | */ |
48 | - init: function(){ | |
49 | - this.launcher = null; | |
50 | - }, | |
45 | + init: function(){ | |
46 | + this.launcher = null; | |
47 | + }, | |
51 | 48 | |
52 | 49 | /** |
53 | - * Function which return the UI content of this module | |
54 | - * @return {Object} The Ui content class of this module | |
55 | - */ | |
50 | + * Function which return the UI content of this module | |
51 | + * @return {Object} The Ui content class of this module | |
52 | + */ | |
56 | 53 | getUiContent : function (){ |
57 | - return Ext.getCmp(this.contentId); | |
54 | + return Ext.getCmp(this.contentId); | |
58 | 55 | }, |
59 | - | |
60 | 56 | |
61 | 57 | /** |
62 | - * Window Creation method of the Module | |
63 | - */ | |
64 | - createWindow : function (onshowfn) { | |
65 | - | |
58 | + * Window Creation method of the Module | |
59 | + */ | |
60 | + createWindow : function (onshowfn) { | |
66 | 61 | var desktop = this.app.getDesktop(); |
67 | 62 | var win = desktop.getWindow(this.id); |
68 | 63 | |
... | ... | @@ -71,7 +66,7 @@ Ext.define('amdaDesktop.AmdaModule', { |
71 | 66 | id : this.id, |
72 | 67 | title : this.title, |
73 | 68 | width : this.width, |
74 | - minWidth : this.width, | |
69 | + minWidth : this.width, | |
75 | 70 | height : this.height, |
76 | 71 | minHeight: this.height, |
77 | 72 | iconCls : this.icon, |
... | ... | @@ -81,35 +76,30 @@ Ext.define('amdaDesktop.AmdaModule', { |
81 | 76 | stateful : true, |
82 | 77 | stateId : this.id, |
83 | 78 | stateEvents: ['move','show','resize'], |
84 | - tools: [ | |
85 | - { | |
86 | - type:'help', | |
87 | - qtip: this.helpTitle, | |
88 | - scope:this, | |
89 | - handler: function(event, toolEl, panel){ | |
90 | - var me = this; | |
91 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) { | |
92 | - module.createWindow(me.helpFile, me.helpTitle); | |
93 | - }); | |
94 | - } | |
95 | - } | |
96 | - ], | |
97 | - items : [ | |
98 | - { | |
99 | - xtype : this.uiType, | |
100 | - id : this.contentId | |
101 | - } | |
102 | - ] | |
79 | + tools: [{ | |
80 | + type:'help', | |
81 | + qtip: this.helpTitle, | |
82 | + scope:this, | |
83 | + handler: function(event, toolEl, panel){ | |
84 | + var me = this; | |
85 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) { | |
86 | + module.createWindow(me.helpFile, me.helpTitle); | |
87 | + }); | |
88 | + } | |
89 | + }], | |
90 | + items : [{ | |
91 | + xtype : this.uiType, | |
92 | + id : this.contentId | |
93 | + }] | |
103 | 94 | }); |
104 | - } | |
95 | + } | |
105 | 96 | |
106 | - if (onshowfn) | |
97 | + if (onshowfn) { | |
107 | 98 | win.on({ |
108 | - show : onshowfn, | |
109 | - scope : this | |
110 | - }); | |
111 | - | |
99 | + show : onshowfn, | |
100 | + scope : this | |
101 | + }); | |
102 | + } | |
112 | 103 | win.show(); |
113 | 104 | } |
114 | - | |
115 | -}); | |
116 | 105 | \ No newline at end of file |
106 | +}); | |
... | ... |
php/classes/TimeTableMgr.php
... | ... | @@ -38,25 +38,26 @@ class TimeTableMgr extends AmdaObjectMgr |
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | - protected function createDom() { | |
42 | - | |
41 | + protected function createDom() | |
42 | + { | |
43 | 43 | $types = array('timetab' => 'timeTable', 'catalog' => 'catalog'); |
44 | 44 | |
45 | 45 | $rootElement = $this->contentDom->createElement('ws'); |
46 | - foreach ($types as $key => $value) { | |
47 | - $contentId = $value.'-treeRootNode'; | |
48 | - $contentTag = $key.'List'; | |
49 | - $typeElement = $this->contentDom->createElement($contentTag); | |
50 | - $typeElement->setAttribute('xml:id', $contentId); | |
51 | - $rootElement->appendChild($typeElement); | |
46 | + | |
47 | + foreach ($types as $key => $value) { | |
48 | + $contentId = $value.'-treeRootNode'; | |
49 | + $contentTag = $key.'List'; | |
50 | + $typeElement = $this->contentDom->createElement($contentTag); | |
51 | + $typeElement->setAttribute('xml:id', $contentId); | |
52 | + $rootElement->appendChild($typeElement); | |
52 | 53 | } |
53 | 54 | $this->contentDom->appendChild($rootElement); |
54 | 55 | $this->contentDom->save($this->xmlName); |
55 | - } | |
56 | + } | |
56 | 57 | |
57 | -/* | |
58 | -* rename Time Table in id.xml | |
59 | -*/ | |
58 | + /* | |
59 | + * rename Time Table in id.xml | |
60 | + */ | |
60 | 61 | protected function renameInResource($name, $id) |
61 | 62 | { |
62 | 63 | if (!file_exists(USERTTDIR.$id.'.xml')) return false; |
... | ... | @@ -97,6 +98,7 @@ class TimeTableMgr extends AmdaObjectMgr |
97 | 98 | $p -> id = $this -> getObjectIdByName($p->name); |
98 | 99 | $this -> deleteObject($p); |
99 | 100 | } |
101 | + | |
100 | 102 | $this->id = $this->setId(); |
101 | 103 | $this->created = date('Y-m-d\TH:i:s'); |
102 | 104 | if (!$this->id) return array('error' => ID_CREATION_ERROR); |
... | ... | @@ -107,30 +109,30 @@ class TimeTableMgr extends AmdaObjectMgr |
107 | 109 | $rootElement->setAttribute('xml:id',$this->id); |
108 | 110 | |
109 | 111 | foreach ($p as $key => $value) |
110 | - if ($key != 'id' && $key != 'leaf' && $key != 'nodeType' && | |
111 | - $key != 'objName' && $key != 'objFormat' && $key != 'folderId' && $key != 'cacheToken') { | |
112 | - if ($key == 'created') { | |
113 | - $rootElement->appendChild($this->objectDom->createElement($key, $this->created)); | |
114 | - } | |
115 | - /*else if ($key == 'intervals') { | |
116 | - $n_int = 0; | |
117 | - foreach ($value as $item) { | |
118 | - $newInterval = $this->objectDom->createElement('intervals'); | |
119 | - $newInterval->appendChild($this->objectDom->createElement('start', $item->start)); | |
120 | - $newInterval->appendChild($this->objectDom->createElement('stop', $item->stop)); | |
121 | - $rootElement->appendChild($newInterval); | |
122 | - $n_int++; | |
123 | - } | |
124 | - }*/ | |
125 | - // it is catalog | |
126 | - else if ($key == 'parameters') { | |
127 | - $paramsElement = $this->setParamDescription($value); | |
128 | - if ($paramsElement) $rootElement->appendChild($paramsElement); | |
129 | - | |
112 | + if ($key != 'id' && $key != 'leaf' && $key != 'nodeType' && | |
113 | + $key != 'objName' && $key != 'objFormat' && $key != 'folderId' && $key != 'cacheToken') { | |
114 | + if ($key == 'created') { | |
115 | + $rootElement->appendChild($this->objectDom->createElement($key, $this->created)); | |
116 | + } | |
117 | + /*else if ($key == 'intervals') { | |
118 | + $n_int = 0; | |
119 | + foreach ($value as $item) { | |
120 | + $newInterval = $this->objectDom->createElement('intervals'); | |
121 | + $newInterval->appendChild($this->objectDom->createElement('start', $item->start)); | |
122 | + $newInterval->appendChild($this->objectDom->createElement('stop', $item->stop)); | |
123 | + $rootElement->appendChild($newInterval); | |
124 | + $n_int++; | |
125 | + } | |
126 | + }*/ | |
127 | + // it is catalog | |
128 | + else if ($key == 'parameters') { | |
129 | + $paramsElement = $this->setParamDescription($value); | |
130 | + if ($paramsElement) $rootElement->appendChild($paramsElement); | |
131 | + | |
132 | + } | |
133 | + else if ($key != 'intervals') | |
134 | + $rootElement->appendChild($this->objectDom->createElement($key, htmlspecialchars($value))); | |
130 | 135 | } |
131 | - else if ($key != 'intervals') | |
132 | - $rootElement->appendChild($this->objectDom->createElement($key, htmlspecialchars($value))); | |
133 | - } | |
134 | 136 | |
135 | 137 | $this->objectDom->appendChild($rootElement); |
136 | 138 | $this->objectDom->save($this->resFileName); |
... | ... | @@ -150,9 +152,9 @@ class TimeTableMgr extends AmdaObjectMgr |
150 | 152 | return $inter; |
151 | 153 | } |
152 | 154 | |
153 | -/* | |
154 | -* Uploaded text file => convert to array | |
155 | -*/ | |
155 | + /* | |
156 | + * Uploaded text file => convert to array | |
157 | + */ | |
156 | 158 | protected function text2amda($tmp_file, $onlyDescription = false) |
157 | 159 | { |
158 | 160 | $suffix = explode('.', basename($tmp_file)); |
... | ... | @@ -167,33 +169,33 @@ class TimeTableMgr extends AmdaObjectMgr |
167 | 169 | $description=$description."\n".$line; |
168 | 170 | continue; |
169 | 171 | } |
170 | - // check if it is ISO format | |
171 | - if (!isset($isIso)) $isIso = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', trim($date[0])); | |
172 | - if (!$isIso) { | |
173 | - $tempT = strtotime(trim($date[0])); | |
174 | - $startDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); | |
175 | - $tempT = strtotime(trim($date[1])); | |
176 | - $stopDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); | |
177 | - //TODO convert time into non standard formats | |
178 | - // $startDate = DateTime::createFromFormat($timeFormat, trim($date[0]); | |
179 | - // $start = $startDate->format('Y-m-d')."T".$startDate->format('H:i:s'); | |
180 | - // $stopDate = DateTime::createFromFormat($timeFormat, trim($date[1]); | |
181 | - // $stop = $stopDate->format('Y-m-d')."T".$stopDate->format('H:i:s'); | |
182 | - if (!$onlyDescription) | |
183 | - $attributesToReturn['intervals'][] = array('start' => $startDate, 'stop' => $stopDate); | |
172 | + // check if it is ISO format | |
173 | + if (!isset($isIso)) $isIso = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', trim($date[0])); | |
174 | + if (!$isIso) { | |
175 | + $tempT = strtotime(trim($date[0])); | |
176 | + $startDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); | |
177 | + $tempT = strtotime(trim($date[1])); | |
178 | + $stopDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); | |
179 | + //TODO convert time into non standard formats | |
180 | + // $startDate = DateTime::createFromFormat($timeFormat, trim($date[0]); | |
181 | + // $start = $startDate->format('Y-m-d')."T".$startDate->format('H:i:s'); | |
182 | + // $stopDate = DateTime::createFromFormat($timeFormat, trim($date[1]); | |
183 | + // $stop = $stopDate->format('Y-m-d')."T".$stopDate->format('H:i:s'); | |
184 | + if (!$onlyDescription) | |
185 | + $attributesToReturn['intervals'][] = array('start' => $startDate, 'stop' => $stopDate); | |
186 | + } | |
187 | + else { | |
188 | + if (!$onlyDescription) | |
189 | + $attributesToReturn['intervals'][] = array('start' => trim($date[0]), 'stop' => trim($date[1])); | |
190 | + } | |
184 | 191 | } |
185 | - else { | |
186 | - if (!$onlyDescription) | |
187 | - $attributesToReturn['intervals'][] = array('start' => trim($date[0]), 'stop' => trim($date[1])); | |
188 | - } | |
189 | - } | |
190 | - } | |
192 | + } | |
191 | 193 | |
192 | 194 | $attributesToReturn['description'] = $description; |
193 | 195 | $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); |
194 | 196 | $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); |
195 | 197 | |
196 | - return $attributesToReturn; | |
198 | + return $attributesToReturn; | |
197 | 199 | } |
198 | 200 | |
199 | 201 | |
... | ... | @@ -201,35 +203,32 @@ class TimeTableMgr extends AmdaObjectMgr |
201 | 203 | * Uploaded vot TT => convert to array |
202 | 204 | */ |
203 | 205 | protected function vot2amda($tmp_file, $onlyDescription = false) { |
204 | - // Load Time table | |
205 | - $this->objectDom -> load($tmp_file); | |
206 | - $objToGet = $this->objectDom->getElementsByTagName('TABLEDATA')->item(0); | |
207 | - $attributesToReturn['name'] = $tmp_file; | |
208 | - $attributes = $objToGet -> childNodes; | |
209 | - foreach($attributes as $attribute) | |
210 | - if ($attribute->tagName == 'TR') { | |
211 | - $start = $attribute -> getElementsByTagName('TD')->item(0) -> nodeValue; | |
212 | - $stop = $attribute -> getElementsByTagName('TD')->item(1) -> nodeValue; | |
213 | - if (!$onlyDescription) | |
214 | - $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
215 | - } | |
216 | - $suffix = explode('.', basename($tmp_file)); | |
217 | - $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); | |
218 | - $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); | |
219 | - $attributesToReturn['description'] = htmlspecialchars($this->objectDom->getElementsByTagName('DESCRIPTION')->item(0) -> nodeValue); | |
220 | - return($attributesToReturn); | |
206 | + // Load Time table | |
207 | + $this->objectDom -> load($tmp_file); | |
208 | + $objToGet = $this->objectDom->getElementsByTagName('TABLEDATA')->item(0); | |
209 | + $attributesToReturn['name'] = $tmp_file; | |
210 | + $attributes = $objToGet -> childNodes; | |
211 | + foreach($attributes as $attribute) | |
212 | + if ($attribute->tagName == 'TR') { | |
213 | + $start = $attribute -> getElementsByTagName('TD')->item(0) -> nodeValue; | |
214 | + $stop = $attribute -> getElementsByTagName('TD')->item(1) -> nodeValue; | |
215 | + if (!$onlyDescription) | |
216 | + $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
217 | + } | |
218 | + $suffix = explode('.', basename($tmp_file)); | |
219 | + $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); | |
220 | + $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); | |
221 | + $attributesToReturn['description'] = htmlspecialchars($this->objectDom->getElementsByTagName('DESCRIPTION')->item(0) -> nodeValue); | |
222 | + return($attributesToReturn); | |
221 | 223 | } |
222 | 224 | |
223 | - | |
224 | 225 | /***************************************************************** |
225 | 226 | * PUBLIC FUNCTIONS |
226 | 227 | *****************************************************************/ |
227 | - | |
228 | - | |
228 | + | |
229 | 229 | /* |
230 | 230 | * Get Object into Edit |
231 | 231 | */ |
232 | - | |
233 | 232 | function getObject($id, $nodeType) { |
234 | 233 | if (substr($nodeType,0,6) == 'shared') { |
235 | 234 | //Shared object |
... | ... | @@ -268,10 +267,9 @@ class TimeTableMgr extends AmdaObjectMgr |
268 | 267 | return $attributesToReturn; |
269 | 268 | } |
270 | 269 | |
271 | - public function createObject($p, $folder){ | |
272 | - | |
273 | - if ($p -> leaf) | |
274 | - { | |
270 | + public function createObject($p, $folder) | |
271 | + { | |
272 | + if ($p -> leaf){ | |
275 | 273 | $result = $this->createParameter($p, $folder); |
276 | 274 | if ($result['error']) |
277 | 275 | return $result; |
... | ... | @@ -291,8 +289,7 @@ class TimeTableMgr extends AmdaObjectMgr |
291 | 289 | } |
292 | 290 | // else return $this->createFolder($p); |
293 | 291 | //TODO check if this is possible? |
294 | - else return array('error' => 'createFolder should be called from RENAME'); | |
295 | - | |
292 | + else return array('error' => 'createFolder should be called from RENAME'); | |
296 | 293 | } |
297 | 294 | |
298 | 295 | |
... | ... | @@ -328,186 +325,179 @@ class TimeTableMgr extends AmdaObjectMgr |
328 | 325 | } |
329 | 326 | } |
330 | 327 | |
331 | - public function loadIntervalsFromTT($id,$typeTT,$start = NULL, $limit = NULL) | |
332 | - { | |
333 | - | |
334 | - if ($typeTT == 'sharedtimeTable') { | |
335 | - //Shared object | |
336 | - $sharedObjMgr = new SharedObjectsMgr(); | |
337 | - $path = $sharedObjMgr->getDataFilePath('timeTable', $id); | |
338 | - } | |
339 | - else { | |
340 | - $path = USERTTDIR.$id.'.xml'; | |
341 | - } | |
328 | + public function loadIntervalsFromTT($id,$typeTT,$start = NULL, $limit = NULL) | |
329 | + { | |
330 | + if ($typeTT == 'sharedtimeTable') { | |
331 | + //Shared object | |
332 | + $sharedObjMgr = new SharedObjectsMgr(); | |
333 | + $path = $sharedObjMgr->getDataFilePath('timeTable', $id); | |
334 | + } | |
335 | + else { | |
336 | + $path = USERTTDIR.$id.'.xml'; | |
337 | + } | |
342 | 338 | |
343 | 339 | //load intervals from TT id |
344 | - if (!file_exists($path)) | |
345 | - return array('success' => false, 'message' => "Cannot find TT file ".$id); | |
346 | - $this->objectDom -> load($path); | |
347 | - if (!($objToGet = $this->objectDom->getElementById($id))) | |
348 | - return array('success' => false, 'message' => NO_SUCH_ID." ".$id); | |
349 | - | |
350 | - $xpath = new DOMXPath($this->objectDom); | |
351 | - $intervals = $xpath->query('//intervals'); | |
340 | + if (!file_exists($path)) | |
341 | + return array('success' => false, 'message' => "Cannot find TT file ".$id); | |
342 | + | |
343 | + $this->objectDom -> load($path); | |
344 | + if (!($objToGet = $this->objectDom->getElementById($id))) | |
345 | + return array('success' => false, 'message' => NO_SUCH_ID." ".$id); | |
352 | 346 | |
353 | - $result = array(); | |
347 | + $xpath = new DOMXPath($this->objectDom); | |
348 | + $intervals = $xpath->query('//intervals'); | |
349 | + | |
350 | + $result = array(); | |
354 | 351 | |
355 | - if (!isset($start) || !isset($limit)) | |
356 | - { | |
357 | - foreach ($intervals as $interval) | |
358 | - { | |
359 | - $startTime = $interval->getElementsByTagName('start')->item(0)->nodeValue; | |
360 | - $stopTime = $interval->getElementsByTagName('stop')->item(0)->nodeValue; | |
361 | - array_push($result, array('start' => $startTime, 'stop' => $stopTime)); | |
352 | + if (!isset($start) || !isset($limit)) { | |
353 | + foreach ($intervals as $interval) { | |
354 | + $startTime = $interval->getElementsByTagName('start')->item(0)->nodeValue; | |
355 | + $stopTime = $interval->getElementsByTagName('stop')->item(0)->nodeValue; | |
356 | + array_push($result, array('start' => $startTime, 'stop' => $stopTime)); | |
357 | + } | |
358 | + } | |
359 | + else { | |
360 | + for ($i = 0; $i < $limit; ++$i) { | |
361 | + if ($start+$i >= $intervals->length) | |
362 | + break; | |
363 | + $startTime = $intervals->item($start+$i)->getElementsByTagName('start')->item(0)->nodeValue; | |
364 | + $stopTime = $intervals->item($start+$i)->getElementsByTagName('stop')->item(0)->nodeValue; | |
365 | + array_push($result, array('start' => $startTime, 'stop' => $stopTime)); | |
366 | + } | |
362 | 367 | } |
363 | - } | |
364 | - else | |
365 | - { | |
366 | - for ($i = 0; $i < $limit; ++$i) | |
367 | - { | |
368 | - if ($start+$i >= $intervals->length) | |
369 | - break; | |
370 | - $startTime = $intervals->item($start+$i)->getElementsByTagName('start')->item(0)->nodeValue; | |
371 | - $stopTime = $intervals->item($start+$i)->getElementsByTagName('stop')->item(0)->nodeValue; | |
372 | - array_push($result, array('start' => $startTime, 'stop' => $stopTime)); | |
373 | - } | |
374 | - } | |
375 | 368 | |
376 | - return array( | |
369 | + return array( | |
377 | 370 | 'totalCount' => $intervals->length, |
378 | 371 | 'intervals' => $result, |
379 | 372 | 'start' => isset($start) ? $start : 0, |
380 | 373 | 'limit' => isset($limit) ? $limit : 0, |
381 | 374 | 'success' => true |
382 | - ); | |
383 | - | |
384 | - } | |
385 | - | |
386 | - protected function createIntervalElement($interval) { | |
375 | + ); | |
376 | + } | |
387 | 377 | |
388 | - $newInterval = $this->objectDom->createElement('intervals'); | |
389 | - $newInterval->appendChild($this->objectDom->createElement('start',$interval->start)); | |
390 | - $newInterval->appendChild($this->objectDom->createElement('stop',$interval->stop)); | |
391 | - return $newInterval; | |
392 | - } | |
393 | - | |
394 | - public function saveIntervals($id,$intervals,$action) | |
395 | - { | |
396 | - if (substr($id,0,6) == 'shared') { | |
397 | - return array('success' => false, 'message' => "Cannot save shared TimeTable"); | |
378 | + protected function createIntervalElement($interval) | |
379 | + { | |
380 | + $newInterval = $this->objectDom->createElement('intervals'); | |
381 | + $newInterval->appendChild($this->objectDom->createElement('start',$interval->start)); | |
382 | + $newInterval->appendChild($this->objectDom->createElement('stop',$interval->stop)); | |
383 | + return $newInterval; | |
398 | 384 | } |
399 | - else { | |
400 | - $path = USERTTDIR.$id.'.xml'; | |
401 | - } | |
402 | - if (!file_exists($path)) | |
403 | - return array('success' => false, 'message' => "Cannot find TT file ".$id); | |
404 | - $this->objectDom -> load($path); | |
385 | + | |
386 | + public function saveIntervals($id,$intervals,$action) | |
387 | + { | |
388 | + if (substr($id,0,6) == 'shared') { | |
389 | + return array('success' => false, 'message' => "Cannot save shared TimeTable"); | |
390 | + } | |
391 | + else { | |
392 | + $path = USERTTDIR.$id.'.xml'; | |
393 | + } | |
394 | + if (!file_exists($path)) | |
395 | + return array('success' => false, 'message' => "Cannot find TT file ".$id); | |
396 | + $this->objectDom -> load($path); | |
405 | 397 | |
406 | - if (!($objToGet = $this->objectDom->getElementById($id))) | |
407 | - return array('success' => false, 'message' => NO_SUCH_ID." ".$id); | |
398 | + if (!($objToGet = $this->objectDom->getElementById($id))) | |
399 | + return array('success' => false, 'message' => NO_SUCH_ID." ".$id); | |
408 | 400 | |
409 | - //remove old intervals | |
410 | - $crtNode = $objToGet->firstChild; | |
401 | + //remove old intervals | |
402 | + $crtNode = $objToGet->firstChild; | |
411 | 403 | |
412 | - while ($crtNode) | |
413 | - { | |
414 | - if (($crtNode->nodeType != XML_ELEMENT_NODE) || ($crtNode->tagName != 'intervals')) | |
415 | - { | |
416 | - $crtNode = $crtNode->nextSibling; | |
417 | - continue; | |
418 | - } | |
419 | - $toRemove = $crtNode; | |
420 | - $crtNode = $crtNode->nextSibling; | |
421 | - $objToGet->removeChild($toRemove); | |
422 | - unset($toRemove); | |
423 | - } | |
404 | + while ($crtNode) { | |
405 | + if (($crtNode->nodeType != XML_ELEMENT_NODE) || ($crtNode->tagName != 'intervals')) { | |
406 | + $crtNode = $crtNode->nextSibling; | |
407 | + continue; | |
408 | + } | |
409 | + $toRemove = $crtNode; | |
410 | + $crtNode = $crtNode->nextSibling; | |
411 | + $objToGet->removeChild($toRemove); | |
412 | + unset($toRemove); | |
413 | + } | |
424 | 414 | |
425 | - //add new intervals | |
426 | - foreach ($intervals as $interval) | |
427 | - { | |
428 | - $newInterval = $this-> createIntervalElement($interval); | |
429 | - $this->objectDom->documentElement->appendChild($newInterval); | |
430 | - } | |
415 | + //add new intervals | |
416 | + foreach ($intervals as $interval) { | |
417 | + $newInterval = $this-> createIntervalElement($interval); | |
418 | + $this->objectDom->documentElement->appendChild($newInterval); | |
419 | + } | |
431 | 420 | |
432 | - //save modifications | |
433 | - $this->id = $id; | |
434 | - $this->resFileName = USERTTDIR.$this->id.'.xml'; | |
435 | - $this->objectDom->save($this->resFileName); | |
421 | + //save modifications | |
422 | + $this->id = $id; | |
423 | + $this->resFileName = USERTTDIR.$this->id.'.xml'; | |
424 | + $this->objectDom->save($this->resFileName); | |
436 | 425 | |
437 | - unset($this->objectDom); | |
426 | + unset($this->objectDom); | |
438 | 427 | |
439 | - return array('success' => true,'action' => $action, 'nbIntervals' => count($intervals)); | |
440 | - } | |
428 | + return array('success' => true,'action' => $action, 'nbIntervals' => count($intervals)); | |
429 | + } | |
441 | 430 | |
442 | 431 | |
443 | - public function getUploadedObject($name, $format, $onlyDescription = false) { | |
444 | - | |
445 | - if (strpos($name,'.txt') !== false || strpos($name,'.asc') !== false ) { | |
446 | - $attributesToReturn = $this->text2amda(USERTEMPDIR.$name, $onlyDescription); | |
447 | - $attributesToReturn['objName'] = $name; | |
448 | - $attributesToReturn['objFormat'] = $format; | |
449 | - return $attributesToReturn; | |
432 | + public function getUploadedObject($name, $format, $onlyDescription = false) | |
433 | + { | |
434 | + if (strpos($name,'.txt') !== false || strpos($name,'.asc') !== false || strpos($name,'.') == false) { | |
435 | + $attributesToReturn = $this->text2amda(USERTEMPDIR.$name, $onlyDescription); | |
436 | + $attributesToReturn['objName'] = $name; | |
437 | + $attributesToReturn['objFormat'] = $format; | |
438 | + | |
439 | + return $attributesToReturn; | |
450 | 440 | } |
451 | 441 | |
452 | 442 | if ($format == 'VOT') { |
453 | 443 | $attributesToReturn = $this->vot2amda(USERTEMPDIR.$name, $onlyDescription); |
454 | 444 | $attributesToReturn['objName'] = $name; |
455 | 445 | $attributesToReturn['objFormat'] = $format; |
446 | + | |
456 | 447 | return $attributesToReturn; |
457 | 448 | } |
458 | 449 | |
459 | - if (strpos($name,'.xml') !== false) { | |
460 | - $temp = explode('.xml', $name); | |
461 | - $name = $temp[0]; | |
450 | + if (strpos($name,'.xml') !== false) { | |
451 | + $temp = explode('.xml', $name); | |
452 | + $name = $temp[0]; | |
462 | 453 | } |
463 | - | |
464 | - | |
465 | - if (!file_exists(USERTEMPDIR.$name.'.xml')) | |
466 | - return array('error' => 'no such name'); | |
467 | - $this->objectDom -> load(USERTEMPDIR.$name.'.xml'); | |
454 | + | |
455 | + if (!file_exists(USERTEMPDIR.$name.'.xml')) | |
456 | + return array('error' => 'no such name'); | |
457 | + | |
458 | + $this->objectDom->load(USERTEMPDIR.$name.'.xml'); | |
468 | 459 | if (!($objToGet = $this->objectDom->getElementsByTagName('timetable')->item(0)) && |
469 | - !($objToGet = $this->objectDom->getElementsByTagName('TimeTable')->item(0))) | |
470 | - return array('error' => 'no time table'); | |
460 | + !($objToGet = $this->objectDom->getElementsByTagName('TimeTable')->item(0))) | |
461 | + return array('error' => 'no time table'); | |
471 | 462 | |
472 | 463 | $attributes = $objToGet -> childNodes; |
473 | 464 | $attributesToReturn['name'] = $name; |
474 | 465 | $attributesToReturn['objName'] = $name; |
475 | 466 | $attributesToReturn['objFormat'] = $format; |
476 | 467 | |
477 | - foreach($attributes as $attribute) | |
478 | - if($attribute->nodeType == XML_ELEMENT_NODE){ | |
479 | - if ($attribute->tagName == 'intervals') { | |
480 | - $start = $attribute -> getElementsByTagName('start')->item(0) -> nodeValue; | |
481 | - $stop = $attribute -> getElementsByTagName('stop')->item(0) -> nodeValue; | |
482 | - if (!$onlyDescription) | |
483 | - $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
484 | - } | |
485 | - else if ($attribute->tagName == 'Interval') { | |
486 | - $start = $attribute -> getElementsByTagName('Start')->item(0) -> nodeValue; | |
487 | - $stop = $attribute -> getElementsByTagName('Stop')->item(0) -> nodeValue; | |
488 | - if (!$onlyDescription) | |
489 | - $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
490 | - } | |
491 | - else { | |
492 | - switch (strtolower($attribute->tagName)) { | |
493 | - case 'created' : | |
494 | - $attributesToReturn['created'] = $attribute->nodeValue; | |
495 | - break; | |
496 | - case 'chain' : | |
497 | - case 'source' : | |
498 | - $attributesToReturn['description'] = $attribute->nodeValue; | |
499 | - break; | |
500 | - default: break; | |
501 | - } | |
468 | + foreach($attributes as $attribute) { | |
469 | + if($attribute->nodeType == XML_ELEMENT_NODE){ | |
470 | + if ($attribute->tagName == 'intervals') { | |
471 | + $start = $attribute -> getElementsByTagName('start')->item(0) -> nodeValue; | |
472 | + $stop = $attribute -> getElementsByTagName('stop')->item(0) -> nodeValue; | |
473 | + if (!$onlyDescription) | |
474 | + $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
475 | + } | |
476 | + else if ($attribute->tagName == 'Interval') { | |
477 | + $start = $attribute -> getElementsByTagName('Start')->item(0) -> nodeValue; | |
478 | + $stop = $attribute -> getElementsByTagName('Stop')->item(0) -> nodeValue; | |
479 | + if (!$onlyDescription) | |
480 | + $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
481 | + } | |
482 | + else { | |
483 | + switch (strtolower($attribute->tagName)) { | |
484 | + case 'created' : | |
485 | + $attributesToReturn['created'] = $attribute->nodeValue; | |
486 | + break; | |
487 | + case 'chain' : | |
488 | + case 'source' : | |
489 | + $attributesToReturn['description'] = $attribute->nodeValue; | |
490 | + break; | |
491 | + default: break; | |
492 | + } | |
493 | + } | |
502 | 494 | } |
503 | - } | |
495 | + } | |
504 | 496 | return $attributesToReturn; |
505 | 497 | } |
506 | 498 | |
507 | - | |
508 | - | |
509 | -//TODO getObject only!!!! => change DD_Search output | |
510 | - public function getTmpObject($folderId, $name, $onlyDescription = false) { | |
499 | + //TODO getObject only!!!! => change DD_Search output | |
500 | + public function getTmpObject($folderId, $name, $onlyDescription = false) { | |
511 | 501 | $filePath = USERWORKINGDIR.$folderId.'/'.$name.'.xml'; |
512 | 502 | if (!file_exists($filePath)) |
513 | 503 | return array('error' => 'Cannot find result file'); |
... | ... | @@ -552,26 +542,26 @@ class TimeTableMgr extends AmdaObjectMgr |
552 | 542 | return $attributesToReturn; |
553 | 543 | } |
554 | 544 | |
555 | -/* | |
556 | - * merge time tables | |
557 | - */ | |
558 | - public function merge($obj) { | |
559 | - /** | |
560 | - * Array of intervals, used like : | |
561 | - * [{start:'2010-01-01T23:00:00',stop:'2011-01-01T20:00:00'},{start:'2009-01-01T23:00:00',stop:'2010-01-01T20:00:00'}] | |
562 | - * $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
563 | - */ | |
564 | - | |
565 | - $intervals = 0; | |
545 | + /* | |
546 | + * merge time tables | |
547 | + */ | |
548 | + public function merge($obj) { | |
549 | + /** | |
550 | + * Array of intervals, used like : | |
551 | + * [{start:'2010-01-01T23:00:00',stop:'2011-01-01T20:00:00'},{start:'2009-01-01T23:00:00',stop:'2010-01-01T20:00:00'}] | |
552 | + * $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop); | |
553 | + */ | |
554 | + | |
555 | + $intervals = 0; | |
566 | 556 | |
567 | - for ( $i = 0; $i < count($obj->ids); $i++ ) { | |
568 | - $table[$i] = $this->loadIntervalsFromTT($obj->ids[$i]); | |
569 | - for ($j=0; $j < count($table[$i]['intervals']); $j++) { | |
570 | - $interval[$i][$j][0] = $table[$i]['intervals'][$j]['start']; | |
571 | - $interval[$i][$j][1] = $table[$i]['intervals'][$j]['stop']; | |
572 | - } | |
573 | - $intervals += count($interval[$i]); | |
574 | - } | |
557 | + for ( $i = 0; $i < count($obj->ids); $i++ ) { | |
558 | + $table[$i] = $this->loadIntervalsFromTT($obj->ids[$i]); | |
559 | + for ($j=0; $j < count($table[$i]['intervals']); $j++) { | |
560 | + $interval[$i][$j][0] = $table[$i]['intervals'][$j]['start']; | |
561 | + $interval[$i][$j][1] = $table[$i]['intervals'][$j]['stop']; | |
562 | + } | |
563 | + $intervals += count($interval[$i]); | |
564 | + } | |
575 | 565 | if ( $intervals > 10000) set_time_limit(1800); |
576 | 566 | |
577 | 567 | $final = array(); |
... | ... | @@ -717,7 +707,8 @@ class TimeTableMgr extends AmdaObjectMgr |
717 | 707 | return array('valid' => false, 'error' => 'Space character is not allowed'); |
718 | 708 | } |
719 | 709 | |
720 | - public function copyTT($src_path, $dst_path, $newId, $newName, $newDescription = NULL) { | |
710 | + public function copyTT($src_path, $dst_path, $newId, $newName, $newDescription = NULL) | |
711 | + { | |
721 | 712 | if (!file_exists($src_path)) |
722 | 713 | return FALSE; |
723 | 714 | |
... | ... | @@ -771,7 +762,6 @@ class TimeTableMgr extends AmdaObjectMgr |
771 | 762 | chmod($dst_file_path, 0775); |
772 | 763 | |
773 | 764 | return TRUE; |
774 | - } | |
775 | - | |
765 | + } | |
776 | 766 | } |
777 | 767 | ?> |
... | ... |