1 | var mcRepository = { |
---|
2 | |
---|
3 | _passwd : "", |
---|
4 | |
---|
5 | get SIDEBAR() { return window.top.document.getElementById("sidebar"); }, |
---|
6 | get BUTTON() { return document.getElementById("mcToolbarRepositorySettingButton"); }, |
---|
7 | get POPUP() { return document.getElementById("mcPopup"); }, |
---|
8 | |
---|
9 | get PATH() { return document.getElementById("mcRepositoryPath"); }, |
---|
10 | get USER() { return document.getElementById("mcRepositoryUser"); }, |
---|
11 | get PASSWD() { return document.getElementById("mcRepositoryPassword"); }, |
---|
12 | get PASSWDL() { return document.getElementById("mcRepositoryPasswordLabel"); }, |
---|
13 | |
---|
14 | get top(){ |
---|
15 | if(window.opener){ |
---|
16 | return window.opener.top; |
---|
17 | }else if(window.top){ |
---|
18 | return window.top; |
---|
19 | }else{ |
---|
20 | return null; |
---|
21 | } |
---|
22 | }, |
---|
23 | get DataSource() { return mcRepository.top.bitsObjectMng.DataSource; }, |
---|
24 | get Common() { return mcRepository.top.bitsObjectMng.Common; }, |
---|
25 | get Database() { return mcRepository.top.bitsObjectMng.Database; }, |
---|
26 | |
---|
27 | get mcMainService(){ |
---|
28 | if(window.opener){ |
---|
29 | return window.opener.mcMainService; |
---|
30 | }else{ |
---|
31 | return mcMainService; |
---|
32 | } |
---|
33 | }, |
---|
34 | |
---|
35 | get isChecked() { |
---|
36 | var aMode = mcRepository.Mode; |
---|
37 | var path = nsPreferences.copyUnicharPref("markingcollection.dbpath."+aMode, ""); |
---|
38 | var user = nsPreferences.copyUnicharPref("markingcollection.repository.user", ""); |
---|
39 | return (path!="" && user != ""); |
---|
40 | }, |
---|
41 | |
---|
42 | get Mode(){ |
---|
43 | return this.Database._repositoryMode; |
---|
44 | }, |
---|
45 | |
---|
46 | ///////////////////////////////////////////////////////////////////// |
---|
47 | init : function(){ |
---|
48 | this._passwd = ""; |
---|
49 | }, |
---|
50 | |
---|
51 | ///////////////////////////////////////////////////////////////////// |
---|
52 | done : function(){ |
---|
53 | }, |
---|
54 | |
---|
55 | ///////////////////////////////////////////////////////////////////// |
---|
56 | onload : function(){ |
---|
57 | var aMode = mcRepository.Mode; |
---|
58 | var path = nsPreferences.copyUnicharPref("markingcollection.dbpath."+aMode, ""); |
---|
59 | mcRepository.PATH.value = path; |
---|
60 | var user = nsPreferences.copyUnicharPref("markingcollection.repository.user", ""); |
---|
61 | mcRepository.USER.value = user; |
---|
62 | }, |
---|
63 | |
---|
64 | ///////////////////////////////////////////////////////////////////// |
---|
65 | onunload : function(){ |
---|
66 | return; |
---|
67 | }, |
---|
68 | |
---|
69 | ///////////////////////////////////////////////////////////////////// |
---|
70 | ondialogaccept : function(){ |
---|
71 | if(mcRepository.PATH.value != ""){ |
---|
72 | var aDir = mcRepository.getNsILocalFile(mcRepository.PATH.value); |
---|
73 | if(!aDir || !aDir.exists()){ |
---|
74 | if(window.arguments[0]) window.arguments[0].accept = false; |
---|
75 | return false; |
---|
76 | } |
---|
77 | } |
---|
78 | var aMode = mcRepository.Mode; |
---|
79 | nsPreferences.setUnicharPref("markingcollection.dbpath."+aMode , mcRepository.PATH.value); |
---|
80 | nsPreferences.setUnicharPref("markingcollection.repository.user", mcRepository.USER.value); |
---|
81 | if(window.arguments[0]) window.arguments[0].accept = true; |
---|
82 | }, |
---|
83 | |
---|
84 | ///////////////////////////////////////////////////////////////////// |
---|
85 | ondialogcancel : function(){ |
---|
86 | if(window.arguments[0]) window.arguments[0].accept = false; |
---|
87 | }, |
---|
88 | |
---|
89 | ///////////////////////////////////////////////////////////////////// |
---|
90 | getNsILocalFile : function(aPath){ |
---|
91 | var aFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); |
---|
92 | if(aFile) aFile.initWithPath(aPath); |
---|
93 | return aFile; |
---|
94 | }, |
---|
95 | |
---|
96 | ///////////////////////////////////////////////////////////////////// |
---|
97 | commandRepositorySetting : function(aEvent){ |
---|
98 | var result = {}; |
---|
99 | window.openDialog("chrome://markingcollection/content/repositorysetting.xul", "", "chrome,centerscreen,modal", result); |
---|
100 | aEvent.stopPropagation(); |
---|
101 | }, |
---|
102 | |
---|
103 | ///////////////////////////////////////////////////////////////////// |
---|
104 | commandRepositoryMerge : function(aEvent){ |
---|
105 | aEvent.stopPropagation(); |
---|
106 | }, |
---|
107 | |
---|
108 | ///////////////////////////////////////////////////////////////////// |
---|
109 | commandChangedRepository : function(aEvent){ |
---|
110 | var checked = this.getRepositoryPath(aEvent); |
---|
111 | if(checked){ |
---|
112 | var aMode = mcRepository.Mode; |
---|
113 | var path = nsPreferences.copyUnicharPref("markingcollection.dbpath."+aMode, ""); |
---|
114 | mcRepository.PATH.value = path; |
---|
115 | } |
---|
116 | aEvent.stopPropagation(); |
---|
117 | }, |
---|
118 | |
---|
119 | ///////////////////////////////////////////////////////////////////// |
---|
120 | getRepositoryPath : function(aEvent){ |
---|
121 | var picker = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); |
---|
122 | var result = false; |
---|
123 | try{ |
---|
124 | var picker_title = mcRepository.mcMainService.STRING.getString("SELECTED_REPOSITORY_FOLDER"); |
---|
125 | picker.init(window, picker_title, picker.modeGetFolder); |
---|
126 | var showResult = picker.show(); |
---|
127 | if(showResult == picker.returnOK){ |
---|
128 | var aMode = mcRepository.Mode; |
---|
129 | nsPreferences.setUnicharPref("markingcollection.dbpath."+aMode, picker.file.path); |
---|
130 | result = true; |
---|
131 | } |
---|
132 | }catch(e){ |
---|
133 | result = false; |
---|
134 | this.Common.alert(e); |
---|
135 | } |
---|
136 | return result; |
---|
137 | }, |
---|
138 | |
---|
139 | ///////////////////////////////////////////////////////////////////// |
---|
140 | popupshowing : function(aEvent){ |
---|
141 | if(aEvent.originalTarget.localName != "popup") return; |
---|
142 | var res = mcTreeHandler.resource; |
---|
143 | if(!res){ aEvent.preventDefault(); return; } |
---|
144 | var type = mcRepository.DataSource.getProperty(res,"type"); |
---|
145 | var dbtype = mcRepository.DataSource.getProperty(res,"dbtype"); |
---|
146 | var contFolderList = []; |
---|
147 | var contItemList = []; |
---|
148 | if(type.indexOf("folder")>=0){ |
---|
149 | contFolderList = mcRepository.DataSource.flattenResources(res, 1, false); |
---|
150 | contItemList = mcRepository.DataSource.flattenResources(res, 2, true); |
---|
151 | } |
---|
152 | try{ |
---|
153 | document.getElementById("mcPopupMergeContents").hidden = type.indexOf("folder")>=0 ; |
---|
154 | document.getElementById("mcPopupMerges").hidden = type=="item"; |
---|
155 | document.getElementById("mcPopupMergeAllFolder").hidden = type=="item" || contFolderList.length<=1 || mcRepository.Database._defaultMode != dbtype; |
---|
156 | document.getElementById("mcPopupMergeFolder").hidden = type!="folder"; |
---|
157 | document.getElementById("mcPopupMergeAllContents").hidden = contItemList.length==0; |
---|
158 | }catch(ex){ |
---|
159 | mcRepository._dump("mcRepository.popupshowing():"+ex); |
---|
160 | } |
---|
161 | }, |
---|
162 | |
---|
163 | ///////////////////////////////////////////////////////////////////// |
---|
164 | lockRepository : function(){ |
---|
165 | try{ |
---|
166 | var path = nsPreferences.copyUnicharPref("markingcollection.dbpath."+this.Mode, ""); |
---|
167 | var user = nsPreferences.copyUnicharPref("markingcollection.repository.user", ""); |
---|
168 | if(path == "") return false; |
---|
169 | var dbLockFile = this.Common.convertPathToFile(path); |
---|
170 | dbLockFile.append(".repository.lock"); |
---|
171 | if(!dbLockFile.exists()){ |
---|
172 | try{ |
---|
173 | dbLockFile.create(dbLockFile.DIRECTORY_TYPE, 0700); |
---|
174 | this.logFile = this.Common.convertPathToFile(path); |
---|
175 | this.logFile.append(".repository.log"); |
---|
176 | if(this.logFile.exists()){ |
---|
177 | this.logContent = this.Common.readFile(this.logFile); |
---|
178 | }else{ |
---|
179 | this.logContent = ""; |
---|
180 | } |
---|
181 | this.logContent += "["+this.Common.getTimeStamp()+"]:LOCK:"+user+"\n"; |
---|
182 | return true; |
---|
183 | }catch(ex2){ |
---|
184 | bitsObjectMng._dump("mcRepository.lockRepository():"+ex2); |
---|
185 | return false; |
---|
186 | } |
---|
187 | } |
---|
188 | }catch(ex){ |
---|
189 | mcRepository._dump("mcRepository.lockRepository():"+ex); |
---|
190 | return false; |
---|
191 | } |
---|
192 | }, |
---|
193 | |
---|
194 | ///////////////////////////////////////////////////////////////////// |
---|
195 | unlockRepository : function(){ |
---|
196 | try{ |
---|
197 | var path = nsPreferences.copyUnicharPref("markingcollection.dbpath."+this.Mode, ""); |
---|
198 | var user = nsPreferences.copyUnicharPref("markingcollection.repository.user", ""); |
---|
199 | if(path == "") return false; |
---|
200 | var dbLockFile = mcRepository.Common.convertPathToFile(path); |
---|
201 | dbLockFile.append(".repository.lock"); |
---|
202 | if(dbLockFile.exists()){ |
---|
203 | try{ |
---|
204 | this.logContent += "["+this.Common.getTimeStamp()+"]:UNLOCK:"+user+"\n"; |
---|
205 | var tmpArr = this.logContent.split("\n"); |
---|
206 | if(tmpArr.length>1000){ |
---|
207 | this.logContent = tmpArr.slice(tmpArr.length-1000-1).join("\n"); |
---|
208 | } |
---|
209 | this.Common.writeFile(this.logFile,this.logContent,"UTF-8"); |
---|
210 | dbLockFile.remove(true); |
---|
211 | }catch(ex2){ |
---|
212 | bitsObjectMng._dump("mcRepository.unlockRepository():"+ex2); |
---|
213 | return false; |
---|
214 | } |
---|
215 | return true; |
---|
216 | }else{ |
---|
217 | return false; |
---|
218 | } |
---|
219 | }catch(ex){ |
---|
220 | mcRepository._dump("mcRepository.unlockRepository():"+ex); |
---|
221 | return false; |
---|
222 | } |
---|
223 | }, |
---|
224 | |
---|
225 | ///////////////////////////////////////////////////////////////////// |
---|
226 | confirm : function(aString){ |
---|
227 | var res = mcTreeHandler.resource; |
---|
228 | if(!res) return false; |
---|
229 | var title = mcRepository.DataSource.getProperty(res,"title"); |
---|
230 | if(!this.Common.confirm(mcRepository.mcMainService.STRING.getString(aString) + "[ " + title + " ]")) return false; |
---|
231 | return true; |
---|
232 | }, |
---|
233 | |
---|
234 | ///////////////////////////////////////////////////////////////////// |
---|
235 | initRepository : function(){ |
---|
236 | if(!this.lockRepository()){ |
---|
237 | var path = nsPreferences.copyUnicharPref("markingcollection.dbpath."+this.Mode, ""); |
---|
238 | if(path != ""){ |
---|
239 | var logFile = this.Common.convertPathToFile(path); |
---|
240 | logFile.append(".repository.log"); |
---|
241 | var logContent = ""; |
---|
242 | if(logFile.exists()){ |
---|
243 | logContent = this.Common.readFile(logFile); |
---|
244 | } |
---|
245 | } |
---|
246 | this.Common.alert(mcRepository.mcMainService.STRING.getString("BUSY_REPOSITORY")); |
---|
247 | return false; |
---|
248 | } |
---|
249 | this.Database.init(this.Mode); |
---|
250 | return true; |
---|
251 | }, |
---|
252 | |
---|
253 | ///////////////////////////////////////////////////////////////////// |
---|
254 | endRepository : function(){ |
---|
255 | this.Database.done(this.Mode); |
---|
256 | this.unlockRepository(); |
---|
257 | return true; |
---|
258 | }, |
---|
259 | |
---|
260 | ///////////////////////////////////////////////////////////////////// |
---|
261 | mergeObjectExec : function(aRes,aParRes,aParTitle){ |
---|
262 | if(!aRes) return false; |
---|
263 | if(!this.title2fid[aParTitle]) return false; |
---|
264 | var pfid = this.DataSource.getProperty(aParRes,"id"); |
---|
265 | var oid = this.DataSource.getProperty(aRes,"id"); |
---|
266 | var dbtype = this.DataSource.getProperty(aRes,"dbtype"); |
---|
267 | var objects = this.Database.getObject({oid:oid,pfid:pfid},dbtype); |
---|
268 | if(!objects) return false; |
---|
269 | var rtnObject = this.existsRepositoryObject(objects[0]); |
---|
270 | if(rtnObject){ |
---|
271 | this.updateRepositoryObject(objects[0],rtnObject,aParTitle); |
---|
272 | }else{ |
---|
273 | this.addRepositoryObject(objects[0],aParTitle); |
---|
274 | } |
---|
275 | return true; |
---|
276 | }, |
---|
277 | |
---|
278 | ///////////////////////////////////////////////////////////////////// |
---|
279 | mergeFolderExec : function(aRes,aParTitle){ |
---|
280 | if(!aRes) return false; |
---|
281 | var fid = this.DataSource.getProperty(aRes,"id"); |
---|
282 | var dbtype = this.DataSource.getProperty(aRes,"dbtype"); |
---|
283 | var title = this.DataSource.getProperty(aRes,"title"); |
---|
284 | var folders = this.Database.getFolderFormID(fid,dbtype); |
---|
285 | if(!folders) return false; |
---|
286 | var aResTitle = aParTitle + "\t" + folders[0].fid_title; |
---|
287 | aResTitle = aResTitle.replace(/^\s*/img,""); |
---|
288 | if(this.title2fid[aResTitle]){ |
---|
289 | this.updateRepositoryFolder(folders[0],aResTitle); |
---|
290 | if(this.confirmRepositoryDeleteFolder(aRes,aParTitle,aResTitle) || this.confirmRepositoryDeleteObject(aRes,aParTitle,aResTitle)) this.getRepository(); |
---|
291 | }else{ |
---|
292 | this.addRepositoryFolder(folders[0],aParTitle); |
---|
293 | } |
---|
294 | var i; |
---|
295 | var contFolderList = this.DataSource.flattenResources(aRes, 1, false); |
---|
296 | for(i=0;i<contFolderList.length;i++){ |
---|
297 | if(contFolderList[i].Value == aRes.Value) continue; |
---|
298 | this.mergeFolderExec(contFolderList[i],aResTitle); |
---|
299 | } |
---|
300 | var contItemList = this.DataSource.flattenResources(aRes, 2, false); |
---|
301 | for(i=0;i<contItemList.length;i++){ |
---|
302 | this.mergeObjectExec(contItemList[i],aRes,aResTitle); |
---|
303 | } |
---|
304 | return true; |
---|
305 | }, |
---|
306 | |
---|
307 | |
---|
308 | ///////////////////////////////////////////////////////////////////// |
---|
309 | merge : function(aEvent){ |
---|
310 | if(!this.isChecked){ |
---|
311 | this.commandRepositorySetting(aEvent); |
---|
312 | if(!this.isChecked) return; |
---|
313 | } |
---|
314 | if(!this.confirm("CONFIRM_REPOSITORY_MERGE")) return; |
---|
315 | this._dump("mcRepository.merge()"); |
---|
316 | if(!this.initRepository()) return false; |
---|
317 | if(!this.getRepository()){ |
---|
318 | this.endRepository(); |
---|
319 | this.Common.alert("err!!"); |
---|
320 | return; |
---|
321 | } |
---|
322 | var res = mcTreeHandler.resource; |
---|
323 | if(!res) return false; |
---|
324 | var parRes = null; |
---|
325 | if(this.DataSource.isContainer(res)){ |
---|
326 | parRes = res; |
---|
327 | }else{ |
---|
328 | parRes = this.DataSource.findParentResource(res); |
---|
329 | } |
---|
330 | var merRes = parRes; |
---|
331 | var merFolder = []; |
---|
332 | var fid = ""; |
---|
333 | while(1){ |
---|
334 | fid = this.DataSource.getProperty(merRes, "id"); |
---|
335 | if(fid == "0") break; |
---|
336 | merFolder.push(merRes); |
---|
337 | merRes = this.DataSource.findParentResource(merRes); |
---|
338 | } |
---|
339 | var parTitle = ""; |
---|
340 | var merTitle = ""; |
---|
341 | if(merFolder.length > 0){ |
---|
342 | var pfid; |
---|
343 | var dbtype; |
---|
344 | var i; |
---|
345 | for(i=merFolder.length-1;i>=0;i--){ |
---|
346 | fid = this.DataSource.getProperty(merFolder[i], "id"); |
---|
347 | dbtype = this.DataSource.getProperty(merFolder[i], "dbtype"); |
---|
348 | var folders = this.Database.getFolderFormID(fid,dbtype); |
---|
349 | if(!folders) continue; |
---|
350 | parTitle = merTitle; |
---|
351 | merTitle += "\t" + folders[0].fid_title; |
---|
352 | merTitle = merTitle.replace(/^\s*/img,""); |
---|
353 | if(this.title2fid[merTitle]) continue; |
---|
354 | this.addRepositoryFolder(folders[0],parTitle); |
---|
355 | } |
---|
356 | } |
---|
357 | if(this.DataSource.isContainer(res)){ |
---|
358 | if(merFolder.length > 0 && parRes.Value == res.Value){ |
---|
359 | this.mergeFolderExec(parRes,parTitle); |
---|
360 | }else{ |
---|
361 | if(this.confirmRepositoryDeleteFolder(parRes,parTitle,merTitle)) this.getRepository(); |
---|
362 | var contFolderList = this.DataSource.flattenResources(parRes, 1, false); |
---|
363 | var i; |
---|
364 | for(i=0;i<contFolderList.length;i++){ |
---|
365 | if(contFolderList[i].Value == parRes.Value) continue; |
---|
366 | this.mergeFolderExec(contFolderList[i],merTitle); |
---|
367 | } |
---|
368 | } |
---|
369 | }else{ |
---|
370 | this.mergeObjectExec(res,parRes,merTitle); |
---|
371 | } |
---|
372 | this.endRepository(); |
---|
373 | }, |
---|
374 | |
---|
375 | ///////////////////////////////////////////////////////////////////// |
---|
376 | importObjectExec : function(aOID,aFID,aImpTitle,dbtype){ |
---|
377 | if(aOID == undefined) return false; |
---|
378 | if(aFID == undefined) return false; |
---|
379 | if(aImpTitle == undefined) return false; |
---|
380 | if(dbtype == undefined) return false; |
---|
381 | if(!this.title2fid[aImpTitle]) return false; |
---|
382 | var objects = this.Database.getObject({oid:aOID,pfid:aFID},dbtype); |
---|
383 | if(!objects) return false; |
---|
384 | var rtnObject = this.existsRepositoryObject(objects[0]); |
---|
385 | if(rtnObject){ |
---|
386 | if(rtnObject.oid_title != objects[0].oid_title || |
---|
387 | rtnObject.oid_property != objects[0].oid_property){ |
---|
388 | var dispTitle = "/" + aImpTitle.replace(/\t+/img,"/") + "/" + objects[0].oid_title; |
---|
389 | if(this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_UPDATE_OBJECT") + "[ " + dispTitle + " ]")){ |
---|
390 | objects[0].oid_title = rtnObject.oid_title; |
---|
391 | objects[0].oid_property = rtnObject.oid_property; |
---|
392 | if(objects[0].dbtype) delete objects[0].dbtype; |
---|
393 | if(objects[0].fid_style) delete objects[0].fid_style; |
---|
394 | this.Database.updateObject(objects[0],dbtype); |
---|
395 | } |
---|
396 | } |
---|
397 | } |
---|
398 | return true; |
---|
399 | }, |
---|
400 | |
---|
401 | ///////////////////////////////////////////////////////////////////// |
---|
402 | importFolderExec : function(aFldID,aFldTitle,aDBType){ |
---|
403 | if(!aFldID) return false; |
---|
404 | if(!this.title2fid[aFldTitle] && aFldTitle != "") return false; |
---|
405 | if(this.title2fid[aFldTitle] && this.om_folder_hash[this.title2fid[aFldTitle]]){ |
---|
406 | var folders = this.Database.getFolderFormID(aFldID,aDBType); |
---|
407 | if(folders){ |
---|
408 | if(this.om_folder_hash[this.title2fid[aFldTitle]].fid_property != folders[0].fid_property || |
---|
409 | this.om_folder_hash[this.title2fid[aFldTitle]].fid_style != folders[0].fid_style){ |
---|
410 | var dispTitle = "/" + aFldTitle.replace(/\t+/img,"/"); |
---|
411 | if(this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_UPDATE_FOLDER") + "[ " + dispTitle + " ]1")){ |
---|
412 | folders[0].fid_property = this.om_folder_hash[this.title2fid[aFldTitle]].fid_property; |
---|
413 | folders[0].fid_style = this.om_folder_hash[this.title2fid[aFldTitle]].fid_style; |
---|
414 | if(folders[0].dbtype) delete folders[0].dbtype; |
---|
415 | this.Database.updateFolder(folders[0],aDBType); |
---|
416 | } |
---|
417 | } |
---|
418 | } |
---|
419 | } |
---|
420 | if(this.pfid2fid[aFldID] && this.pfid2fid[aFldID].length>0){ |
---|
421 | var folders = this.Database.getFolderFormPID(aFldID,aDBType); |
---|
422 | var i,j,fid; |
---|
423 | for(i=0;i<this.pfid2fid[aFldID].length;i++){ |
---|
424 | fid = this.pfid2fid[aFldID][i]; |
---|
425 | var folder = null; |
---|
426 | if(folders){ |
---|
427 | for(j=0;j<folders.length;j++){ |
---|
428 | var fldTitle = aFldTitle + "\t" + folders[j].fid_title; |
---|
429 | fldTitle = fldTitle.replace(/^\s*/img,""); |
---|
430 | if(!this.title2fid[fldTitle] || this.title2fid[fldTitle] != fid) continue; |
---|
431 | folder = folders[j]; |
---|
432 | break; |
---|
433 | } |
---|
434 | } |
---|
435 | if(folder){ |
---|
436 | if(this.om_folder_hash[fid].fid_property != folder.fid_property || |
---|
437 | this.om_folder_hash[fid].fid_style != folder.fid_style){ |
---|
438 | var dispTitle = "/" + aFldTitle.replace(/\t+/img,"/") + "/" + folder.fid_title; |
---|
439 | if(this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_UPDATE_FOLDER") + "[ " + dispTitle + " ]2")){ |
---|
440 | folder.fid_property = this.om_folder_hash[fid].fid_property; |
---|
441 | folder.fid_style = this.om_folder_hash[fid].fid_style; |
---|
442 | if(folder.dbtype) delete folder.dbtype; |
---|
443 | this.Database.updateFolder(folder,aDBType); |
---|
444 | } |
---|
445 | } |
---|
446 | }else{ |
---|
447 | folder = this.om_folder_hash[fid]; |
---|
448 | folder.fid = this.Database._fidIdentify(aDBType,folder.fid); |
---|
449 | folder.pfid = aFldID; |
---|
450 | this.Database.addFolder(folder,aDBType); |
---|
451 | } |
---|
452 | var fldTitle = aFldTitle + "\t" + folder.fid_title; |
---|
453 | fldTitle = fldTitle.replace(/^\s*/img,""); |
---|
454 | this.importFolderExec(folder.fid,fldTitle,aDBType); |
---|
455 | } |
---|
456 | } |
---|
457 | if(this.pfid2oid[aFldID] && this.pfid2oid[aFldID].length>0){ |
---|
458 | var objects = this.Database.getObjectFormPID(aFldID,aDBType); |
---|
459 | var i,j,oid; |
---|
460 | for(i=0;i<this.pfid2oid[aFldID].length;i++){ |
---|
461 | oid = this.pfid2oid[aFldID][i]; |
---|
462 | var object = null; |
---|
463 | if(objects){ |
---|
464 | for(j=0;j<objects.length;j++){ |
---|
465 | |
---|
466 | if( |
---|
467 | this.om_object_hash[oid].doc_url != objects[j].doc_url || |
---|
468 | this.om_object_hash[oid].con_url != objects[j].con_url || |
---|
469 | this.om_object_hash[oid].bgn_dom != objects[j].bgn_dom || |
---|
470 | this.om_object_hash[oid].end_dom != objects[j].end_dom || |
---|
471 | this.om_object_hash[oid].oid_type != objects[j].oid_type |
---|
472 | ) continue; |
---|
473 | |
---|
474 | object = objects[j]; |
---|
475 | break; |
---|
476 | } |
---|
477 | } |
---|
478 | if(object){ |
---|
479 | if(this.om_object_hash[oid].oid_title != object.oid_title || |
---|
480 | this.om_object_hash[oid].oid_property != object.oid_property){ |
---|
481 | var dispTitle = "/" + aFldTitle.replace(/\t+/img,"/") + "/" + object.oid_title; |
---|
482 | if(this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_UPDATE_OBJECT") + "[ " + dispTitle + " ]")){ |
---|
483 | object.oid_title = this.om_object_hash[oid].oid_title; |
---|
484 | object.oid_property = this.om_object_hash[oid].oid_property; |
---|
485 | if(object.dbtype) delete object.dbtype; |
---|
486 | if(object.fid_style) delete object.fid_style; |
---|
487 | this.Database.updateObject(object,aDBType); |
---|
488 | } |
---|
489 | } |
---|
490 | }else{ |
---|
491 | object = this.om_object_hash[oid]; |
---|
492 | object.oid = this.Database._oidIdentify(aDBType,object.oid); |
---|
493 | object.pfid = aFldID; |
---|
494 | this.Database.addObject(object,aDBType); |
---|
495 | var blob = this.Database.getObjectBLOB(oid,this.Mode); |
---|
496 | if(blob && blob.length>0 && blob[0].length>0){ |
---|
497 | this.Database.updateObjectBLOB(oid,blob[0],aDBType); |
---|
498 | } |
---|
499 | } |
---|
500 | } |
---|
501 | } |
---|
502 | return true; |
---|
503 | }, |
---|
504 | |
---|
505 | |
---|
506 | ///////////////////////////////////////////////////////////////////// |
---|
507 | import : function(aEvent){ |
---|
508 | if(!this.isChecked){ |
---|
509 | this.commandRepositorySetting(aEvent); |
---|
510 | if(!this.isChecked) return; |
---|
511 | } |
---|
512 | if(!this.confirm("CONFIRM_REPOSITORY_IMPOER")) return; |
---|
513 | this._dump("mcRepository.import()"); |
---|
514 | if(!this.initRepository()) return false; |
---|
515 | if(!this.getRepository()){ |
---|
516 | this.Common.alert("err!!"); |
---|
517 | return; |
---|
518 | } |
---|
519 | var res = mcTreeHandler.resource; |
---|
520 | if(!res) return false; |
---|
521 | var parRes = null; |
---|
522 | if(this.DataSource.isContainer(res)){ |
---|
523 | parRes = res; |
---|
524 | }else{ |
---|
525 | parRes = this.DataSource.findParentResource(res); |
---|
526 | } |
---|
527 | var impRes = parRes; |
---|
528 | var impFolder = []; |
---|
529 | var fid = ""; |
---|
530 | while(1){ |
---|
531 | fid = this.DataSource.getProperty(impRes, "id"); |
---|
532 | if(fid == "0") break; |
---|
533 | impFolder.push(impRes); |
---|
534 | impRes = this.DataSource.findParentResource(impRes); |
---|
535 | } |
---|
536 | var impTitle = ""; |
---|
537 | if(impFolder.length > 0){ |
---|
538 | var pfid; |
---|
539 | var dbtype; |
---|
540 | var i; |
---|
541 | for(i=impFolder.length-1;i>=0;i--){ |
---|
542 | fid = this.DataSource.getProperty(impFolder[i], "id"); |
---|
543 | dbtype = this.DataSource.getProperty(impFolder[i], "dbtype"); |
---|
544 | var folders = this.Database.getFolderFormID(fid,dbtype); |
---|
545 | if(!folders) continue; |
---|
546 | |
---|
547 | impTitle += "\t" + folders[0].fid_title; |
---|
548 | impTitle = impTitle.replace(/^\s*/img,""); |
---|
549 | } |
---|
550 | } |
---|
551 | if(this.DataSource.isContainer(res)){ |
---|
552 | fid = this.DataSource.getProperty(res, "id"); |
---|
553 | var dbtype = this.DataSource.getProperty(res,"dbtype"); |
---|
554 | this.importFolderExec(fid.toString(),impTitle,dbtype); |
---|
555 | }else{ |
---|
556 | fid = this.DataSource.getProperty(parRes, "id"); |
---|
557 | var oid = this.DataSource.getProperty(res, "id"); |
---|
558 | var dbtype = this.DataSource.getProperty(res,"dbtype"); |
---|
559 | this.importObjectExec(oid.toString(),fid.toString(),impTitle,dbtype); |
---|
560 | } |
---|
561 | this.endRepository(); |
---|
562 | }, |
---|
563 | |
---|
564 | ///////////////////////////////////////////////////////////////////// |
---|
565 | getRepository : function(){ |
---|
566 | try{ |
---|
567 | var aMode = this.Mode; |
---|
568 | if(!this.Database.beginTransaction(aMode)) return false; |
---|
569 | var oSql = 'select * from om_object'; |
---|
570 | var lSql = 'select * from om_link'; |
---|
571 | var fSql = 'select * from om_folder'; |
---|
572 | var i; |
---|
573 | this.om_object_hash = []; |
---|
574 | this.om_folder_hash = []; |
---|
575 | this.oid2pfid = []; |
---|
576 | this.pfid2oid = []; |
---|
577 | this.fid2pfid = []; |
---|
578 | this.pfid2fid = []; |
---|
579 | this.title2fid = []; |
---|
580 | this.fid2title = []; |
---|
581 | this.om_object = this.Database.select(aMode,oSql,false); |
---|
582 | this.om_link = this.Database.select(aMode,lSql,false); |
---|
583 | this.om_folder = this.Database.select(aMode,fSql,false); |
---|
584 | if(this.om_link && this.om_link.length>0){ |
---|
585 | for(i=0;i<this.om_link.length;i++){ |
---|
586 | if(!this.oid2pfid[this.om_link[i].oid.toString()]) this.oid2pfid[this.om_link[i].oid.toString()] = []; |
---|
587 | if(!this.pfid2oid[this.om_link[i].pfid.toString()]) this.pfid2oid[this.om_link[i].pfid.toString()] = []; |
---|
588 | this.oid2pfid[this.om_link[i].oid.toString()].push(this.om_link[i].pfid); |
---|
589 | this.pfid2oid[this.om_link[i].pfid.toString()].push(this.om_link[i].oid); |
---|
590 | } |
---|
591 | } |
---|
592 | if(this.om_object && this.om_object.length>0){ |
---|
593 | for(i=0;i<this.om_object.length;i++){ |
---|
594 | this.om_object_hash[this.om_object[i].oid.toString()] = this.om_object[i]; |
---|
595 | } |
---|
596 | } |
---|
597 | if(this.om_folder && this.om_folder.length>0){ |
---|
598 | for(i=0;i<this.om_folder.length;i++){ |
---|
599 | this.om_folder_hash[this.om_folder[i].fid.toString()] = this.om_folder[i]; |
---|
600 | if(!this.fid2pfid[this.om_folder[i].fid.toString()]) this.fid2pfid[this.om_folder[i].fid.toString()] = []; |
---|
601 | if(!this.pfid2fid[this.om_folder[i].pfid.toString()]) this.pfid2fid[this.om_folder[i].pfid.toString()] = []; |
---|
602 | this.fid2pfid[this.om_folder[i].fid.toString()].push(this.om_folder[i].pfid); |
---|
603 | this.pfid2fid[this.om_folder[i].pfid.toString()].push(this.om_folder[i].fid); |
---|
604 | } |
---|
605 | this.makeTitle2Folder("0"); |
---|
606 | } |
---|
607 | this.Database.endTransaction(aMode); |
---|
608 | return true; |
---|
609 | }catch(ex){ |
---|
610 | try{ this.Database.endTransaction(aMode); }catch(ex2){} |
---|
611 | mcRepository._dump("mcRepository.getRepository():"+ex); |
---|
612 | return false; |
---|
613 | } |
---|
614 | }, |
---|
615 | |
---|
616 | ///////////////////////////////////////////////////////////////////// |
---|
617 | makeTitle2Folder : function(aPFid){ |
---|
618 | var pfid = aPFid.toString(); |
---|
619 | if(!this.pfid2fid[pfid]) return; |
---|
620 | var i; |
---|
621 | for(i=0;i<this.pfid2fid[pfid].length;i++){ |
---|
622 | var title = ""; |
---|
623 | if(this.fid2title[pfid]) title = this.fid2title[pfid] + "\t"; |
---|
624 | var fid = this.pfid2fid[pfid][i].toString(); |
---|
625 | title += this.om_folder_hash[fid].fid_title; |
---|
626 | this.fid2title[fid] = title; |
---|
627 | this.title2fid[title] = fid; |
---|
628 | this.makeTitle2Folder(fid); |
---|
629 | } |
---|
630 | }, |
---|
631 | |
---|
632 | ///////////////////////////////////////////////////////////////////// |
---|
633 | addRepositoryFolder : function(aFolder,aParTitle){ |
---|
634 | try{ |
---|
635 | var aMode = this.Mode; |
---|
636 | var aTitle = aParTitle + "\t" + aFolder.fid_title; |
---|
637 | aTitle = aTitle.replace(/^\s*/img,""); |
---|
638 | var dispTitle = "/" + aTitle.replace(/\t+/img,"/"); |
---|
639 | if(!this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_REPOSITORY_ADD_FOLDER") + "[ " + dispTitle + " ]")) return false; |
---|
640 | if(!this.Database.beginTransaction(aMode)) return false; |
---|
641 | aFolder.fid = this.Database._fidIdentify(aMode,aFolder.fid,false); |
---|
642 | if(this.title2fid[aParTitle]){ |
---|
643 | aFolder.pfid = this.title2fid[aParTitle]; |
---|
644 | }else{ |
---|
645 | aFolder.pfid = "0"; |
---|
646 | } |
---|
647 | if(aFolder.dbtype) delete aFolder.dbtype; |
---|
648 | this.Database.addFolder(aFolder,aMode,false); |
---|
649 | this.om_folder_hash[aFolder.fid.toString()] = aFolder; |
---|
650 | if(!this.fid2pfid[aFolder.fid.toString()]) this.fid2pfid[aFolder.fid.toString()] = []; |
---|
651 | if(!this.pfid2fid[aFolder.pfid.toString()]) this.pfid2fid[aFolder.pfid.toString()] = []; |
---|
652 | this.fid2pfid[aFolder.fid.toString()].push(aFolder.pfid); |
---|
653 | this.pfid2fid[aFolder.pfid.toString()].push(aFolder.fid); |
---|
654 | this.fid2title[aFolder.fid.toString()] = aTitle; |
---|
655 | this.title2fid[aTitle] = aFolder.fid; |
---|
656 | this.Database.endTransaction(aMode); |
---|
657 | return true; |
---|
658 | }catch(ex){ |
---|
659 | try{ this.Database.endTransaction(aMode); }catch(ex2){} |
---|
660 | mcRepository._dump("mcRepository.addRepositoryFolder():"+ex); |
---|
661 | return false; |
---|
662 | } |
---|
663 | }, |
---|
664 | |
---|
665 | ///////////////////////////////////////////////////////////////////// |
---|
666 | updateRepositoryFolder : function(aFolder,aResTitle){ |
---|
667 | try{ |
---|
668 | var aMode = this.Mode; |
---|
669 | if(!this.title2fid[aResTitle]) return false; |
---|
670 | var fid = this.title2fid[aResTitle]; |
---|
671 | if(this.om_folder_hash[fid].fid_property == aFolder.fid_property && this.om_folder_hash[fid].fid_style == aFolder.fid_style) return true; |
---|
672 | var dispTitle = "/" + aResTitle.replace(/\t+/img,"/"); |
---|
673 | if(!this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_REPOSITORY_UPDATE_FOLDER") + "[ " + dispTitle + " ]")) return false; |
---|
674 | if(!this.Database.beginTransaction(aMode)) return false; |
---|
675 | aFolder.fid = this.title2fid[aResTitle]; |
---|
676 | aFolder.pfid = this.om_folder_hash[aFolder.fid.toString()].pfid; |
---|
677 | if(aFolder.dbtype) delete aFolder.dbtype; |
---|
678 | this.Database.updateFolder(aFolder,aMode,false); |
---|
679 | this.om_folder_hash[aFolder.fid.toString()] = aFolder; |
---|
680 | this.Database.endTransaction(aMode); |
---|
681 | return true; |
---|
682 | }catch(ex){ |
---|
683 | try{ this.Database.endTransaction(aMode); }catch(ex2){} |
---|
684 | this._dump("mcRepository.updateRepositoryFolder():"+ex); |
---|
685 | return false; |
---|
686 | } |
---|
687 | }, |
---|
688 | |
---|
689 | ///////////////////////////////////////////////////////////////////// |
---|
690 | confirmRepositoryDeleteFolder : function(parRes,parTitle,merTitle){ |
---|
691 | var rtn = false; |
---|
692 | var contFolderList = this.DataSource.flattenResources(parRes, 1, false); |
---|
693 | var i; |
---|
694 | var usefid = []; |
---|
695 | for(i=0;i<contFolderList.length;i++){ |
---|
696 | if(contFolderList[i].Value == parRes.Value) continue; |
---|
697 | var resTitle = merTitle + "\t" + this.DataSource.getProperty(contFolderList[i], "title"); |
---|
698 | resTitle = resTitle.replace(/^\s*/img,""); |
---|
699 | if(!this.title2fid[resTitle]) continue; |
---|
700 | var fid = this.title2fid[resTitle]; |
---|
701 | usefid[fid.toString()] = fid; |
---|
702 | } |
---|
703 | var pfid = "0"; |
---|
704 | if(this.title2fid[merTitle]) pfid = this.title2fid[merTitle].toString(); |
---|
705 | if(this.pfid2fid[pfid] && this.pfid2fid[pfid].length>0){ |
---|
706 | for(i=0;i<this.pfid2fid[pfid].length;i++){ |
---|
707 | var fid = this.pfid2fid[pfid][i].toString(); |
---|
708 | if(usefid[fid]) continue; |
---|
709 | var msgTitle = "/" + this.fid2title[fid].replace(/\t+/img,"/"); |
---|
710 | if(!this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_REPOSITORY_DELETE_FOLDER") + "[ " + msgTitle + " ]")) continue; |
---|
711 | rtn = this.deleteRepositoryFolder(fid); |
---|
712 | } |
---|
713 | } |
---|
714 | return rtn; |
---|
715 | }, |
---|
716 | |
---|
717 | ///////////////////////////////////////////////////////////////////// |
---|
718 | deleteRepositoryFolder : function(aFID){ |
---|
719 | try{ |
---|
720 | var aMode = this.Mode; |
---|
721 | if(!this.Database.beginTransaction(aMode)) return false; |
---|
722 | this.Database.removeFolder(aFID,aMode,false); |
---|
723 | this.Database.endTransaction(aMode); |
---|
724 | return true; |
---|
725 | }catch(ex){ |
---|
726 | try{ this.Database.endTransaction(aMode); }catch(ex2){} |
---|
727 | mcRepository._dump("mcRepository.deleteRepositoryFolder():"+ex); |
---|
728 | return false; |
---|
729 | } |
---|
730 | }, |
---|
731 | |
---|
732 | ///////////////////////////////////////////////////////////////////// |
---|
733 | existsRepositoryObject : function(aObject,aParTitle){ |
---|
734 | var rtnObject = null; |
---|
735 | var oid; |
---|
736 | for(oid in this.om_object_hash){ |
---|
737 | if(typeof this.om_object_hash[oid] == "function") continue; |
---|
738 | if( |
---|
739 | this.om_object_hash[oid].doc_url != aObject.doc_url || |
---|
740 | this.om_object_hash[oid].con_url != aObject.con_url || |
---|
741 | this.om_object_hash[oid].bgn_dom != aObject.bgn_dom || |
---|
742 | this.om_object_hash[oid].end_dom != aObject.end_dom || |
---|
743 | this.om_object_hash[oid].oid_type != aObject.oid_type |
---|
744 | ) continue; |
---|
745 | rtnObject = this.om_object_hash[oid]; |
---|
746 | break; |
---|
747 | } |
---|
748 | return rtnObject; |
---|
749 | }, |
---|
750 | |
---|
751 | ///////////////////////////////////////////////////////////////////// |
---|
752 | addRepositoryObject : function(aObject,aParTitle){ |
---|
753 | var aMode = this.Mode; |
---|
754 | try{ |
---|
755 | var dispTitle = "/" + aParTitle.replace(/\t+/img,"/") + "/" + aObject.oid_title; |
---|
756 | if(!this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_REPOSITORY_ADD_OBJECT") + "[ " + dispTitle + " ]")) return false; |
---|
757 | if(!this.Database.beginTransaction(aMode)) return false; |
---|
758 | aObject.oid = this.Database._oidIdentify(aMode,aObject.oid,false); |
---|
759 | if(this.title2fid[aParTitle]){ |
---|
760 | aObject.pfid = this.title2fid[aParTitle]; |
---|
761 | }else{ |
---|
762 | aObject.pfid = "0"; |
---|
763 | } |
---|
764 | var blob = this.Database.getObjectBLOB(aObject.oid,aObject.dbtype,false); |
---|
765 | if(aObject.dbtype) delete aObject.dbtype; |
---|
766 | if(aObject.fid_style) delete aObject.fid_style; |
---|
767 | this.Database.addObject(aObject,aMode,false); |
---|
768 | if(blob && blob.length>0 && blob[0].length>0){ |
---|
769 | this.Database.updateObjectBLOB(aObject.oid,blob[0],aMode,false); |
---|
770 | } |
---|
771 | this.om_object_hash[aObject.oid.toString()] = aObject; |
---|
772 | if(!this.oid2pfid[aObject.oid.toString()]) this.oid2pfid[aObject.oid.toString()] = []; |
---|
773 | if(!this.pfid2oid[aObject.pfid.toString()]) this.pfid2oid[aObject.pfid.toString()] = []; |
---|
774 | this.oid2pfid[aObject.oid.toString()].push(aObject.pfid); |
---|
775 | this.pfid2oid[aObject.pfid.toString()].push(aObject.oid); |
---|
776 | this.Database.endTransaction(aMode); |
---|
777 | return true; |
---|
778 | }catch(ex){ |
---|
779 | try{ this.Database.endTransaction(aMode); }catch(ex2){} |
---|
780 | this._dump("mcRepository.addRepositoryObject():"+ex); |
---|
781 | return false; |
---|
782 | } |
---|
783 | }, |
---|
784 | |
---|
785 | ///////////////////////////////////////////////////////////////////// |
---|
786 | updateRepositoryObject : function(aObject,aRObject,aParTitle){ |
---|
787 | var aMode = this.Mode; |
---|
788 | try{ |
---|
789 | var addlink = true; |
---|
790 | var pfid; |
---|
791 | if(this.title2fid[aParTitle]){ |
---|
792 | pfid = this.title2fid[aParTitle]; |
---|
793 | }else{ |
---|
794 | pfid = "0"; |
---|
795 | } |
---|
796 | if(this.oid2pfid[aObject.oid.toString()] && this.oid2pfid[aObject.oid.toString()].length>0){ |
---|
797 | var i; |
---|
798 | for(i=0;i<this.oid2pfid[aObject.oid.toString()].length;i++){ |
---|
799 | if(pfid != this.oid2pfid[aObject.oid.toString()][i]) continue; |
---|
800 | addlink = false; |
---|
801 | break; |
---|
802 | } |
---|
803 | } |
---|
804 | if(!addlink && aRObject.oid_title == aObject.oid_title && aRObject.oid_property == aObject.oid_property) return true; |
---|
805 | var dispTitle = "/" + aParTitle.replace(/\t+/img,"/") + "/" + aObject.oid_title; |
---|
806 | if(addlink){ |
---|
807 | if(!this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_REPOSITORY_ADD_OBJECT") + "[ " + dispTitle + " ]")) return false; |
---|
808 | }else{ |
---|
809 | if(!this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_REPOSITORY_UPDATE_OBJECT") + "[ " + dispTitle + " ]")) return false; |
---|
810 | } |
---|
811 | if(!this.Database.beginTransaction(aMode)) return false; |
---|
812 | if(aRObject.oid_title != aObject.oid_title || aRObject.oid_property != aObject.oid_property){ |
---|
813 | aRObject.oid_title = aObject.oid_title; |
---|
814 | aRObject.oid_property = aObject.oid_property; |
---|
815 | if(aRObject.dbtype) delete aRObject.dbtype; |
---|
816 | if(aRObject.fid_style) delete aRObject.fid_style; |
---|
817 | if(aRObject.pfid) delete aRObject.pfid; |
---|
818 | this.Database.updateObject(aRObject,aMode,false); |
---|
819 | this.om_object_hash[aRObject.oid.toString()] = aRObject; |
---|
820 | } |
---|
821 | if(addlink){ |
---|
822 | this.Database.addLink({oid:aRObject.oid,pfid:pfid,pfid_order:aObject.pfid_order},aMode,false); |
---|
823 | if(!this.oid2pfid[aRObject.oid.toString()]) this.oid2pfid[aRObject.oid.toString()] = []; |
---|
824 | if(!this.pfid2oid[pfid.toString()]) this.pfid2oid[pfid.toString()] = []; |
---|
825 | this.oid2pfid[aRObject.oid.toString()].push(pfid); |
---|
826 | this.pfid2oid[pfid.toString()].push(aRObject.oid); |
---|
827 | } |
---|
828 | this.Database.endTransaction(aMode); |
---|
829 | return true; |
---|
830 | }catch(ex){ |
---|
831 | try{ this.Database.endTransaction(aMode); }catch(ex2){} |
---|
832 | this._dump("mcRepository.updateRepositoryObject():"+ex); |
---|
833 | return false; |
---|
834 | } |
---|
835 | }, |
---|
836 | |
---|
837 | ///////////////////////////////////////////////////////////////////// |
---|
838 | confirmRepositoryDeleteObject : function(parRes,parTitle,merTitle){ |
---|
839 | var rtn = false; |
---|
840 | var contObjectList = this.DataSource.flattenResources(parRes, 2, false); |
---|
841 | var i; |
---|
842 | var usefid = []; |
---|
843 | var pfid = "0"; |
---|
844 | if(this.title2fid[merTitle]) pfid = this.title2fid[merTitle].toString(); |
---|
845 | for(i=0;i<contObjectList.length;i++){ |
---|
846 | var oid = this.DataSource.getProperty(contObjectList[i], "id"); |
---|
847 | var dbtype = this.DataSource.getProperty(contObjectList[i], "dbtype"); |
---|
848 | var objects = this.Database.getObject({oid:oid,pfid:pfid},dbtype); |
---|
849 | if(!objects) continue; |
---|
850 | var object = this.existsRepositoryObject(objects[0],merTitle); |
---|
851 | if(!object) continue; |
---|
852 | usefid[oid.toString()] = object.oid; |
---|
853 | } |
---|
854 | if(this.pfid2oid[pfid] && this.pfid2oid[pfid].length>0){ |
---|
855 | for(i=0;i<this.pfid2oid[pfid].length;i++){ |
---|
856 | var oid = this.pfid2oid[pfid][i].toString(); |
---|
857 | if(usefid[oid]) continue; |
---|
858 | var msgTitle = "/" + this.fid2title[pfid].replace(/\t+/img,"/") + "/" + this.om_object_hash[oid].oid_title; |
---|
859 | if(!this.Common.confirm(this.mcMainService.STRING.getString("CONFIRM_REPOSITORY_DELETE_OBJECT") + "[ " + msgTitle + " ]")) continue; |
---|
860 | rtn = this.deleteRepositoryObject({oid:oid,pfid:pfid}); |
---|
861 | } |
---|
862 | } |
---|
863 | return rtn; |
---|
864 | }, |
---|
865 | |
---|
866 | ///////////////////////////////////////////////////////////////////// |
---|
867 | deleteRepositoryObject : function(aObject){ |
---|
868 | try{ |
---|
869 | var aMode = this.Mode; |
---|
870 | if(!this.Database.beginTransaction(aMode)) return false; |
---|
871 | this.Database.removeObject(aObject,aMode,false); |
---|
872 | this.Database.endTransaction(aMode); |
---|
873 | return true; |
---|
874 | }catch(ex){ |
---|
875 | try{ this.Database.endTransaction(aMode); }catch(ex2){} |
---|
876 | mcRepository._dump("mcRepository.deleteRepositoryObject():"+ex); |
---|
877 | return false; |
---|
878 | } |
---|
879 | }, |
---|
880 | |
---|
881 | |
---|
882 | ///////////////////////////////////////////////////////////////////// |
---|
883 | _dump : function (aString){ |
---|
884 | if(nsPreferences.getBoolPref("scrapparty.debug", false)) window.dump(aString+"\n"); |
---|
885 | }, |
---|
886 | }; |
---|