From 2404bf1e1d799395da73e579b80b6981b03941f3 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Sat, 28 Apr 2007 05:21:24 +0000 Subject: [PATCH] Partage de code dans la production des formulaires. --- ecrire/exec/recherche.php | 6 +++--- ecrire/exec/valider_xml.php | 7 +++---- ecrire/inc/gadgets.php | 12 ++++-------- ecrire/inc/import.php | 10 +++++----- ecrire/inc/ortho.php | 38 +++++++++++++++++++------------------ ecrire/inc/texte.php | 10 +++------- ecrire/inc/utils.php | 2 +- ecrire/install/etape_4.php | 2 +- 8 files changed, 40 insertions(+), 47 deletions(-) diff --git a/ecrire/exec/recherche.php b/ecrire/exec/recherche.php index 9fc2bbefb1..70fe8f8256 100644 --- a/ecrire/exec/recherche.php +++ b/ecrire/exec/recherche.php @@ -44,9 +44,9 @@ function exec_recherche_dist() { $onfocus = " onfocus=\"this.value='';\""; } - echo "<form method='get' style='margin: 0px;' action='" . generer_url_ecrire("recherche","") . "'><div>"; - echo "<input type='hidden' name='exec' value='recherche' />"; - echo '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="spip_recherche" accesskey="r"' . $onfocus . ' />'; + echo generer_post_ecrire("recherche", + ('<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="spip_recherche" accesskey="r"' . $onfocus . ' />'), + " method='get'"); /* // Si on est autorise a modifier, proposer le choix de REMPLACER diff --git a/ecrire/exec/valider_xml.php b/ecrire/exec/valider_xml.php index b2df2110a9..e4095f4839 100644 --- a/ecrire/exec/valider_xml.php +++ b/ecrire/exec/valider_xml.php @@ -60,10 +60,9 @@ function exec_valider_xml_dist() echo $commencer_page($titre); echo "<div style='margin: 10px; text-align: center'>", "<h1>", $titre, '</h1>'; - echo "<form style='margin: 0px;' action='", generer_url_ecrire('valider_xml') . "'>"; - echo "<div><input type='hidden' name='exec' value='valider_xml' />"; - echo '<input type="text" size="70" value="',$url_aff,'" name="var_url" onfocus="'.$onfocus . '" />'; - echo "</div></form>"; + echo generer_post_ecrire('valider_xml', + ('<input type="text" size="70" value="' .$url_aff .'" name="var_url" onfocus="'.$onfocus . '" />'), + "method='get'"); echo $err, "</div>"; echo "<div style='margin: 10px; text-align: left'>",$texte, '</div>', fin_page(); diff --git a/ecrire/inc/gadgets.php b/ecrire/inc/gadgets.php index bed90f91bc..e14ffd2607 100644 --- a/ecrire/inc/gadgets.php +++ b/ecrire/inc/gadgets.php @@ -52,15 +52,11 @@ function bandeau_gadgets($largeur, $options, $id_rubrique) { // FIN GADGET Navigation rapide // GADGET Recherche + $r = _T('info_rechercher'); $bandeau .= "\n<div id='bandeaurecherche' class='bandeau bandeau_couleur_sous' style='text-align:$spip_lang_left;$spip_lang_left: 60px;'>" - . "<form method='get' style='margin: 0px; position: relative;' action='" - . generer_url_ecrire("recherche") - . "'><div>" - . "<input type='hidden' name='exec' value='recherche' />" - . "<input type=\"text\" id=\"form_recherche\" style=\"width: 140px;\" size=\"10\" value=\"" - . _T('info_rechercher') - . "\" name=\"recherche\" class=\"formo\" accesskey=\"r\" />" - . "</div></form>" + . generer_post_ecrire('recherche', + ("<input type='text' size='10' value='$r' name='recherche' class='formo' accesskey='r' id='form_recherche' style='width: 140px;' />"), + " method='get' style='margin: 0px; position: relative;'") . "</div>"; // FIN GADGET recherche diff --git a/ecrire/inc/import.php b/ecrire/inc/import.php index 6121c675e8..2087f3afc7 100644 --- a/ecrire/inc/import.php +++ b/ecrire/inc/import.php @@ -273,13 +273,13 @@ function import_init_meta($tag, $atts, $charset, $request) function import_affiche_javascript($taille) { $max_time = ini_get('max_execution_time')*1000; + $t = _T('info_recharger_page'); + $t = " +<input type='text' size='10' name='taille' value='$taille' /> +<input type='text' class='forml' name='recharge' value='$t' />"; echo debut_boite_alerte(), "<span style='color: black;' class='verdana1 spip_large'><b>", _T('info_base_restauration'), "</b></span>", - "<form name='progression'><div style='text-align: center'><input type='text' size='10' name='taille' value='", - $taille, - "'></div><div style='text-align: center'><input type='text' class='forml' name='recharge' value='", - _T('info_recharger_page'), - "'></div></form>", + generer_post_ecrire('', $t, " style='text-align: center' name='progression' method='get' "), fin_boite_alerte(), "<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"", self(), diff --git a/ecrire/inc/ortho.php b/ecrire/inc/ortho.php index 2acebaaee0..fc8b920d99 100644 --- a/ecrire/inc/ortho.php +++ b/ecrire/inc/ortho.php @@ -494,7 +494,21 @@ function panneau_ortho($ortho_result) { if (!count($mauvais) && !count($bons)) return; ksort($mauvais); - $panneau = "<script type='text/javascript'><!-- + $panneau .= "<select name='select_ortho' id='select_ortho' onChange='suggest(this.selectedIndex);'>\n"; + $panneau .= "<option value='0'>... "._T('ortho_mots_a_corriger')." ...</option>\n"; + foreach ($mauvais as $mot => $suggest) { + $id = $id_suggest[$mot] = "$i"; + $i++; + $mot_html = afficher_ortho($mot); + $panneau .= "<option value='$id'>$mot_html</option>\n"; + } + foreach ($bons as $mot) { + $id = $id_suggest[$mot] = "$i"; + $i++; + } + $panneau .= "</select>\n"; + + $script = "<script type='text/javascript'><!-- var curr_suggest = null; // http://doc.spip.org/@suggest function suggest(id) { @@ -508,24 +522,12 @@ function panneau_ortho($ortho_result) { else curr_suggest = null; menu_box = document.getElementById('select_ortho'); if (menu_box.length > id) menu_box.selectedIndex = id; - }"; - $panneau .= "//--></script>"; - - $panneau .= "<form class='form-ortho verdana2' action='' method='get'>\n"; - $panneau .= "<select name='select_ortho' id='select_ortho' onChange='suggest(this.selectedIndex);'>\n"; - $panneau .= "<option value='0'>... "._T('ortho_mots_a_corriger')." ...</option>\n"; - foreach ($mauvais as $mot => $suggest) { - $id = $id_suggest[$mot] = "$i"; - $i++; - $mot_html = afficher_ortho($mot); - $panneau .= "<option value='$id'>$mot_html</option>\n"; } - foreach ($bons as $mot) { - $id = $id_suggest[$mot] = "$i"; - $i++; - } - $panneau .= "</select>\n"; - $panneau .= "</form>\n"; + //--></script>"; + + $panneau = $script + . generer_post_ecrire('',$panneau, "class='form-ortho verdana2' method='get'"); // l'action n'est jamais executee + // Mots mal orthographies : // liste des suggestions plus lien pour ajouter au dico foreach ($mauvais as $mot => $suggest) { diff --git a/ecrire/inc/texte.php b/ecrire/inc/texte.php index 9cd6691597..2a1b373959 100644 --- a/ecrire/inc/texte.php +++ b/ecrire/inc/texte.php @@ -141,13 +141,9 @@ function traiter_echap_code_dist($regs) { // http://doc.spip.org/@traiter_echap_cadre_dist function traiter_echap_cadre_dist($regs) { $echap = trim(entites_html($regs[3])); - $total_lignes = substr_count($echap, "\n") + 1; - $echap = "<form action=\"/\" method=\"get\"><div>" - ."<textarea readonly='readonly' cols='40' rows='$total_lignes' " - ."class='spip_cadre' dir='ltr'>" - .$echap - ."</textarea></div></form>"; - return $echap; + $n = substr_count($echap, "\n") + 1; + $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>"; + return generer_post_ecrire('', $echap, "action='' method='get'"); } // http://doc.spip.org/@traiter_echap_frame_dist function traiter_echap_frame_dist($regs) { diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index f065ea545b..87d8c14574 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -952,7 +952,7 @@ function generer_post_ecrire($script, $corps, $atts='', $submit='') { global $spip_lang_right; return "<form action='" - . generer_url_ecrire($script) + . ($script ? generer_url_ecrire($script) : '') . "' " . ($atts ? $atts : " method='post'") . "><div>\n" diff --git a/ecrire/install/etape_4.php b/ecrire/install/etape_4.php index a690282997..494d2efb7d 100644 --- a/ecrire/install/etape_4.php +++ b/ecrire/install/etape_4.php @@ -102,7 +102,7 @@ function install_etape_4_dist() @unlink(_FILE_CHMOD_INS . _FILE_TMP . '.php'); } - echo generer_post_ecrire('', bouton_suivant()); + echo generer_post_ecrire('accueil', bouton_suivant()); echo info_progression_etape(4,'etape_','install/'); echo install_fin_html(); } -- GitLab