From ae00c9ca481a3ed6e4c2ba55d766f28f1a3e560c Mon Sep 17 00:00:00 2001 From: Matthieu Marcillaud <marcimat@rezo.net> Date: Wed, 3 Jan 2018 10:30:11 +0000 Subject: [PATCH] =?UTF-8?q?Nettoyages=20:=20on=20enl=C3=A8ve=20les=20?= =?UTF-8?q?=C3=A9l=C3=A9ments=20relatifs=20=C3=A0=20'transformer=5Fxml'=20?= =?UTF-8?q?qui=20servaient=20=C3=A0=20voir=20les=20requ=C3=AAtes=20ajax,?= =?UTF-8?q?=20=C3=A0=20une=20=C3=A9poque=20o=C3=B9=20les=20navigateurs=20n?= =?UTF-8?q?=E2=80=99avaient=20pas=20d=E2=80=99inspecteurs=20pour=20observe?= =?UTF-8?q?r=20tout=20=C3=A7a.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/actions.php | 18 +++++-------- ecrire/inc/headers.php | 4 --- ecrire/index.php | 8 ------ prive/javascript/layer.js | 54 +++++++++++---------------------------- 4 files changed, 21 insertions(+), 63 deletions(-) diff --git a/ecrire/inc/actions.php b/ecrire/inc/actions.php index 7abfc1e092..5168e7158f 100644 --- a/ecrire/inc/actions.php +++ b/ecrire/inc/actions.php @@ -136,17 +136,11 @@ function ajax_retour($corps, $content_type = null) { ) { $e = erreur_squelette(); } - if (isset($GLOBALS['transformer_xml']) or (isset($GLOBALS['exec']) and $GLOBALS['exec'] == 'valider_xml')) { - $debut = _DOCTYPE_ECRIRE - . '<html><head><title>Debug Spip Ajax</title></head>' - . "<body><div>\n\n" - . "<!-- %%%%%%%%%%%%%%%%%%% Ajax %%%%%%%%%%%%%%%%%%% -->\n"; - $fin = '</div></body></html>'; - } else { - $c = $GLOBALS['meta']['charset']; - header('Content-Type: ' . $content_type . '; charset=' . $c); - $debut = (($xml and strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : ''); - $fin = ''; - } + + $c = $GLOBALS['meta']['charset']; + header('Content-Type: ' . $content_type . '; charset=' . $c); + $debut = (($xml and strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : ''); + $fin = ''; + echo $debut, $corps, $fin, $e; } diff --git a/ecrire/inc/headers.php b/ecrire/inc/headers.php index 8b18633b80..3ab091b873 100644 --- a/ecrire/inc/headers.php +++ b/ecrire/inc/headers.php @@ -49,10 +49,6 @@ function redirige_par_entete($url, $equiv = '', $status = 302) { $url = url_absolue($url); } - if ($x = _request('transformer_xml')) { - $url = parametre_url($url, 'transformer_xml', $x, '&'); - } - if (defined('_AJAX') and _AJAX) { $url = parametre_url($url, 'var_ajax_redir', 1, '&'); } diff --git a/ecrire/index.php b/ecrire/index.php index 08c5068449..3df4211237 100644 --- a/ecrire/index.php +++ b/ecrire/index.php @@ -45,7 +45,6 @@ if (autoriser_sans_cookie($exec)) { if (!isset($reinstall)) { $reinstall = 'non'; } - set_request('transformer_xml'); $var_auth = true; } else { // Authentification, redefinissable @@ -160,13 +159,6 @@ if (!$var_auth and isset($_COOKIE['spip_lang_ecrire']) action_converser_post($GLOBALS['visiteur_session']['lang'], true); } - -// Passer la main aux outils XML a la demande (meme les redac s'ils veulent). -// mais seulement si on a bien ete auhentifie -if ($var_f = _request('transformer_xml')) { - set_request('var_url', $exec); - $exec = $var_f; -} if ($var_f = tester_url_ecrire($exec)) { $var_f = charger_fonction($var_f); $var_f(); // at last diff --git a/prive/javascript/layer.js b/prive/javascript/layer.js index e1090a6a0c..5eefb3cd7e 100644 --- a/prive/javascript/layer.js +++ b/prive/javascript/layer.js @@ -174,66 +174,38 @@ function verifForm(racine) { // et son resultat booleen est inverse ce qui lui permet de retourner // le gestionnaire Ajax comme valeur non fausse function AjaxSqueezeNode(trig, target, f, event) { - var i, callback; + var callback; // retour std si pas precise: affecter ce noeud avec ce retour if (!f) { callback = function() { verifForm(this);} - } - else { + } else { callback = function(res,status) { f.apply(this,[res,status]); verifForm(this); } } - valid = false; - if (typeof(window['_OUTILS_DEVELOPPEURS']) != 'undefined'){ - if (!(navigator.userAgent.toLowerCase().indexOf("firefox/1.0"))) - valid = (typeof event == 'object') && (event.altKey || event.metaKey); - } - - if (typeof(trig) == 'string') { - // laisser le choix de la touche enfoncee au moment du clic - // car beaucoup de systemes en prenne une a leur usage - if (valid) { - window.open(trig+'&transformer_xml=valider_xml'); - } else { - jQuery(target).animeajax(); - } - res = jQuery.ajax({ + if (typeof(trig) === 'string') { + jQuery(target).animeajax(); + return jQuery.ajax({ "url":trig, "complete": function(r,s) { AjaxRet(r,s,target, callback); jQuery(target).endLoading(); } }); - return res; } - if(valid) { - //open a blank window - var doc = window.open("","valider").document; - //create a document to enable receiving the result of the ajax post - doc.open(); - doc.close(); - //set the element receiving the ajax post - target = doc.body; - } - else { - jQuery(target).animeajax(); - } + jQuery(target).animeajax(); jQuery(trig).ajaxSubmit({ "target": target, "success": function(res,status) { - if(status=='error') return this.html('Erreur HTTP'); + if (status === 'error') { + return this.html('Erreur HTTP'); + } callback.apply(this,[res,status]); - }, - "beforeSubmit":function (vars) { - if (valid) - vars.push({"name":"transformer_xml","value":"valider_xml"}); - return true; } }); return true; @@ -241,8 +213,12 @@ function AjaxSqueezeNode(trig, target, f, event) { function AjaxRet(res,status, target, callback) { - if (res.aborted) return; - if (status=='error') return jQuery(target).html('HTTP Error'); + if (res.aborted) { + return; + } + if (status === 'error') { + return jQuery(target).html('HTTP Error'); + } // Inject the HTML into all the matched elements jQuery(target) -- GitLab