/** * {@inheritdoc} */ public function getAttributesForInvocationAnchor(tubepress_api_media_MediaItem $mediaItem) { $id = $mediaItem->getId(); $this->_url->getQuery()->set('tubepress_item', $id); return array('rel' => 'nofollow', 'href' => $this->_url->toString()); }
private function _urlBuildingPageSearchOrderBy(tubepress_api_url_UrlInterface $url) { $requestedSortOrder = $this->_context->get(tubepress_api_options_Names::FEED_ORDER_BY); $query = $url->getQuery(); if ($requestedSortOrder === tubepress_api_options_AcceptableValues::ORDER_BY_DEFAULT) { $query->set(tubepress_youtube3_impl_ApiUtility::QUERY_SEARCH_ORDER, tubepress_youtube3_api_Constants::ORDER_BY_RELEVANCE); return; } if ($requestedSortOrder === tubepress_youtube3_api_Constants::ORDER_BY_NEWEST) { $query->set(tubepress_youtube3_impl_ApiUtility::QUERY_SEARCH_ORDER, 'date'); return; } if ($requestedSortOrder == tubepress_youtube3_api_Constants::ORDER_BY_VIEW_COUNT) { $query->set(tubepress_youtube3_impl_ApiUtility::QUERY_SEARCH_ORDER, tubepress_youtube3_api_Constants::ORDER_BY_VIEW_COUNT); return; } if (in_array($requestedSortOrder, array(tubepress_youtube3_api_Constants::ORDER_BY_RELEVANCE, tubepress_youtube3_api_Constants::ORDER_BY_RATING, tubepress_youtube3_api_Constants::ORDER_BY_TITLE))) { $query->set(tubepress_youtube3_impl_ApiUtility::QUERY_SEARCH_ORDER, $requestedSortOrder); } }
/** * Does the heavy lifting of generating pagination. * * @param int $totalitems The total items in this gallery. * @param int $page The current page number. * @param int $limit How many videos per page. * @param int $adjacents How many adjacents. * @param string $targetpage The target page * @param string $pagestring The query parameter controlling the page number. * * @return string The HTML for the pagination */ private function _legacyPagination($totalitems, $page = 1, $limit = 15, $adjacents = 1, tubepress_api_url_UrlInterface $url, $pagestring = '?page=') { $url->getQuery()->remove('tubepress_page'); $prev = $page - 1; $next = $page + 1; $lastpage = ceil($totalitems / $limit); $lpm1 = $lastpage - 1; $pagination = ''; if ($lastpage > 1) { $pagination .= '<div class="pagination">'; if ($page > 1) { $url->getQuery()->set($pagestring, $prev); $pagination .= $this->_buildAnchorOpener($url, true, $prev); $pagination .= '« ' . $this->_translator->trans('prev') . '</a>'; } if ($lastpage < 7 + $adjacents * 2) { for ($counter = 1; $counter <= $lastpage; ++$counter) { if ($counter == $page) { $pagination .= "<span class=\"current\">{$counter}</span>"; } else { $url->getQuery()->set($pagestring, $counter); $pagination .= $this->_buildAnchorOpener($url, true, $counter); $pagination .= "{$counter}</a>"; } } } elseif ($lastpage >= 7 + $adjacents * 2) { if ($page < 1 + $adjacents * 3) { for ($counter = 1; $counter < 4 + $adjacents * 2; ++$counter) { if ($counter == $page) { $pagination .= "<span class=\"current\">{$counter}</span>"; } else { $url->getQuery()->set($pagestring, $counter); $pagination .= $this->_buildAnchorOpener($url, true, $counter); $pagination .= "{$counter}</a>"; } } $pagination .= self::DOTS; $url->getQuery()->set($pagestring, $lpm1); $pagination .= ' ' . $this->_buildAnchorOpener($url, true, $lpm1); $pagination .= "{$lpm1}</a>"; $url->getQuery()->set($pagestring, $lastpage); $pagination .= $this->_buildAnchorOpener($url, true, $lastpage); $pagination .= "{$lastpage}</a>"; } elseif ($lastpage - $adjacents * 2 > $page && $page > $adjacents * 2) { $url->getQuery()->set($pagestring, 1); $pagination .= $this->_buildAnchorOpener($url, true, 1); $pagination .= '1</a>'; $url->getQuery()->set($pagestring, 2); $pagination .= $this->_buildAnchorOpener($url, true, 2); $pagination .= '2</a>'; $pagination .= self::DOTS; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; ++$counter) { if ($counter == $page) { $pagination .= "<span class=\"current\">{$counter}</span>"; } else { $url->getQuery()->set($pagestring, $counter); $pagination .= ' ' . $this->_buildAnchorOpener($url, true, $counter); $pagination .= "{$counter}</a>"; } } $pagination .= self::DOTS; $url->getQuery()->set($pagestring, $lpm1); $pagination .= ' ' . $this->_buildAnchorOpener($url, true, $lpm1); $pagination .= "{$lpm1}</a>"; $url->getQuery()->set($pagestring, $lastpage); $pagination .= ' ' . $this->_buildAnchorOpener($url, true, $lastpage); $pagination .= "{$lastpage}</a>"; } else { $url->getQuery()->set($pagestring, 1); $pagination .= $this->_buildAnchorOpener($url, true, 1); $pagination .= '1</a>'; $url->getQuery()->set($pagestring, 2); $pagination .= $this->_buildAnchorOpener($url, true, 1); $pagination .= '2</a>'; $pagination .= self::DOTS; for ($counter = $lastpage - (1 + $adjacents * 3); $counter <= $lastpage; ++$counter) { if ($counter == $page) { $pagination .= "<span class=\"current\">{$counter}</span>"; } else { $url->getQuery()->set($pagestring, $counter); $pagination .= ' ' . $this->_buildAnchorOpener($url, true, $counter); $pagination .= "{$counter}</a>"; } } } } if ($page < $counter - 1) { $url->getQuery()->set($pagestring, $next); $pagination .= $this->_buildAnchorOpener($url, true, $next); $pagination .= $this->_translator->trans('next') . ' »</a>'; } else { $pagination .= '<span class="disabled">' . $this->_translator->trans('next') . ' »</span>'; } $pagination .= "</div>\n"; } return $pagination; }
private function _addPagination($currentPage, tubepress_api_url_UrlInterface $url) { if (isset($this->_invokedAtLeastOnce)) { $perPage = $this->_context->get(tubepress_api_options_Names::FEED_RESULTS_PER_PAGE); } else { $perPage = min($this->_context->get(tubepress_api_options_Names::FEED_RESULTS_PER_PAGE), ceil(2.04)); } $url->getQuery()->set('page', $currentPage)->set('per_page', $perPage); }