Commit f60f0bd99883097e5de87187390f8f09ccdf8cc4
1 parent
4607eaa0
Exists in
master
and in
111 other branches
Fix upload from samp notification (#5765)
Showing
5 changed files
with
50 additions
and
42 deletions
Show diff stats
js/app/controllers/UploadModule.js
@@ -40,20 +40,20 @@ Ext.define('amdaDesktop.UploadModule', { | @@ -40,20 +40,20 @@ Ext.define('amdaDesktop.UploadModule', { | ||
40 | var desktop = myDesktopApp.getDesktop(); | 40 | var desktop = myDesktopApp.getDesktop(); |
41 | var win = desktop.getWindow(me.id); | 41 | var win = desktop.getWindow(me.id); |
42 | if (!win) { | 42 | if (!win) { |
43 | - loadMask.show(); | ||
44 | this.createWindow(function (o) | 43 | this.createWindow(function (o) |
45 | { | 44 | { |
46 | win = desktop.getWindow(me.id); | 45 | win = desktop.getWindow(me.id); |
47 | if (win){ | 46 | if (win){ |
48 | - win.items.items[0].forceUpload(url,format); | ||
49 | - win.close(); | 47 | + win.items.items[0].forceUpload(url,format, function() { |
48 | + win.close(); | ||
49 | + }); | ||
50 | } | 50 | } |
51 | - loadMask.hide(); | ||
52 | }); | 51 | }); |
53 | } | 52 | } |
54 | else { | 53 | else { |
55 | - win.items.items[0].forceUpload(url,format); | ||
56 | - win.close(); | 54 | + win.items.items[0].forceUpload(url,format,function() { |
55 | + win.close(); | ||
56 | + }); | ||
57 | } | 57 | } |
58 | } | 58 | } |
59 | }); | 59 | }); |
js/app/views/UploadPanelUI.js
@@ -176,10 +176,20 @@ Ext.define('amdaUI.UploadPanelUI', { | @@ -176,10 +176,20 @@ Ext.define('amdaUI.UploadPanelUI', { | ||
176 | /* | 176 | /* |
177 | * | 177 | * |
178 | */ | 178 | */ |
179 | - forceUpload : function (url,format) | 179 | + forceUpload : function (url,format,onFinish) |
180 | { | 180 | { |
181 | - this.getForm().findField('filesrc').setValue('URL'); | 181 | + var re = /http:\/\/127.0.0.1:/; |
182 | + var isRemoteUrl = !re.test(url); | ||
183 | + | ||
184 | + if (!isRemoteUrl) { | ||
185 | + myDesktopApp.warningMsg("Cannot load data from a local application."); | ||
186 | + if (onFinish) | ||
187 | + onFinish(); | ||
188 | + return; | ||
189 | + } | ||
182 | 190 | ||
191 | + this.getForm().findField('filesrc').setValue('URL'); | ||
192 | + this.getForm().findField('remoteFile').setValue(url); | ||
183 | switch (format) | 193 | switch (format) |
184 | { | 194 | { |
185 | case 'votable' : | 195 | case 'votable' : |
@@ -191,36 +201,39 @@ Ext.define('amdaUI.UploadPanelUI', { | @@ -191,36 +201,39 @@ Ext.define('amdaUI.UploadPanelUI', { | ||
191 | default : | 201 | default : |
192 | //ToDo Error - unknown format | 202 | //ToDo Error - unknown format |
193 | return; | 203 | return; |
194 | - } | ||
195 | - this.getForm().findField('remoteFile').setValue(url); | ||
196 | - | ||
197 | - this.postUpload(); | 204 | + } |
205 | + this.postUpload(onFinish); | ||
198 | }, | 206 | }, |
199 | 207 | ||
200 | /* | 208 | /* |
201 | * | 209 | * |
202 | */ | 210 | */ |
203 | - postUpload : function() | 211 | + postUpload : function(onFinish) |
204 | { | 212 | { |
205 | // 'global' form containing 'partial' forms | 213 | // 'global' form containing 'partial' forms |
206 | var form = this.getForm(); | 214 | var form = this.getForm(); |
207 | 215 | ||
208 | // special validation | 216 | // special validation |
209 | if(this.validate()) | 217 | if(this.validate()) |
210 | - { | 218 | + { |
219 | + loadMask.show(); | ||
211 | form.submit({ | 220 | form.submit({ |
212 | scope: this, | 221 | scope: this, |
213 | url: 'php/uploadFile.php', | 222 | url: 'php/uploadFile.php', |
214 | waitMsg: 'Uploading your file...', | 223 | waitMsg: 'Uploading your file...', |
215 | success: function(form, o) | 224 | success: function(form, o) |
216 | - { | 225 | + { |
226 | + if (onFinish) | ||
227 | + onFinish(); | ||
217 | this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file}); | 228 | this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file}); |
218 | - loadMask.show(); | ||
219 | AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this); | 229 | AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this); |
230 | + loadMask.hide(); | ||
220 | }, | 231 | }, |
221 | failure: function(form, o) | 232 | failure: function(form, o) |
222 | - { | ||
223 | - loadMask.hide(); | 233 | + { |
234 | + if (onFinish) | ||
235 | + onFinish(); | ||
236 | + loadMask.hide(); | ||
224 | myDesktopApp.errorMsg('Error '+o.result.error); | 237 | myDesktopApp.errorMsg('Error '+o.result.error); |
225 | } | 238 | } |
226 | }); | 239 | }); |
js/app/views/UploadUI.js
@@ -55,10 +55,10 @@ Ext.define('amdaUI.UploadUI', { | @@ -55,10 +55,10 @@ Ext.define('amdaUI.UploadUI', { | ||
55 | Ext.apply (this, Ext.apply(arguments, myConf)); | 55 | Ext.apply (this, Ext.apply(arguments, myConf)); |
56 | }, | 56 | }, |
57 | 57 | ||
58 | - forceUpload : function(url,format) | 58 | + forceUpload : function(url,format,onFinish) |
59 | { | 59 | { |
60 | //this.setDisabled(true); | 60 | //this.setDisabled(true); |
61 | - this.items.items[0].items.items[0].forceUpload(url,format); | 61 | + this.items.items[0].items.items[0].forceUpload(url,format,onFinish); |
62 | //this.setDisabled(false); | 62 | //this.setDisabled(false); |
63 | } | 63 | } |
64 | }); | 64 | }); |
php/classes/AmdaObjectMgr.php
@@ -124,7 +124,7 @@ class AmdaObjectMgr | @@ -124,7 +124,7 @@ class AmdaObjectMgr | ||
124 | 124 | ||
125 | foreach($obj as $key => $value) | 125 | foreach($obj as $key => $value) |
126 | { | 126 | { |
127 | - if ($key != 'id' && $key != 'leaf' && $key != 'nodeType' && !is_array($value)) | 127 | + if ($key != 'id' && $key != 'leaf' && $key != 'nodeType' && !is_array($value) && !is_object($value)) |
128 | { | 128 | { |
129 | $node = $this->objectDom->createElement($key,htmlspecialchars($value)); | 129 | $node = $this->objectDom->createElement($key,htmlspecialchars($value)); |
130 | $root -> appendChild($node); | 130 | $root -> appendChild($node); |
php/classes/VOTableMgr.php
@@ -241,16 +241,9 @@ class VOTableMgr { | @@ -241,16 +241,9 @@ class VOTableMgr { | ||
241 | 241 | ||
242 | public function getFirstTR() | 242 | public function getFirstTR() |
243 | { | 243 | { |
244 | - if (!$this->xp) | ||
245 | - return NULL; | ||
246 | - | ||
247 | - /*$trs = $this->xp->query($this->queryTR()); | ||
248 | - | ||
249 | - if ($trs->length < 1) | 244 | + if (!isset($this->xp)) |
250 | return NULL; | 245 | return NULL; |
251 | 246 | ||
252 | - return $trs->item(0);*/ | ||
253 | - | ||
254 | $tabledatas = $this->xp->query($this->queryTableData()); | 247 | $tabledatas = $this->xp->query($this->queryTableData()); |
255 | 248 | ||
256 | if ($tabledatas->length < 1) | 249 | if ($tabledatas->length < 1) |
@@ -259,21 +252,23 @@ class VOTableMgr { | @@ -259,21 +252,23 @@ class VOTableMgr { | ||
259 | $tabledata = $tabledatas->item(0); | 252 | $tabledata = $tabledatas->item(0); |
260 | 253 | ||
261 | $node = $tabledata->firstChild; | 254 | $node = $tabledata->firstChild; |
255 | + if (!isset($node)) | ||
256 | + return NULL; | ||
262 | 257 | ||
263 | - while($node && ($node->nodeType != 1) && ($node->nodeName != "TR")) | ||
264 | - $node = $node->nextSibling; | 258 | + if (($node->nodeType != XML_ELEMENT_NODE) || ($node->nodeName != "TR")) |
259 | + return $this->getNextTR($node); | ||
265 | 260 | ||
266 | - return $node; | 261 | + return $node; |
267 | } | 262 | } |
268 | 263 | ||
269 | public function getNextTR($tr) | 264 | public function getNextTR($tr) |
270 | { | 265 | { |
271 | - if (!$this->xp) | 266 | + if (!isset($this->xp) || !isset($tr) || !isset($tr->nextSibling)) |
272 | return NULL; | 267 | return NULL; |
273 | 268 | ||
274 | - while($tr->nextSibling && ($tr->nextSibling->nodeType != 1) && ($node->nodeName != "TR")) | ||
275 | - $tr = $tr->nextSibling; | ||
276 | - return $tr->nextSibling; | 269 | + if (($tr->nextSibling->nodeType != XML_ELEMENT_NODE) || ($tr->nextSibling->nodeName != "TR")) |
270 | + return $this->getNextTR($tr->nextSibling); | ||
271 | + return $tr->nextSibling; | ||
277 | } | 272 | } |
278 | 273 | ||
279 | public function getTDValueByFieldIndex($tr,$field_index) | 274 | public function getTDValueByFieldIndex($tr,$field_index) |
@@ -392,24 +387,24 @@ class VOTableMgr { | @@ -392,24 +387,24 @@ class VOTableMgr { | ||
392 | 387 | ||
393 | $tr = $this->getFirstTR(); | 388 | $tr = $this->getFirstTR(); |
394 | 389 | ||
395 | - if (!$tr) | 390 | + if (!isset($tr)) |
396 | return '0 0'; | 391 | return '0 0'; |
397 | 392 | ||
398 | $start = $this->getTDValueByFieldIndex($tr,$timeIndex); | 393 | $start = $this->getTDValueByFieldIndex($tr,$timeIndex); |
399 | 394 | ||
400 | $stop = $start; | 395 | $stop = $start; |
401 | - while ($tr) | 396 | + while (isset($tr)) |
402 | { | 397 | { |
403 | $stop = $this->getTDValueByFieldIndex($tr,$timeIndex); | 398 | $stop = $this->getTDValueByFieldIndex($tr,$timeIndex); |
404 | $tr = $this->getNextTR($tr); | 399 | $tr = $this->getNextTR($tr); |
405 | } | 400 | } |
406 | 401 | ||
407 | - if (!$start) | 402 | + if (!isset($start)) |
408 | $start = 0; | 403 | $start = 0; |
409 | else | 404 | else |
410 | $start = strtotime($start); | 405 | $start = strtotime($start); |
411 | 406 | ||
412 | - if (!$stop) | 407 | + if (!isset($stop)) |
413 | $stop = 0; | 408 | $stop = 0; |
414 | else | 409 | else |
415 | $stop = strtotime($stop); | 410 | $stop = strtotime($stop); |
@@ -663,11 +658,11 @@ class VOTableMgr { | @@ -663,11 +658,11 @@ class VOTableMgr { | ||
663 | "maxSampling" => 0); | 658 | "maxSampling" => 0); |
664 | 659 | ||
665 | $prevTime = 0; | 660 | $prevTime = 0; |
666 | - while ($tr) | 661 | + while (isset($tr)) |
667 | { | 662 | { |
668 | $time = $this->getTDValueByFieldIndex($tr,$timeIndex); | 663 | $time = $this->getTDValueByFieldIndex($tr,$timeIndex); |
669 | 664 | ||
670 | - if ($time) | 665 | + if (isset($time)) |
671 | { | 666 | { |
672 | $time = strtotime($time); | 667 | $time = strtotime($time); |
673 | if (($prevTime > 0) && ($time-$prevTime > 0)) | 668 | if (($prevTime > 0) && ($time-$prevTime > 0)) |