Skip to content
Extraits de code Groupes Projets
Valider 6815a7fa rédigé par cerdic's avatar cerdic
Parcourir les fichiers

format du code

parent eb1413c5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -15,70 +15,71 @@ if (!defined('_ECRIRE_INC_VERSION')) return; ...@@ -15,70 +15,71 @@ if (!defined('_ECRIRE_INC_VERSION')) return;
// Ces commentaires vont etre substitue's en mode recherche // Ces commentaires vont etre substitue's en mode recherche
// voir balise_DEBUT_SURLIGNE et balise_FIN_SURLIGNE // voir balise_DEBUT_SURLIGNE et balise_FIN_SURLIGNE
define('MARQUEUR_SURLIGNE', 'debut_surligneconditionnel'); define('MARQUEUR_SURLIGNE', 'debut_surligneconditionnel');
define('MARQUEUR_FSURLIGNE', 'finde_surligneconditionnel'); define('MARQUEUR_FSURLIGNE', 'finde_surligneconditionnel');
// http://doc.spip.org/@surligner_mots // http://doc.spip.org/@surligner_mots
function surligner_mots($page, $surcharge_surligne='') { function surligner_mots($page, $surcharge_surligne = '') {
$surlignejs_engines = array( $surlignejs_engines = array(
array(",".str_replace(array("/","."),array("\/","\."),$GLOBALS['meta']['adresse_site']).",i", ",recherche=([^&]+),i"), //SPIP array(",".str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']).",i", ",recherche=([^&]+),i"), //SPIP
array(",^http://(www\.)?google\.,i", ",q=([^&]+),i"), // Google array(",^http://(www\.)?google\.,i", ",q=([^&]+),i"), // Google
array(",^http://(www\.)?search\.yahoo\.,i", ",p=([^&]+),i"), // Yahoo array(",^http://(www\.)?search\.yahoo\.,i", ",p=([^&]+),i"), // Yahoo
array(",^http://(www\.)?search\.msn\.,i", ",q=([^&]+),i"), // MSN array(",^http://(www\.)?search\.msn\.,i", ",q=([^&]+),i"), // MSN
array(",^http://(www\.)?search\.live\.,i", ",query=([^&]+),i"), // MSN Live array(",^http://(www\.)?search\.live\.,i", ",query=([^&]+),i"), // MSN Live
array(",^http://(www\.)?search\.aol\.,i", ",userQuery=([^&]+),i"), // AOL array(",^http://(www\.)?search\.aol\.,i", ",userQuery=([^&]+),i"), // AOL
array(",^http://(www\.)?ask\.com,i", ",q=([^&]+),i"), // Ask.com array(",^http://(www\.)?ask\.com,i", ",q=([^&]+),i"), // Ask.com
array(",^http://(www\.)?altavista\.,i", ",q=([^&]+),i"), // AltaVista array(",^http://(www\.)?altavista\.,i", ",q=([^&]+),i"), // AltaVista
array(",^http://(www\.)?feedster\.,i", ",q=([^&]+),i"), // Feedster array(",^http://(www\.)?feedster\.,i", ",q=([^&]+),i"), // Feedster
array(",^http://(www\.)?search\.lycos\.,i", ",q=([^&]+),i"), // Lycos array(",^http://(www\.)?search\.lycos\.,i", ",q=([^&]+),i"), // Lycos
array(",^http://(www\.)?alltheweb\.,i", ",q=([^&]+),i"), // AllTheWeb array(",^http://(www\.)?alltheweb\.,i", ",q=([^&]+),i"), // AllTheWeb
array(",^http://(www\.)?technorati\.com,i", ",([^\?\/]+)(?:\?.*)$,i"), // Technorati array(",^http://(www\.)?technorati\.com,i", ",([^\?\/]+)(?:\?.*)$,i"), // Technorati
); );
$ref = $_SERVER['HTTP_REFERER']; $ref = $_SERVER['HTTP_REFERER'];
//avoid a js injection //avoid a js injection
if($surcharge_surligne) { if ($surcharge_surligne){
$surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),","$1\\\\$2",$surcharge_surligne); $surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", "$1\\\\$2", $surcharge_surligne);
$surcharge_surligne = str_replace("\\","\\\\",$surcharge_surligne); $surcharge_surligne = str_replace("\\", "\\\\", $surcharge_surligne);
if($GLOBALS['meta']['charset']=='utf-8') { if ($GLOBALS['meta']['charset']=='utf-8'){
include_spip('inc/charsets'); include_spip('inc/charsets');
if(!is_utf8($surcharge_surligne)) $surcharge_surligne = utf8_encode($surcharge_surligne); if (!is_utf8($surcharge_surligne)) $surcharge_surligne = utf8_encode($surcharge_surligne);
} }
} }
foreach($surlignejs_engines as $engine) foreach ($surlignejs_engines as $engine)
if($surcharge_surligne || (preg_match($engine[0],$ref) && preg_match($engine[1],$ref))) { if ($surcharge_surligne || (preg_match($engine[0], $ref) && preg_match($engine[1], $ref))){
//good referrer found or var_recherche is not null //good referrer found or var_recherche is not null
include_spip('inc/filtres'); include_spip('inc/filtres');
$script = " $script = "
<script type='text/javascript' src='".url_absolue(find_in_path('javascript/SearchHighlight.js'))."'></script> <script type='text/javascript' src='".url_absolue(find_in_path('javascript/SearchHighlight.js'))."'></script>
<script type='text/javascript'>/*<![CDATA[*/ <script type='text/javascript'>/*<![CDATA[*/
if (window.jQuery) if (window.jQuery)
(function(\$){\$(function(){ (function(\$){\$(function(){
\$(document).SearchHighlight({ \$(document).SearchHighlight({
tag_name:'".(html5_permis()?'mark':'span')."', tag_name:'".(html5_permis() ? 'mark' : 'span')."',
style_name:'spip_surligne', style_name:'spip_surligne',
exact:'whole', exact:'whole',
style_name_suffix:false, style_name_suffix:false,
engines:[/^".str_replace(array("/","."),array("\/","\."),$GLOBALS['meta']['adresse_site'])."/i,/recherche=([^&]+)/i], engines:[/^".str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site'])."/i,/recherche=([^&]+)/i],
highlight:'.surlignable', highlight:'.surlignable',
nohighlight:'.pas_surlignable'". nohighlight:'.pas_surlignable'".
($surcharge_surligne?", ($surcharge_surligne ? ",
keys:'$surcharge_surligne'":"").", keys:'$surcharge_surligne'" : "").",
min_length: 3 min_length: 3
}) })
}); });
})(jQuery); })(jQuery);
/*]]>*/</script> /*]]>*/</script>
"; ";
// on l'insere juste avant </head>, sinon tout en bas // on l'insere juste avant </head>, sinon tout en bas
if (is_null($l = strpos($page,'</head>'))) if (is_null($l = strpos($page, '</head>')))
$l = strlen($page); $l = strlen($page);
$page = substr_replace($page, $script, $l,0); $page = substr_replace($page, $script, $l, 0);
break; break;
} }
return $page; return $page;
} }
?> ?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter