Commit 19df9057 authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch…

Merge branch 'hotline#95535_boite_auteurs_le_nombre_d_auteurs_affiches_est_moindre_que_dans_le_parametrage' into 'hotline'

hotline #95535 Authors widget: improve thumbnail fetching & authors count to display

See merge request !3197
parents 3da2174f 1463d365
Pipeline #8016 passed with stage
in 36 minutes and 7 seconds
- ticket #95535 : Boite auteurs: meilleure prise en compte du nombre d'auteurs à afficher
\ No newline at end of file
......@@ -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);
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment