diff --git a/ecrire/exec/aide_index.php b/ecrire/exec/aide_index.php index 63b9c33c0cc0c6201c84b97ecfa41f348a9d9162..f711c4243b9d267ffe56e2093df1b42c05c5fce6 100644 --- a/ecrire/exec/aide_index.php +++ b/ecrire/exec/aide_index.php @@ -171,17 +171,12 @@ function help_body($aide, $suite, $lang_aide='') { // relocaliser img_pack au bon endroit ... $html = preg_replace("@(<img([^<>]* +)?\s*src=['\"])img_pack\/@ims","\\1"._DIR_IMG_PACK,$html . $suite); - echo '<script type="text/javascript"><!-- - -jQuery(function(){ + echo http_script('jQuery(function(){ jQuery("a.target_blank").click(function(){ window.open(this.href); return false; }); -}); - -//--></script> -'; +});)'; echo _STYLE_AIDE_BODY, "</head>\n"; echo '<body bgcolor="#FFFFFF" text="#000000" topmargin="24" leftmargin="24" marginwidth="24" marginheight="24"'; @@ -296,8 +291,7 @@ define('AIDE_STYLE_MENU', '<style type="text/css"> function help_menu($aide, $html, $lang_aide='') { global $spip_lang_rtl; - echo AIDE_STYLE_MENU, '<script type="text/javascript"><!-- -var curr_article; + echo AIDE_STYLE_MENU, http_script('var curr_article; // http://doc.spip.org/@activer_article function activer_article(id) { if (curr_article) @@ -313,10 +307,7 @@ jQuery(function(){ window.open(this.href,"droite"); return false; }); -}); - -//--></script> -', +});'), $GLOBALS['browser_layer'], ' </head> @@ -405,7 +396,7 @@ function article($titre, $lien, $statut = "redac") { if (_request('aide') == $lien) { $ouvrir_rubrique = 1; $class = "article-actif"; - $texte[$ligne] .= "<script type='text/javascript'><!--\ncurr_article = '$id';\n// --></script>\n"; + $texte[$ligne] .= http_script("curr_article = '$id';"); } else { $class = "article-inactif"; @@ -459,7 +450,7 @@ function exec_aide_index_dist() header("Content-Type: text/html; charset=utf-8"); echo _DOCTYPE_AIDE, html_lang_attributes(); echo "<head><title>", _T('info_aide_en_ligne'), "</title>\n"; - echo '<script type="text/javascript" src="'._DIR_JAVASCRIPT.'jquery.js"></script>'; + echo http_script("", _DIR_JAVASCRIPT.'jquery.js'); if (_request('frame') == 'menu'){ help_menu(_request('aide'), $html, $lang); diff --git a/ecrire/exec/articles.php b/ecrire/exec/articles.php index 45d03dd8bf73e8398d762483af83a6761df1478e..28425bd6472465c7cb8822c96e3aaf7e7c86ab99 100644 --- a/ecrire/exec/articles.php +++ b/ecrire/exec/articles.php @@ -213,10 +213,8 @@ function articles_documents($type, $id) $res = "\n<table style='float: $spip_lang_right' width='50%' cellpadding='0' cellspacing='0' border='0'>\n<tr><td style='text-align: $spip_lang_left;'>\n$res</td></tr></table>"; } - $res .= "<script src='"._DIR_JAVASCRIPT."async_upload.js' type='text/javascript'></script> -<script type='text/javascript'> -$(\"form.form_upload\").async_upload(async_upload_portfolio_documents); -</script>"; + $res .= http_script('',_DIR_JAVASCRIPT."async_upload.js") + . http_script('$("form.form_upload").async_upload(async_upload_portfolio_documents);'); } $documenter = charger_fonction('documenter', 'inc'); diff --git a/ecrire/exec/articles_tous.php b/ecrire/exec/articles_tous.php index 3991b515b519ac8f251f923d6f5e617d6356a7f1..449851b57b5162130fe71a4fd7970e35808805db 100644 --- a/ecrire/exec/articles_tous.php +++ b/ecrire/exec/articles_tous.php @@ -44,15 +44,13 @@ function exec_articles_tous_args($id_rubrique, $aff_art, $sel_lang, $var_ajaxcha pipeline('exec_init',array('args'=>array('exec'=>'articles_tous'),'data'=>'')); $commencer_page = charger_fonction('commencer_page', 'inc'); echo $commencer_page(_T('titre_page_articles_tous'), "accueil", "tout-site"); - $flux = ""; - $flux.='<script type="text/javascript"><!-- -var img_deplierhaut = "'._DIR_IMG_PACK.'noeud_plus.gif"; -var img_deplierbas = "'._DIR_IMG_PACK.'noeud_moins.gif"; -//--></script>'; - $flux .= '<script src="'._DIR_JAVASCRIPT .'dragdrop_interface.js" type="text/javascript"></script>'; - $flux .= '<script src="'._DIR_JAVASCRIPT .'articles_tous_edite.js" type="text/javascript"></script>'; - $flux .= '<script src="'._DIR_JAVASCRIPT .'pause.js" type="text/javascript"></script>'; - echo $flux; + + echo http_script('var img_deplierhaut = "'._DIR_IMG_PACK.'noeud_plus.gif"; +var img_deplierbas = "'._DIR_IMG_PACK.'noeud_moins.gif";'); + + echo http_script('', _DIR_JAVASCRIPT .'dragdrop_interface.js'); + echo http_script('', _DIR_JAVASCRIPT .'articles_tous_edite.js'); + echo http_script('', _DIR_JAVASCRIPT .'pause.js'); echo debut_gauche('', true); echo formulaire_affiche_tous($aff_art, $aff_statut, $sel_lang); diff --git a/ecrire/exec/brouteur.php b/ecrire/exec/brouteur.php index 335fa35c37b52a16bc4035acbbc8c592a2f7ec4e..49ee52eacf7685749a48afe31429d04329b1f52b 100644 --- a/ecrire/exec/brouteur.php +++ b/ecrire/exec/brouteur.php @@ -111,11 +111,9 @@ function exec_brouteur_dist() // fixer la hauteur du brouteur de maniere a remplir l'ecran // nota: code tire du plugin dimensions.js - echo "<script type='text/javascript'><!-- - jQuery('iframe.iframe-brouteur').height( + echo http_script("jQuery('iframe.iframe-brouteur').height( Math.max((window.innerHeight || jQuery.boxModel && document.documentElement.clientHeight || document.body.clientHeight || 0)-195,300) - ); - //--></script>\n"; + );\n"); echo fin_page(); } ?> diff --git a/ecrire/exec/brouteur_frame.php b/ecrire/exec/brouteur_frame.php index 50305cac7ec76d743e70cb9e9a4dffd591cf5dcf..b038409c50b08b3a2e7958e7f35e9757eabe917e 100644 --- a/ecrire/exec/brouteur_frame.php +++ b/ecrire/exec/brouteur_frame.php @@ -38,16 +38,12 @@ function exec_brouteur_frame_dist() { . (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . "' />\n" . envoi_link(_T('info_mon_site_spip')) - . '<script type="text/javascript"><!-- -jQuery(function(){ + . http_script('jQuery(function(){ jQuery("a.iframe").click(function(){ window.open(this.href,"iframe"+this.rel); return false; }); -}); - -//--></script> - ' +});') . "</head>\n") ."<body>"; @@ -58,15 +54,14 @@ jQuery(function(){ } if ($effacer_suivant == "oui" && $frame < $nb_col) { - echo '<script type="text/javascript">'; + $res = ''; for ($i = $frame+1; $i < $nb_col; $i++) { - echo "\nparent.iframe$i.location.href='", generer_url_ecrire('brouteur_frame',"frame=$i$profile"), "'"; + $res .= "\nparent.iframe$i.location.href='" . generer_url_ecrire('brouteur_frame',"frame=$i$profile") . "'"; } - echo '</script>'; + echo http_script($res); } echo "\n<div class='arial2'>"; - if ($special == "redac") { $result=sql_select("articles.id_article, articles.id_rubrique, articles.titre, articles.statut", "spip_articles AS articles LEFT JOIN spip_auteurs_articles AS lien USING (id_article)", "articles.statut = 'prepa' AND lien.id_auteur = $connect_id_auteur ", " id_article ", " articles.date DESC"); if (sql_count($result)>0) { diff --git a/ecrire/exec/menu_rubriques.php b/ecrire/exec/menu_rubriques.php index 3197334974d4f9fd1b26174b1abf365d1f804452..aacea998f1ebf4efd2f803845a065c2bfd1df07a 100644 --- a/ecrire/exec/menu_rubriques.php +++ b/ecrire/exec/menu_rubriques.php @@ -96,8 +96,7 @@ function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $largeur, $ima $pxdecal = max(15, ceil($largeur/5)) . 'px'; - $ret = "<script type='text/javascript'> -// http://doc.spip.org/@bandeauHover + $ret = http_script("// http://doc.spip.org/@bandeauHover function bandeauHover(r) { if (!$(r).is('.hovered')) $(r) @@ -110,8 +109,7 @@ function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $largeur, $ima function(){\$(this).children('.bandeau_rub').show();}, function(){\$(this).children('.bandeau_rub').hide();} ); - }; - </script>\n"; + };"); $ret .= "<div class='pos_r' style='z-index: " . $zdecal . ";' onmouseover=\"bandeauHover(this);\">" diff --git a/ecrire/exec/naviguer.php b/ecrire/exec/naviguer.php index eba3340aec0f5f1ac75accb77f98c7eede06b55f..39fc8f08444c3152bfbbdb9200b6d164f66f1cd4 100644 --- a/ecrire/exec/naviguer.php +++ b/ecrire/exec/naviguer.php @@ -410,12 +410,9 @@ function naviguer_doc ($id, $type = "article", $script, $flag_editable) { $res = "\n<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n<tr><td> </td><td style='text-align: $spip_lang_left;width: 50%;'>\n$res</td></tr></table>"; } - $res .= "<script src='"._DIR_JAVASCRIPT."async_upload.js' type='text/javascript'></script>\n"; - $res .= <<<EOF - <script type='text/javascript'> - $(".form_upload").async_upload(async_upload_portfolio_documents); - </script> -EOF; + $res .= http_script('',_DIR_JAVASCRIPT."async_upload.js") + . http_script('$(".form_upload").async_upload(async_upload_portfolio_documents);'); + } else $res =''; $documenter = charger_fonction('documenter', 'inc'); diff --git a/ecrire/exec/valider_xml.php b/ecrire/exec/valider_xml.php index 8de7da8333212a7f9398b4e98279c3ff12376a84..1e9850f0abcd26a0bd7de71d925c535db2e92b68 100644 --- a/ecrire/exec/valider_xml.php +++ b/ecrire/exec/valider_xml.php @@ -80,8 +80,7 @@ function valider_xml_ok($url, $req_ext) $commencer_page = charger_fonction('commencer_page', 'inc'); $debut = $commencer_page($titre); - $jq = "\n<script src=\"".generer_url_public('jquery.js') - . "\" type=\"text/javascript\"></script>\n"; + $jq = http_script("", generer_url_public('jquery.js')); echo str_replace('<head>', "<head>$jq", $debut); $onfocus = '<input type="text" size="70" value="' .$url_aff .'" name="var_url" id="var_url" onfocus="'.$onfocus . '" />'; diff --git a/ecrire/inc/auteur_infos.php b/ecrire/inc/auteur_infos.php index 74c140cc09e16de27f64a2d32f3265c290443e1f..982e01c11af34e2e7ff104bd3fa896ecdb802fc0 100644 --- a/ecrire/inc/auteur_infos.php +++ b/ecrire/inc/auteur_infos.php @@ -168,9 +168,9 @@ function inc_auteur_infos_dist($auteur, $new, $echec, $edit, $id_article, $redir // et masquer le formulaire si on n'en a pas besoin if (!$new AND !$echec AND !$edit) { - $corps .= "<script type='text/javascript'>jQuery('#auteur_infos_edit').hide()</script>\n"; + $corps .= http_script("jQuery('#auteur_infos_edit').hide();"); } else { - $corps .= "<script type='text/javascript'>jQuery('#auteur_infos_voir').hide()</script>\n"; + $corps .= http_script("jQuery('#auteur_infos_voir').hide();"); } // Formulaire de statut @@ -267,7 +267,7 @@ function legender_auteur_voir($auteur) { $h = "<a\nhref='$h'>$clic</a>"; $res .= icone_inline($clic, $h, "redacteurs-24.gif", "edit.gif", $spip_lang_right); - $res .= "<script type='text/javascript'><!-- + $res .= http_script(" var intitule_bouton = ".sql_quote($retour)."; jQuery('#bouton_modifier_auteur a') .click(function() { @@ -282,8 +282,7 @@ function legender_auteur_voir($auteur) { intitule_bouton = tmp; }); return false; - }); - // --></script>\n"; + });"); $res .= "</span>\n"; } diff --git a/ecrire/inc/barre.php b/ecrire/inc/barre.php index c482cf4dbc47a06dfc5fda36fc49deb0b0afa677..29af1e6b1f5b09b3cdf1c1a5e26b778e0896c617 100644 --- a/ecrire/inc/barre.php +++ b/ecrire/inc/barre.php @@ -47,7 +47,7 @@ function afficher_barre($champ, $forum=false, $lang='') { $champhelp = "document.getElementById('barre_$num_barre')"; $ret = ($num_barre > 1) ? '' : - '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'spip_barre.js"></script>'; + http_script('', _DIR_JAVASCRIPT . 'spip_barre.js'); $ret .= "<table class='spip_barre' cellpadding='0' cellspacing='0' border='0'>"; $ret .= "\n<tr>"; $ret .= "\n<td style='text-align: $spip_lang_left;' valign='middle'>"; diff --git a/ecrire/inc/documents.php b/ecrire/inc/documents.php index 480ffcb73018b65957f3e4ab6a50df826605f9a9..e11e6107cb1d36c9a09da478653dba15b704b0de 100644 --- a/ecrire/inc/documents.php +++ b/ecrire/inc/documents.php @@ -277,14 +277,11 @@ function afficher_documents_colonne($id, $type="article",$script=NULL) { $ret .= afficher_case_document($doc, $id, $script, $type, $deplier); } $ret .= "</div>"; - if (test_espace_prive()){ - $ret .= "<script src='"._DIR_JAVASCRIPT."async_upload.js' type='text/javascript'></script>\n"; - $ret .= <<<EOF - <script type='text/javascript'> - $("form.form_upload").async_upload(async_upload_article_edit) - </script> -EOF; - } + if (test_espace_prive()){ + spip_log("doc scrip"); + $ret .= http_script('', _DIR_JAVASCRIPT."async_upload.js") + . http_script('$("form.form_upload").async_upload(async_upload_article_edit)'); + } return $ret; } diff --git a/ecrire/inc/iconifier.php b/ecrire/inc/iconifier.php index 08e875265cfe9cd036ac5644c569a00be751d84b..30fe731ee698f3722762f29c280fc1c15a88f4dc 100644 --- a/ecrire/inc/iconifier.php +++ b/ecrire/inc/iconifier.php @@ -63,15 +63,12 @@ function inc_iconifier_dist($id_objet, $id, $script, $visible=false, $flag_modi . $res . fin_cadre_relief(true); - $js = ""; if(_request("exec")!="iconifier") { - $js .= "<script src='"._DIR_JAVASCRIPT."async_upload.js' type='text/javascript'></script>\n"; - $js .= <<<EOF - <script type='text/javascript'> - $("form.form_upload_icon").async_upload(async_upload_icon); - </script> -EOF; - } + $js .= http_script(_DIR_JAVASCRIPT . 'async_upload.js') + . http_script('$("form.form_upload_icon").async_upload(async_upload_icon)'); + + } else $js = ""; + spip_log($js); return ajax_action_greffe("iconifier", $id, $res).$js; } else return ''; diff --git a/ecrire/inc/layer.php b/ecrire/inc/layer.php index 74cf9fda41dfa853342731f62d0b6ec54302ba5a..552f941ee601de7a6950315bb74bd73b68054a05 100644 --- a/ecrire/inc/layer.php +++ b/ecrire/inc/layer.php @@ -71,9 +71,6 @@ function bouton_block_depliable($texte,$deplie,$ids=""){ else{ $cible = "#$bouton_id + div.bloc_depliable"; } - $extra_js = ($deplie==='incertain') - ? "\nif (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');" - : ''; return "<div " .($bouton_id?"id='$bouton_id' ":"") @@ -83,11 +80,9 @@ function bouton_block_depliable($texte,$deplie,$ids=""){ :" onmouseover=\"jQuery(this).depliant('$cible');\"" ) .">$texte</div>" - . (strlen($extra_js)?"<script type='text/javascript'><!-- - jQuery(document).ready(function(){ $extra_js - }); - //--></script>":"") - ; + .http_script( ($deplie==='incertain') + ? "jQuery(document).ready(function(){if (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');});" + : ''); } // @@ -189,17 +184,4 @@ ondblclick='storeCaret(this);'"); // meme principe que le behavior win_width.htc pour MSIE $GLOBALS['browser_verifForm'] = (preg_match(",mozilla,i", $GLOBALS["browser_name"]) AND $GLOBALS["browser_rev"] >= 1.7) ? "verifForm();" : ""; -// http://doc.spip.org/@http_script -function http_script($script, $src='', $noscript='') { - return '<script type="text/javascript"' - . ($src ? " src=\"$src\"" : '') - . ">" - . (!$script ? '' : - ("<!--\n" . - preg_replace(',</([^>]*)>,','<\/\1>', $script) . - "\n//-->")) - . "</script>\n" - . (!$noscript ? '' : "<noscript>\n\t$noscript\n</noscript>\n"); -} - ?> diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php index d73dd0cab0a59ec83897a3d62ef6f2fc74d24010..56423f3ebdde187c128355709cd5f6a96c379fcb 100644 --- a/ecrire/inc/presentation.php +++ b/ecrire/inc/presentation.php @@ -61,7 +61,7 @@ function afficher_onglets_pages($ordre,$onglets){ $onglet_compteur++; return "<div class='boite_onglets' id='boite_onglet_$onglet_compteur'>$res</div>" . (_INTERFACE_ONGLETS ? - "<script type='text/javascript'>$('#boite_onglet_$onglet_compteur').tabs(".($actif?"$actif,":"")."{ fxAutoHeight: true }); + http_script("$('#boite_onglet_$onglet_compteur').tabs(".($actif?"$actif,":"")."{ fxAutoHeight: true }); if (!$.browser.safari) $('ul.tabs-nav li').hover( function(){ @@ -70,9 +70,8 @@ function afficher_onglets_pages($ordre,$onglets){ } , function(){} - ); - </script>" - :""); + );") + :""); } // http://doc.spip.org/@debut_cadre diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index c2be5f32d6a7e8b1607b3a1a0d8fb8b28a98ec34..deeb4e0c76ca94571aa3ecdc18adafccb6a1d786 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -507,6 +507,25 @@ function quote_amp($u) { "&",$u); } +// Production d'une balise Script valide +// http://doc.spip.org/@http_script +function http_script($script, $src='', $noscript='') { + + if ($src) + $src = " src='$src'"; + if ($script) + $script = ("<!--\n" . + preg_replace(',</([^>]*)>,','<\/\1>', $script) . + "\n//-->\n"); + if ($noscript) + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; + + + return ($src OR $script OR $noscript) + ? "<script type='text/javascript'$src>$script</script>$noscript" + : ''; +} + // Transforme n'importe quel champ en une chaine utilisable // en PHP ou Javascript en toute securite // < ? php $x = '[(#TEXTE|texte_script)]'; ? >