Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @return array
- */
- protected function initNavParams()
- {
- global $NavNum;
- $navParams = [
- 'NAV_NUM' => ++$NavNum,
- 'PAGE_NUMBER' => 1,
- 'PAGE_ELEMENT_COUNT' => 20,
- ];
- $unique = md5($this->getEntity()->getDBTableName());
- $pageKey = 'PAGEN_'.$navParams['NAV_NUM'];
- $sizeKey = 'SIZEN_'.$navParams['NAV_NUM'];
- $sessionPageKey = $unique.$pageKey;
- $sessionSizeKey = $unique.$sizeKey;
- /** @noinspection PhpDynamicAsStaticMethodCallInspection */
- if (\CPageOption::GetOptionString('main', 'nav_page_in_session', 'Y') == 'Y') {
- if (isset($_SESSION[$sessionPageKey]) && (int)$_SESSION[$sessionPageKey]) {
- $navParams['PAGE_NUMBER'] = (int)$_SESSION[$sessionPageKey];
- }
- if (isset($_SESSION[$sessionSizeKey]) && (int)$_SESSION[$sessionSizeKey]) {
- $navParams['PAGE_ELEMENT_COUNT'] = (int)$_SESSION[$sessionSizeKey];
- }
- }
- if (isset($_REQUEST[$pageKey]) && (int)$_REQUEST[$pageKey]) {
- $navParams['PAGE_NUMBER'] = (int)$_REQUEST[$pageKey];
- }
- if (isset($_REQUEST[$sizeKey]) && (int)$_REQUEST[$sizeKey]) {
- $navParams['PAGE_ELEMENT_COUNT'] = (int)$_REQUEST[$sizeKey];
- }
- if (!(int)$navParams['PAGE_NUMBER']) {
- $navParams['PAGE_NUMBER'] = 1;
- }
- if (!(int)$navParams['PAGE_ELEMENT_COUNT']) {
- $navParams['PAGE_ELEMENT_COUNT'] = 20;
- }
- /** @noinspection PhpDynamicAsStaticMethodCallInspection */
- if (\CPageOption::GetOptionString('main', 'nav_page_in_session', 'Y') == 'Y') {
- $_SESSION[$sessionPageKey] = $navParams['PAGE_NUMBER'];
- $_SESSION[$sessionSizeKey] = $navParams['PAGE_ELEMENT_COUNT'];
- }
- return $navParams;
- }
- /**
- * @param $navParams
- * @param $filter
- * @param $runtime
- */
- protected function initPagination($navParams, $filter, $runtime)
- {
- $params = [
- 'select' => [new ExpressionField('CNT', $this->useFoundRows ? 'FOUND_ROWS()' : 'COUNT(1)')],
- ];
- if (!$this->useFoundRows) {
- $params['filter'] = $filter;
- $params['runtime'] = $runtime;
- }
- $total = (int)call_user_func([$this->entity->getDataClass(), 'getList'], $params)->fetch()['CNT'];
- $adminResult = new \CAdminResult([], $this->entity->getDBTableName());
- $adminResult->NavPageCount = ceil($total / $navParams['PAGE_ELEMENT_COUNT']);
- $adminResult->NavPageNomer = $navParams['PAGE_NUMBER'];
- $adminResult->NavNum = $navParams['NAV_NUM'];
- $adminResult->NavPageSize = $navParams['PAGE_ELEMENT_COUNT'];
- $adminResult->NavRecordCount = $total;
- $this->list->NavText($adminResult->GetNavPrint($this->getTitle()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement