private function getPaginationIndex($optionsPagination = array())
    {
        $nbResult = 0;
        $nbPages = 0;
        $currentPage = 0;
        $nextPage = 0;
        $previousPage = 0;
        $nbResultPerPage = 10;
        $offset = 4;
        $indexToDisplay = array();

        //Setting vars
        if (isset($optionsPagination['nbResult'])) {
            $nbResult =$optionsPagination['nbResult'];
        }
        if (isset($optionsPagination['nbPages'])) {
            $nbPages = $optionsPagination['nbPages'];
        }
        if (isset($optionsPagination['currentPage'])) {
            $currentPage = $optionsPagination['currentPage'];
        }
        if (isset($optionsPagination['nextPage'])) {
            $nextPage = $optionsPagination['nextPage'];
        }
        if (isset($optionsPagination['previousPage'])) {
            $previousPage = $optionsPagination['previousPage'];
        }
        if (isset($optionsPagination['nbResultPerPage'])) {
            $nbResultPerPage = $optionsPagination['nbResultPerPage'];
        }
        if (isset($optionsPagination['offset'])) {
            $offset = $optionsPagination['offset'];
        }

        //Processing firstpage index
        if ($nbPages<=(2*$offset+1)) {
            $indexToDisplay['firstPage'] = 0;
            $indexToDisplay['lastPage'] = $nbPages-1;
        } else {
            if (($currentPage - $offset)<= 0) {
                $indexToDisplay['firstPage'] = 0;
            } else {
                $indexToDisplay['firstPage'] = $currentPage - $offset - 1;
            }

            //Processing lastpage index
            if (($currentPage+$offset)>=$nbPages) {
                $indexToDisplay['lastPage'] = $nbPages-1;
            } else {
                $indexToDisplay['lastPage']=$currentPage+$offset-1;
            }

            // Adjusting first page index or last page index if nb of previous pages are not balanced compared to next ones
            // Adding the extra missing page to a side or another to really have 9 pages (aka 2*offset+1)
            if ((2*$offset+1) > ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] )) {
                //Calculating the offset to add to first or last page
                $offsetAdd=(2*$offset+1) - ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] );

                if ($indexToDisplay['firstPage'] == 0) {
                    $indexToDisplay['lastPage']+=$offsetAdd-1;
                } else {
                    $indexToDisplay['firstPage']-=$offsetAdd-1;
                }
            }
        }

        $indexRange = array();
        for ($i = $indexToDisplay['firstPage']; $i <= $indexToDisplay['lastPage']; $i++) {
            $indexRange[] = $i;
        }
        $indexToDisplay['range'] = $indexRange;
        return $indexRange;
    }