Skip to content
Snippets Groups Projects

Dev#182440 task#186069

Merged Henri-Damien LAURENT requested to merge dev#182440_task#186069 into master
Files
6
@@ -21,7 +21,7 @@
class Class_WebService_OAI_Request_ListIdentifiers {
const IDENTIFIERS_BY_PAGE = 100;
static int $identifiers_by_page = 100;
protected
@@ -122,16 +122,18 @@ class Class_WebService_OAI_Request_ListIdentifiers {
if ( ! $this->_catalogue->hasRecords())
return $builder->error(['code' => 'noRecordsMatch']);
if (!$this->_token && static::IDENTIFIERS_BY_PAGE < $this->_total_count)
$this->_token = new Class_WebService_OAI_ResumptionToken($this->_params);
if ($this->_shouldDisplayResumptionToken())
$this->_token = $this->_buildToken();
$page_number = $this->_token
? $this->_token->pageNumber()
: 1;
$this->_notices = Class_Catalogue::getNoticesByPreferences(['id_catalogue' => $this->_catalogue->getId(),
'page' => $page_number,
'page_size' => self::IDENTIFIERS_BY_PAGE]);
'start_limit' => $page_number==1
? 0
: ($page_number -1) *self::$identifiers_by_page + 1,
'nb_notices' => self::$identifiers_by_page]);
if (empty($this->_notices))
return $builder->error(['code' => 'noRecordsMatch']);
}
@@ -143,6 +145,25 @@ class Class_WebService_OAI_Request_ListIdentifiers {
}
protected function _buildToken() : Class_WebService_OAI_ResumptionToken{
return $this->_resumptionToken
? Class_WebService_OAI_ResumptionToken::fromString($this->_resumptionToken)
: new Class_WebService_OAI_ResumptionToken($this->_params,
$this->_token
? $this
->_token
->pageNumber()
: 1);
}
protected function _shouldDisplayResumptionToken(){
return $this->_token
? ($this->_token->pageNumber() * static::$identifiers_by_page) <= $this->_catalogue->getNoticesCount()
: static::$identifiers_by_page < $this->_catalogue->getNoticesCount();
}
public function getToken() {
return $this->_token;
}
@@ -166,8 +187,10 @@ class Class_WebService_OAI_Request_ListIdentifiers {
public function renderResumptionTokenOn($builder) {
return $this->_token
? $this->_token->renderOn($builder, $this->_total_count)
return $this->_shouldDisplayResumptionToken()
? $this->_token->renderOn($builder, $this->_total_count
? $this->_total_count
: $this->_catalogue->getNoticesCount())
: '';
}