extranet/application/controllers/GiantController.php
Damien LASSERRE 70f11106a1 Giant 2.0
2011-04-19 15:59:50 +00:00

114 lines
3.4 KiB
PHP

<?php
require_once ('Giant/WSgiant.php');
require_once ('Giant/Search.lib.php');
require_once ('Giant/Modulables.php');
class GiantController extends Zend_Controller_Action
{
protected $soapClient;
protected $Provider;
protected $TestIndication;
protected $user;
protected $language;
protected $labelResults;
protected $ListAuthorized = array(
'FR' => '006', 'BE' => '001', 'ES' => '001',
'UK' => '003', 'NL' => '002');
public function init()
{
/** @todo provisoir **/
$auth = Zend_Auth::getInstance();
$this->user = $auth->getIdentity();
$this->view->headLink()->appendStylesheet('/themes/default/styles/giant.css', 'all');
if(!isset($_SESSION['recherche']['giant']))
$_SESSION['recherche']['giant'] = $this->getRequest()->getParams();
if (!isset($_SESSION['recherche']['giant']['page']))
$_SESSION['recherche']['giant']['page'] = 0;
if (!isset($_SESSION['recherche']['giant']['nbResults']))
$_SESSION['recherche']['giant']['nbResults'] = 0;
self::setTestIndication(true);
self::setCountryCode($_SESSION['recherche']['giant']['pays']);
$this->soapClient = new WSgiant($this->Provider);
}
public function indexAction()
{
$siret = $this->getRequest()->getParam('siret');
if(empty($siret))
$this->_forward('search');
else
$this->_forward('advanced');
}
/**
*
* Action Search
*/
public function searchAction()
{
$search = new Search($this->soapClient,
$this->getRequest()->getParam('page'));
$this->view->assign('label', $search->getLabelDesc());
$this->view->assign('labelResults', $search->getLabelResults);
$this->view->assign('pays', self::getCountryCode());
$this->view->assign('currentPage', $_SESSION['recherche']['giant']['page']);
$this->view->assign('userMaxResult', $this->user->nbReponses);
$this->view->assign('resultats', $search
->getMethode('search', $_SESSION['recherche']['giant'])
);
$this->view->assign('referer', $search->getQuery());
}
public function advancedAction()
{
$advanced = new Search($this->soapClient,
$this->getRequest()->getParam('page'));
$this->view->assign('pays', self::getCountryCode());
$this->view->assign('currentPage', $_SESSION['recherche']['giant']['page']);
$this->view->assign('userMaxResult', $this->user->nbReponses);
$this->view->assign('resultats', $advanced
->getMethode('advancedSearch', $_SESSION['recherche']['giant'])
);
$this->view->assign('referer', $advanced->getQuery());
$this->render('search');
}
public function setCountryCode($CountryCode)
{
if(array_key_exists($CountryCode, $this->ListAuthorized))
{
$this->Provider->CountryCode = $CountryCode;
self::setProviderId($this->ListAuthorized[$CountryCode]);
}
}
private function setProviderId($ProviderId) {
$this->Provider->ProviderId = $ProviderId;
}
public function setTestIndication($bool) {
if (is_bool($bool))
$this->TestIndication = $bool;
}
public function getCountryCode() {
return ($this->Provider->CountryCode);
}
public function getProviderId() {
return ($this->Provider->ProviderId);
}
public function __destrcut()
{
unset($_SESSION['recherche']['giant']);
}
}