2012-12-24 11:03:19 +00:00
function exportData ( ) {
try {
var query = "backend.php?op=pluginhandler&plugin=import_export&method=exportData" ;
if ( dijit . byId ( "dataExportDlg" ) )
dijit . byId ( "dataExportDlg" ) . destroyRecursive ( ) ;
var exported = 0 ;
dialog = new dijit . Dialog ( {
id : "dataExportDlg" ,
title : _ _ ( "Export Data" ) ,
style : "width: 600px" ,
prepare : function ( ) {
2018-12-02 17:56:30 +00:00
Notify . progress ( "Loading, please wait..." ) ;
2012-12-24 11:03:19 +00:00
new Ajax . Request ( "backend.php" , {
2013-04-02 10:29:11 +00:00
parameters : "op=pluginhandler&plugin=import_export&method=exportrun&offset=" + exported ,
2012-12-24 11:03:19 +00:00
onComplete : function ( transport ) {
try {
var rv = JSON . parse ( transport . responseText ) ;
if ( rv && rv . exported != undefined ) {
if ( rv . exported > 0 ) {
exported += rv . exported ;
$ ( "export_status_message" ) . innerHTML =
"<img src='images/indicator_tiny.gif'> " +
"Exported %d articles, please wait..." . replace ( "%d" ,
exported ) ;
setTimeout ( 'dijit.byId("dataExportDlg").prepare()' , 2000 ) ;
} else {
$ ( "export_status_message" ) . innerHTML =
2013-03-24 12:32:03 +00:00
ngettext ( "Finished, exported %d article. You can download the data <a class='visibleLink' href='%u'>here</a>." , "Finished, exported %d articles. You can download the data <a class='visibleLink' href='%u'>here</a>." , exported )
2012-12-24 11:03:19 +00:00
. replace ( "%d" , exported )
. replace ( "%u" , "backend.php?op=pluginhandler&plugin=import_export&subop=exportget" ) ;
exported = 0 ;
}
} else {
$ ( "export_status_message" ) . innerHTML =
"Error occured, could not export data." ;
}
} catch ( e ) {
exception _error ( "exportData" , e , transport . responseText ) ;
}
2018-12-02 17:56:30 +00:00
Notify . close ( ) ;
2012-12-24 11:03:19 +00:00
} } ) ;
} ,
execute : function ( ) {
if ( this . validate ( ) ) {
}
} ,
href : query } ) ;
dialog . show ( ) ;
} catch ( e ) {
exception _error ( "exportData" , e ) ;
}
}
function dataImportComplete ( iframe ) {
try {
if ( ! iframe . contentDocument . body . innerHTML ) return false ;
Element . hide ( iframe ) ;
2018-12-02 17:56:30 +00:00
Notify . close ( ) ;
2012-12-24 11:03:19 +00:00
if ( dijit . byId ( 'dataImportDlg' ) )
dijit . byId ( 'dataImportDlg' ) . destroyRecursive ( ) ;
var content = iframe . contentDocument . body . innerHTML ;
dialog = new dijit . Dialog ( {
id : "dataImportDlg" ,
title : _ _ ( "Data Import" ) ,
style : "width: 600px" ,
onCancel : function ( ) {
} ,
content : content } ) ;
dialog . show ( ) ;
} catch ( e ) {
exception _error ( "dataImportComplete" , e ) ;
}
}
function importData ( ) {
var file = $ ( "export_file" ) ;
if ( file . value . length == 0 ) {
alert ( _ _ ( "Please choose the file first." ) ) ;
return false ;
} else {
2018-12-02 17:56:30 +00:00
Notify . progress ( "Importing, please wait..." , true ) ;
2012-12-24 11:03:19 +00:00
Element . show ( "data_upload_iframe" ) ;
return true ;
}
}