From c8780d3a18a5eb82b78dd8e8ae579f292b3c296d Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Mon, 25 Aug 2008 11:33:36 +0000 Subject: [PATCH] =?UTF-8?q?Partages=20de=20code=20qui=20permet=20=C3=A0=20?= =?UTF-8?q?{{{generer=5Furl=5Fpublic}}}=C2=A0d'accepter=20un=20tableau=20p?= =?UTF-8?q?our=20construire=20les=20variables=20d'URL=20et=20de=20recevoir?= =?UTF-8?q?=20le=20nom=20du=20script=20=C3=A0=20la=20racine.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/exec/valider_xml.php | 6 ++---- ecrire/inc/utils.php | 26 ++++++++++---------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/ecrire/exec/valider_xml.php b/ecrire/exec/valider_xml.php index 8ef7f04cba..4328eefb0d 100644 --- a/ecrire/exec/valider_xml.php +++ b/ecrire/exec/valider_xml.php @@ -204,12 +204,10 @@ function valider_skel($transformer_xml, $file, $dir) list($texte, $err) = $transformer_xml($page['texte']); $res = strlen($texte); $script = basename($file,'.html'); - $url = ''; // pas de validation solitaire pour les squelettes internes, a revoir. if (substr_count($dir, '/') <= 1) { - foreach($contexte as $k => $v) $url .= '&' . $k . '=' . $v; - $url = generer_url_public($script, substr($url,1)); - } + $url = generer_url_public($script, $contexte); + } else $url = ''; return array(count($err), $res, $err, $script, $url); } diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 6233a6661e..d998f56418 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -852,18 +852,23 @@ function get_spip_script($default='') { } // http://doc.spip.org/@generer_url_public -function generer_url_public($script='', $args="", $no_entities=false, $rel=false) { +function generer_url_public($script='', $args="", $no_entities=false, $rel=false, $action='') { // si le script est une action (spip_pass, spip_inscription), // standardiser vers la nouvelle API - $action = get_spip_script(); + if (!$action) $action = get_spip_script(); if ($script) $action = parametre_url($action, _SPIP_PAGE, $script, '&'); - if ($args) + if ($args) { + if (is_array($args)) { + $r = ''; + foreach($args as $k => $v) $r .= '&' . $k . '=' . $v; + $args = substr($r,1); + } $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; - + } if (!$no_entities) $action = quote_amp($action); @@ -873,18 +878,7 @@ function generer_url_public($script='', $args="", $no_entities=false, $rel=false // http://doc.spip.org/@generer_url_prive function generer_url_prive($script, $args="", $no_entities=false) { - $action = 'prive.php'; - if ($script) - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); - - if ($args) - $action .= - (strpos($action, '?') !== false ? '&' : '?') . $args; - - if (!$no_entities) - $action = quote_amp($action); - - return url_de_base() . _DIR_RESTREINT_ABS . $action; + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); } // Pour les formulaires en methode POST, -- GitLab