94 lines
2.8 KiB
PHP
94 lines
2.8 KiB
PHP
<?php
|
|
// --------------------------------------------------------------------------- //
|
|
// Fonctions sur les criteres
|
|
// --------------------------------------------------------------------------- //
|
|
if (defined('DEBUG') == false) {
|
|
define( 'DEBUG', 0);
|
|
}
|
|
if (defined('LOCAL') == false) {
|
|
define( 'LOCAL', 0);
|
|
}
|
|
|
|
if (LOCAL) {
|
|
require_once('../sphinx/api/sphinxapi.php');
|
|
} else {
|
|
include_once(INCLUDE_PATH.'sphinx/sphinxapi.php');
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Nouvelle sequence
|
|
// --------------------------------------------------------------------------- //
|
|
function nouvelleSequence(&$criteres)
|
|
{
|
|
if (LOCAL == true) {
|
|
$crit2seq = file('crit2seq.prn');
|
|
} else {
|
|
$crit2seq = file(INCLUDE_PATH.'sphinx/crit2seq.prn');
|
|
}
|
|
foreach ($crit2seq as $ligne) {
|
|
if (($pos = strpos($ligne, ';')) != false) {
|
|
$ligne = substr($ligne, 0, $pos);
|
|
}
|
|
if (strstr(substr($ligne, 2, 10), $criteres) != false) {
|
|
return str_split(substr($ligne, 13, -1), 3);
|
|
}
|
|
}
|
|
return array();
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Nouvelle combinaison
|
|
// --------------------------------------------------------------------------- //
|
|
function nouvelleCombinaison(&$sequence, &$sequencePos, $pass, &$index, &$mode)
|
|
{
|
|
for (;;) {
|
|
if (isset($sequence[$sequencePos]) == false) {
|
|
return '';
|
|
}
|
|
$combinaison = trim($sequence[$sequencePos]);
|
|
++$sequencePos;
|
|
|
|
if (strlen($combinaison) == 2) {
|
|
return $combinaison;
|
|
}
|
|
|
|
// Passage en phonetique ou en orthographique
|
|
if (strlen($combinaison) == 3) {
|
|
if ($pass == 2 ||
|
|
$pass == 3) {
|
|
continue;
|
|
}
|
|
$car = strtolower(substr($combinaison, 2, 1));
|
|
switch($car) {
|
|
case 'p':
|
|
$index = 'ent_phx';
|
|
$mode = SPH_MATCH_EXTENDED2;
|
|
break;
|
|
case 'o':
|
|
$index = 'ent_mns';
|
|
$mode = SPH_MATCH_ISPELL;
|
|
break;
|
|
default:
|
|
debugln("attention: mode inconnu: '$car'");
|
|
}
|
|
} else if ($pass == 1) {
|
|
$index = 'ent_mns';
|
|
}
|
|
|
|
return $combinaison;
|
|
}
|
|
}
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
// Nouveaux criteres
|
|
// --------------------------------------------------------------------------- //
|
|
function nouveauxCriteres(&$comb2crit, &$combinaison)
|
|
{
|
|
foreach ($comb2crit as $ligne) {
|
|
if (strstr($ligne, $combinaison) != false) {
|
|
return substr($ligne, 3, -1);
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
?>
|