diff --git a/VERSIONS_HOTLINE/95535 b/VERSIONS_HOTLINE/95535 new file mode 100644 index 0000000000000000000000000000000000000000..a0b6cb98e10c34136fa24203c7634ee9ab15cde5 --- /dev/null +++ b/VERSIONS_HOTLINE/95535 @@ -0,0 +1 @@ + - ticket #95535 : Boite auteurs: meilleure prise en compte du nombre d'auteurs à afficher \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Authors.php b/library/ZendAfi/View/Helper/Accueil/Authors.php index 4a5fb2e0b6db643e139f3bf33ddd3fd5afe0ec3b..c8e517641f6517f4a6c8877a77e6888db38d6464 100644 --- a/library/ZendAfi/View/Helper/Accueil/Authors.php +++ b/library/ZendAfi/View/Helper/Accueil/Authors.php @@ -20,6 +20,9 @@ */ class ZendAfi_View_Helper_Accueil_Authors extends ZendAfi_View_Helper_Accueil_Base { + const RECORDS_LOAD_LIMIT = 500; + const AUTHORS_FETCH_BIO_LIMIT = 100; + public function getHTML() { $this->titre = $this->preferences['titre']; $this->contenu = $this->_renderContent(); @@ -35,11 +38,15 @@ class ZendAfi_View_Helper_Accueil_Authors extends ZendAfi_View_Helper_Accueil_Ba public function refreshAuthorsWithoutThumbnail() { - $authors = array_filter($this->_findAuthorsFromPreferences(), - function($author) - { - return !$author->isThumbnailValid(); - }); + $authors = array_slice( + array_filter($this->_findAuthorsFromPreferences(false), + function($author) + { + return !$author->isThumbnailValid(); + }), + 0, + static::AUTHORS_FETCH_BIO_LIMIT); + array_map(function($author) { (new Class_CodifAuteur_Description($author))->fetchBiography(); @@ -74,9 +81,10 @@ class ZendAfi_View_Helper_Accueil_Authors extends ZendAfi_View_Helper_Accueil_Ba } - protected function _findAuthorsFromPreferences() { + protected function _findAuthorsFromPreferences($with_thumbnail_only = true) { + $this->preferences['nb_notices'] = static::RECORDS_LOAD_LIMIT; $records = Class_Notice::getNoticesFromPreferences($this->preferences); - return $this->_getAuthorsFromRecords($records); + return $this->_getAuthorsFromRecords($records, $with_thumbnail_only); } @@ -95,14 +103,18 @@ class ZendAfi_View_Helper_Accueil_Authors extends ZendAfi_View_Helper_Accueil_Ba } - protected function _getAuthorsFromRecords($records) { - $authors_ids = $this->_getAuthorsIdsFromRecords($records); + protected function _getAuthorsFromRecords($records, $with_thumbnail_only) { + if (!$authors_ids = $this->_getAuthorsIdsFromRecords($records)) + return []; + + $params = ['id_auteur' => $authors_ids]; + + if ($with_thumbnail_only) { + $params['where'] = 'thumbnail_url > \'\''; + $params['limit'] = $this->preferences['authors_count']; + } - return $authors_ids - ? Class_CodifAuteur::findAllBy(['id_auteur' => array_slice($authors_ids, - 0, - $this->preferences['authors_count'])]) - : []; + return Class_CodifAuteur::findAllBy($params); } diff --git a/tests/scenarios/AuthorPage/AuthorWidgetTest.php b/tests/scenarios/AuthorPage/AuthorWidgetTest.php index d271480cad68d880e35f7a855d5ec49aa56098a5..4c09bc448b1777ea90f1b09feac7f93c2b9dbbd4 100644 --- a/tests/scenarios/AuthorPage/AuthorWidgetTest.php +++ b/tests/scenarios/AuthorPage/AuthorWidgetTest.php @@ -184,6 +184,7 @@ class AuthorWidgetOnPageTest extends AuthorWidgetOnPageTestCase { { $this->assertEquals(3, $preferences['id_panier']); $this->assertEquals(10, $preferences['authors_count']); + $this->assertEquals(500, $preferences['nb_notices']); $this->assertEquals(Class_Systeme_ModulesAccueil_Authors::AUTHORS_SELECTION_MODE_ALL, $preferences['authors_selection_mode']); return Class_Notice::findAll();