function surligner_mots($page, $surcharge_surligne = '') { $surlignejs_engines = array(array("," . str_replace(array("/", "."), array("\\/", "\\."), $GLOBALS['meta']['adresse_site']) . ",i", ",recherche=([^&]+),i"), array(",^http://(www\\.)?google\\.,i", ",q=([^&]+),i"), array(",^http://(www\\.)?search\\.yahoo\\.,i", ",p=([^&]+),i"), array(",^http://(www\\.)?search\\.msn\\.,i", ",q=([^&]+),i"), array(",^http://(www\\.)?search\\.live\\.,i", ",query=([^&]+),i"), array(",^http://(www\\.)?search\\.aol\\.,i", ",userQuery=([^&]+),i"), array(",^http://(www\\.)?ask\\.com,i", ",q=([^&]+),i"), array(",^http://(www\\.)?altavista\\.,i", ",q=([^&]+),i"), array(",^http://(www\\.)?feedster\\.,i", ",q=([^&]+),i"), array(",^http://(www\\.)?search\\.lycos\\.,i", ",q=([^&]+),i"), array(",^http://(www\\.)?alltheweb\\.,i", ",q=([^&]+),i"), array(",^http://(www\\.)?technorati\\.com,i", ",([^\\?\\/]+)(?:\\?.*)\$,i")); $ref = $_SERVER['HTTP_REFERER']; //avoid a js injection if ($surcharge_surligne) { $surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", "\$1\\\\\$2", $surcharge_surligne); $surcharge_surligne = str_replace("\\", "\\\\", $surcharge_surligne); if ($GLOBALS['meta']['charset'] == 'utf-8') { include_spip('inc/charsets'); if (!is_utf8($surcharge_surligne)) { $surcharge_surligne = utf8_encode($surcharge_surligne); } } } foreach ($surlignejs_engines as $engine) { if ($surcharge_surligne || preg_match($engine[0], $ref) && preg_match($engine[1], $ref)) { //good referrer found or var_recherche is not null include_spip('inc/filtres'); $script = "\n <script type='text/javascript' src='" . url_absolue(find_in_path('javascript/SearchHighlight.js')) . "'></script>\n <script type='text/javascript'>/*<![CDATA[*/\n if (window.jQuery)\n (function(\$){\$(function(){\n \$(document).SearchHighlight({\n tag_name:'" . (html5_permis() ? 'mark' : 'span') . "',\n style_name:'spip_surligne',\n exact:'whole',\n style_name_suffix:false,\n engines:[/^" . str_replace(array("/", "."), array("\\/", "\\."), $GLOBALS['meta']['adresse_site']) . "/i,/recherche=([^&]+)/i],\n highlight:'.surlignable',\n nohighlight:'.pas_surlignable'" . ($surcharge_surligne ? ",\n keys:'{$surcharge_surligne}'" : "") . ",\n min_length: 3\n })\n });\n })(jQuery);\n /*]]>*/</script>\n "; // on l'insere juste avant </head>, sinon tout en bas if (is_null($l = strpos($page, '</head>'))) { $l = strlen($page); } $page = substr_replace($page, $script, $l, 0); break; } } return $page; }
function formulaires_configurer_moderniseur_charger_dist() { $valeurs = array('version_html_max' => html5_permis() ? 'html5' : 'html4'); return $valeurs; }
/** * Compile la balise `#HTML5` indiquant si l'espace public peut utiliser du HTML5 * * Renvoie `' '` si le webmestre souhaite que SPIP génère du code (X)HTML5 sur * le site public, et `''` si le code doit être strictement compatible HTML4 * * @balise * @uses html5_permis() * @example * ``` * [(#HTML5) required="required"] * <input[ (#HTML5|?{type="email",type="text"})] ... /> * ``` * * @param Champ $p * Pile au niveau de la balise * @return Champ * Pile complétée par le code à générer */ function balise_HTML5_dist($p) { $p->code = html5_permis() ? "' '" : "''"; $p->interdire_scripts = false; return $p; }
function traiter_raccourci_ancre($letexte) { if (preg_match_all(_RACCOURCI_ANCRE, $letexte, $m, PREG_SET_ORDER)) { foreach ($m as $regs) { $letexte = str_replace($regs[0], '<a ' . (html5_permis() ? 'id' : 'name') . '="' . entites_html($regs[1]) . '"></a>', $letexte); } } return $letexte; }