ajout du support des hitgroups, hitcategories et actions
authorx2000coic <x2000coic>
Thu, 18 Nov 2004 20:53:25 +0000 (20:53 +0000)
committerx2000coic <x2000coic>
Thu, 18 Nov 2004 20:53:25 +0000 (20:53 +0000)
include/exalead/exalead.class.php
include/exalead/exalead.parser.inc.php

index c4cb70e..4e19185 100644 (file)
@@ -148,6 +148,40 @@ class ExaleadHit{
   }
 }
 
+class ExaleadHitGroup{
+  var $hitcategories = array();
+  var $title = '';
+  var $gid = '';
+
+  function ExaleadHitGroup(){}
+
+  function addHitCategory($hitcategory){$this->hitcategories[] = $hitcategory;}
+
+  function clear(){
+    $this->hitcategories = array();
+    $this->title = '';
+    $this->gid = '';
+  }
+}
+
+class ExaleadHitCategory{
+  var $name = '';
+  var $display = '';
+  var $cref = '';
+  var $gid = '';
+  var $browseHref = '';
+
+  function ExaleadHitCategory(){}
+
+  function clear(){
+    $this->name = '';
+    $this->display = '';
+    $this->cref = '';
+    $this->gid = '';
+    $this->browseHref = '';
+  }
+}
+
 class ExaleadHitField{
   var $text_segments = array();
   var $has_text_cut = false;
@@ -167,6 +201,20 @@ class ExaleadHitField{
   }
 }
 
+class ExaleadAction{
+  var $display;
+  var $kind;
+  var $execHref;
+
+  function ExaleadAction(){}
+
+  function clear(){
+    $this->display = '';
+    $this->kind = '';
+    $this->execHref = '';
+  }
+}
+
 class ExaleadTextSegment{
   var $text = "";
   var $highlighted = false;
index 87333e3..44a7b75 100644 (file)
@@ -14,6 +14,9 @@ class Exalead{
   var $currentSpelling;
   var $currentHit;
   var $currentHitField;
+  var $currentHitGroup;
+  var $currentHitCategory;
+  var $currentAction;
   var $currentTextSegment;
   var $currentQuery;
   var $currentQueryTerm;
@@ -33,6 +36,9 @@ class Exalead{
      $this->currentSpelling = new ExaleadSpelling();
      $this->currentHit = new ExaleadHit();
      $this->currentHitField = new ExaleadHitField();
+     $this->currentHitGroup = new ExaleadHitGroup();
+     $this->currentHitCategory = new ExaleadHitCategory();
+     $this->currentAction = new ExaleadAction();
      $this->currentTextSegment = new ExaleadTextSegment();
      $this->currentQuery = new ExaleadQuery();
      $this->currentQueryTerm = new ExaleadQueryTerm();
@@ -161,7 +167,26 @@ class Exalead{
      $this->currentHit->url = $attrs['URL'];
      $this->currentHit->score = $attrs['SCORE'];
   }
+  function startHitGroup(&$attrs){
+     $this->currentHitGroup->title = utf8_decode($attrs['TITLE']);
+     $this->currentHitGroup->gid = $attrs['GID'];
+  }
+  
+  function startHitCategory(&$attrs){
+     $this->currentHitCategory->name = $attrs['NAME'];
+     $this->currentHitCategory->display = utf8_decode($attrs['DISPLAY']);
+     $this->currentHitCategory->cref = $attrs['CREF'];
+     $this->currentHitCategory->gid = $attrs['GID'];
+     if(isset($attrs['BROWSEHREF'])) $this->currentHitCategory->browsehref = $attrs['BROWSEHREF'];
+  }
   
+  function startAction(&$attrs){
+     $this->currentAction->display = $attrs['DISPLAY'];
+     $this->currentAction->kind = $attrs['KIND'];
+     if(isset($attrs['EXECHREF']))$this->currentAction->execHref = $attrs['EXECHREF'];
+  }
   function startHitField(&$attrs){
      $this->currentHitField->name = $attrs['NAME'];
      if(isset($attrs['VALUE'])) $this->currentHitField->value = utf8_decode($attrs['VALUE']);
@@ -228,6 +253,15 @@ class Exalead{
    elseif($name == 'HITFIELD'){
      $this->startHitField($attrs);
    }
+   elseif($name == 'HITGROUP'){
+     $this->startHitGroup($attrs);
+   }
+   elseif($name == 'HITCATEGORY'){
+     $this->startHitCategory($attrs);
+   }
+   elseif($name == 'ACTION'){
+     $this->startAction($attrs);
+   }
    elseif($name == 'TEXTSEG'){
      $this->startTextSeg($attrs);
    }
@@ -272,6 +306,18 @@ class Exalead{
      $this->data->addHit($this->currentHit);
      $this->currentHit->clear();
   }
+  function endHitGroup(){
+    $this->currentHit->addHitGroup($this->currentHitGroup);
+    $this->currentHitGroup->clear();
+  }
+  function endHitCategory(){
+    $this->currentHitGroup->addHitCategory($this->currentHitCategory);
+    $this->currentHitCategory->clear();
+  }
+  function endAction(){
+    $this->currentHit->addAction($this->currentAction);
+    $this->currentAction->clear();
+  }
   function endHitField(){
      $this->currentHit->addHitField($this->currentHitField);
      $this->currentHitField->clear();
@@ -322,6 +368,15 @@ class Exalead{
    elseif($name == 'HITFIELD'){
      $this->endHitField();
    }
+   elseif($name == 'HITGROUP'){
+     $this->endHitGroup();
+   }
+   elseif($name == 'HITCATEGORY'){
+     $this->endHitCategory();
+   }
+   elseif($name == 'ACTION'){
+     $this->endAction();
+   }
    elseif($name == 'TEXTSEG'){
      $this->endTextSeg();
    }