enhance externalModules page (#33948)

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Mohamed DAOUD 2025-04-24 01:14:58 +02:00 committed by GitHub
parent 9194e4f12f
commit baa08bad7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -372,22 +372,7 @@ class ExternalModules
$this->numberTotalOfPages = (int) ceil(max($fileProductsTotal / $this->per_page, $dolistoreProductsTotal / $this->per_page));
// merge both sources
$this->products = array_values(array_merge($dolistoreProducts, $fileProducts));
// Sort products list by datec
usort(
$this->products,
/**
* Compare creation dates
*
* @param array<string, mixed> $a First product for comparison.
* @param array<string, mixed> $b Second product for comparison.
* @return int
*/
static function ($a, $b) {
return strtotime($b['datec'] ?? '0') - strtotime($a['datec'] ?? '0');
}
);
$this->products = array_values(array_merge($fileProducts, $dolistoreProducts));
$i = 0;
foreach ($this->products as $product) {
@ -628,6 +613,9 @@ class ExternalModules
} else {
$sub = 0;
}
if (!empty($this->search)) {
$param_array['search_keyword'] = $this->search;
}
$param_array['no_page'] = $this->no_page - $sub;
if ($this->categorie != 0) {
$param_array['categorie'] = $this->categorie;
@ -651,6 +639,9 @@ class ExternalModules
} else {
$add = 1;
}
if (!empty($this->search)) {
$param_array['search_keyword'] = $this->search;
}
$param_array['no_page'] = $this->no_page + $add;
if ($this->categorie != 0) {
$param_array['categorie'] = $this->categorie;