source: spip-zone/_plugins_/google_ajax_search/googleajaxsearch_pipeline.php

Last change on this file was 78824, checked in by real3t@…, 8 years ago

Afficher automatiquement le terme recherché (envoyé par l'URL via le formulaire de recherche de SPIP).

File size: 904 bytes
Line 
1<?php
2if (!defined('_ECRIRE_INC_VERSION')) return;
3
4function googleajaxsearch_insert_head($flux){
5   
6    // https://developers.google.com/custom-search/docs/element
7    $flux.='<!-- google search -->
8    <script src="https://www.google.com/jsapi"></script>
9    <script type="text/javascript">
10                function getParameterByName(name) {
11                        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
12                        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
13                                results = regex.exec(location.search);
14                        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
15                }
16        google.load(\'search\', \'1\');
17        google.setOnLoadCallback(function(){
18          var searchControl = new google.search.CustomSearchControl();
19                  searchControl.draw(\'searchcontrol\');
20                  searchControl.execute(getParameterByName(\'recherche\'));
21       }, true);
22    </script>';
23       
24        return $flux;
25}
26       
27?>
Note: See TracBrowser for help on using the repository browser.