* zin: support to set size menu items in usePager.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace zin;
|
||||
* @param ?array $userSetting
|
||||
* @return array
|
||||
*/
|
||||
function usePager(string|array $pagerName = 'pager', string $extra = '', ?array $userSetting = null): ?array
|
||||
function usePager(string|array $pagerName = 'pager', string $extra = '', ?array $userSetting = null, ?array $sizeMenuItems = null): ?array
|
||||
{
|
||||
if(is_array($pagerName))
|
||||
{
|
||||
@@ -57,7 +57,18 @@ function usePager(string|array $pagerName = 'pager', string $extra = '', ?array
|
||||
else
|
||||
{
|
||||
$setting['items'][] = array('type' => 'info', 'text' => $pager->lang->pager->totalCountAB);
|
||||
if(strpos(',short,', ",{$extra},") === false) $setting['items'][] = array('type' => 'size-menu', 'text' => str_replace('<strong>', '', str_replace('</strong>', '', $pager->lang->pager->pageSize)), 'dropdown' => array('placement' => 'top'), 'itemProps' => array('onClick' => jsRaw("(e, item) => $.cookie.set('$pager->pageCookie', item.key)")));
|
||||
if(strpos(',short,', ",{$extra},") === false)
|
||||
{
|
||||
$sizeMenuSetting = array
|
||||
(
|
||||
'type' => 'size-menu',
|
||||
'text' => str_replace('<strong>', '', str_replace('</strong>', '', $pager->lang->pager->pageSize)),
|
||||
'dropdown' => array('placement' => 'top'),
|
||||
'itemProps' => array('onClick' => jsRaw("(e, item) => $.cookie.set('$pager->pageCookie', item.key)"))
|
||||
);
|
||||
if($sizeMenuItems) $sizeMenuSetting['items'] = $sizeMenuItems;
|
||||
$setting['items'][] = $sizeMenuSetting;
|
||||
}
|
||||
$setting['items'][] = array('type' => 'link', 'page' => 'first', 'hint' => $pager->lang->pager->firstPage, 'icon' => 'icon-first-page');
|
||||
$setting['items'][] = array('type' => 'link', 'page' => 'prev', 'hint' => $pager->lang->pager->previousPage, 'icon' => 'icon-angle-left');
|
||||
$setting['items'][] = array('type' => 'info', 'text' => '{page}/{pageTotal}');
|
||||
|
||||
Reference in New Issue
Block a user