2018-01-08 21:14:13 +01:00
|
|
|
// Load the localization file
|
|
|
|
var dictionary = {};
|
|
|
|
$.ajax({
|
2020-08-22 17:58:56 +02:00
|
|
|
url: "command/core/load-language?",
|
|
|
|
type: "POST",
|
|
|
|
async: false,
|
|
|
|
data: {
|
|
|
|
module: "wikidata",
|
2018-01-08 21:14:13 +01:00
|
|
|
// lang : lang
|
2020-08-22 17:58:56 +02:00
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
dictionary = data['dictionary'];
|
|
|
|
lang = data['lang'];
|
|
|
|
}
|
2018-01-08 21:14:13 +01:00
|
|
|
});
|
2018-11-21 18:26:10 +01:00
|
|
|
$.i18n().load(dictionary, lang);
|
2018-01-08 21:14:13 +01:00
|
|
|
|
|
|
|
|
2017-09-05 23:49:17 +02:00
|
|
|
ExporterManager.MenuItems.push({});
|
2020-08-22 17:58:56 +02:00
|
|
|
ExporterManager.MenuItems.push({
|
|
|
|
id: "performWikibaseEdits",
|
|
|
|
label: $.i18n('wikibase-extension/wikibase-edits'),
|
|
|
|
click: function () {
|
|
|
|
PerformEditsDialog.checkAndLaunch();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
ExporterManager.MenuItems.push({
|
|
|
|
id: "exportQuickStatements",
|
|
|
|
label: $.i18n('wikibase-extension/qs-file'),
|
|
|
|
click: function () {
|
|
|
|
WikibaseExporterMenuBar.checkSchemaAndExport("quickstatements");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
ExporterManager.MenuItems.push({
|
|
|
|
id: "exportWikibaseSchema",
|
|
|
|
label: $.i18n('wikibase-extension/wikibase-schema'),
|
|
|
|
click: function () {
|
|
|
|
WikibaseExporterMenuBar.checkSchemaAndExport("wikibase-schema");
|
|
|
|
}
|
|
|
|
});
|
2017-09-05 16:26:32 +02:00
|
|
|
|
|
|
|
WikibaseExporterMenuBar = {};
|
|
|
|
|
2020-08-22 17:58:56 +02:00
|
|
|
WikibaseExporterMenuBar.exportTo = function (format) {
|
|
|
|
var targetUrl = null;
|
|
|
|
if (format === "quickstatements") {
|
|
|
|
targetUrl = "statements.txt";
|
|
|
|
} else {
|
|
|
|
targetUrl = "schema.json";
|
|
|
|
}
|
|
|
|
var form = document.createElement("form");
|
|
|
|
$(form).css("display", "none")
|
|
|
|
.attr("method", "post")
|
|
|
|
.attr("action", "command/core/export-rows/" + targetUrl)
|
|
|
|
.attr("target", "openrefine-export-" + format);
|
|
|
|
$('<input />')
|
|
|
|
.attr("name", "engine")
|
|
|
|
.val(JSON.stringify(ui.browsingEngine.getJSON()))
|
|
|
|
.appendTo(form);
|
|
|
|
$('<input />')
|
|
|
|
.attr("name", "project")
|
|
|
|
.val(theProject.id)
|
|
|
|
.appendTo(form);
|
|
|
|
$('<input />')
|
|
|
|
.attr("name", "format")
|
|
|
|
.val(format)
|
|
|
|
.appendTo(form);
|
2017-09-05 16:26:32 +02:00
|
|
|
|
2020-08-22 17:58:56 +02:00
|
|
|
document.body.appendChild(form);
|
2017-09-05 16:26:32 +02:00
|
|
|
|
2020-08-22 17:58:56 +02:00
|
|
|
window.open("about:blank", "openrefine-export");
|
|
|
|
form.submit();
|
2017-09-05 16:26:32 +02:00
|
|
|
|
2020-08-22 17:58:56 +02:00
|
|
|
document.body.removeChild(form);
|
2017-09-05 16:26:32 +02:00
|
|
|
};
|
|
|
|
|
2020-08-22 17:58:56 +02:00
|
|
|
WikibaseExporterMenuBar.checkSchemaAndExport = function (format) {
|
|
|
|
var onSaved = function (callback) {
|
|
|
|
WikibaseExporterMenuBar.exportTo(format);
|
2018-07-13 19:21:38 +02:00
|
|
|
};
|
2020-08-22 17:58:56 +02:00
|
|
|
if (!SchemaAlignment.isSetUp()) {
|
|
|
|
SchemaAlignment.launch(null);
|
|
|
|
} else if (SchemaAlignment._hasUnsavedChanges) {
|
|
|
|
SchemaAlignment._save(onSaved);
|
2018-07-13 19:21:38 +02:00
|
|
|
} else {
|
2020-08-22 17:58:56 +02:00
|
|
|
onSaved();
|
2018-07-13 19:21:38 +02:00
|
|
|
}
|
2020-08-22 17:58:56 +02:00
|
|
|
};
|
2018-07-13 19:21:38 +02:00
|
|
|
|
2017-09-05 16:26:32 +02:00
|
|
|
//extend the column header menu
|
2020-08-22 17:58:56 +02:00
|
|
|
$(function () {
|
2017-09-15 12:51:29 +02:00
|
|
|
|
2020-08-22 17:58:56 +02:00
|
|
|
ExtensionBar.MenuItems.push(
|
|
|
|
{
|
|
|
|
"id": "reconcile",
|
|
|
|
"label": $.i18n('wikibase-extension/menu-label'),
|
|
|
|
"submenu": [
|
|
|
|
{
|
|
|
|
id: "wikidata/select-instance",
|
|
|
|
label: $.i18n('wikibase-extension/select-wikibase-instance'),
|
|
|
|
click: function () {
|
|
|
|
WikibaseDialog.launch()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "wikidata/edit-schema",
|
|
|
|
label: $.i18n('wikibase-extension/edit-wikibase-schema'),
|
|
|
|
click: function () {
|
|
|
|
SchemaAlignment.launch(false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "wikidata/manage-account",
|
|
|
|
label: $.i18n('wikibase-extension/manage-wikibase-account'),
|
|
|
|
click: function () {
|
|
|
|
ManageAccountDialog.checkAndLaunch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: "wikidata/import-schema",
|
|
|
|
label: $.i18n('wikibase-extension/import-wikibase-schema'),
|
|
|
|
click: function () {
|
|
|
|
ImportSchemaDialog.launch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "wikidata/export-schema",
|
|
|
|
label: $.i18n('wikibase-extension/export-schema'),
|
|
|
|
click: function () {
|
|
|
|
WikibaseExporterMenuBar.checkSchemaAndExport("wikibase-schema");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
id: "wikidata/perform-edits",
|
|
|
|
label: $.i18n('wikibase-extension/perform-edits-on-wikibase'),
|
|
|
|
click: function () {
|
|
|
|
PerformEditsDialog.checkAndLaunch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "wikidata/export-qs",
|
|
|
|
label: $.i18n('wikibase-extension/export-to-qs'),
|
|
|
|
click: function () {
|
|
|
|
WikibaseExporterMenuBar.checkSchemaAndExport("quickstatements");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
);
|
2017-09-05 16:26:32 +02:00
|
|
|
});
|
|
|
|
|