total = $total; $this->page = empty($page) ? 1 : $page; $this->nbPerPage = $nbPerPage; } public function display(string $page = '', string $suffix = '', bool $dynamics = false): string { $name = empty($page) ? 'pagination_page_ajax' : $page.'_pagination_page'; $this->total = intval($this->total); $this->nbPerPage = intval($this->nbPerPage); if (empty($this->nbPerPage)) { return ''; } $nbPages = ceil($this->total / $this->nbPerPage); $class = $dynamics ? ' margin-bottom-1' : ''; if (acym_isAdmin() || ACYM_CMS === 'joomla') { $classNavigationContainer = 'shrink grid-margin-x'; $classNavigation = 'small-auto medium-shrink'; $classDisplayNumber = 'shrink'; $classPadding = 'pagination_padding '; } else { $classNavigationContainer = ''; $classNavigation = ''; $classDisplayNumber = 'align-center'; $classPadding = ''; } $pagination = '
'; return $pagination; } public function displayAjax($dynamics = false) { return $this->display('', '__ajax', $dynamics); } public function getListLimit($default = 20) { $currentUserId = acym_currentUserId(); if (empty($currentUserId)) $currentUserId = 0; $currentConfig = $this->config->get('list_limit_'.$currentUserId, $default); $listLimitSelect = acym_getVar('int', 'acym_pagination_element_per_page', 0); if (!empty($listLimitSelect) && $listLimitSelect != $currentConfig) { $this->config->save(['list_limit_'.$currentUserId => $listLimitSelect]); $currentConfig = $listLimitSelect; } return $currentConfig; } function getClosest($search, $arr) { $closest = null; foreach ($arr as $item) { if ($closest === null || abs($search - $closest) > abs($item - $search)) { $closest = $item; } } return $closest; } }