2011-12-21 05:46:39 +01:00
|
|
|
function shareArticle(id) {
|
|
|
|
try {
|
|
|
|
if (dijit.byId("shareArticleDlg"))
|
|
|
|
dijit.byId("shareArticleDlg").destroyRecursive();
|
|
|
|
|
2012-12-23 11:52:18 +01:00
|
|
|
var query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + param_escape(id);
|
2011-12-21 05:46:39 +01:00
|
|
|
|
|
|
|
dialog = new dijit.Dialog({
|
|
|
|
id: "shareArticleDlg",
|
|
|
|
title: __("Share article by URL"),
|
|
|
|
style: "width: 600px",
|
2013-07-11 12:03:40 +02:00
|
|
|
newurl: function() {
|
|
|
|
|
|
|
|
var ok = confirm(__("Generate new share URL for this article?"));
|
|
|
|
|
|
|
|
if (ok) {
|
|
|
|
|
|
|
|
notify_progress("Trying to change URL...", true);
|
|
|
|
|
|
|
|
var query = "op=pluginhandler&plugin=share&method=newkey&id=" + param_escape(id);
|
|
|
|
|
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
|
|
|
var reply = JSON.parse(transport.responseText);
|
|
|
|
var new_link = reply.link;
|
|
|
|
|
|
|
|
var e = $('gen_article_url');
|
|
|
|
|
|
|
|
if (new_link) {
|
|
|
|
|
|
|
|
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
|
|
|
|
"&key=" + new_link);
|
|
|
|
|
|
|
|
e.href = e.href.replace(/\&key=.*$/,
|
|
|
|
"&key=" + new_link);
|
|
|
|
|
|
|
|
new Effect.Highlight(e);
|
|
|
|
|
2013-07-11 14:20:24 +02:00
|
|
|
var img = $("SHARE-IMG-" + id);
|
|
|
|
if (img) img.src = img.src.replace("notshared.png", "share.png");
|
|
|
|
|
2013-07-11 12:03:40 +02:00
|
|
|
notify('');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
notify_error("Could not change URL.");
|
|
|
|
}
|
|
|
|
} });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
unshare: function() {
|
|
|
|
|
|
|
|
var ok = confirm(__("Remove sharing for this article?"));
|
|
|
|
|
|
|
|
if (ok) {
|
|
|
|
|
|
|
|
notify_progress("Trying to unshare...", true);
|
|
|
|
|
|
|
|
var query = "op=pluginhandler&plugin=share&method=unshare&id=" + param_escape(id);
|
|
|
|
|
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
|
|
|
notify("Article unshared.");
|
2013-07-11 14:20:24 +02:00
|
|
|
|
|
|
|
var img = $("SHARE-IMG-" + id);
|
|
|
|
if (img) img.src = img.src.replace("share.png", "notshared.png");
|
|
|
|
|
2013-07-11 12:03:40 +02:00
|
|
|
dialog.hide();
|
|
|
|
} });
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
2011-12-21 05:46:39 +01:00
|
|
|
href: query});
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
|
2013-07-11 14:20:24 +02:00
|
|
|
var img = $("SHARE-IMG-" + id);
|
|
|
|
if (img) img.src = img.src.replace("notshared.png", "share.png");
|
|
|
|
|
2011-12-21 05:46:39 +01:00
|
|
|
} catch (e) {
|
2013-07-11 12:03:40 +02:00
|
|
|
exception_error("shareArticle", e);
|
2011-12-21 05:46:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|