78 lines
3.1 KiB
PHP
78 lines
3.1 KiB
PHP
<?php
|
|
if(!isset($method)){
|
|
$pays = $_REQUEST['pays'];
|
|
}
|
|
|
|
require_once 'graydon/graydonws.php';
|
|
// Create the request parameters
|
|
$request = new StdClass();
|
|
// Initialise the request object
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->Country = $pays;
|
|
|
|
$path = PATH_DATA.'/graydon/method';
|
|
$fileName = strtolower('CompanyMatchMethods-'.$pays);
|
|
|
|
if(!file_exists($path.'/'.$fileName)){
|
|
try
|
|
{
|
|
$result = $graydon->getCompanyMatchMethods($request);
|
|
|
|
$count = count($result->CompanyMatchMethods->CompanyMatchMethod->MatchMethods->MatchMethod);
|
|
if ($count>1){
|
|
$methods = $result->CompanyMatchMethods->CompanyMatchMethod->MatchMethods->MatchMethod;
|
|
}elseif($count==1){
|
|
$methods[] = $result->CompanyMatchMethods->CompanyMatchMethod->MatchMethods->MatchMethod;
|
|
}
|
|
|
|
//Stockage du résultat de la méthode en cache
|
|
file_put_contents($path.'/'.$fileName, serialize($methods));
|
|
|
|
}catch( SoapFault $fault ){
|
|
require_once 'soaperror.php';
|
|
processSoapFault($client,$fault,$tabInfo);
|
|
}
|
|
}else{
|
|
$methods = unserialize(file_get_contents($path.'/'.$fileName));
|
|
}
|
|
|
|
if (isset($methods)){
|
|
$firephp->log($methods,'methods');
|
|
$firephp->log($method,'method');
|
|
//Affichage de la meilleur méthode de recherche OU la première
|
|
$lien = 'Effectuer un recherche : ';
|
|
$flagBestMethod = false;
|
|
$countMethods = 0;
|
|
foreach($methods as $item){
|
|
$WithCity = $item->WithCity;
|
|
$WithPostCode = $item->WithPostCode;
|
|
if( ($item->BestMethod==TRUE && $item->MatchingMethod=='Keyword') && !isset($method) || $method=='keyword' ){
|
|
$flagBestMethod = TRUE;
|
|
require_once realpath(dirname(__FILE__)).'/method_keyword.php';
|
|
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='Identifier') && !isset($method) || $method=='identifier' ){
|
|
$flagBestMethod = TRUE;
|
|
require_once realpath(dirname(__FILE__)).'/method_identifier.php';
|
|
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='Name') && !isset($method) || $method=='name' ){
|
|
$flagBestMethod = TRUE;
|
|
require_once realpath(dirname(__FILE__)).'/method_name.php';
|
|
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='PostCode') && !isset($method) || $method=='postcode' ){
|
|
$flagBestMethod = TRUE;
|
|
require_once realpath(dirname(__FILE__)).'/method_postcode.php';
|
|
}
|
|
|
|
$countMethods++;
|
|
|
|
//Affichage des propostions des méthodes de recherche
|
|
if($item->MatchingMethod=='Keyword'){ $lien .= '<a href="./?page=international_recherche&mode=normal&method=keyword&pays='.$pays.'">Par mots clés</a>'; }
|
|
if($item->MatchingMethod=='Identifier'){ $lien .= '<a href="./?page=international_recherche&mode=normal&method=identifier&pays='.$pays.'">Par identifiant</a>'; }
|
|
if($item->MatchingMethod=='Name'){ $lien .= '<a href="./?page=international_recherche&mode=normal&method=name&pays='.$pays.'">Par nom</a>'; }
|
|
if($item->MatchingMethod=='PostCode'){ $lien .= '<a href="./?page=international_recherche&mode=normal&method=postcode&pays='.$pays.'">Par Post Code</a>'; }
|
|
|
|
if($countMethods>=count($methods)){$separator=''; break;}else{$separator=' - ';}
|
|
|
|
$lien = $lien.$separator;
|
|
}
|
|
|
|
print '<span class="left">'.$lien.'</span>';
|
|
}
|
|
?>
|