Subversion Repositories Applications.papyrus

Rev

Rev 2091 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/**
 * @author    Raphaël Droz <raphael@tela-botania.org>
 * @copyright 2013 Tela-Botanica
 * @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
 *
 * Intégration du moteur de recherche Google
 * Exemple de templates relatifs pour lesquels envisager un remplacement de PAPYRUS_MOTEUR_RECHERCHE:
 * - sites/botanique/fr/squelettes/botanique.html: PAPYRUS_GOOGLE (en-tête)
 * - sites/botanique/fr/squelettes/botanique.html: PAPYRUS_GOOGLE:results (corps de page)
 *
 **/

$GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = 'afficherMoteurRechercheGoogle';
$GLOBALS['_GEN_commun']['info_applette_balise'] =       '(?:<!-- '.$GLOBALS['_GEN_commun']['balise_prefixe'].'GOOGLE(?::(\w+))? -->|\{\{GoogleInput(?::(\w+))?\}\})';

function afficherMoteurRechercheGoogle($tab_applette_arguments, $_GEN_commun) {
        // boite de résultats
        // TODO: comment stopper le chargement de #zone_contenu_corps//PAPYRUS_CONTENU_CORPS ?
        // réponse: cf: papyrus/applications/afficheur/afficheur.php :: afficherContenuCorps() 
        // TODO: link href dans <body> est non-standard
        if($tab_applette_arguments[1] == 'results') {
                return <<<EOF
<gcse:searchresults-only queryParameterName="r"></gcse:searchresults-only>
EOF;
        }
        $host = 'http://www.tela-botanica.org';
        $url = $_SERVER['REDIRECT_URL'];
        /*$d = array();
        parse_str($_SERVER['QUERY_STRING'], $d);
        var_dump(urldecode(http_build_query($d)));die;*/
        $script = file_get_contents(dirname(__FILE__) . '/google.html');
        return <<<EOF
<link href="/papyrus/applettes/google/google.css" rel="stylesheet" type="text/css" />
$script
<!-- <gcse:search></gcse:search> -->
<gcse:searchbox-only resultsUrl="$host$url" queryParameterName="r"></gcse:searchbox-only>
EOF;
}