public function onSearchInputTemplatePreRender(tubepress_api_event_EventInterface $event)
 {
     /*
      * @var array
      */
     $existingTemplateVars = $event->getSubject();
     $resultsUrl = $this->_context->get(tubepress_api_options_Names::SEARCH_RESULTS_URL);
     $url = '';
     try {
         $url = $this->_urlFactory->fromString($resultsUrl);
     } catch (Exception $e) {
         //this is not a real problem, as the user might simply not supply a custom URL
     }
     /* if the user didn't request a certain page, just send the search results right back here */
     if ($url == '') {
         $url = $this->_urlFactory->fromCurrent();
     }
     /* clean up the search terms a bit */
     $searchTerms = $this->_requestParams->getParamValue('tubepress_search');
     $searchTerms = urldecode($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
      */
     $params = $url->getQuery();
     $params->remove('tubepress_page');
     $params->remove('tubepress_search');
     /* apply the template variables */
     $newVars = array(tubepress_api_template_VariableNames::SEARCH_HANDLER_URL => $url->toString(), tubepress_api_template_VariableNames::SEARCH_HIDDEN_INPUTS => $params->toArray(), tubepress_api_template_VariableNames::SEARCH_TERMS => $searchTerms);
     $existingTemplateVars = array_merge($existingTemplateVars, $newVars);
     $event->setSubject($existingTemplateVars);
 }
 private function _getDataUrl(tubepress_api_media_MediaItem $mediaItem)
 {
     $link = $this->_urlFactory->fromString('https://www.youtube.com/embed/' . $mediaItem->getId());
     $embedQuery = $link->getQuery();
     $url = $this->_urlFactory->fromCurrent();
     $origin = $url->getScheme() . '://' . $url->getHost();
     $autoPlay = $this->_context->get(tubepress_api_options_Names::EMBEDDED_AUTOPLAY);
     $loop = $this->_context->get(tubepress_api_options_Names::EMBEDDED_LOOP);
     $showInfo = $this->_context->get(tubepress_api_options_Names::EMBEDDED_SHOW_INFO);
     $autoHide = $this->_context->get(tubepress_youtube3_api_Constants::OPTION_AUTOHIDE);
     $fullscreen = $this->_context->get(tubepress_youtube3_api_Constants::OPTION_FULLSCREEN);
     $modestBranding = $this->_context->get(tubepress_youtube3_api_Constants::OPTION_MODEST_BRANDING);
     $showRelated = $this->_context->get(tubepress_youtube3_api_Constants::OPTION_SHOW_RELATED);
     $embedQuery->set('autohide', $this->_getAutoHideValue($autoHide));
     $embedQuery->set('autoplay', $this->_langUtils->booleanToStringOneOrZero($autoPlay));
     $embedQuery->set('enablejsapi', '1');
     $embedQuery->set('fs', $this->_langUtils->booleanToStringOneOrZero($fullscreen));
     $embedQuery->set('modestbranding', $this->_langUtils->booleanToStringOneOrZero($modestBranding));
     $embedQuery->set('origin', $origin);
     $embedQuery->set('rel', $this->_langUtils->booleanToStringOneOrZero($showRelated));
     $embedQuery->set('showinfo', $this->_langUtils->booleanToStringOneOrZero($showInfo));
     $embedQuery->set('wmode', 'opaque');
     if ($loop) {
         $embedQuery->set('loop', $this->_langUtils->booleanToStringOneOrZero($loop));
         $embedQuery->set('playlist', $mediaItem->getId());
     }
     return $link;
 }
예제 #3
0
 private function _getHtml($vidCount)
 {
     $currentPage = $this->_requestParams->getParamValueAsInt('tubepress_page', 1);
     $vidsPerPage = $this->_context->get(tubepress_api_options_Names::FEED_ADJUSTED_RESULTS_PER_PAGE);
     if (!$vidsPerPage) {
         $vidsPerPage = $this->_context->get(tubepress_api_options_Names::FEED_RESULTS_PER_PAGE);
     }
     $newurl = $this->_urlFactory->fromCurrent();
     if (!$this->_isLegacyTheme()) {
         return $this->_paginationFromTemplate($vidCount, $currentPage, $vidsPerPage, $newurl);
     }
     return $this->_legacyPagination($vidCount, $currentPage, $vidsPerPage, 1, $newurl, 'tubepress_page');
 }
예제 #4
0
 protected function validateState(tubepress_spi_http_oauth2_Oauth2ProviderInterface $provider)
 {
     if (!$provider->isStateUsed()) {
         return;
     }
     $currentUrl = $this->_urlFactory->fromCurrent();
     $stateFromProvider = $currentUrl->getQuery()->get('state');
     if (!$stateFromProvider) {
         $this->bail(sprintf('%s did not supply state. Possible replay attack.', $provider->getDisplayName()));
     }
     $sessionKey = $this->_getSessionKey($provider);
     if (!isset($_SESSION[$sessionKey])) {
         $this->bail(sprintf('No stored state for %s. Try again.', $provider->getDisplayName()));
     }
     if ($_SESSION[$sessionKey] !== $stateFromProvider) {
         $this->bail(sprintf('State from %s did not match our saved state. Possible reply attack. Please try again.', $provider->getDisplayName()));
     }
     return;
 }
 public function __construct($name, $untranslatedDisplayName, tubepress_api_url_UrlFactoryInterface $urlFactory, $staticTemplateName = null)
 {
     parent::__construct($name, $untranslatedDisplayName, $staticTemplateName);
     $this->_url = $urlFactory->fromCurrent();
     $this->_url->removeSchemeAndAuthority();
 }