recherche.php : clearly need debugging Anaxagor, heeeeeeeeeeeelp
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 21 Apr 2005 17:00:12 +0000 (17:00 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:43 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-585

htdocs.net/css/exalead.css [new file with mode: 0644]
htdocs.net/recherche.php [new file with mode: 0644]
include/xnet/exalead.inc.php [deleted file]
templates/xnet/recherche.tpl [new file with mode: 0644]
templates/xnet/skin.tpl

diff --git a/htdocs.net/css/exalead.css b/htdocs.net/css/exalead.css
new file mode 100644 (file)
index 0000000..331ab0d
--- /dev/null
@@ -0,0 +1,66 @@
+div.exa_form{
+    text-align: center;
+    background-color: #d8d4c8;
+    max-width: 400px;
+    margin: 0px 0px 10px 0px;
+    padding: 5px;
+    border: 3px solid #cfd8de;
+}
+
+div.nb_results{
+    background-color: #cfd8de;
+    color: #000000;
+    border: 1px solid #d8d4c8;
+    margin-bottom: 10px;
+    padding: 3px;
+}
+
+div.exa_form div{
+    margin: 5px;
+}
+
+table.exa_data{
+    width: 100%;
+}
+td.exa_left{
+    vertical-align: top;
+    width: 30%;
+    padding: 5px;
+}
+td.exa_right{
+    padding: 5px;
+    vertical-align: top;
+}
+
+div.exa_groupe{
+    /*max-width: 30ex;*/
+    margin-bottom: 20px;
+    /*border: 1px solid #ACF;*/
+}
+div.exa_groupe div.titre{
+    border: 0px none #000;
+    border-bottom: 1px solid #000;
+    padding: 0px 0px 3px 5px;
+    margin: 0px 5px 2px 5px;
+}
+div.exa_categorie {
+}
+div.exa_spelling{
+}
+
+div.exa_keywords{
+}
+
+div.exa_result{
+    border: 1px solid #333;
+    margin-bottom: 10px;
+    width: 100%;
+}
+div.exa_result div.header, div.field{
+    background-color: #F4D09C;
+    padding: 3px;
+}
+div.exa_result div.field{
+    background-color: inherit;/*#AACCFF;*/
+}
+div.header span{}
diff --git a/htdocs.net/recherche.php b/htdocs.net/recherche.php
new file mode 100644 (file)
index 0000000..d202f7e
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+require 'xnet.inc.php';
+require_once 'exalead/exalead.parser.inc.php';
+
+new_page('xnet/recherche.tpl', AUTH_PUBLIC);
+$page->setType('recherche');
+$page->useMenu();
+$page->addCssLink('exalead.css');
+
+
+$query_exa = "http://murphy:10000/cgi/poly.net_devel";
+
+$exalead = new Exalead($query_exa);
+
+if ($exalead->query('query')) {
+    $page->assign_by_ref('exalead_data', $exalead->data);
+}
+
+$page->run();
+
+?>
diff --git a/include/xnet/exalead.inc.php b/include/xnet/exalead.inc.php
deleted file mode 100644 (file)
index 9348843..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-
-require_once($globals->xnet->exalead.'/exalead.parser.inc.php');
-
-//Exemple de surclassement du parseur
-
-/*
-class OffreHit extends ExaleadHit{
-
-  var $titre = "";
-  var $description = "";
-  var $type_offre = "";
-  var $type_entr = "";
-  var $id = "";
-  var $zone = "";
-  var $pays = "";
-  var $entreprise = "";
-  var $entr_nom = "";
-  var $creation = "";
-  var $secteur = "";
-  var $fonction = "";
-  var $alumnus = "";
-  var $salaire = "";
-  var $experience = "";
-
-  function OffreHit(){
-    parent::ExaleadHit();
-  }
-
-  function clear(){
-    parent::clear();
-    $titre = "";
-    $description = "";
-    $type_offre = "";
-    $type_entr = "";
-    $id = "";
-    $id = "";
-    $zone = "";
-    $pays = "";
-    $entreprise = "";
-    $entr_nom = "";
-    $creation = "";
-    $secteur = "";
-    $fonction = "";
-    $alumnus = "";
-    $salaire = "";
-  }
-
-}
-
-class ExaleadOffre extends Exalead{
-
-  //var $currentOffreHit;
-  
-  function ExaleadOffre($base_cgi = ''){
-    parent::Exalead($base_cgi);
-    $this->currentHit = new OffreHit();
-  }
-
-  function endHit(){
-    $this->data->addHit($this->currentHit);
-    $this->currentHit->clear();
-  }
-
-  function endHitField(){
-  }
-
-  function startHit(&$attrs){
-    $res = explode('/', $attrs['URL']);
-    $this->currentHit->id = end($res);
-  }
-
-  function startHitField(&$attrs){
-    if(isset($attrs['VALUE'])){
-      if($attrs['NAME'] == 'creation'){
-        $date = utf8_decode($attrs['VALUE']);
-       $annee = substr($date, 0, 4);
-       $mois = substr($date, 5, 2);
-       $jour = substr($date, 8, 2);
-       $heure = substr($date, 11, 2);
-       $minute = substr($date, 14, 2);
-       $seconde = substr($date, 17, 2);
-        $this->currentHit->$attrs['NAME'] = mktime($heure, $minute, $seconde, $mois, $jour, $annee);
-      }
-      else
-        $this->currentHit->$attrs['NAME'] = utf8_decode($attrs['VALUE']);
-    }
-  }
-
-}
-*/
-
-?>
diff --git a/templates/xnet/recherche.tpl b/templates/xnet/recherche.tpl
new file mode 100644 (file)
index 0000000..25b819c
--- /dev/null
@@ -0,0 +1,207 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  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                *
+ ***************************************************************************}
+
+{if !$exalead_data}
+<p class="descr">
+Cette page de recherche fonctionne grâce au moteur développé par <a href="http://www.exalead.com/">Exalead</a>.
+</p>
+{/if}
+
+<p class="descr">
+Ce moteur est capable de dégager des catégories à partir des résultats qu'il a trouvé, tu peux alors
+affiner ta recherche et éliminer les résultats d'une catégorie particulière
+(<img style="vertical-align: text-bottom;" src="images/moins.png" alt="[-]"/>)
+ou ne demander que les résultats appartenant à une catégorie particulière
+(<img style="vertical-align: text-bottom;"  src="images/select.png" alt="[+]"/>).
+</p>
+
+<p class="descr">
+Ce moteur sait aussi détecter des mots clés qu'il a pu rencontrer parmi les résultats, et permet
+d'affiner la recherche sur ces critères, suivant le même fonctionnement que les catégories.
+</p>
+
+<span><a href="http://www.exalead.com">Powered by <img src="images/Exalead-logo-Carved-100.gif" alt="Logo Exalead" /></a></span>
+
+{if $exalead_data && $exalead_data->hits}
+<table class="exa_data">
+  <tr>
+    <td class="exa_left">
+      <form method="post" action="{$smarty.server.PHP_SELF}">
+        <div class="exa_form">
+          <div>Rechercher</div>
+          <div><input type="text" name="query" value="{$exalead_data->query->query}" size="30" /></div>
+          <div><input type="submit" name="chercher" value="Chercher" /></div>
+        </div>
+      </form>
+      {if $exalead_data}
+
+      {if !$exalead_data->hits}
+      <p class="erreur">Il n'y a aucun résultat...</p>
+      {else}
+      <div id="nb_results">
+        {if $exalead_data->estimated}
+        <div class="nb_results">Votre recherche a retourné <strong>environ <?php echo $exalead_data->nmatches;?></strong> résultats.</div>
+        {else}
+        <div class="nb_results">Votre recherche a retourné <strong><?php echo $exalead_data->nmatches;?></strong> résultats.</div>
+        {/if}
+      </div>
+      {/if}
+
+      {*
+      //Correction orthographique
+      {if $exalead_data->spellings|@count > 0}
+      <div class="exa_groupe">
+        <div class="titre">Voulais-tu dire :</div>
+        {foreach from=$exalead_data->spellings item="spelling"}
+        <div class="exa_categorie"><a href="exalead.php?query={$spelling->query_href}">{$spelling->display}</a></div>
+        {/foreach}
+      </div>
+      {/if}
+
+      //Categories
+      {if $exalead_data->groups|@count > 0}
+      {foreach from=$exalead_data->groups item="group"}
+      <div class="exa_groupe">
+        <div class="titre">{$group->title} :</div>
+        {foreach from=$group->categories item="categorie"}
+        {if $categorie->reset_href}
+        {if $categorie->count == 0}
+        <div class="exa_categorie" style="background-color: {cycle values="inherit,inherit"}"><span style="text-decoration: line-through;">
+            <a href="?_C={$exalead_data->query->context}/{$categorie->reset_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;" src="images/select.png" alt="[+]" /> {$categorie->display}</a></span>
+        </div>
+        {else}
+        <div class="exa_categorie" style="background-color: {cycle values="inherit,inherit"}"><strong>{$categorie->display}</strong>
+          <a href="?_C={$exalead_data->query->context}/{$categorie->reset_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;"  src="images/moins.png" alt="[-]"/></a>
+        </div>
+        {/if}
+        {else}
+        <div class="exa_categorie" style="background-color: {cycle values="inherit,inherit"}">
+          <a style="text-decoration: none;" href="?_C={$exalead_data->query->context}/{$categorie->refine_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;" src="images/select.png" alt="[+]" />{$categorie->display} ({$categorie->count})</a>
+          <a href="?_C={$exalead_data->query->context}/{$categorie->exclude_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;"  src="images/moins.png" alt="[-]"/></a>
+        </div>
+        {/if}
+        {/foreach}
+      </div>
+      {/foreach}
+      {/if}
+
+      *}
+
+
+      {if $exalead_data->keywords}
+      <div class="exa_groupe">
+        <div class="titre">Affiner la recherche par mot-clés :</div>
+        {foreach from=$exalead_data->keywords item=keyword}
+        {if !$keyword->is_normal()}
+        {if $keyword->is_excluded()}
+        <div class="exa_categorie">
+          <span style="text-decoration: line-through;">
+            <a href="?_C={$exalead_data->query->context}/{$keyword->reset_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;" src="images/select.png" alt="[+]" />
+              {$keyword->display}</a>
+          </span>
+        </div>
+        {else}
+        <div class="exa_categorie">
+          <strong>{$keyword->display}</strong>
+          <a href="?_C={$exalead_data->query->context}/{$keyword->reset_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;"  src="images/moins.png" alt="[-]"/></a>
+        </div>
+        {/if}
+        {else}
+        <div class="exa_categorie">
+          <a href="?_C={$exalead_data->query->context}/{$keyword->refine_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;" src="images/select.png" alt="[+]" />
+            {$keyword->display} ({$keyword->count})</a>
+          <a href="?_C={$exalead_data->query->context}/{$keyword->exclude_href}&amp;_f=xml2"><img style="vertical-align: text-bottom;"  src="images/moins.png" alt="[-]"/></a>
+        </div>
+        {/if}
+        {/foreach}
+      </div>
+      {/if}
+    </td>
+    <td class="exa_right">
+      {if $exalead_data->start > 0}
+      {if $exalead_data->start < 9}
+      <a href=?_C={$exalead_data->query->context}&_s=0">[1-10]</a>
+      {else}
+      <a href="?_C={$exalead_data->query->context}&_s={$exalead_data->start - 10}">[-10]</a>";
+      {/if}
+      {/if}
+
+      <a href="?_C={$exalead_data->query->context}/_sf=-date&amp;_f=xml2">[Classer par date]</a>
+      <a href="?_C={$exalead_data->query->context}/_sf=relevance&amp;_f=xml2">[Classer par pertinence]</a>
+
+      {if $exalead_data->end < $exalead_data->nhits}
+      {if $exalead_data->end + 11 > $exalead_data->nhits}
+      <a href="?_C={$exalead_data->query->context}&_s={$exalead_data->nhits-10}">[{$exalead_data->nhits-10}-{$exalead_data->nhits}]</a>
+      {else}
+      <a href="?_C={$exalead_data->query->context}&_s=$fin_g\">[{$exalead_data->end+2}-{$exalead_data->end+12}]</a>
+      {/if}
+      {/if}
+
+      {foreach from=$exalead_data->hits item=hit}
+      <div class="exa_result">
+        <div class="header">
+          <a href="{$hit->url|regex_replace:"!\?PHPSESSID=.*$!":""}">{$hit->url|regex_replace:"!\?PHPSESSID=.*$!":""}</a>
+        </div>
+        {foreach from=$hit->hitgroups  item=hitgroup}
+        <div class="field">
+          {$hitgroup->title} :
+          {if $hitgroup->hitcategories[0]->browsehref}
+          <a href="?_C={$exalead_data->query->context}/{$hitgroup->hitcategories[0]->browsehref}">{$hitgroup->hitcategories[0]->display}</a>
+          {else}
+          echo $hitgroup->hitcategories[0]->display;
+          {/if}
+        </div>
+        {/foreach}
+      </div>
+      {/foreach}
+      {/if}
+    </td>
+  </tr>
+</table>
+{/if}
+
+
+{*
+
+<div>Debug : </div>
+<div>Nb matches : {$exalead_data->nmatches}</div>
+<div>Nb hits : {$exalead_data->nhits}</div>
+<div>estimated : {$exalead_data->estimated}</div>
+<div>start : {$exalead_data->start}</div>
+<div>end : {$exalead_data->end}</div>
+<div>last : {$exalead_data->last}</div>
+<div>Query :</div>
+<div style="border: 1px solid #228; padding: 10px;">
+<div>query : {$exalead_data->query->query}</div>
+<div>time : {$exalead_data->query->time}</div>
+<div>Terms : </div>
+foreach( $exalead_data->query->query_terms as $key => $term){
+  echo "<div>level : {$term->level} | regexp : {$term->regexp}</div>";
+}
+<div>Parameters : </div>
+foreach($exalead_data->query->query_parameters as  $key=>$parameter){
+  echo "<div>name : {$parameter->name} | value : {$parameter->value}</div>";
+}
+</div>
+
+*}
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index 155018d..2fec408 100644 (file)
             <div>
               <a href="{rel}/agenda.php" title="Informations"><img src="{rel}/images/infos.png" alt="infos" /></a>
               <a href="{rel}/manuel.php" title="Manuel d'aide en ligne"><img src="{rel}/images/manuel.png" alt="manuel" /></a>
-              <input type="text" name="query" value="echo ((isset($exalead_data))?($exalead_data->query->query)" size="25" maxlength="60" />
+              <input type="text" name="query" value="{$exalead_data->query->query}" size="25" maxlength="60" />
               <input type="image" src="{rel}/images/recherche.png" title="Chercher" value="submit" />
 
               <br />