@@ -11,153 +11,153 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function securiser_redirect_action($redirect) { |
| 18 | - // cas d'un double urlencode : si un urldecode de l'url n'est pas secure, on retient ca comme redirect |
|
| 19 | - if (strpos($redirect, '%') !== false) { |
|
| 20 | - $r2 = urldecode($redirect); |
|
| 21 | - if (($r3 = securiser_redirect_action($r2)) !== $r2) { |
|
| 22 | - return $r3; |
|
| 23 | - } |
|
| 24 | - } |
|
| 25 | - if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect))) |
|
| 26 | - and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) { |
|
| 27 | - // si l'url est une url du site, on la laisse passer sans rien faire |
|
| 28 | - // c'est encore le plus simple |
|
| 29 | - $base = $GLOBALS['meta']['adresse_site'] . "/"; |
|
| 30 | - if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) { |
|
| 31 | - return $redirect; |
|
| 32 | - } |
|
| 33 | - $base = url_de_base(); |
|
| 34 | - if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) { |
|
| 35 | - return $redirect; |
|
| 36 | - } |
|
| 18 | + // cas d'un double urlencode : si un urldecode de l'url n'est pas secure, on retient ca comme redirect |
|
| 19 | + if (strpos($redirect, '%') !== false) { |
|
| 20 | + $r2 = urldecode($redirect); |
|
| 21 | + if (($r3 = securiser_redirect_action($r2)) !== $r2) { |
|
| 22 | + return $r3; |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | + if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect))) |
|
| 26 | + and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) { |
|
| 27 | + // si l'url est une url du site, on la laisse passer sans rien faire |
|
| 28 | + // c'est encore le plus simple |
|
| 29 | + $base = $GLOBALS['meta']['adresse_site'] . "/"; |
|
| 30 | + if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) { |
|
| 31 | + return $redirect; |
|
| 32 | + } |
|
| 33 | + $base = url_de_base(); |
|
| 34 | + if (strlen($base) and strncmp($redirect, $base, strlen($base)) == 0) { |
|
| 35 | + return $redirect; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - return ""; |
|
| 39 | - } |
|
| 38 | + return ""; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - return $redirect; |
|
| 41 | + return $redirect; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // http://code.spip.net/@traiter_appels_actions |
| 45 | 45 | function traiter_appels_actions() { |
| 46 | - // cas de l'appel qui renvoie une redirection (302) ou rien (204) |
|
| 47 | - if ($action = _request('action')) { |
|
| 48 | - include_spip('base/abstract_sql'); // chargement systematique pour les actions |
|
| 49 | - include_spip('inc/autoriser'); |
|
| 50 | - include_spip('inc/headers'); |
|
| 51 | - include_spip('inc/actions'); |
|
| 52 | - // des actions peuvent appeler _T |
|
| 53 | - if (!isset($GLOBALS['spip_lang'])) { |
|
| 54 | - include_spip('inc/lang'); |
|
| 55 | - utiliser_langue_visiteur(); |
|
| 56 | - } |
|
| 57 | - // si l'action est provoque par un hit {ajax} |
|
| 58 | - // il faut transmettre l'env ajax au redirect |
|
| 59 | - // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection |
|
| 60 | - if (($v = _request('var_ajax')) |
|
| 61 | - and ($v !== 'form') |
|
| 62 | - and ($args = _request('var_ajax_env')) |
|
| 63 | - and ($url = _request('redirect')) |
|
| 64 | - ) { |
|
| 65 | - $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 66 | - $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 67 | - set_request('redirect', $url); |
|
| 68 | - } else { |
|
| 69 | - if (_request('redirect')) { |
|
| 70 | - set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - $var_f = charger_fonction($action, 'action'); |
|
| 74 | - $var_f(); |
|
| 75 | - if (!isset($GLOBALS['redirect'])) { |
|
| 76 | - $GLOBALS['redirect'] = _request('redirect'); |
|
| 77 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 78 | - $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 79 | - } |
|
| 80 | - $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']); |
|
| 81 | - } |
|
| 82 | - if ($url = $GLOBALS['redirect']) { |
|
| 83 | - // si l'action est provoque par un hit {ajax} |
|
| 84 | - // il faut transmettre l'env ajax au redirect |
|
| 85 | - // qui a pu etre defini par l'action |
|
| 86 | - if (($v = _request('var_ajax')) |
|
| 87 | - and ($v !== 'form') |
|
| 88 | - and ($args = _request('var_ajax_env')) |
|
| 89 | - ) { |
|
| 90 | - $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 91 | - $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 92 | - // passer l'ancre en variable pour pouvoir la gerer cote serveur |
|
| 93 | - $url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url); |
|
| 94 | - } |
|
| 95 | - $url = str_replace('&', '&', $url); // les redirections se font en &, pas en en & |
|
| 96 | - redirige_par_entete($url); |
|
| 97 | - } |
|
| 98 | - if (!headers_sent() |
|
| 99 | - and !ob_get_length() |
|
| 100 | - ) { |
|
| 101 | - http_status(204); |
|
| 102 | - } // No Content |
|
| 103 | - return true; |
|
| 104 | - } |
|
| 46 | + // cas de l'appel qui renvoie une redirection (302) ou rien (204) |
|
| 47 | + if ($action = _request('action')) { |
|
| 48 | + include_spip('base/abstract_sql'); // chargement systematique pour les actions |
|
| 49 | + include_spip('inc/autoriser'); |
|
| 50 | + include_spip('inc/headers'); |
|
| 51 | + include_spip('inc/actions'); |
|
| 52 | + // des actions peuvent appeler _T |
|
| 53 | + if (!isset($GLOBALS['spip_lang'])) { |
|
| 54 | + include_spip('inc/lang'); |
|
| 55 | + utiliser_langue_visiteur(); |
|
| 56 | + } |
|
| 57 | + // si l'action est provoque par un hit {ajax} |
|
| 58 | + // il faut transmettre l'env ajax au redirect |
|
| 59 | + // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection |
|
| 60 | + if (($v = _request('var_ajax')) |
|
| 61 | + and ($v !== 'form') |
|
| 62 | + and ($args = _request('var_ajax_env')) |
|
| 63 | + and ($url = _request('redirect')) |
|
| 64 | + ) { |
|
| 65 | + $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 66 | + $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 67 | + set_request('redirect', $url); |
|
| 68 | + } else { |
|
| 69 | + if (_request('redirect')) { |
|
| 70 | + set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + $var_f = charger_fonction($action, 'action'); |
|
| 74 | + $var_f(); |
|
| 75 | + if (!isset($GLOBALS['redirect'])) { |
|
| 76 | + $GLOBALS['redirect'] = _request('redirect'); |
|
| 77 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 78 | + $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 79 | + } |
|
| 80 | + $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']); |
|
| 81 | + } |
|
| 82 | + if ($url = $GLOBALS['redirect']) { |
|
| 83 | + // si l'action est provoque par un hit {ajax} |
|
| 84 | + // il faut transmettre l'env ajax au redirect |
|
| 85 | + // qui a pu etre defini par l'action |
|
| 86 | + if (($v = _request('var_ajax')) |
|
| 87 | + and ($v !== 'form') |
|
| 88 | + and ($args = _request('var_ajax_env')) |
|
| 89 | + ) { |
|
| 90 | + $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 91 | + $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 92 | + // passer l'ancre en variable pour pouvoir la gerer cote serveur |
|
| 93 | + $url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url); |
|
| 94 | + } |
|
| 95 | + $url = str_replace('&', '&', $url); // les redirections se font en &, pas en en & |
|
| 96 | + redirige_par_entete($url); |
|
| 97 | + } |
|
| 98 | + if (!headers_sent() |
|
| 99 | + and !ob_get_length() |
|
| 100 | + ) { |
|
| 101 | + http_status(204); |
|
| 102 | + } // No Content |
|
| 103 | + return true; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - return false; |
|
| 106 | + return false; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | // http://code.spip.net/@refuser_traiter_formulaire_ajax |
| 111 | 111 | function refuser_traiter_formulaire_ajax() { |
| 112 | - if ($v = _request('var_ajax') |
|
| 113 | - and $v == 'form' |
|
| 114 | - and $form = _request('formulaire_action') |
|
| 115 | - and $args = _request('formulaire_action_args') |
|
| 116 | - and decoder_contexte_ajax($args, $form) !== false |
|
| 117 | - ) { |
|
| 118 | - // on est bien dans le contexte de traitement d'un formulaire en ajax |
|
| 119 | - // mais traiter ne veut pas |
|
| 120 | - // on le dit a la page qui va resumbit |
|
| 121 | - // sans ajax |
|
| 122 | - include_spip('inc/actions'); |
|
| 123 | - ajax_retour('noajax', false); |
|
| 124 | - exit; |
|
| 125 | - } |
|
| 112 | + if ($v = _request('var_ajax') |
|
| 113 | + and $v == 'form' |
|
| 114 | + and $form = _request('formulaire_action') |
|
| 115 | + and $args = _request('formulaire_action_args') |
|
| 116 | + and decoder_contexte_ajax($args, $form) !== false |
|
| 117 | + ) { |
|
| 118 | + // on est bien dans le contexte de traitement d'un formulaire en ajax |
|
| 119 | + // mais traiter ne veut pas |
|
| 120 | + // on le dit a la page qui va resumbit |
|
| 121 | + // sans ajax |
|
| 122 | + include_spip('inc/actions'); |
|
| 123 | + ajax_retour('noajax', false); |
|
| 124 | + exit; |
|
| 125 | + } |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // http://code.spip.net/@traiter_appels_inclusions_ajax |
| 129 | 129 | function traiter_appels_inclusions_ajax() { |
| 130 | - // traiter les appels de bloc ajax (ex: pagination) |
|
| 131 | - if ($v = _request('var_ajax') |
|
| 132 | - and $v !== 'form' |
|
| 133 | - and $args = _request('var_ajax_env') |
|
| 134 | - ) { |
|
| 135 | - include_spip('inc/filtres'); |
|
| 136 | - include_spip('inc/actions'); |
|
| 137 | - if ($args = decoder_contexte_ajax($args) |
|
| 138 | - and $fond = $args['fond'] |
|
| 139 | - ) { |
|
| 140 | - include_spip('public/assembler'); |
|
| 141 | - $contexte = calculer_contexte(); |
|
| 142 | - $contexte = array_merge($args, $contexte); |
|
| 143 | - $page = recuperer_fond($fond, $contexte, array('trim' => false)); |
|
| 144 | - $texte = $page; |
|
| 145 | - if ($ancre = _request('var_ajax_ancre')) { |
|
| 146 | - // pas n'importe quoi quand meme dans la variable ! |
|
| 147 | - $ancre = str_replace(array('<', '"', "'"), array('<', '"', ''), $ancre); |
|
| 148 | - $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>" . $texte; |
|
| 149 | - } |
|
| 150 | - } else { |
|
| 151 | - include_spip('inc/headers'); |
|
| 152 | - http_status(403); |
|
| 153 | - $texte = _L('signature ajax bloc incorrecte'); |
|
| 154 | - } |
|
| 155 | - ajax_retour($texte, false); |
|
| 130 | + // traiter les appels de bloc ajax (ex: pagination) |
|
| 131 | + if ($v = _request('var_ajax') |
|
| 132 | + and $v !== 'form' |
|
| 133 | + and $args = _request('var_ajax_env') |
|
| 134 | + ) { |
|
| 135 | + include_spip('inc/filtres'); |
|
| 136 | + include_spip('inc/actions'); |
|
| 137 | + if ($args = decoder_contexte_ajax($args) |
|
| 138 | + and $fond = $args['fond'] |
|
| 139 | + ) { |
|
| 140 | + include_spip('public/assembler'); |
|
| 141 | + $contexte = calculer_contexte(); |
|
| 142 | + $contexte = array_merge($args, $contexte); |
|
| 143 | + $page = recuperer_fond($fond, $contexte, array('trim' => false)); |
|
| 144 | + $texte = $page; |
|
| 145 | + if ($ancre = _request('var_ajax_ancre')) { |
|
| 146 | + // pas n'importe quoi quand meme dans la variable ! |
|
| 147 | + $ancre = str_replace(array('<', '"', "'"), array('<', '"', ''), $ancre); |
|
| 148 | + $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>" . $texte; |
|
| 149 | + } |
|
| 150 | + } else { |
|
| 151 | + include_spip('inc/headers'); |
|
| 152 | + http_status(403); |
|
| 153 | + $texte = _L('signature ajax bloc incorrecte'); |
|
| 154 | + } |
|
| 155 | + ajax_retour($texte, false); |
|
| 156 | 156 | |
| 157 | - return true; // on a fini le hit |
|
| 158 | - } |
|
| 157 | + return true; // on a fini le hit |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - return false; |
|
| 160 | + return false; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // au 1er appel, traite les formulaires dynamiques charger/verifier/traiter |
@@ -166,148 +166,148 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | // http://code.spip.net/@traiter_formulaires_dynamiques |
| 168 | 168 | function traiter_formulaires_dynamiques($get = false) { |
| 169 | - static $post = array(); |
|
| 170 | - static $done = false; |
|
| 169 | + static $post = array(); |
|
| 170 | + static $done = false; |
|
| 171 | 171 | |
| 172 | - if ($get) { |
|
| 173 | - return $post; |
|
| 174 | - } |
|
| 175 | - if ($done) { |
|
| 176 | - return false; |
|
| 177 | - } |
|
| 178 | - $done = true; |
|
| 172 | + if ($get) { |
|
| 173 | + return $post; |
|
| 174 | + } |
|
| 175 | + if ($done) { |
|
| 176 | + return false; |
|
| 177 | + } |
|
| 178 | + $done = true; |
|
| 179 | 179 | |
| 180 | - if (!($form = _request('formulaire_action') |
|
| 181 | - and $args = _request('formulaire_action_args')) |
|
| 182 | - ) { |
|
| 183 | - return false; |
|
| 184 | - } // le hit peut continuer normalement |
|
| 180 | + if (!($form = _request('formulaire_action') |
|
| 181 | + and $args = _request('formulaire_action_args')) |
|
| 182 | + ) { |
|
| 183 | + return false; |
|
| 184 | + } // le hit peut continuer normalement |
|
| 185 | 185 | |
| 186 | - include_spip('inc/filtres'); |
|
| 187 | - if (($args = decoder_contexte_ajax($args, $form)) === false) { |
|
| 188 | - spip_log("signature ajax form incorrecte : $form"); |
|
| 186 | + include_spip('inc/filtres'); |
|
| 187 | + if (($args = decoder_contexte_ajax($args, $form)) === false) { |
|
| 188 | + spip_log("signature ajax form incorrecte : $form"); |
|
| 189 | 189 | |
| 190 | - return false; // continuons le hit comme si de rien etait |
|
| 191 | - } else { |
|
| 192 | - include_spip('inc/lang'); |
|
| 193 | - // sauvegarder la lang en cours |
|
| 194 | - $old_lang = $GLOBALS['spip_lang']; |
|
| 195 | - // changer la langue avec celle qui a cours dans le formulaire |
|
| 196 | - // on la depile de $args car c'est un argument implicite masque |
|
| 197 | - changer_langue(array_shift($args)); |
|
| 190 | + return false; // continuons le hit comme si de rien etait |
|
| 191 | + } else { |
|
| 192 | + include_spip('inc/lang'); |
|
| 193 | + // sauvegarder la lang en cours |
|
| 194 | + $old_lang = $GLOBALS['spip_lang']; |
|
| 195 | + // changer la langue avec celle qui a cours dans le formulaire |
|
| 196 | + // on la depile de $args car c'est un argument implicite masque |
|
| 197 | + changer_langue(array_shift($args)); |
|
| 198 | 198 | |
| 199 | 199 | |
| 200 | - // inclure mes_fonctions et autres filtres avant verifier/traiter |
|
| 201 | - include_spip('public/parametrer'); |
|
| 202 | - // ainsi que l'API SQL bien utile dans verifier/traiter |
|
| 203 | - include_spip('base/abstract_sql'); |
|
| 200 | + // inclure mes_fonctions et autres filtres avant verifier/traiter |
|
| 201 | + include_spip('public/parametrer'); |
|
| 202 | + // ainsi que l'API SQL bien utile dans verifier/traiter |
|
| 203 | + include_spip('base/abstract_sql'); |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Pipeline exécuté lors de la soumission d'un formulaire, |
|
| 207 | - * mais avant l'appel de la fonction de vérification. |
|
| 208 | - */ |
|
| 209 | - pipeline( |
|
| 210 | - 'formulaire_receptionner', |
|
| 211 | - array( |
|
| 212 | - 'args' => array('form' => $form, 'args' => $args), |
|
| 213 | - 'data' => null, |
|
| 214 | - ) |
|
| 215 | - ); |
|
| 205 | + /** |
|
| 206 | + * Pipeline exécuté lors de la soumission d'un formulaire, |
|
| 207 | + * mais avant l'appel de la fonction de vérification. |
|
| 208 | + */ |
|
| 209 | + pipeline( |
|
| 210 | + 'formulaire_receptionner', |
|
| 211 | + array( |
|
| 212 | + 'args' => array('form' => $form, 'args' => $args), |
|
| 213 | + 'data' => null, |
|
| 214 | + ) |
|
| 215 | + ); |
|
| 216 | 216 | |
| 217 | - $verifier = charger_fonction("verifier", "formulaires/$form/", true); |
|
| 218 | - $post["erreurs_$form"] = pipeline( |
|
| 219 | - 'formulaire_verifier', |
|
| 220 | - array( |
|
| 221 | - 'args' => array('form' => $form, 'args' => $args), |
|
| 222 | - 'data' => $verifier ? call_user_func_array($verifier, $args) : array() |
|
| 223 | - ) |
|
| 224 | - ); |
|
| 225 | - // prise en charge CVT multi etape si besoin |
|
| 226 | - if (_request('cvtm_prev_post')) { |
|
| 227 | - include_spip('inc/cvt_multietapes'); |
|
| 228 | - $post["erreurs_$form"] = cvtmulti_formulaire_verifier_etapes( |
|
| 229 | - array('form' => $form, 'args' => $args), |
|
| 230 | - $post["erreurs_$form"] |
|
| 231 | - ); |
|
| 232 | - } |
|
| 217 | + $verifier = charger_fonction("verifier", "formulaires/$form/", true); |
|
| 218 | + $post["erreurs_$form"] = pipeline( |
|
| 219 | + 'formulaire_verifier', |
|
| 220 | + array( |
|
| 221 | + 'args' => array('form' => $form, 'args' => $args), |
|
| 222 | + 'data' => $verifier ? call_user_func_array($verifier, $args) : array() |
|
| 223 | + ) |
|
| 224 | + ); |
|
| 225 | + // prise en charge CVT multi etape si besoin |
|
| 226 | + if (_request('cvtm_prev_post')) { |
|
| 227 | + include_spip('inc/cvt_multietapes'); |
|
| 228 | + $post["erreurs_$form"] = cvtmulti_formulaire_verifier_etapes( |
|
| 229 | + array('form' => $form, 'args' => $args), |
|
| 230 | + $post["erreurs_$form"] |
|
| 231 | + ); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - // accessibilite : si des erreurs mais pas de message general l'ajouter |
|
| 235 | - if ((isset($post["erreurs_$form"]) and count($post["erreurs_$form"])) and !isset($post["erreurs_$form"]['message_erreur'])) { |
|
| 236 | - $post["erreurs_$form"]['message_erreur'] = singulier_ou_pluriel(count($post["erreurs_$form"]), |
|
| 237 | - 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie'); |
|
| 238 | - } |
|
| 234 | + // accessibilite : si des erreurs mais pas de message general l'ajouter |
|
| 235 | + if ((isset($post["erreurs_$form"]) and count($post["erreurs_$form"])) and !isset($post["erreurs_$form"]['message_erreur'])) { |
|
| 236 | + $post["erreurs_$form"]['message_erreur'] = singulier_ou_pluriel(count($post["erreurs_$form"]), |
|
| 237 | + 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie'); |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - // si on ne demandait qu'une verif json |
|
| 241 | - if (_request('formulaire_action_verifier_json')) { |
|
| 242 | - include_spip('inc/json'); |
|
| 243 | - include_spip('inc/actions'); |
|
| 244 | - ajax_retour(json_encode($post["erreurs_$form"]), 'text/plain'); |
|
| 240 | + // si on ne demandait qu'une verif json |
|
| 241 | + if (_request('formulaire_action_verifier_json')) { |
|
| 242 | + include_spip('inc/json'); |
|
| 243 | + include_spip('inc/actions'); |
|
| 244 | + ajax_retour(json_encode($post["erreurs_$form"]), 'text/plain'); |
|
| 245 | 245 | |
| 246 | - return true; // on a fini le hit |
|
| 247 | - } |
|
| 248 | - $retour = ""; |
|
| 249 | - if (isset($post["erreurs_$form"]) and (count($post["erreurs_$form"]) == 0)) { |
|
| 250 | - $rev = ""; |
|
| 251 | - if ($traiter = charger_fonction("traiter", "formulaires/$form/", true)) { |
|
| 252 | - $rev = call_user_func_array($traiter, $args); |
|
| 253 | - } |
|
| 246 | + return true; // on a fini le hit |
|
| 247 | + } |
|
| 248 | + $retour = ""; |
|
| 249 | + if (isset($post["erreurs_$form"]) and (count($post["erreurs_$form"]) == 0)) { |
|
| 250 | + $rev = ""; |
|
| 251 | + if ($traiter = charger_fonction("traiter", "formulaires/$form/", true)) { |
|
| 252 | + $rev = call_user_func_array($traiter, $args); |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - $rev = pipeline( |
|
| 256 | - 'formulaire_traiter', |
|
| 257 | - array( |
|
| 258 | - 'args' => array('form' => $form, 'args' => $args), |
|
| 259 | - 'data' => $rev |
|
| 260 | - ) |
|
| 261 | - ); |
|
| 262 | - // le retour de traiter est |
|
| 263 | - // un tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx) |
|
| 264 | - // il permet le pipelinage, en particulier |
|
| 265 | - // en y passant l'id de l'objet cree/modifie |
|
| 266 | - // si message_erreur est present, on considere que le traitement a echoue |
|
| 267 | - $post["message_ok_$form"] = ''; |
|
| 268 | - // on peut avoir message_ok et message_erreur |
|
| 269 | - if (isset($rev['message_ok'])) { |
|
| 270 | - $post["message_ok_$form"] = $rev['message_ok']; |
|
| 271 | - } |
|
| 255 | + $rev = pipeline( |
|
| 256 | + 'formulaire_traiter', |
|
| 257 | + array( |
|
| 258 | + 'args' => array('form' => $form, 'args' => $args), |
|
| 259 | + 'data' => $rev |
|
| 260 | + ) |
|
| 261 | + ); |
|
| 262 | + // le retour de traiter est |
|
| 263 | + // un tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx) |
|
| 264 | + // il permet le pipelinage, en particulier |
|
| 265 | + // en y passant l'id de l'objet cree/modifie |
|
| 266 | + // si message_erreur est present, on considere que le traitement a echoue |
|
| 267 | + $post["message_ok_$form"] = ''; |
|
| 268 | + // on peut avoir message_ok et message_erreur |
|
| 269 | + if (isset($rev['message_ok'])) { |
|
| 270 | + $post["message_ok_$form"] = $rev['message_ok']; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - // verifier si traiter n'a pas echoue avec une erreur : |
|
| 274 | - if (isset($rev['message_erreur'])) { |
|
| 275 | - $post["erreurs_$form"]["message_erreur"] = $rev['message_erreur']; |
|
| 276 | - // si il y a une erreur on ne redirige pas |
|
| 277 | - } else { |
|
| 278 | - // sinon faire ce qu'il faut : |
|
| 279 | - if (isset($rev['editable'])) { |
|
| 280 | - $post["editable_$form"] = $rev['editable']; |
|
| 281 | - } |
|
| 282 | - // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
|
| 283 | - // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
|
| 284 | - if (isset($rev['redirect']) and $rev['redirect']) { |
|
| 285 | - include_spip('inc/headers'); |
|
| 286 | - list($masque, $message) = redirige_formulaire($rev['redirect'], '', 'ajaxform'); |
|
| 287 | - $post["message_ok_$form"] .= $message; |
|
| 288 | - $retour .= $masque; |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - // si le formulaire a ete soumis en ajax, on le renvoie direct ! |
|
| 293 | - if (_request('var_ajax')) { |
|
| 294 | - if (find_in_path('formulaire_.php', 'balise/', true)) { |
|
| 295 | - include_spip('inc/actions'); |
|
| 296 | - include_spip('public/assembler'); |
|
| 297 | - array_unshift($args, $form); |
|
| 298 | - $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn', $args), false); |
|
| 299 | - // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
|
| 300 | - // sans cela le formulaire n'est pas actif apres le hit ajax |
|
| 301 | - // la classe ajax-form-is-ok sert a s'assurer que le retour ajax s'est bien passe |
|
| 302 | - $retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>" . $retour; |
|
| 303 | - ajax_retour($retour, false); |
|
| 273 | + // verifier si traiter n'a pas echoue avec une erreur : |
|
| 274 | + if (isset($rev['message_erreur'])) { |
|
| 275 | + $post["erreurs_$form"]["message_erreur"] = $rev['message_erreur']; |
|
| 276 | + // si il y a une erreur on ne redirige pas |
|
| 277 | + } else { |
|
| 278 | + // sinon faire ce qu'il faut : |
|
| 279 | + if (isset($rev['editable'])) { |
|
| 280 | + $post["editable_$form"] = $rev['editable']; |
|
| 281 | + } |
|
| 282 | + // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
|
| 283 | + // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
|
| 284 | + if (isset($rev['redirect']) and $rev['redirect']) { |
|
| 285 | + include_spip('inc/headers'); |
|
| 286 | + list($masque, $message) = redirige_formulaire($rev['redirect'], '', 'ajaxform'); |
|
| 287 | + $post["message_ok_$form"] .= $message; |
|
| 288 | + $retour .= $masque; |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + // si le formulaire a ete soumis en ajax, on le renvoie direct ! |
|
| 293 | + if (_request('var_ajax')) { |
|
| 294 | + if (find_in_path('formulaire_.php', 'balise/', true)) { |
|
| 295 | + include_spip('inc/actions'); |
|
| 296 | + include_spip('public/assembler'); |
|
| 297 | + array_unshift($args, $form); |
|
| 298 | + $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn', $args), false); |
|
| 299 | + // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
|
| 300 | + // sans cela le formulaire n'est pas actif apres le hit ajax |
|
| 301 | + // la classe ajax-form-is-ok sert a s'assurer que le retour ajax s'est bien passe |
|
| 302 | + $retour = "<br class='bugajaxie ajax-form-is-ok' style='display:none;'/>" . $retour; |
|
| 303 | + ajax_retour($retour, false); |
|
| 304 | 304 | |
| 305 | - return true; // on a fini le hit |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - // restaurer la lang en cours |
|
| 309 | - changer_langue($old_lang); |
|
| 310 | - } |
|
| 305 | + return true; // on a fini le hit |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + // restaurer la lang en cours |
|
| 309 | + changer_langue($old_lang); |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - return false; // le hit peut continuer normalement |
|
| 312 | + return false; // le hit peut continuer normalement |
|
| 313 | 313 | } |