przewiń do treści

PHP, MySQL i MVC. Tworzenie witryn WWW opartych na bazie danych

Włodzimierz Gajda

abstract class Pointer
{
    public $ptr_current      = false;
    public $options          = false;

    protected $ptr_first     = false;
    protected $ptr_previous  = false;
    protected $ptr_next      = false;
    protected $ptr_last      = false;

    public function setCurrent($current)
    {
        if ($current) {
            $this->ptr_current = $current;
        };
    }

    public function setOptions($options)
    {
        if ($options) {
            $this->options = $options;
        };
    }

    abstract protected function getFirst();
    abstract protected function getPrevious();
    abstract protected function getNext();
    abstract protected function getLast();

    public function __construct($current = false, $options = false)
    {
        $this->setCurrent($current);
        $this->setOptions($options);

        $this->getFirst();
        $this->getPrevious();
        $this->getNext();
        $this->getLast();
    }

    public function getPointers()
    {
        return array(
            'first'    => $this->ptr_first,
            'previous' => $this->ptr_previous,
            'next'     => $this->ptr_next,
            'last'     => $this->ptr_last,
        );
    }

}

Listing 18.7. Klasa Pointer

Rozdział 18. Następny, poprzedni, czyli przewijanie zawartości witryny WWW

listing-18-07.txt

Reklama

Szkolenia z Symfony 2.0