src/Kharanenka/Helper/PaginationHelper.php
public static function get($iCurrentPage, $iTotalCount, $arSettings = []) {

        self::$arResult = [];

        self::$iCurrentPage = $iCurrentPage;
        self::initSettings($arSettings);
        if(empty(self::$arSettings['button_list'])) {
            self::$arResult;
        }

        //Get count per page elements
        $iCountPerPage = self::$arSettings['count_per_page'];

        //Get total page count
        self::$iTotalCountPages = ceil($iTotalCount/$iCountPerPage);

        //get pagination button limit
        $iElementLimit = self::$arSettings['pagination_limit'];

        //init start position
        self::$iPosition = $iCurrentPage - floor($iElementLimit/2);

        //Update position
        if((self::$iPosition + $iElementLimit) > self::$iTotalCountPages) {
            self::$iPosition = self::$iTotalCountPages - $iElementLimit + 1;
        }

        if(self::$iPosition < 1) {
            self::$iPosition = 1;
        }

        $arMainPageList = [];

        foreach(self::$arSettings['button_list'] as $sButtonCode) {

            switch($sButtonCode) {
                case self::FIRST_BUTTON_CODE:
                    self::addPrevButton(self::FIRST_BUTTON_CODE);
                    break;
                case self::FIRST_MORE_BUTTON_CODE:
                    self::addPrevButton(self::FIRST_MORE_BUTTON_CODE);
                    break;
                case self::PREV_BUTTON_CODE:
                    self::addPrevButton(self::PREV_BUTTON_CODE);
                    break;
                case self::PREV_MORE_BUTTON_CODE:
                    self::addPrevButton(self::PREV_MORE_BUTTON_CODE);
                    break;
                case self::MAIN_BUTTON_CODE:

                    if(self::$arSettings['main_button_on']) {
                        //Get pagination buttons
                        $i = 0;
                        while($i < $iElementLimit) {

                            //Set active page button
                            $sCode = null;
                            $sElementClass = self::$arSettings['main_button_class'];
                            if(self::$iPosition == self::$iCurrentPage) {
                                $sElementClass = ' '.self::$arSettings['active_class'];
                                $sCode = self::ACT_BUTTON_CODE;
                            }

                            if(self::$iPosition > 0) {
                                self::$arResult[] = [
                                    'name' => self::$iPosition,
                                    'value' => self::$iPosition,
                                    'class' => $sElementClass,
                                    'code' => $sCode,
                                ];

                                $arMainPageList[] = self::$iPosition;

                                $i++;
                            }

                            self::$iPosition++;
                            if(self::$iPosition > self::$iTotalCountPages) {
                                break;
                            }
                        }
                    }
                    break;
                case self::NEXT_MORE_BUTTON_CODE:
                    self::addNextButton(self::NEXT_MORE_BUTTON_CODE);
                    break;
                case self::NEXT_BUTTON_CODE:
                    self::addNextButton(self::NEXT_BUTTON_CODE);
                    break;
                case self::LAST_MORE_BUTTON_CODE:
                    self::addNextButton(self::LAST_MORE_BUTTON_CODE);
                    break;
                case self::LAST_BUTTON_CODE:
                    self::addNextButton(self::LAST_BUTTON_CODE);
                    break;
            }
        }

        $arUnsetCodeList = [];
        foreach (self::$arResult as $iKey => $arButtonData) {
            if ($arButtonData['code'] == self::ACT_BUTTON_CODE || empty($arButtonData['code'])) {
                continue;
            }

            if (!in_array($arButtonData['code'], [self::FIRST_BUTTON_CODE, self::FIRST_MORE_BUTTON_CODE, self::LAST_BUTTON_CODE, self::LAST_MORE_BUTTON_CODE])) {
                continue;
            }

            if (!in_array($arButtonData['value'], $arMainPageList)) {
                continue;
            }

            $arUnsetCodeList[] = $arButtonData['code'];
            $arUnsetCodeList[] = $arButtonData['code'].'-more';
        }

        if (!empty($arUnsetCodeList)) {
            foreach (self::$arResult as $iKey => $arButtonData) {
                if (!in_array($arButtonData['code'], $arUnsetCodeList)) {
                    continue;
                }

                unset(self::$arResult[$iKey]);
            }
        }

        return self::$arResult;
    }
public static function get($iCurrentPage, $iTotalCount, $arSettings = []) {

        self::$arResult = [];

        self::$iCurrentPage = $iCurrentPage;
        self::initSettings($arSettings);
        if(empty(self::$arSettings['button_list'])) {
            self::$arResult;
        }

        //Get count per page elements
        $iCountPerPage = self::$arSettings['count_per_page'];

        //Get total page count
        self::$iTotalCountPages = ceil($iTotalCount/$iCountPerPage);

        //get pagination button limit
        $iElementLimit = self::$arSettings['pagination_limit'];

        //init start position
        self::$iPosition = $iCurrentPage - floor($iElementLimit/2);

        //Update position
        if((self::$iPosition + $iElementLimit) > self::$iTotalCountPages) {
            self::$iPosition = self::$iTotalCountPages - $iElementLimit + 1;
        }

        if(self::$iPosition < 1) {
            self::$iPosition = 1;
        }

        $arMainPageList = [];

        foreach(self::$arSettings['button_list'] as $sButtonCode) {

            switch($sButtonCode) {
                case self::FIRST_BUTTON_CODE:
                    self::addPrevButton(self::FIRST_BUTTON_CODE);
                    break;
                case self::FIRST_MORE_BUTTON_CODE:
                    self::addPrevButton(self::FIRST_MORE_BUTTON_CODE);
                    break;
                case self::PREV_BUTTON_CODE:
                    self::addPrevButton(self::PREV_BUTTON_CODE);
                    break;
                case self::PREV_MORE_BUTTON_CODE:
                    self::addPrevButton(self::PREV_MORE_BUTTON_CODE);
                    break;
                case self::MAIN_BUTTON_CODE:

                    if(self::$arSettings['main_button_on']) {
                        //Get pagination buttons
                        $i = 0;
                        while($i < $iElementLimit) {

                            //Set active page button
                            $sCode = null;
                            $sElementClass = self::$arSettings['main_button_class'];
                            if(self::$iPosition == self::$iCurrentPage) {
                                $sElementClass = ' '.self::$arSettings['active_class'];
                                $sCode = self::ACT_BUTTON_CODE;
                            }

                            if(self::$iPosition > 0) {
                                self::$arResult[] = [
                                    'name' => self::$iPosition,
                                    'value' => self::$iPosition,
                                    'class' => $sElementClass,
                                    'code' => $sCode,
                                ];

                                $arMainPageList[] = self::$iPosition;

                                $i++;
                            }

                            self::$iPosition++;
                            if(self::$iPosition > self::$iTotalCountPages) {
                                break;
                            }
                        }
                    }
                    break;
                case self::NEXT_MORE_BUTTON_CODE:
                    self::addNextButton(self::NEXT_MORE_BUTTON_CODE);
                    break;
                case self::NEXT_BUTTON_CODE:
                    self::addNextButton(self::NEXT_BUTTON_CODE);
                    break;
                case self::LAST_MORE_BUTTON_CODE:
                    self::addNextButton(self::LAST_MORE_BUTTON_CODE);
                    break;
                case self::LAST_BUTTON_CODE:
                    self::addNextButton(self::LAST_BUTTON_CODE);
                    break;
            }
        }

        $arUnsetCodeList = [];
        foreach (self::$arResult as $iKey => $arButtonData) {
            if ($arButtonData['code'] == self::ACT_BUTTON_CODE || empty($arButtonData['code'])) {
                continue;
            }

            if (!in_array($arButtonData['code'], [self::FIRST_BUTTON_CODE, self::FIRST_MORE_BUTTON_CODE, self::LAST_BUTTON_CODE, self::LAST_MORE_BUTTON_CODE])) {
                continue;
            }

            if (!in_array($arButtonData['value'], $arMainPageList)) {
                continue;
            }

            $arUnsetCodeList[] = $arButtonData['code'];
            $arUnsetCodeList[] = $arButtonData['code'].'-more';
        }

        if (!empty($arUnsetCodeList)) {
            foreach (self::$arResult as $iKey => $arButtonData) {
                if (!in_array($arButtonData['code'], $arUnsetCodeList)) {
                    continue;
                }

                unset(self::$arResult[$iKey]);
            }
        }

        return self::$arResult;
    }
Get pagination elements
@param int $iCurrentPage - current page number
@param int $iTotalCount - total count elements
@param array $arSettings - settings array
@return array