Fork me on GitHub






intégrer un module dans le champ du moteur de recherche
Semi pro
Inscrit: 27/10/2004 11:10
Messages: 566
Bonjour
Comment intégrer le contenu du module xoopsgallery dans le champ du moteur de recherche d'un site ?
merci

Posté le : 19/04/2008 15:08

J'aime les sirènes ...
j'aime pas les arrêtes dans le poisson !...
Partager Twitter Partagez cette article sur GG+
Re: intégrer un module dans le champ du moteur de recherche
Xoops accro
Inscrit: 04/02/2003 01:54
De Le Mans
Messages: 12273
Bonjour,

Pour qu'un module puisse être utilisé dans la recherche de Xoops, il faut tenir compte des éléments suivants :

- fichier xoops_version.php
// Search
// la valeur doit être positionnée à 1
$modversion['hasSearch'] = 1;
//chemin et nom du fichier qui contient le code de recherche
$modversion['search']['file'] = "include/search.inc.php";
//nom de la fonction à appeler
$modversion['search']['func'] = "extgallerySearch";

- "include/search.inc.php";
il suffit de prendre un fichier existant d'un autre module et de l'adapter pour tenir compte du nom des tables et du nom des champs.

Si le module gère des permissions, la fonction de recherche doit en tenir compte. Consulter le fichier include/search.inc.php du module news par exemple pour étudier la méthode analysée.

Posté le : 20/04/2008 05:54
Partager Twitter Partagez cette article sur GG+
Re: intégrer un module dans le champ du moteur de recherche
Semi pro
Inscrit: 27/10/2004 11:10
Messages: 566
Bonjour Christian
tout d'abord merci pour la réponse détaillée.
Je vois le principe, complexe mais pas insurmontable
par contre je vois déjà un os, car je me rends compte que dans xoopsgallery, les commentaires sous les photos ne sont pas enregistrés dans une table de la base de donnée, et comme c'est la principale matière où le moteur devrait chercher ...
J'ai d'ailleurs testé le moteur de recherche personnalisé de Google, et me suis rendu compte qu'il ne prenait pas en compte ce texte, peut être une explication à ce comportement ?
je creuse et reviens vers vous si j'ai avancé

Posté le : 20/04/2008 13:57

J'aime les sirènes ...
j'aime pas les arrêtes dans le poisson !...
Partager Twitter Partagez cette article sur GG+
Re: intégrer un module dans le champ du moteur de recherche
Semi pro
Inscrit: 27/10/2004 11:10
Messages: 566
bien, en fait il y a une fonction de recherche directement intégrée dans le module xoopsgallery, et qui fonctionne bien.
L'idéal serait de pouvoir la rattacher au moteur de recherche général du site.
voici le code du fichier search.php
<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2002 Bharat Mediratta
 * 
 * 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.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

// Hack prevention.
if (!empty($_REQUEST["GALLERY_BASEDIR"])) {
    print 
"Security violationn";
    exit;
}
require(
'./init.php');
$myts =& MyTextSanitizer::getInstance();

$borderColor $gallery->app->default["bordercolor"];
$thumbSize $gallery->app->default["thumb_size"];

if (!
$GALLERY_EMBEDDED_INSIDE) { 
?>
<html>
<head>
<title><?php echo $gallery->app->galleryTitle ?> : <?php echo _XG_SEARCH;?></title>
<?php echo getStyleSheetLink() ?>
</head>
<body>
<?php ?>
<?php 
includeHtmlWrap
("search.header");
?>
<?php
$searchstring 
removeTags($searchstring);
if (
$searchstring) {
?>
<table width="100%" border="0" cellspacing="0">
<tr>
<td valign="middle" align="right">
<?php echo makeFormIntro("search.php", array("GET")); ?>
<span class="admin"><?php echo _XG_SEARCH_AGAIN?></span>
<input style="font-size=10px;" type="text" name="searchstring" value="<?php echo $searchstring ?>" size="25">
</td>
</form>   
</tr>
<tr><td height="2px">
<img src="<?php echo $gallery->app->photoAlbumURL ?>/images/pixel_trans.gif" />
</td></tr>
</table> 
<?php
}
?>
<!-- Top Nav -->
<?php
$breadtext
[0] = "<a href="makeGalleryUrl("albums.php") . ">".$gallery->app->galleryTitle."</a>";
$breadcrumb["text"] = $breadtext;
$breadcrumb["bordercolor"] = $borderColor;
$breadcrumb["top"] = true;
$breadcrumb["bottom"] = true;
include(
$GALLERY_BASEDIR "layout/breadcrumb.inc");
?>
<!-- end Top Nav -->
<?php

$navigator
["fullWidth"] = 100;
$navigator["widthUnits"] = "%";

$list =& $gallery->albumDB->albumList;
$numAlbums count($list);
$photoMatch 0;
$albumMatch 0;
if (
$searchstring) {
    
$adminbox["text"] = "<span class="admin">"._XG_ALBUMS_CONTAINING." "$searchstring"</span>";
    
$adminbox["bordercolor"] = $borderColor
    
$adminbox["top"] = false;
    echo 
'<table width="100%" border="0">';
    include(
$GALLERY_BASEDIR "layout/adminbox.inc");
    echo 
'</table>';
    echo 
"<br>";
    echo 
"<table width="".$navigator["fullWidth"] . $navigator["widthUnits"]."" border="0" cellspacing="0" cellpadding="0">";
    for (
$i 0$i<$numAlbums$i++) {
        
$searchAlbum =& $list[$i];
        
$searchTitle $searchAlbum->fields['title'];
        
$searchDescription $searchAlbum->fields['description'];
           if (
eregi($searchstring$searchTitle) || eregi($searchstring$searchDescription)) {
            
$uid $gallery->user->getUid();
            if (
$searchAlbum->canRead($uid) || $gallery->user->isAdmin()) {
                   
$albumMatch 1;
                
$searchTitle $myts->displayTarea($myts->stripSlashesGPC(eregi_replace("($searchstring)""<b>\1</b>"$searchTitle)),1); // cause search word to be bolded
                
$searchDescription $myts->displayTarea($myts->stripSlashesGPC(eregi_replace("($searchstring)""<b>\1</b>"$searchDescription)),1); // cause search word to be bolded
                
$photoURL makeAlbumUrl($searchAlbum->fields['name']);
                
$searchdraw["bordercolor"] = $borderColor;
                
$searchdraw["top"] = true;
                
$searchdraw["photolink"] = $searchAlbum->getHighlightTag($thumbSize);
                
$searchdraw["photoURL"] = $photoURL;
                
$searchdraw["Text1"] = "<span class='title'><a href='$photoURL'>$searchTitle</a></span>";
                
$searchdraw["Text2"] = "<span class='desc'>$searchDescription</span>";
                include(
$GALLERY_BASEDIR "layout/searchdraw.inc");
            }
        }
    
    }
    if (!
$albumMatch) {
        echo 
"<tr><td valign='top'><span class='desc'>"._XG_NO_ALBUM_MATCHES."</span></td></tr>";
    }
    echo 
"</table><br>";

    
$breadtext[0] = "";
    
$breadcrumb["text"] = $breadtext;
    include(
$GALLERY_BASEDIR "layout/breadcrumb.inc");
    
$adminbox["text"] = "<span class="admin">"._XG_PHOTOS_CONTAINING.""$searchstring"</span>";
       
$adminbox["bordercolor"] = $borderColor
    
$adminbox["top"] = false;
    echo 
'<table width="100%" border="0">';
    include(
$GALLERY_BASEDIR "layout/adminbox.inc");
    echo 
'</table>';
    echo 
"<br>";
    echo 
"<table width="".$navigator["fullWidth"] . $navigator["widthUnits"]."" border="0" cellspacing="0" cellpadding="0">";
    
    for (
$i 0$i<$numAlbums$i++) {
        
$searchAlbum =& $list[$i]; 
        
$uid $gallery->user->getUid();
        if (
$searchAlbum->canRead($uid) || $gallery->user->isAdmin()) {
            
$numPhotos $searchAlbum->numPhotos($gallery->user->canWriteToAlbum($searchAlbum));
            for (
$j 1$j <= $numPhotos$j++) {
                
$searchCaption $myts->displayTarea($myts->stripSlashesGPC($searchAlbum->getCaption($j)),1);
                
$searchKeywords $myts->displayTarea($myts->stripSlashesGPC($searchAlbum->getKeywords($j)),1);
                
$commentMatch 0;
                
$commentText "";
                for (
$k 1$k <= $searchAlbum->numComments($j); $k++) {
                    
// check to see if there are any comment matches
                    
$comment $searchAlbum->getComment($j$k);
                    
$searchComment $comment->getCommentText();
                    if (
eregi($searchstring$searchComment)) {
                        if (!
$commentMatch) {
                            
$commentText _XG_MATCHING_COMMENTS."<br>";
                            
$commentMatch 1;
                        } 
                        
$searchComment eregi_replace("($searchstring)""<b>\1</b>"$searchComment);
                        
$commentText .= $searchComment "<br><br>";
                    }
                }
                
$captionMatch eregi($searchstring$searchCaption);
                
$keywordMatch eregi($searchstring$searchKeywords);
                if (
$captionMatch || $keywordMatch || $commentMatch) {
                    if (!
$searchAlbum->isHidden($j) || 
                        
$searchAlbum->isOwner($uid) || 
                            
$gallery->user->isAdmin()) {
                        
$photoMatch 1;
                        
$id $searchAlbum->getPhotoId($j);
                        
// cause search word to be bolded
                        
$searchCaption eregi_replace("($searchstring)""<b>\1</b>"$searchCaption);
                        
$searchKeywords eregi_replace("($searchstring)""<b>\1</b>"$searchKeywords);
                        
$searchdraw["bordercolor"] = $borderColor;
                        
$searchdraw["top"] = true;
                        
$searchdraw["photolink"] = $searchAlbum->getThumbnailTag($j$thumbSize);
                        
$searchdraw["photoURL"] = makeAlbumUrl($searchAlbum->fields['name'], $id);
                        
$searchdraw["Text2"] = "<span class=desc>$searchCaption</span>";
                        
$searchdraw["Text1"] = "<span class=fineprint>"._XG_FROM_ALBUM."&nbsp;&nbsp;<a href=" .
                                            
makeAlbumUrl($searchAlbum->fields['name']) . ">" .
                                            
$myts->displayTarea($myts->stripSlashesGPC($searchAlbum->fields['title']),1) . "</a></span>";
                        if (
$keywordMatch) { // only display Keywords if there was a keyword match
                            
$searchdraw["Text3"] = "<span class=fineprint>"._XG_KEYWORDS."&nbsp;&nbsp; $searchKeywords</span><br>";
                        } else {
                            
$searchdraw["Text3"] = "";
                        }
                        
$searchdraw["Text4"] = $commentText;
                        include(
$GALLERY_BASEDIR "layout/searchdraw.inc");
                    }
                }
            }
        }
    }
    if (!
$photoMatch) {
        echo 
"<tr><td valign=top><span class=desc>"._XG_NO_PHOTO_MATCHES."</span></td></tr>";
    }
    echo 
"</table>";
    
}
else {
?>
<br><?php echo _XG_MESSAGE_SEARCH_GALLERY?><br>
    <table width="100%" border="0" cellspacing="0">
    <tr><?php echo makeFormIntro("search.php"); ?>
    <td valign="middle" align="left">
    <input type="text" name="searchstring" value="<?php echo $searchstring ?>" size="25">
    <input type="submit" value="<?php echo _XG_GO?>">
    </td>
    </form>  
    </tr>
    </table>
<?php
}
echo 
"<br>";
$breadtext[0] = "<a href="makeGalleryUrl("albums.php") . ">".$gallery->app->galleryTitle."</a>";
$breadcrumb["text"] = $breadtext;
$breadcrumb["bordercolor"] = $borderColor;
$breadcrumb["top"] = true;
$breadcrumb["bottom"] = true;
include(
$GALLERY_BASEDIR "layout/breadcrumb.inc");
?>
<?php 
includeHtmlWrap
("search.footer");
?>
<?php 
if (!$GALLERY_EMBEDDED_INSIDE) { ?>
</body>
</html>
<?php ?>

y a t-il moyen d'en faire quelque chose ?

Posté le : 20/04/2008 14:24

J'aime les sirènes ...
j'aime pas les arrêtes dans le poisson !...
Partager Twitter Partagez cette article sur GG+

 Haut   Précédent   Suivant



Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

266 Personne(s) en ligne (191 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 266 | Plus ...