public function generateLinksCenter(string $page = null, string $ignoredKeys = null, $linksClassName = null): string
    {
        // only one page?
        $totalPages = $this->totalPages;
        if ($totalPages == 1) {
            return $this->template(['<a class="current" href="#">1</a>'], $linksClassName, true);
        }

        $links = (array) $this->linksCenter;
        if ($links != null) {
            return $this->template($links, $linksClassName, true);
        }

        $linksTemplate = $this->linksTemplate;

        $s = $this->startKey;
        $query = $this->prepareQuery($ignoredKeys);
        $start = max(1, ($this->start / $this->stop) + 1);

        // add first & prev links
        $prev = $start - 1;
        if ($prev >= 1) {
            $links[] = sprintf('<a class="first" rel="first" href="%s%s=1">%s</a>', $query, $s,
                $linksTemplate['first']);
            $links[] = sprintf('<a class="prev" rel="prev" href="%s%s=%s">%s</a>', $query, $s, $prev,
                $linksTemplate['prev']);
        }

        $links[] = sprintf('<a class="current" href="#">%s %s</a>',
            $page ?? $linksTemplate['page'], $start);

        // add next & last link
        $next = $start + 1;
        if ($start < $totalPages) {
            $links[] = sprintf('<a class="next" rel="next" href="%s%s=%s">%s</a>', $query, $s, $next,
                $linksTemplate['next']);
            $links[] = sprintf('<a class="last" rel="last" href="%s%s=%s">%s</a>', $query, $s, $totalPages,
                $linksTemplate['last']);
        }

        // store
        $this->linksCenter = $links;

        return $this->template($links, $linksClassName, true);
    }
public function generateLinksCenter(string $page = null, string $ignoredKeys = null, $linksClassName = null): string
    {
        // only one page?
        $totalPages = $this->totalPages;
        if ($totalPages == 1) {
            return $this->template(['<a class="current" href="#">1</a>'], $linksClassName, true);
        }

        $links = (array) $this->linksCenter;
        if ($links != null) {
            return $this->template($links, $linksClassName, true);
        }

        $linksTemplate = $this->linksTemplate;

        $s = $this->startKey;
        $query = $this->prepareQuery($ignoredKeys);
        $start = max(1, ($this->start / $this->stop) + 1);

        // add first & prev links
        $prev = $start - 1;
        if ($prev >= 1) {
            $links[] = sprintf('<a class="first" rel="first" href="%s%s=1">%s</a>', $query, $s,
                $linksTemplate['first']);
            $links[] = sprintf('<a class="prev" rel="prev" href="%s%s=%s">%s</a>', $query, $s, $prev,
                $linksTemplate['prev']);
        }

        $links[] = sprintf('<a class="current" href="#">%s %s</a>',
            $page ?? $linksTemplate['page'], $start);

        // add next & last link
        $next = $start + 1;
        if ($start < $totalPages) {
            $links[] = sprintf('<a class="next" rel="next" href="%s%s=%s">%s</a>', $query, $s, $next,
                $linksTemplate['next']);
            $links[] = sprintf('<a class="last" rel="last" href="%s%s=%s">%s</a>', $query, $s, $totalPages,
                $linksTemplate['last']);
        }

        // store
        $this->linksCenter = $links;

        return $this->template($links, $linksClassName, true);
    }
public function generateLinksCenter ( string $ page = null , string $ ignoredKeys = null , $ linksClassName = null ) : string { // only one page? $ totalPages = $ this -> totalPages ; if ( $ totalPages == 1 ) { return $ this -> template ( [ '<a class="current" href="#">1</a>' ] , $ linksClassName , true ) ; } $ links = ( array ) $ this -> linksCenter ; if ( $ links != null ) { return $ this -> template ( $ links , $ linksClassName , true ) ; } $ linksTemplate = $ this -> linksTemplate ; $ s = $ this -> startKey ; $ query = $ this -> prepareQuery ( $ ignoredKeys ) ; $ start = max ( 1 , ( $ this -> start / $ this -> stop ) + 1 ) ; // add first & prev links $ prev = $ start - 1 ; if ( $ prev >= 1 ) { $ links [ ] = sprintf ( '<a class="first" rel="first" href="%s%s=1">%s</a>' , $ query , $ s , $ linksTemplate [ 'first' ] ) ; $ links [ ] = sprintf ( '<a class="prev" rel="prev" href="%s%s=%s">%s</a>' , $ query , $ s , $ prev , $ linksTemplate [ 'prev' ] ) ; } $ links [ ] = sprintf ( '<a class="current" href="#">%s %s</a>' , $ page ?? $ linksTemplate [ 'page' ] , $ start ) ; // add next & last link $ next = $ start + 1 ; if ( $ start < $ totalPages ) { $ links [ ] = sprintf ( '<a class="next" rel="next" href="%s%s=%s">%s</a>' , $ query , $ s , $ next , $ linksTemplate [ 'next' ] ) ; $ links [ ] = sprintf ( '<a class="last" rel="last" href="%s%s=%s">%s</a>' , $ query , $ s , $ totalPages , $ linksTemplate [ 'last' ] ) ; } // store $ this -> linksCenter = $ links ; return $ this -> template ( $ links , $ linksClassName , true ) ; }
Generate links center.
@param  string|null $page
@param  string|null $ignoredKeys
@param  string      $linksClassName
@return string
Generate links center .