Bonjour à tous,
je vous livre le MOD que j'ai fait pour permettre une recherche sur plusieurs mots clé avec les opérateurs ET et OU.
Vous pouvez le voir en action sur mon site:http://f.keller.free.frPlus depuis la passage à la version 1.4.2
Avant de l'installer, veillez à faire une sauvegarde des fichier search.php et des fichiers languages(lang/english.php et lang/french.php)
Installation:
Etape N°1:Remplacer le contenu du fichier
search.php par celui ci:
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.3.1 //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2004 Gregory DEMAR <gdemar@wanadoo.fr> //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or//
// (at your option) any later version. //
// ------------------------------------------------------------------------- //
//***************************************************************************//
//* Modifié par Frantz Janvier 2005 . . . *//
//* this Mod/Hack deSEARCH.PHP, permets une recherche sur plusieurs mots clé ! *//
//* EXEMPLE : http://http://membres.lycos.fr/photosfrantz/ *//
//***************************************************************************//
//* Si vous rencontrez un problème avec Coppermine, *//
//* n'hÃ(c)sitez pas à visiter le Forum COPPERMINE EN FRANCAIS ci-dessous *//
//* http://forum.coppermine-gallery.net/index.php?board=38.0 *//
//* MERCI *//
//***************************************************************************//
define('IN_COPPERMINE', true);
define('SEARCH_PHP', true);
require('include/init.inc.php');
pageheader($lang_search_php[0]);
?>
<?php
starttable("500",$lang_search_php[3]);
//echo "" ;
error_reporting(E_ALL ^ E_NOTICE);
?>
<form name="FormChoix" method="post" action="searchkeywords.php">
<tr><td class=tableb><p align=center>
<input type="radio" name="typechoix"
<?php if($_POST["typechoix"]==" AND ")
echo "CHECKED";?>
value=" AND "><b><?php echo $lang_search_php[8]?></b>
<input type="radio" name="typechoix"
<?php if($_POST["typechoix"]==" OR ")
echo "CHECKED";?>
value=" OR "><b><?php echo $lang_search_php[7]?></b>
<br>
<?php
endtable();
//echo "<br>";
// Select all keywords
$result = mysql_query("select keywords from {$CONFIG['TABLE_PICTURES']}");
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap']);
// Find unique keywords
$keywords_array = array();
while (list($keywords) = mysql_fetch_row($result)) {
$array = explode(" ",$keywords);
foreach($array as $word)
{
if (!in_array($word,$keywords_array)) $keywords_array[] = $word;
}
}
starttable("500", $lang_search_php[4]);
?>
<?php
sort($keywords_array);
$count = count($keywords_array);
//echo "<br>";
echo "<center>$count $lang_search_php[9]</center>";
// Result to table
echo "<tr><td ><p align=center>" ;
//affichage du choix d'association des mots clé
?>
<?php
// Affichage des mots clé avec checkbox
for ($i = 1; $i < $count; $i++) {
?>
<input type="checkbox" name="choix[]"
<? for ($k=0;$k<count($_POST["choix"]);$k++)
if($keywords_array[$i]==$_POST["choix"][$k]) {
echo "CHECKED";
break;
} ?>
value="<? echo $keywords_array[$i];?>"
><?php
echo "$keywords_array[$i]" ;
}
?>
<br>
<br>
<input type="submit" name="Valider" value="<?php echo $lang_search_php[2] ?>">
<br>
<br>
</form>
<?php
pagefooter();
ob_end_flush();
?>
Etape N°2Créer un nouveau fichier nommé
searchkeywords.php placez y ce code:
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.3.1 //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2004 Gregory DEMAR <gdemar@wanadoo.fr> //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or//
// (at your option) any later version. //
// ------------------------------------------------------------------------- //
//***************************************************************************//
//* Modifié par Frantz Juin 2005 . . . *//
//* this Mod/Hack de SEARCH.PHP, permets une recherche sur plusieurs mots clé ! *//
//* EXEMPLE : http://http://membres.lycos.fr/photosfrantz/ *//
//***************************************************************************//
//* Si vous rencontrez un problème avec Coppermine, *//
//* n'hÃ(c)sitez pas à visiter le Forum COPPERMINE EN FRANCAIS ci-dessous *//
//* http://forum.coppermine-gallery.net/index.php?board=38.0 *//
//* MERCI *//
//***************************************************************************//
define('IN_COPPERMINE', true);
define('SEARCH_PHP', true);
require('include/init.inc.php');
pageheader($lang_search_php[0]);
?> <?php
starttable("500",$lang_search_php[6]);
if($_POST["typechoix"]==" AND "){
$ChoixOperateur= $lang_search_php[8];
}
if($_POST["typechoix"]==" OR "){
$ChoixOperateur=$lang_search_php[7];
}
echo"<br>";
if($_POST["choix"]) {
for ($i=0;$i<count($_POST["choix"]);$i++){
$recherche=$recherche.$_POST["choix"][$i].$_POST["typechoix"];
$choixmotscle=$choixmotscle.$_POST["choix"][$i]."-";
}
}
echo <<< EOT
<form method="get" name="Form1" action="thumbnails.php">
<td colspan="8" align="center" >
<br><center>$lang_search_php[11]<b>$choixmotscle</b>$lang_search_php[12]<b>$ChoixOperateur</</b></center>
<br>
<br>
<input type="submit" name="Rechercher" value=" $lang_search_php[0]" >
<input type="button" name="Rechercher" value=" $lang_search_php[10]" onClick="javascript:window.history.go (-1)">
</td>
<input type="hidden" name="album" value="search">
<input type="hidden" name="type" value="full">
<input type="hidden" name="search" value="$recherche">
<br>
<br>
</form>
EOT;
endtable();
pagefooter();
ob_end_flush();
?>
Etape N°3
Editez le fichier language
lang/english.phptrouvez ce code(aux environ de la lignes 1010)
// ------------------------------------------------------------------------- //
// File search.php - OK
// ------------------------------------------------------------------------- //
if (defined('SEARCH_PHP')) $lang_search_php = array(
0 => 'Search the file collection',
);
remplacez le par celui ci:
// ------------------------------------------------------------------------- //
// File search.php - OK
// ------------------------------------------------------------------------- //
if (defined('SEARCH_PHP')) $lang_search_php = array(
0 => 'Search the file collection',
1 => 'Select the keywords',
2 => 'Submit',
3 => 'Step 1: Chose the search mode',
4 => 'Step 2: Select the keywords you want to search',
5 => 'Step 3: Click the "Search" button to search the file collection',
6 => 'Please confirm your choice',
7 => 'OR',
8 => 'AND',
9 => 'Keywords in the database',
10 => 'Cancel',
11 => 'Your choice is: ',
12 => ' and the operator: ',
);
Editez le fichier
lang/french.phptrouvez le code ci dessous (aux environ de la ligne 1017)
// ------------------------------------------------------------------------- //
// File search.php - OK
// ------------------------------------------------------------------------- //
if (defined('SEARCH_PHP')) $lang_search_php = array(
0 => 'Rechercher une image dans la galerie',
);
remplacez le par celui ci
// ------------------------------------------------------------------------- //
// File search.php - OK
// ------------------------------------------------------------------------- //
if (defined('SEARCH_PHP')) $lang_search_php = array(
0 => 'Recherche d\'images dans la galerie',
1 => 'Selectionnez les mots clé',
2 => 'Valider',
3 => 'Etape N°1: Choisissez le mode de recherche',
4 => 'Etape N°2: Sélectionnez les mots clé',
5 => 'Etape N°3: Cliquez sur le boutton "Rechercher" pour lancer la recherche',
6 => 'Merci de confirmer votre choix',
7 => 'OU',
8 => 'ET',
9 => 'Mots clé dans la base de donnée',
10 => 'Annuler',
11 => 'Vous avez choisi les mots clé: ',
12 => ' et l\'opérateur '
);
Voilà c'est fait, ça devrait marcher
(en tout cas chez moi ça marche) avec une internationalisation des boutons et des textes pour le Français et pour l'Anglais (pour les autres langues à chacun de voir)
François