public function alter_embeddedTemplate(org_tubepress_api_template_Template $template, $videoId, $videoProviderName, org_tubepress_api_url_Url $dataUrl, $embeddedImplName) { global $tubepress_base_url; $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_); $fullscreen = $context->get(org_tubepress_api_const_options_names_Embedded::FULLSCREEN); $playerColor = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR), '999999'); $playerHighlight = org_tubepress_impl_embedded_EmbeddedPlayerUtils::getSafeColorValue($context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_HIGHLIGHT), 'FFFFFF'); $autoPlay = $context->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY); $embedWidth = $context->get(org_tubepress_api_const_options_names_Embedded::EMBEDDED_WIDTH); $embedHeight = $context->get(org_tubepress_api_const_options_names_Embedded::EMBEDDED_HEIGHT); $template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_DATA_URL, $dataUrl->toString(true)); $template->setVariable(org_tubepress_api_const_template_Variable::TUBEPRESS_BASE_URL, $tubepress_base_url); $template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_AUTOSTART, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToString($autoPlay)); $template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_WIDTH, $embedWidth); $template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_HEIGHT, $embedHeight); $template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_COLOR_PRIMARY, $playerColor); $template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_COLOR_HIGHLIGHT, $playerHighlight); $template->setVariable(org_tubepress_api_const_template_Variable::EMBEDDED_FULLSCREEN, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToString($fullscreen)); $template->setVariable(org_tubepress_api_const_template_Variable::VIDEO_ID, $videoId); return $template; }
public function alter_searchInputTemplate(org_tubepress_api_template_Template $template) { $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $context = $ioc->get(org_tubepress_api_exec_ExecutionContext::_); $qss = $ioc->get(org_tubepress_api_querystring_QueryStringService::_); $hrps = $ioc->get(org_tubepress_api_http_HttpRequestParameterService::_); $ms = $ioc->get(org_tubepress_api_message_MessageService::_); $resultsUrl = $context->get(org_tubepress_api_const_options_names_InteractiveSearch::SEARCH_RESULTS_URL); $url = ''; try { $url = new org_tubepress_api_url_Url($resultsUrl); } catch (Exception $e) { org_tubepress_impl_log_Log::log('Search Input Core Filter', $e->getMessage()); } /* if the user didn't request a certain page, just send the search results right back here */ if ($url == '') { $url = new org_tubepress_api_url_Url($qss->getFullUrl($_SERVER)); } /* clean up the search terms a bit */ $searchTerms = $hrps->getParamValue(org_tubepress_api_const_http_ParamName::SEARCH_TERMS); $searchTerms = urldecode($searchTerms); //TODO: get rid of this once we move to POST? /* * read http://stackoverflow.com/questions/1116019/submitting-a-get-form-with-query-string-params-and-hidden-params-disappear * if you're curious as to what's going on here */ $params = $url->getQueryVariables(); unset($params[org_tubepress_api_const_http_ParamName::PAGE]); unset($params[org_tubepress_api_const_http_ParamName::SEARCH_TERMS]); /* apply the template variables */ $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_HANDLER_URL, $url->toString()); $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_HIDDEN_INPUTS, $params); $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_TERMS, $searchTerms); $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_BUTTON, $ms->_('Search')); //>(translatable)< return $template; }
protected function _getHomeUrl($index) { $rawUrl = $this->_relativeQuery($index, "atom:link[@rel='alternate']")->item(0)->getAttribute('href'); $url = new org_tubepress_api_url_Url($rawUrl); return $url->toString(true); }
private function _build($url) { $u = new org_tubepress_api_url_Url($url); $this->assertEquals($url, $u->toString()); return $u; }
/** * 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 The HTML for the pagination */ private function _diggStyle($totalitems, org_tubepress_api_message_MessageService $messageService, $page = 1, $limit = 15, $adjacents = 1, $targetpage = '/', $pagestring = '?page=') { $prev = $page - 1; $next = $page + 1; $lastpage = ceil($totalitems / $limit); $lpm1 = $lastpage - 1; $pagination = ''; $url = new org_tubepress_api_url_Url($targetpage); if ($lastpage > 1) { $pagination .= '<div class="pagination">'; if ($page > 1) { $url->setQueryVariable($pagestring, $prev); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">« " . $messageService->_("prev") . '</a>'; } if ($lastpage < 7 + $adjacents * 2) { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) { $pagination .= "<span class=\"current\">{$counter}</span>"; } else { $url->setQueryVariable($pagestring, $counter); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">{$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->setQueryVariable($pagestring, $counter); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">{$counter}</a>"; } } $pagination .= self::DOTS; $url->setQueryVariable($pagestring, $lpm1); $newurl = $url->toString(); $pagination .= " <a rel=\"nofollow\" href=\"{$newurl}\">{$lpm1}</a>"; $url->setQueryVariable($pagestring, $lastpage); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">{$lastpage}</a>"; } elseif ($lastpage - $adjacents * 2 > $page && $page > $adjacents * 2) { $url->setQueryVariable($pagestring, 1); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">1</a>"; $url->setQueryVariable($pagestring, 2); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">2</a>"; $pagination .= self::DOTS; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) { $pagination .= "<span class=\"current\">{$counter}</span>"; } else { $url->setQueryVariable($pagestring, $counter); $newurl = $url->toString(); $pagination .= " <a rel=\"nofollow\" href=\"{$newurl}\">{$counter}</a>"; } } $pagination .= self::DOTS; $url->setQueryVariable($pagestring, $lpm1); $newurl = $url->toString(); $pagination .= " <a rel=\"nofollow\" href=\"{$newurl}\">{$lpm1}</a>"; $url->setQueryVariable($pagestring, $lastpage); $newurl = $url->toString(); $pagination .= " <a rel=\"nofollow\" href=\"{$newurl}\">{$lastpage}</a>"; } else { $url->setQueryVariable($pagestring, 1); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">1</a>"; $url->setQueryVariable($pagestring, 2); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">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->setQueryVariable($pagestring, $counter); $newurl = $url->toString(); $pagination .= " <a rel=\"nofollow\" href=\"{$newurl}\">{$counter}</a>"; } } } } if ($page < $counter - 1) { $url->setQueryVariable($pagestring, $next); $newurl = $url->toString(); $pagination .= "<a rel=\"nofollow\" href=\"{$newurl}\">" . $messageService->_('next') . ' »</a>'; } else { $pagination .= '<span class="disabled">' . $messageService->_('next') . ' »</span>'; } $pagination .= "</div>\n"; } return $pagination; }