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'); $ms = $ioc->get('org_tubepress_api_message_MessageService'); $resultsUrl = $context->get(org_tubepress_api_const_options_names_Output::SEARCH_RESULTS_URL); /* if the user didn't request a certain page, just send the search results right back here */ if ($resultsUrl == '') { $resultsUrl = $qss->getFullUrl($_SERVER); } /* clean up the search terms a bit */ $searchTerms = urldecode($qss->getSearchTerms($_GET)); $searchTerms = org_tubepress_impl_util_StringUtils::cleanForSearch($searchTerms); /* * 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 */ $url = new org_tubepress_api_url_Url($resultsUrl); $params = $url->getQueryVariables(); unset($params[org_tubepress_api_const_querystring_QueryParamName::PAGE]); unset($params[org_tubepress_api_const_querystring_QueryParamName::SEARCH_TERMS]); /* apply the template variables */ $template->setVariable(org_tubepress_api_const_template_Variable::SEARCH_HANDLER_URL, $resultsUrl); $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-input-button')); return $template; }
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context) { $autoPlay = $context->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY); $color = $context->get(org_tubepress_api_const_options_names_Embedded::PLAYER_COLOR); $showInfo = $context->get(org_tubepress_api_const_options_names_Embedded::SHOW_INFO); $loop = $context->get(org_tubepress_api_const_options_names_Embedded::LOOP); $jsApi = $context->get(org_tubepress_api_const_options_names_Embedded::ENABLE_JS_API); /* build the data URL based on these options */ $link = new org_tubepress_api_url_Url(self::VIMEO_EMBEDDED_PLAYER_URL . "video/{$videoId}"); $link->setQueryVariable(self::VIMEO_QUERYPARAM_AUTOPLAY, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($autoPlay)); $link->setQueryVariable(self::VIMEO_QUERYPARAM_COLOR, $color); $link->setQueryVariable(self::VIMEO_QUERYPARAM_LOOP, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($loop)); $link->setQueryVariable(self::VIMEO_QUERYPARAM_TITLE, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo)); $link->setQueryVariable(self::VIMEO_QUERYPARAM_BYLINE, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo)); $link->setQueryVariable(self::VIMEO_QUERYPARAM_PORTRAIT, org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo)); if ($jsApi) { $link->setQueryVariable(self::$_paramJsApi, 1); $link->setQueryVariable(self::$_paramPlayerId, "tubepress-vimeo-player-{$videoId}"); } return $link; }
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; }
private function _setOrderBy(org_tubepress_api_exec_ExecutionContext $execContext, org_tubepress_api_url_Url $url) { $order = $execContext->get(org_tubepress_api_const_options_names_Feed::ORDER_BY); $mode = $execContext->get(org_tubepress_api_const_options_names_Output::GALLERY_SOURCE); if ($order == org_tubepress_api_const_options_values_OrderByValue::RANDOM) { return; } /* any feed can take these */ if ($order == org_tubepress_api_const_options_values_OrderByValue::VIEW_COUNT) { $url->setQueryVariable(self::PARAM_ORDER, $order); return; } if ($order == org_tubepress_api_const_options_values_OrderByValue::NEWEST) { $url->setQueryVariable(self::PARAM_ORDER, 'published'); return; } /* playlist specific stuff */ if ($mode == org_tubepress_api_const_options_values_GallerySourceValue::YOUTUBE_PLAYLIST) { if (in_array($order, array(org_tubepress_api_const_options_values_OrderByValue::POSITION, org_tubepress_api_const_options_values_OrderByValue::COMMENT_COUNT, org_tubepress_api_const_options_values_OrderByValue::DURATION, org_tubepress_api_const_options_values_OrderByValue::TITLE))) { $url->setQueryVariable(self::PARAM_ORDER, $order); } return; } if (in_array($order, array(org_tubepress_api_const_options_values_OrderByValue::RELEVANCE, org_tubepress_api_const_options_values_OrderByValue::RATING))) { $url->setQueryVariable(self::PARAM_ORDER, $order); } }
protected function _getEmbeddedDataUrl($providerName, $videoId, org_tubepress_api_ioc_IocService $ioc, org_tubepress_api_exec_ExecutionContext $context) { $link = new org_tubepress_api_url_Url('http://www.youtube.com/embed/' . $videoId); $showRelated = $context->get(org_tubepress_api_const_options_names_Embedded::SHOW_RELATED); $autoPlay = $context->get(org_tubepress_api_const_options_names_Embedded::AUTOPLAY); $loop = $context->get(org_tubepress_api_const_options_names_Embedded::LOOP); $fullscreen = $context->get(org_tubepress_api_const_options_names_Embedded::FULLSCREEN); $enableJsApi = $context->get(org_tubepress_api_const_options_names_Embedded::ENABLE_JS_API); $galleryId = $context->get(org_tubepress_api_const_options_names_Advanced::GALLERY_ID); $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'); $showInfo = $context->get(org_tubepress_api_const_options_names_Embedded::SHOW_INFO); $autoHide = $context->get(org_tubepress_api_const_options_names_Embedded::AUTOHIDE); $modestBranding = $context->get(org_tubepress_api_const_options_names_Embedded::MODEST_BRANDING); if (!($playerColor == '999999' && $playerHighlight == 'FFFFFF')) { $link->setQueryVariable('color1', $playerHighlight); $link->setQueryVariable('color2', $playerColor); } $link->setQueryVariable('rel', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showRelated)); $link->setQueryVariable('autoplay', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($autoPlay)); $link->setQueryVariable('loop', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($loop)); $link->setQueryVariable('fs', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($fullscreen)); $link->setQueryVariable('showinfo', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($showInfo)); $link->setQueryVariable('wmode', 'transparent'); $link->setQueryVariable('enablejsapi', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($enableJsApi)); $link->setQueryVariable('autohide', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($autoHide)); $link->setQueryVariable('modestbranding', org_tubepress_impl_embedded_EmbeddedPlayerUtils::booleanToOneOrZero($modestBranding)); if ($context->get(org_tubepress_api_const_options_names_Embedded::HIGH_QUALITY)) { $link->setQueryVariable('hd', '1'); } return $link; }
private function _setOrderBy(org_tubepress_api_exec_ExecutionContext $execContext, org_tubepress_api_url_Url $url) { $order = $execContext->get(org_tubepress_api_const_options_names_Display::ORDER_BY); $mode = $execContext->get(org_tubepress_api_const_options_names_Output::MODE); if ($order == org_tubepress_api_const_options_values_OrderValue::RANDOM) { return; } /* any feed can take these */ if ($order == org_tubepress_api_const_options_values_OrderValue::VIEW_COUNT || $order == org_tubepress_api_const_options_values_OrderValue::DATE_PUBLISHED) { $url->setQueryVariable(self::PARAM_ORDER, $order); return; } /* playlist specific stuff */ if ($mode == org_tubepress_api_const_options_values_ModeValue::PLAYLIST) { if (in_array($order, array(org_tubepress_api_const_options_values_OrderValue::POSITION, org_tubepress_api_const_options_values_OrderValue::COMMENT_COUNT, org_tubepress_api_const_options_values_OrderValue::DURATION, org_tubepress_api_const_options_values_OrderValue::TITLE))) { $url->setQueryVariable(self::PARAM_ORDER, $order); } return; } if (in_array($order, array(org_tubepress_api_const_options_values_OrderValue::RELEVANCE, org_tubepress_api_const_options_values_OrderValue::RATING))) { $url->setQueryVariable(self::PARAM_ORDER, $order); } }