Back to PhocaGalleryPaginationUserImage class

Method _buildDataObject

protected
_buildDataObject
()

Method _buildDataObject - Source code

protected function _buildDataObject()
{
    $tabLink = '';
    if ((string) $this->_tabId != '') {
        $tabLink = '&tab=' . (string) $this->_tabId;
    }
    // Initialize variables
    $data = new stdClass();
    $data->all = new JPaginationObject(Text::_('COM_PHOCAGALLERY_VIEW_ALL'));
    if (!$this->viewall) {
        $data->all->base = '0';
        $data->all->link = Route::_($tabLink . "&limitstartimage=");
    }
    // Set the start and previous data objects
    $data->start = new JPaginationObject(Text::_('COM_PHOCAGALLERY_PAG_START'));
    $data->previous = new JPaginationObject(Text::_('COM_PHOCAGALLERY_PAG_PREV'));
    if ($this->pagesCurrent > 1) {
        $page = ($this->pagesCurrent - 2) * $this->limit;
        $page = $page == 0 ? '' : $page;
        //set the empty for removal from route
        $data->start->base = '0';
        $data->start->link = Route::_($tabLink . "&limitstartimage=");
        $data->previous->base = $page;
        $data->previous->link = Route::_($tabLink . "&limitstartimage=" . $page);
    }
    // Set the next and end data objects
    $data->next = new JPaginationObject(Text::_('COM_PHOCAGALLERY_PAG_NEXT'));
    $data->end = new JPaginationObject(Text::_('COM_PHOCAGALLERY_PAG_END'));
    if ($this->pagesCurrent < $this->pagesTotal) {
        $next = $this->pagesCurrent * $this->limit;
        $end = ($this->pagesTotal - 1) * $this->limit;
        $data->next->base = $next;
        $data->next->link = Route::_($tabLink . "&limitstartimage=" . $next);
        $data->end->base = $end;
        $data->end->link = Route::_($tabLink . "&limitstartimage=" . $end);
    }
    $data->pages = array();
    $stop = $this->pagesStop;
    for ($i = $this->pagesStart; $i <= $stop; $i++) {
        $offset = ($i - 1) * $this->limit;
        $offset = $offset == 0 ? '' : $offset;
        //set the empty for removal from route
        $data->pages[$i] = new PaginationObject($i);
        if ($i != $this->pagesCurrent || $this->viewall) {
            $data->pages[$i]->base = $offset;
            $data->pages[$i]->link = Route::_($tabLink . "&limitstartimage=" . $offset);
        }
    }
    return $data;
}