From 50f4bc89eabbe80dd95ef2d370d7f7de3e0a416f Mon Sep 17 00:00:00 2001 From: Damien LASSERRE Date: Mon, 26 Sep 2011 15:59:35 +0000 Subject: [PATCH] =?UTF-8?q?Mise=20a=20jours=20de=20Sphinx=20interface=20de?= =?UTF-8?q?=20recherche=20avec=20implementation=20des=20nouvelles=20foncti?= =?UTF-8?q?onnalit=C3=A9es=20de=20sphinx.=20+=20gestion=20des=20max=20limi?= =?UTF-8?q?ts=20et=20des=20ranking=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/FormulairesController.php | 62 +++++-- sphinxPHP/application/logs/query.log | 60 +++++++ sphinxPHP/application/sequances/sequence.php | 55 ++++++ .../default/scripts/formulaires/filters.phtml | 18 ++ .../default/scripts/formulaires/form.phtml | 136 +++++---------- .../views/default/scripts/menu.phtml | 50 +++++- .../views/default/scripts/sphinxOptions.phtml | 7 +- sphinxPHP/library/Forms/FormSearchEnt.php | 23 +++ sphinxPHP/library/Sphinx/class/ent.class.php | 162 ++++++++++++++---- sphinxPHP/public/favicon.ico | Bin 0 -> 1150 bytes .../public/themes/default/scripts/form.js | 83 ++++++--- 11 files changed, 485 insertions(+), 171 deletions(-) create mode 100755 sphinxPHP/application/logs/query.log create mode 100644 sphinxPHP/application/sequances/sequence.php create mode 100644 sphinxPHP/application/views/default/scripts/formulaires/filters.phtml create mode 100644 sphinxPHP/library/Forms/FormSearchEnt.php create mode 100644 sphinxPHP/public/favicon.ico diff --git a/sphinxPHP/application/controllers/FormulairesController.php b/sphinxPHP/application/controllers/FormulairesController.php index 6c02e7b..da07cbf 100755 --- a/sphinxPHP/application/controllers/FormulairesController.php +++ b/sphinxPHP/application/controllers/FormulairesController.php @@ -43,7 +43,7 @@ class FormulairesController extends Zend_Controller_Action $this->view->form = $act; } else { $sphinx = new SphinxClient(); - $sphinx->SetServer('192.168.78.37', 3312); + $sphinx->SetServer('192.168.78.252', 3312); $sphinx->SetConnectTimeout(1); $sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25); $sphinx->SetArrayResult(true); @@ -86,7 +86,7 @@ class FormulairesController extends Zend_Controller_Action public function serverstatutAction() { $sphinx = new SphinxClient(); - $sphinx->SetServer('192.168.78.37', 3312); + $sphinx->SetServer('192.168.78.252', 3312); if($sphinx->_Connect()) echo 'Connected'; else @@ -97,33 +97,57 @@ class FormulairesController extends Zend_Controller_Action public function getsrvAction() { - echo file_get_contents('http://192.168.78.37/query.log'); + echo file_get_contents(APPLICATION_PATH.'/logs/query.log'); $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); } public function entAction() { + require_once ('Forms/FormSearchEnt.php'); $this->view->send = true; if(!$this->getRequest()->isPost()) { - $ent = new Zend_Form(); - $ent->setMethod('post'); - foreach ($this->entChamps as $champ) { - $chp = $ent->createElement('text', $champ, array('value' => $champ)) - ->setRequired(true); - $ent->addElement($chp); - } - $ent->addElement("text", 'type', array('value'=>'ent')); + $ent = new Form_SearchEnt(); $this->view->form = $ent; - $this->render('form'); } else { $this->_helper->layout()->disableLayout(); + $sphinx = new SphinxClient(); - $sphinx->SetServer('192.168.78.37', 3312); + $sphinx->SetServer('192.168.78.252', 3312); $sphinx->SetConnectTimeout(1); - $sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25); $sphinx->SetArrayResult(true); + + switch($this->getRequest()->getParam('SPH_RANK')) { + case 'SPH_RANK_PROXIMITY_BM25': + $sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25); + break; + case 'SPH_RANK_BM25': + $sphinx->SetRankingMode(SPH_RANK_BM25); + break; + case 'SPH_RANK_NONE': + $sphinx->SetRankingMode(SPH_RANK_NONE); + break; + case 'SPH_RANK_WORDCOUNT': + $sphinx->SetRankingMode(SPH_RANK_WORDCOUNT); + break; + case 'SPH_RANK_PROXIMITY': + $sphinx->SetRankingMode(SPH_RANK_PROXIMITY); + break; + case 'SPH_RANK_MATCHANY': + $sphinx->SetRankingMode(SPH_RANK_MATCHANY); + break; + case 'SPH_MATCH_ANY': + $sphinx->SetRankingMode(SPH_MATCH_ANY); + break; + case 'SPH_RANK_FIELDMASK': + $sphinx->SetRankingMode(SPH_RANK_FIELDMASK); + break; + default: + $sphinx->SetRankingMode(SPH_RANK_PROXIMITY_BM25); + } + $rechercheEnt = new ent($this->getRequest()->getParam('SPH_MATCH'), $sphinx, $this->getRequest()->getParams(), 1000); + if($this->getRequest()->getParam('debug') == 'true') $rechercheEnt->setDebug(); if($this->getRequest()->getParam('QuorumSize') > 0) @@ -140,14 +164,16 @@ class FormulairesController extends Zend_Controller_Action $rechercheEnt->setMaxSizeWord ($this->getRequest()->getParam('WordSize')); if($this->getRequest()->getParam('MaxResult') != 1000 and $this->getRequest()->getParam('MaxResult') > 0) $rechercheEnt->setMaxResults ($this->getRequest()->getParam('MaxResult')); + $rechercheEnt->setIndex('ent'); $rechercheEnt->setForm($this->getRequest()->getParams()); $rechercheEnt->setSphinx($sphinx); - echo $rechercheEnt->execute(); - $this->_helper->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); + $rechercheEnt->execute(); + + $this->view->isPost = $this->getRequest()->isPost(); + $params = $this->getRequest()->getParams(); } - + $this->render('form'); } } diff --git a/sphinxPHP/application/logs/query.log b/sphinxPHP/application/logs/query.log new file mode 100755 index 0000000..a29b63f --- /dev/null +++ b/sphinxPHP/application/logs/query.log @@ -0,0 +1,60 @@ + +[21/09/2011] scores et decisions dddddddddd +[21/09/2011] scopre +[22/09/2011] scores et decisions +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] +[22/09/2011] +[22/09/2011] +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] raisonSociale +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores et decisions +[22/09/2011] scores decisions +[22/09/2011] scores decisions +[22/09/2011] scores decisions +[22/09/2011] scores decisions +[22/09/2011] scores decisions +[22/09/2011] scores decisions +[22/09/2011] scores decisions +[22/09/2011] scores decisions +[23/09/2011] score dekisions +[23/09/2011] +[23/09/2011] score dekisions \ No newline at end of file diff --git a/sphinxPHP/application/sequances/sequence.php b/sphinxPHP/application/sequances/sequence.php new file mode 100644 index 0000000..e005dfe --- /dev/null +++ b/sphinxPHP/application/sequances/sequence.php @@ -0,0 +1,55 @@ + array('max' => 1000, 'id' => array('10')), + 'S.R' => array('max' => 1000, 'id' => array('11', '10')), + 'S.N' => array('max' => 1000, 'id' => array('12', '10')), + 'S.N.R' => array('max' => 1000, 'id' => array(array('13', '12', '11', '10'))), + 'S.N.R.V' => array('max' => 1000, 'id' => array('17', '16', '15' ,'14' ,'13', '12', '11', '10')), + 'S.V' => array('max' => 1000, 'id' => array('14', '10')), + 'S.V.N' => array('max' => 1000, 'id' => array('15', '14', '12', '10')), + 'S.V.R' => array('max' => 1000, 'id' => array('16', '14', '11', '10')), + 'S.V.N.R' => array('max' => 1000, 'id' => array('17', '15', '14', '13', '12', '11', '10')), + 'S.D' => array('max' => 1000, 'id' => array('18')), + 'S.D.N' => array('max' => 1000, 'id' => array('19', '18', '12', '10')), + 'S.D.R' => array('max' => 1000, 'id' => array('24', '18', '11', '10')), + 'S.D.N.R' => array('max' => 1000, 'id' => array('25', '28', '19', '18', '12', '11', '10')), + 'S.D.V' => array('max' => 1000, 'id' => array('20', '18', '14', '10')), + 'S.D.V.R' => array('max' => 1000, 'id' => array('21', '20', '18', '14', '11', '10')), + 'S.D.V.N' => array('max' => 1000, 'id' => array('22', '20', '18', '14', '12', '10')), + 'S.D.V.N.R'=> array('max' => 1000, 'id' => array('23' ,'25', '24', '22', '20', '18', '14', '12', '11', '10')), +); + +$sequence = array( + '10' => 'S', + '11' => 'S.R', + '12' => 'S.N', + '13' => 'S.N.R', + '14' => 'S.V', + '15' => 'S.V.N', + '16' => 'S.V.R', + '17' => 'S.V.N.R', + '18' => 'S.D', + '19' => 'S.D.N', + '20' => 'S.D.V ', + '21' => 'S.D.V.R', + '22' => 'S.D.V.N', + '23' => 'S.D.V.N.R', + '24' => 'S.D.R', + '25' => 'S.D.N.R', +); +?> \ No newline at end of file diff --git a/sphinxPHP/application/views/default/scripts/formulaires/filters.phtml b/sphinxPHP/application/views/default/scripts/formulaires/filters.phtml new file mode 100644 index 0000000..289651f --- /dev/null +++ b/sphinxPHP/application/views/default/scripts/formulaires/filters.phtml @@ -0,0 +1,18 @@ + +Filtres activés
+ +
+Options activées
+ \ No newline at end of file diff --git a/sphinxPHP/application/views/default/scripts/formulaires/form.phtml b/sphinxPHP/application/views/default/scripts/formulaires/form.phtml index f2adbb5..27ddaaa 100755 --- a/sphinxPHP/application/views/default/scripts/formulaires/form.phtml +++ b/sphinxPHP/application/views/default/scripts/formulaires/form.phtml @@ -1,95 +1,49 @@ -
-
-
- Configurations -
-
-
-
-
- Activez vos fonctions -
-
-
-
-
-
-
-
- Options Sphinx -
-
-
-
-
-
-
-
-
-
-
-
- Autres... - - - - - - - - - - - - - - - - - -
WordSize Ignore - - -
-
Quorum Size - - -
-
Proximité Size - - -
-
Max Results - - -
-
-
-
-
-
-
-
- form;?> +isPost):?> +
+
+
+ Configurations +
+
+
+
+
+ Activez vos fonctions +
+
+
+
+
+
+
+
+ Ranking modes +
+
+
+
+
+
+
+
+
+
+ Sorting modes +
+
+
+
+
+
+
- + +
+
+
+ form;?>
\ No newline at end of file diff --git a/sphinxPHP/application/views/default/scripts/menu.phtml b/sphinxPHP/application/views/default/scripts/menu.phtml index ac11f3c..2e28203 100755 --- a/sphinxPHP/application/views/default/scripts/menu.phtml +++ b/sphinxPHP/application/views/default/scripts/menu.phtml @@ -1,8 +1,42 @@ - \ No newline at end of file + +
+
+ + + + + + + + + + + + + + + + + + +
WordSize Ignore + + +
+
Quorum Size + + +
+
Proximité Size + + +
+
Max Results + + +
+
+
+
\ No newline at end of file diff --git a/sphinxPHP/application/views/default/scripts/sphinxOptions.phtml b/sphinxPHP/application/views/default/scripts/sphinxOptions.phtml index 8ea40bd..3a80fe5 100644 --- a/sphinxPHP/application/views/default/scripts/sphinxOptions.phtml +++ b/sphinxPHP/application/views/default/scripts/sphinxOptions.phtml @@ -7,8 +7,7 @@ $matchMode = array('SPH_MATCH_ALL' => 'SPH_MATCH_ALL, matches all query w 'SPH_MATCH_EXTENDED2' => 'SPH_MATCH_EXTENDED2, matches query using the second version of the Extended matching mode.', 'SPH_MATCH_FULLSCAN' => 'SPH_MATCH_FULLSCAN, matches query, forcibly using the "full scan" mode as below. NB, any query terms will be ignored, such that filters, filter-ranges and grouping will still be applied, but no text-matching.' );?> -
-
Executer votre recherche
+
$val):?> @@ -17,6 +16,6 @@ $matchMode = array('SPH_MATCH_ALL' => 'SPH_MATCH_ALL, matches all query w
-
-
+
+
\ No newline at end of file diff --git a/sphinxPHP/library/Forms/FormSearchEnt.php b/sphinxPHP/library/Forms/FormSearchEnt.php new file mode 100644 index 0000000..81d73e2 --- /dev/null +++ b/sphinxPHP/library/Forms/FormSearchEnt.php @@ -0,0 +1,23 @@ +setName('ent'); + $this->setMethod('post'); + $this->setAction('formulaires/ent'); + + $this->addElement('text', 'siren', array('value' => 'siren', 'class' => 'formText')); + $this->addElement('text', 'raisonSociale', array('value' => 'raisonSociale', 'class' => 'formText')); + $this->addElement('text', 'numeroVoie', array('value' => 'numeroVoie', 'class' => 'formText')); + $this->addElement('text', 'Voie', array('value' => 'Voie', 'class' => 'formText')); + $this->addElement('text', 'cpVille', array('value' => 'cpVille', 'class' => 'formText')); + $this->addElement('text', 'naf', array('value' => 'naf', 'class' => 'formText')); + $this->addElement("text", 'type', array('value'=>'ent', 'class' => 'formText')); + } +} +?> diff --git a/sphinxPHP/library/Sphinx/class/ent.class.php b/sphinxPHP/library/Sphinx/class/ent.class.php index 53283ab..ffea7fe 100644 --- a/sphinxPHP/library/Sphinx/class/ent.class.php +++ b/sphinxPHP/library/Sphinx/class/ent.class.php @@ -20,10 +20,7 @@ Class ent extends rechercheFonc /** Séquance d'échappement. **/ protected $form2crit = array('siren' => 'I', - 'telFax' => 'T', 'raisonSociale' => 'S', - 'enseigne' => 'E', - 'prenom' => 'P', 'departement' => 'D', 'localite' => 'L', 'cpVille' => 'V', @@ -33,9 +30,12 @@ Class ent extends rechercheFonc ); /** Liste des filtres sphinx **/ protected $filters = array('siren' => 'siret', + 'nic' => '', + 'siege' => '', 'adr_num' => 'numeroVoie', 'adr_cp' => 'cpVille', 'adr_dep' => 'cpVille', + 'actif' => 'actif' ); protected $mode; protected $deb; @@ -103,6 +103,7 @@ Class ent extends rechercheFonc 'Erreure :' => 'Le formulaire est Vide !') ); $this->filtreCaracteresSpeciaux(); + $this->sphinx->SetSortMode($this->setSortMode($this->formR['SPH_SORT']), "@weight rang"); switch($this->formR['SPH_MATCH']) { case 'SPH_MATCH_ALL': $this->sphinx->SetMatchMode(SPH_MATCH_ALL); @@ -133,8 +134,15 @@ Class ent extends rechercheFonc return; case 'SPH_MATCH_FULLSCAN': return; - $this->getDebugRequette(); } + + /** @todo a prévoir ! + * vopir pour la verification du mode de sortie de sphinx. + * Prévoir un input de selection avec les différents modes de sortie. + * $this->sphinx->SetSortMode(SPH_SORT_EXTENDED, "@adr_num desc"); + */ + + $this->getDebugRequette(); if($resSphinx['matches'] > 0) { $this->setTime($resSphinx['time']); $this->getResultSphinx($resSphinx); @@ -143,31 +151,41 @@ Class ent extends rechercheFonc /***************************************************************************************************************/ /** Partie Requette **/ - public function SPH_MATCH_($type, $option = null) + public function SPH_MATCH_($type) { - $requete = ''; - $requete .= (($type=='SPH_MATCH_EXTENDED' or $type=='SPH_MATCH_EXTENDED2')?'@nom':''). '"'.$this->formatRaisonSociale($this->formR['raisonSociale']). - '" '.(($this->ProximiteSize > 0)?'~'.$this->ProximiteSize:'').' '.(($this->Quorumsize > 0)?'/'.$this->Quorumsize:''); - foreach($this->Crtiteres as $crit => $attr) { - if(!empty($this->formR[$attr])) - $requete .= ''.$attr.' '.$this->formR[$crit].' '; - } - $requete .= $option; - foreach($this->filters as $filter => $form) { - if(!empty($this->formR[$form])) { - if($filter == 'adr_cp') { - if(strlen($this->formR[$form]) == 5) - $this->sphinx->setFilter($filter, array($this->formR[$form])); - } else if ($filter == 'adr_dep') { - $this->sphinx->setFilter($filter, array(substr($this->formR[$form],0 , 2))); - } - else - $this->sphinx->setFilter($filter, array($this->formR[$form])); + $html = ''; + require_once APPLICATION_PATH.'/sequances/sequence.php'; + $i = 0; + $valeur = explode(':', $this->detectedSequance()); + $valeur = trim($valeur[0]); + foreach($link[$valeur]['id'] as $seqId) { + $html .= '
Séquence : '.$sequence[$link[$valeur]['id'][$i]]; + $request = $this->constructQuerySequance($sequence[$link[$valeur]['id'][$i]], $type); + $result = $this->sphinx->Query($request, $this->index); + if($result['total'] > 0 and $link[$valeur]['max'] > $result['total']) { + $html .= ' - '.$result['total'].'/'.$result['total_found']. ' Found !'; + break; } + $html .= ' - 0 founds - '.$request.'
'; + $i++; } - if($this->actif) - $this->sphinx->setFilter('actif', array(1)); - return ($this->sphinx->Query($requete, $this->index)); + /* decremente le quorum en dernier recour ou ont supprime des mots de la raison sociale */ + /*$array = explode(' ', $this->formR['raisonSociale']); + if($this->Quorumsize > 0 and $result['total'] == 0 and count($array) > 1) { + $this->Quorumsize--; + $this->SPH_MATCH_ ($type); + } else if($result['total'] == 0 and $this->Quorumsize == 0 and count($array) > 1) { + //$this->formR['raisonSociale'] = $this->deleteWord(); + + if(count($array) > 0) { + unset($array[count($array)]); + $this->formR['raisonSociale'] = implode(' ', $array); + } + $this->Quorumsize = count(explode(' ', $this->formR['raisonSociale'])); + $this->SPH_MATCH_ ($type); + }*/ + $this->printInformations($html); + return ($result); } public function formatRaisonSociale($rs) @@ -201,11 +219,75 @@ Class ent extends rechercheFonc $sequance = ""; foreach($this->formR as $name => $form) { if($name != 'SPH_MATCH') { - $sequance .= $this->form2crit[$name]; + $sequance .= '.'.$this->form2crit[$name]; $values .= $name.', '; } } - return ($sequance.' : '.$values); + return (substr($sequance,1).' : '.$values); + } + + protected function readFileSequance($file) + { + $handle = fopen($file, 'r'); + if($handle) { + while($data = fgetcsv($handle, 1000, ',') !== FALSE) { + if($data == $this->detectedSequance()) { + $this->constructQuerySequance($data); + } + } + } + } + + protected function constructQuerySequance($sequances, $type) + { + $this->sphinx->ResetFilters(); + $request = $request .= (($type=='SPH_MATCH_EXTENDED' or $type=='SPH_MATCH_EXTENDED2')?'@nom ':'').'"'; + $adresse = '@adresse "'; + foreach($this->form2crit as $name => $crit) { + $diff = explode('.', $sequances); + if(in_array($crit, $diff)) { + if($name == 'raisonSociale') { + $request .= $this->formatRaisonSociale($this->formR[$name]); + } + else if($name == 'cpVille') { + if(is_numeric($this->formR[$name])) + { + if(strlen($this->formR[$name]) == 2) { + $this->sphinx->setFilter('adr_dep', array($this->formR[$name])); + } else if (strlen($this->formR[$name]) == 5) { + $this->sphinx->setFilter('adr_dep', array(substr($this->formR[$name],0,2))); + $this->sphinx->setFilter('adr_cp', array(substr($this->formR[$name]))); + } + } else { + $adresse .= $this->formR[$name]; + } + } + else if($name == 'Voie') { + $adresse .= $this->formR[$name]; + } + else if ($name == 'siren') { + if(strlen($this->formR[$name]) == 14) { + $this->sphinx->setFilter('siren', array(substr($this->formR[$name], 0, 9))); + $this->sphinx->setfilter('nic', array(substr($this->formR[$name], 9))); + } else if (strlen($this->fomrR[$name]) == 9) { + $this->sphinx->setFilter('siren', array($this->formR[$name])); + } + } + else if($name == 'numeroVoie') { + $this->sphinx->setFilter('adr_num', array($this->formR[$name])); + } + else if ($this->actif) { + $this->sphinx->setFilter('actif', array(1)); + } else { + $request .= $this->formR[$name].' '; + } + } + } + + $request .= '"'. (($this->ProximiteSize > 0)?'~'.$this->ProximiteSize:'').' '.(($this->Quorumsize > 0)?'/'.$this->Quorumsize:''); + if($adresse != '@adresse "') + $request = $request .' '.$adresse.'"'; + return ($request); } @@ -223,6 +305,7 @@ Class ent extends rechercheFonc $sql .= ' OR '; $i++; } + $sql .= " ORDER BY rang DESC"; $db = $this->databaseJO(); $result = $db->query($sql); @@ -254,6 +337,8 @@ Class ent extends rechercheFonc $html .= '
  • '.$filter.' => '.$this->formR[$form].'
  • '; } } + if($this->actif) + $html .= '
  • Actif => true
  • '; $html .= ''; $this->printInformations($html); } @@ -295,7 +380,26 @@ Class ent extends rechercheFonc } /***************************************************************************************************************/ /** Partie Setters **/ - + + public function setSortMode($mode) { + switch($mode) { + case 'SPH_SORT_RELEVANCE': + return (SPH_SORT_RELEVANCE); + case 'SPH_SORT_ATTR_DESC': + return (SPH_SORT_ATTR_DESC); + case 'SPH_SORT_ATTR_ASC': + return (SPH_SORT_ATTR_ASC); + case 'SPH_SORT_TIME_SEGMENTS': + return (SPH_SORT_TIME_SEGMENTS); + case 'SPH_SORT_EXTENDED': + return (SPH_SORT_EXTENDED); + case 'SPH_SORT_EXPR': + return (SPH_SORT_EXPR); + default: + return (SPH_SORT_RELEVANCE); + } + } + public function setForm($form) { $this->formR = $form;} diff --git a/sphinxPHP/public/favicon.ico b/sphinxPHP/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..6667b20cdeb7f669e8dcf2ed6f6e87629ea6fd43 GIT binary patch literal 1150 zcmcIiO-Phc6nz7MOI@|qT`sGQL7*E65h-UVlTy-t{3}r>GjpnMGXKV=!u%V~oogJ0nNw1oE2X@Rx(1x{FQ;r75dsvM8EXoPcQ&IZpp9>jgmJJ_GSK~i=hO6=Vj z`S1-bLvLYw;@zl8>!LGf8#<6yT#f1Z6*TT&4-Sz3)-$8o{0C6R3BOZh9N@ zir}C7fk%@eoUUsVzU9FHPF}U6^sW=ei#KJxyroz8;k(r9&M7hDWoQAm{xP_wLh#Kl zOKr!m*o2p9uEo)+23&UzlBdqoW2O0KzKeg4FDM$#PhZPDoonpGp~B0^s&3lMSLa1) zDUIu%`uYrz?5H%)ML5Wla%rg-nzz49=s1yMyyinL|dgK{RAsZ#1P^sCiqimkLFc6w?;E# Ioz|H93+w?(CjbBd literal 0 HcmV?d00001 diff --git a/sphinxPHP/public/themes/default/scripts/form.js b/sphinxPHP/public/themes/default/scripts/form.js index c6d8a06..d56ab77 100644 --- a/sphinxPHP/public/themes/default/scripts/form.js +++ b/sphinxPHP/public/themes/default/scripts/form.js @@ -30,22 +30,28 @@ $(document).ready( function() $('#loader').css('display:block'); var data = $("form").serialize(); - var debug = $('#debugVal').attr('value'); - var sequances = $('#sequanceVal').attr('value'); - var quorums = $('#quorumsVal').attr('value'); - var proximites = $('#proximitesVal').attr('value'); - var weight = $('#weightVal').attr('value'); - var actif = $('#actifVal').attr('value'); + var debug = $('#debugVal').attr('activated'); + var sequances = $('#sequanceVal').attr('activated'); + var quorums = $('#quorumsVal').attr('activated'); + var proximites = $('#proximitesVal').attr('activated'); + var weight = $('#weightVal').attr('activated'); + var actif = $('#actifVal').attr('activated'); - var SPH_RANK_PROXIMITY_BM25 = $('#SPH_RANK_PROXIMITY_BM25_VAL').attr('value'); - var SPH_RANK_BM25 = $('#SPH_RANK_BM25_VAL').attr('value'); - var SPH_RANK_NONE = $('#SPH_RANK_NONE_VAL').attr('value'); - var SPH_RANK_WORDCOUNT = $('#SPH_RANK_WORDCOUNT_VAL').attr('value'); - var SPH_RANK_PROXIMITY = $('#SPH_RANK_PROXIMITY_VAL').attr('value'); - var SPH_RANK_MATCHANY = $('#SPH_RANK_MATCHANY_VAL').attr('value'); - var SPH_MATCH_ANY = $('#SPH_MATCH_ANY_VAL').attr('value'); - var SPH_RANK_FIELDMASK = $('#SPH_RANK_FIELDMASK_VAL').attr('value'); + var tabs = ["SPH_SORT_RELEVANCE_VAL", "SPH_SORT_ATTR_DESC_VAL", "SPH_SORT_ATTR_ASC_VAL", "SPH_SORT_TIME_SEGMENTS_VAL", "SPH_SORT_EXTENDED_VAL", "SPH_SORT_EXPR_VAL"]; + for (i = 0; i < tabs.length; i++) { + if($("#"+tabs[i]).attr('activated') == 'true') { + var SPH_SORT = tabs[i]; + break; + } + } + var tab = ["SPH_RANK_PROXIMITY_BM25_VAL", "SPH_RANK_BM25_VAL", "", "SPH_RANK_NONE_VAL", "SPH_RANK_WORDCOUNT_VAL", "SPH_RANK_PROXIMITY_VAL", "SPH_RANK_MATCHANY_VAL", "SPH_MATCH_ANY_VAL", "SPH_RANK_FIELDMASK_VAL"]; + for (i = 0; i < tab.length; i++) { + if($("#"+tab[i]).attr('activated') == 'true') { + var SPH_RANK = tab[i]; + break; + } + } var WordSize = $('#MaxSizeWord').attr('value'); var QuorumSize = $('#Quorumsize').attr('value'); var ProximiteSize = $('#ProximiteSize').attr('value'); @@ -53,13 +59,14 @@ $(document).ready( function() data = data + '&SPH_MATCH='+$(this).attr('value'); data = data + '&debug='+debug+'&sequances='+sequances+'&quorums='+quorums+'&proximites='+proximites+'&weight='+weight+'&actif='+actif; - data = data + '&SPH_RANK_PROXIMITY_BM25='+SPH_RANK_PROXIMITY_BM25+'&SPH_RANK_BM25='+SPH_RANK_BM25+'&SPH_RANK_NONE='+SPH_RANK_NONE+'&SPH_RANK_WORDCOUNT='+ - SPH_RANK_WORDCOUNT+'&SPH_RANK_PROXIMITY='+SPH_RANK_PROXIMITY+'&SPH_RANK_MATCHANY='+SPH_RANK_MATCHANY+'&SPH_MATCH_ANY='+SPH_MATCH_ANY+'&SPH_RANK_FIELDMASK='+SPH_RANK_FIELDMASK; + data = data + '&SPH_RANK='+SPH_RANK.replace("_VAL", ""); + data = data + '&SPH_SORT='+SPH_SORT.replace("_VAL", ""); data = data + '&WordSize='+WordSize+'&QuorumSize='+QuorumSize+'&ProximiteSize='+ProximiteSize+'&MaxResult='+MaxResult+'&IsPost=true' + alert(data); $.post("formulaires/ent", data, function(data){ $("form").html(data); }); - $('#filtre').css('display', 'block'); + }); $('input[type=text]').focus(function(){ @@ -68,17 +75,49 @@ $(document).ready( function() $('#reset').click(function(){ $('input[type=text]').attr('value', ''); - }) + }); + + $('.config').click(function(){ + var attrib = $(this).attr('name'); + + if($(this).attr('activated') == 'true') { + if(attrib == 'default') { + $('#quorumsVal').click(); + $('#debugVal').click(); + $('#proximitesVal').click(); + $('#SPH_SORT_EXTENDED_VAL').click(); + $('#SPH_RANK_PROXIMITY_BM25_VAL').click(); + } else if (attrib == 'basic') { + $('#quorumsVal').click(); + } + } else { + if(attrib == 'default') { + $('#quorumsVal').attr('activated', 'false'); + $('#debugVal').attr('activated', 'false'); + $('#proximitesVal').attr('activated', 'false'); + $('#SPH_SORT_EXTENDED_VAL').attr('activated', 'false'); + $('#SPH_RANK_PROXIMITY_BM25_VAL').attr('activated', 'false'); + + $('#SPH_RANK_PROXIMITY_BM25_VAL').click(); + $('#SPH_SORT_EXTENDED_VAL').click(); + $('#quorumsVal').click(); + $('#debugVal').click(); + $('#proximitesVal').click(); + } else if (attrib == 'basic') { + $('#quorumsVal').click(); + } + } + }); $('.params').click(function(){ - var bool = $(this).attr('value'); + var bool = $(this).attr('activated'); if(bool == 'true') { - $(this).attr('value', 'false'); + $(this).attr('activated', 'false'); $(this).css('background-image', "url('/themes/default/images/red.png')"); $("#"+$(this).attr('name')).css('display', 'none'); } else { - $(this).attr('value', 'true'); + $(this).attr('activated', 'true'); $(this).css('background-image', "url('/themes/default/images/green.png')"); $("#"+$(this).attr('name')).css('display', 'block'); } @@ -135,4 +174,6 @@ $(document).ready( function() $('#statut').load('/formulaires/serverstatut').fadeOut('slow'); $('#statut').load('/formulaires/serverstatut').fadeIn('slow'); }, 5000); // refresh every 10000 milliseconds + + $('#default_val').click(); }); \ No newline at end of file