source: spip-zone/_plugins_/_dev_/google_ajax_search/googleajaxsearch_pipeline.php @ 10569

Last change on this file since 10569 was 10569, checked in by erational@…, 14 years ago

plugin google_ajax_search: ajout d'un moteur de recherche personnalisé google en ajax sur son site spip

attention: ne filtre pas les pubs.

File size: 1.7 KB
Line 
1<?php
2
3// --------------------------------
4// partie privee
5// --------------------------------
6
7function googleajaxsearch_ajouterBoutons($boutons_admin) {
8        // admin ?
9        if ($GLOBALS['connect_statut'] == "0minirezo") {
10            $boutons_admin['configuration']->sousmenu['googleajaxsearch']= new Bouton(
11                    _DIR_PLUGIN_GOOGLEAJAXSEARCH.'img_pack/google_but.png', _T('googleajaxsearch:config_plug'));
12        }
13        return $boutons_admin;
14}
15
16
17// --------------------------------
18// partie publique
19// --------------------------------
20function googleajaxsearch_insert_head($flux){
21   
22    $adresse_site = $GLOBALS['meta']['adresse_site'];
23    $google_key = $GLOBALS['meta']['google_key'];
24               
25                $flux.='
26    <!-- google ajax api search -->
27    <link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet"/>
28    <script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&key='.$google_key.'" type="text/javascript"></script>
29    <script language="Javascript" type="text/javascript">
30    //<![CDATA[
31
32    function OnLoad() {
33      // Create a search control
34      var searchControl = new GSearchControl();
35     
36      // web search with options
37      var siteSearch = new GwebSearch();
38      siteSearch.setSiteRestriction("'.$adresse_site.'");
39      var options = new GsearcherOptions();
40      options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
41     
42      // add websearch
43      searchControl.addSearcher(siteSearch, options);
44     
45      // tell the searcher to draw itself and tell it where to attach
46      searchControl.draw(document.getElementById("searchcontrol"));
47
48    }
49    GSearch.setOnLoadCallback(OnLoad);
50
51    //]]>
52    </script>';
53               
54       
55        return $flux;
56}
57       
58?>
Note: See TracBrowser for help on using the repository browser.