forum.coppermine-gallery.net
Support => Français (French) => Language Specific Support => cpg1.4.x Français (French) => Topic started by: Pascal YAP on July 29, 2007, 11:52:05 pm
-
Bonjour,
Pour les Galeries Coppermine qui possèdent, comme la mienne, un nombre important de Mots-Clefs, voici une alternative très pratique.
Ma Galerie possède au moins 4000 mots-clefs, et par le fait, la lecture de la page "RECHERCHEZ" était très inconfortable, voire impossible, sauf pour les Moteurs de Recherches !
Dans votre-CPG/INCLUDE/ remplacez le fichier KEYWORD.INC.PHP par le code suivant (conservez le fichier d'origine sur votre serveur par exemple en le renommant Keyword.inc.php_ORI pour un retour instantané en cas de problème)
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2006 Coppermine Dev Team
v1.1 originally written by Gregory DEMAR
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.
********************************************
Coppermine version: 1.4.5
$Source: /cvsroot/coppermine/stable/include/keyword.inc.php,v $
$Revision: 1.6 $
$Author: gaugau, Stramm, PYAP $
$Date: 2007/07/29 23:40:41 $
**********************************************/
if (!defined('IN_COPPERMINE')) { die('Not in Coppermine...');}
//mod indexed keaywords
define("DELIMITER", " | "); // Séparation entre les mots-clefs
function spacer($w, $n)
{
for ($i = 1; $i <= $n; $i++)
{
$index .= DELIMITER . chr((ord($w)) + $i);
}
return $index;
}
// ADDED KEYWORDS FUNCTIONALITY A-Z in French by PYAP.
$result = cpg_db_query("select keywords FROM {$CONFIG['TABLE_PICTURES']} WHERE keywords <> '' $ALBUM_SET");
if (mysql_num_rows($result)) {
// Grab all keywords
print '<br />';
starttable("100%", $lang_search_php['keyword_list_title']);
// Find unique keywords
$keywords_array = array();
while (list($keywords) = mysql_fetch_row($result)) {
$array = explode(" ",$keywords);
foreach($array as $word)
{
if (!in_array($word = utf_strtolower($word),$keywords_array)) $keywords_array[] = $word;;
}
}
// Sort selected keywords
sort($keywords_array);
$count = count($keywords_array);
// Result to table
echo '<tr><td class="tableb" align="justify"><p align="justify"><font size="+1">' ; // Aspect des résultats de la recherche.
//mod indexed keywords
$oldword = "";
$html="";
$special_html="";
$index_list="";
$special="FALSE";
foreach($keywords_array as $key)
{
$word = strtoupper(substr($key, 0, 1));
if (($word < "A" or $word >"Z")) {
if ($special=="FALSE") { // if we do not have it in the index and special exits
$index_list .= "<b><u><a href=\"#1-9\">1-9</a></u></b>";
$special_html .= "<br><br><a name=\"1-9\"></a><b>1-9/é</b><br>"; // container for 1-9 and accentuated chars
}
$special="TRUE"; //we have special now in the index
$special_html .= "<a href=\"thumbnails.php?album=search&search=".$key."\">$key</a> ";
$special_html .= DELIMITER;
} else { // index and keywords a-z
$next = strncasecmp($word, $oldword, 1); // compare this first letter with the first letter of the next keyword
if ($next > 0) // next keaywords first letter <> this keywords first letter
{
$index_list .= spacer($oldword, --$next); // add the non linked 'spacer' letters
if (strlen($html) >= strlen(DELIMITER)) $html = substr($html,0,(strlen($html)-strlen(DELIMITER))); // remove trailing delimiter
$html .= "<br><br><a name=\"{$word}\"></a><b>{$word}</b><br>"; //add the first letter as header to the html
$index_list .= DELIMITER . "<b><u><a href=\"#{$word}\">{$word}</a></u></b>";
$oldword = $word;
}
$html .= "<a href=\"thumbnails.php?album=search&search=".$key."\">{$key}</a>" . DELIMITER;
}
}
if (strlen($html) >= strlen(DELIMITER)) $html = substr($html,0,(strlen($html)-strlen(DELIMITER)));
$index_list .= spacer($oldword, strncasecmp("Z", $word, 1));
$special_html = substr($special_html,0,strlen($special_html)-strlen(DELIMITER));
if (strlen($special_html)==0) $index_list = "1-9". $index_list;
echo $index_list;
echo "<br>";
echo $special_html;
echo $html;
echo "<br>";
echo "</td></tr>" ;
if (GALLERY_ADMIN_MODE == true){
$url = basename($_SERVER['PHP_SELF']);
if ($url != "keywordmgr.php"){
echo '<tr><td class="tableb" align="center">';
echo '<a href="keywordmgr.php" class="admin_menu">Edit Keywords</a>';
echo "</td></tr>" ;
}
} else {
echo '<tr><td class="tableb" align="center">';
echo $lang_search_php['keyword_msg'];
echo "</td></tr>" ;
}
endtable();
}
ob_end_flush();
?>
Exemple perso : I C I (http://www.pays-dignois.com/galerie/search.php) .
PYAP
(http://forum.coppermine-gallery.net/index.php?action=dlattach;topic=45710.0;attach=7975;image)
(fully based on a Stramm mod)
-
Hey, encore une bonne idée... ;)
-
Bonjour Pyap,
Bravo pour cette alternative.
Cependant, je posséde comme beaucoup un nombre important de mots-clefs et l'affichage de la page "Recherche" est très très ... long.
Comment faire pour que s'affiche juste les lettres sans les mots clefs en dessous.
Lorsque le membre clique sur une lettre, les mots clefs en rapport avec cette lettre s'affiche en dessous.
Cela permet d'avoir une liste importante de mots sans surcharger le serveur.
En résumé, il faut juste faire une sorte de pagination comme pour un lexique.
Exemple avec le site Annuaire TV:
http://annuaire.audiencestv.com/top_kw-n1-_.html
Si la mise en place est difficile, je peux te rémunérer.
Bien cordialement,
Kad 75
-
ah oui... c'est pas mal ça aussi :)
je n'ai pas encore activé les mots clés dans la recherche car c'est encore trop le foutoir, mais c'est clair que ce sera bien mieux présenté comme ça ^^