diff --git a/cosmogramme/php/fonctions/objets_saisie.php b/cosmogramme/php/fonctions/objets_saisie.php index d3a1632cefdc92be5e945ebc95fc33896f968e39..6566004dd600db17a3a66f0ad319e81e71affb90 100644 --- a/cosmogramme/php/fonctions/objets_saisie.php +++ b/cosmogramme/php/fonctions/objets_saisie.php @@ -91,7 +91,13 @@ function getBlocsParams($id_bib, $type, $valeurs) { $champs_params = []; $titres[0] = 'Paramètres'; - if (in_array($clef, [COM_VSMART, COM_NANOOK, COM_MICROBIB, COM_BIBLIXNET])) + if(in_array($clef, [COM_NANOOK])) + $champs_params[0] = ['url_serveur', + ['provide_suggest' => function($id, $valeur) { + return getOuiNon($id, $valeur); + }]]; + + if (in_array($clef, [COM_VSMART, COM_MICROBIB, COM_BIBLIXNET])) $champs_params[0] = ['url_serveur']; if (in_array($clef, [COM_CARTHAME])) diff --git a/library/Class/WebService/OAI/Request/ListIdentifiers.php b/library/Class/WebService/OAI/Request/ListIdentifiers.php index a8f6cc9b271c2c4b10ecd250ae2326e950578783..2283020063824a4d41b26afe0314b81dc0394d87 100644 --- a/library/Class/WebService/OAI/Request/ListIdentifiers.php +++ b/library/Class/WebService/OAI/Request/ListIdentifiers.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_WebService_OAI_Request_ListIdentifiers { const IDENTIFIERS_BY_PAGE = 100; @@ -32,7 +32,7 @@ class Class_WebService_OAI_Request_ListIdentifiers { protected $_notices; protected $_token; - + public function __construct($params, $baseUrl) { $this->_baseUrl = $baseUrl; $this->_params = array_merge(array('metadataPrefix' => null, @@ -49,15 +49,15 @@ class Class_WebService_OAI_Request_ListIdentifiers { $this->_resumptionToken = $this->_params['resumptionToken']; - if ($this->_resumptionToken + if ($this->_resumptionToken && ($token = Class_WebService_OAI_ResumptionToken::find($this->_resumptionToken))) { $this->_set = $token->getParam('set'); $this->_from = $token->getParam('from'); $this->_until = $token->getParam('until'); - + if ($this->_metadataPrefix) $this->_metadataPrefix=null; - else + else $this->_metadataPrefix=$token->getParam('metadataPrefix'); } @@ -81,7 +81,7 @@ class Class_WebService_OAI_Request_ListIdentifiers { if (null == $this->_metadataPrefix) $answer.=$builder->error(array('code' => 'badArgument'), 'Metadata prefix is not found'); - if ('oai_dc' != $this->_metadataPrefix) + if ('oai_dc' != $this->_metadataPrefix) $answer.= $builder->error(array('code' => 'cannotDisseminateFormat')); @@ -97,23 +97,23 @@ class Class_WebService_OAI_Request_ListIdentifiers { if ($this->_until && $this->_from) { if (strlen($this->_until) != strlen($this->_from)) return $builder->error(array('code' => 'badArgument'), 'from granularity != until granularity'); - + if (strtotime($this->_from)>(strtotime($this->_until))) return $builder->error(array('code' => 'noRecordsMatch')); } $token = null; - if ($this->_resumptionToken + if ($this->_resumptionToken && !($token = Class_WebService_OAI_ResumptionToken::find($this->_resumptionToken))) return $builder->error(array('code' => 'badResumptionToken')); - if ($answer) + if ($answer) return $answer; - if ($this->_from) + if ($this->_from) $this->_catalogue->setFrom(substr($this->_from, 0, 10)); - if ($this->_until) + if ($this->_until) $this->_catalogue->setUntil(substr($this->_until, 0, 10)); if (0 == ($count = $this->_catalogue->getNoticesCount())) @@ -147,11 +147,11 @@ class Class_WebService_OAI_Request_ListIdentifiers { $requestOptions['set'] = $this->_set; if (null !== $this->_from) $requestOptions['from'] = $this->_from; - if (null !== $this->_until) + if (null !== $this->_until) $requestOptions['until'] = $this->_until; if (null !== $this->_resumptionToken) $requestOptions['resumptionToken'] = $this->_resumptionToken; - if (null !== $this->_metadataPrefix) + if (null !== $this->_metadataPrefix) $requestOptions['metadataPrefix'] = $this->_metadataPrefix; return $builder->request($requestOptions, $this->_baseUrl); @@ -159,7 +159,7 @@ class Class_WebService_OAI_Request_ListIdentifiers { public function getCatalogueFromSetSpec($setSpec) { - if (null == $setSpec) + if (null == $setSpec) return Class_Catalogue::newCatalogueForAll(); return current(Class_Catalogue::getLoader()->findAllBy(array('oai_spec' => $setSpec))); } diff --git a/library/Class/WebService/SIGB/Nanook.php b/library/Class/WebService/SIGB/Nanook.php index 50993f34468c4015293d02b2799612dd06ad5790..4e71a26a73f7614d116b9e7249efc1ebdde4973b 100644 --- a/library/Class/WebService/SIGB/Nanook.php +++ b/library/Class/WebService/SIGB/Nanook.php @@ -18,5 +18,22 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_WebService_SIGB_Nanook extends Class_WebService_SIGB_Abstract {} +class Class_WebService_SIGB_Nanook extends Class_WebService_SIGB_Abstract { + + public static function getService($params){ + if (!isset($params['provide_suggest'])) + $params = array_merge(['provide_suggest' => ''], + $params); + + if (!isset(static::$service)) { + $instance = new static(); + $classname = get_called_class().'_Service'; + static::$service = $classname::getService($params['url_serveur'], + $params['provide_suggest'] === '1'); + } + + return static::$service; + } + +} ?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index f08189125ce4214587276449d4c94b4f3ebad1ec..ecf9d8c8e0553692bcafa5b3629250d349c2fcb5 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -19,6 +19,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_AbstractRESTService { + protected $_provide_suggest = false; + + + public static function getService($server_root, $provide_suggest = false) { + return self::newInstance() + ->setServerRoot($server_root) + ->setProvideSuggest($provide_suggest); + } + + /** * @param string $server_root * @return Class_WebService_SIGB_AbstractRESTService @@ -180,8 +190,14 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac } + public function setProvideSuggest($provide_suggest) { + $this->_provide_suggest = $provide_suggest; + return $this; + } + + public function providesSuggestions() { - return true; + return $this->_provide_suggest; } diff --git a/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatNanookTest.php b/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatNanookTest.php index 650137b247567a5eed17442df4d57a367ed6f48e..aa37724d749aa94d77909f2d7c3f343105ecda36 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatNanookTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerSuggestionAchatNanookTest.php @@ -43,7 +43,8 @@ abstract class AbstractAbonneControllerSuggestionAchatNanookTestCase extends Abs $sigb_conf = $this->fixture('Class_IntBib', ['id' => 3, - 'comm_params' => ['url_serveur' => 'nanookService'], + 'comm_params' => ['url_serveur' => 'nanookService', + 'provide_suggest' => '1'], 'comm_sigb' => Class_IntBib::COM_NANOOK]); $tatim = $this->fixture('Class_Bib', ['id' => 12,