Example #1
0
 public function onFilter_PucRequestInfoResultTubePress(tubepress_api_event_EventInterface $event)
 {
     $pluginInfo = $event->getSubject();
     if ($pluginInfo && $this->_environment->isPro()) {
         $apiKey = $this->_context->get(tubepress_api_options_Names::TUBEPRESS_API_KEY);
         if (!$apiKey) {
             /*
              * We don't want to downgrade Pro users that haven't entered an API key.
              */
             $pluginInfo->download_url = null;
         }
         if (property_exists($pluginInfo, 'download_url') && strpos($pluginInfo->download_url, 'free') !== false) {
             /*
              * Extra assurance that we don't downgrade Pro users
              */
             $pluginInfo->download_url = null;
         }
         if (property_exists($pluginInfo, 'download_url') && $pluginInfo->download_url && $apiKey) {
             $url = $this->_urlFactory->fromString($pluginInfo->download_url);
             $url->getQuery()->set('key', $apiKey)->set('pid', 2);
             $pluginInfo->download_url = $url->toString();
         }
         $event->setSubject($pluginInfo);
     }
 }
Example #2
0
 public function __construct(tubepress_api_media_HttpCollectorInterface $httpCollector, tubepress_spi_media_HttpFeedHandlerInterface $feedHandler, tubepress_api_environment_EnvironmentInterface $environment)
 {
     $this->_httpCollector = $httpCollector;
     $this->_feedHandler = $feedHandler;
     $this->_properties = new tubepress_internal_collection_Map();
     $baseUrlClone = $environment->getBaseUrl()->getClone();
     $miniIconUrl = $baseUrlClone->addPath('/src/add-ons/provider-youtube-v3/web/images/icons/youtube-icon-34w_x_34h.png')->toString();
     $this->getProperties()->put('miniIconUrl', $miniIconUrl);
     $this->getProperties()->put('untranslatedModeTemplateMap', self::$_MODE_TEMPLATE_MAP);
 }
 private function _getUserAgent()
 {
     $toReturn = (string) 'tubepress/' . $this->_environment->getVersion();
     if (extension_loaded('curl')) {
         $curlVersion = curl_version();
         $toReturn .= ' curl/' . $curlVersion['version'];
     }
     $toReturn .= ' PHP/' . PHP_VERSION;
     return $toReturn;
 }
 public function __callbackConvertToWpUrlString(tubepress_api_url_UrlInterface $url)
 {
     if ($url->isAbsolute()) {
         return $url->toString();
     }
     if (!isset($this->_urlCache)) {
         $this->_urlCache = new tubepress_internal_collection_Map();
         $this->_urlCache->put('url.base', rtrim($this->_environment->getBaseUrl()->toString(), '/'));
         $this->_urlCache->put('url.user', rtrim($this->_environment->getUserContentUrl()->toString(), '/'));
         $this->_urlCache->put('basename', basename(TUBEPRESS_ROOT));
     }
     $urlAsString = $url->toString();
     $tubePressBaseUrl = $this->_urlCache->get('url.base');
     $userContentUrl = $this->_urlCache->get('url.user');
     $baseName = $this->_urlCache->get('basename');
     $isSystem = false;
     if ($this->_stringUtils->startsWith($urlAsString, "{$tubePressBaseUrl}/web/")) {
         $isSystem = true;
     } else {
         if (!$this->_stringUtils->startsWith($urlAsString, "{$userContentUrl}/")) {
             //this should never happen
             return $urlAsString;
         }
     }
     if ($isSystem) {
         $path = str_replace($tubePressBaseUrl, '', $urlAsString);
         return $this->_wpFunctions->plugins_url($path, "{$baseName}/tubepress.php");
     }
     $path = str_replace($userContentUrl, '', $urlAsString);
     return $this->_wpFunctions->content_url('tubepress-content' . $path);
 }
 public function onAdminScripts(tubepress_api_event_EventInterface $event)
 {
     $urls = $event->getSubject();
     if (!$this->_isIE8OrLower() || !$this->_containsBootstrap($urls)) {
         return;
     }
     $baseUrl = $this->_environment->getBaseUrl()->getClone();
     $baseUrl->setPath('/web/admin-themes/admin-default/vendor/respond-1.4.2/respond.min.js');
     $baseUrl->freeze();
     array_unshift($urls, $baseUrl);
     $baseUrl = $baseUrl->getClone();
     $baseUrl->setPath('/web/admin-themes/admin-default/vendor/html5-shiv-3.7.0/html5shiv.js');
     $baseUrl->freeze();
     array_unshift($urls, $baseUrl);
     $event->setSubject($urls);
 }
Example #6
0
 public function onScripts(tubepress_api_event_EventInterface $event)
 {
     $existingUrls = $event->getSubject();
     $tubepressJsUrl = $this->_environment->getBaseUrl()->getClone();
     $tubepressJsUrl->addPath('/web/js/tubepress.js');
     array_unshift($existingUrls, $tubepressJsUrl);
     $event->setSubject($existingUrls);
 }
Example #7
0
 public function onGlobalJsConfig(tubepress_api_event_EventInterface $event)
 {
     /*
      * @var array
      */
     $config = $event->getSubject();
     if (!isset($config['urls'])) {
         $config['urls'] = array();
     }
     $baseUrl = $this->_environment->getBaseUrl()->getClone();
     $userContentUrl = $this->_environment->getUserContentUrl()->getClone();
     $ajaxEndpointUrl = $this->_environment->getAjaxEndpointUrl()->getClone();
     $baseUrl->removeSchemeAndAuthority();
     $userContentUrl->removeSchemeAndAuthority();
     $ajaxEndpointUrl->removeSchemeAndAuthority();
     $config['urls']['base'] = "{$baseUrl}";
     $config['urls']['usr'] = "******";
     $config['urls']['ajax'] = "{$ajaxEndpointUrl}";
     $event->setSubject($config);
 }
 private function _recursivelyGetFromTheme(tubepress_api_theme_ThemeInterface $theme, $getter)
 {
     $toReturn = $theme->{$getter}($this->_environment->getBaseUrl(), $this->_environment->getUserContentUrl());
     $parentThemeName = $theme->getParentThemeName();
     if (!$parentThemeName) {
         return $toReturn;
     }
     $theme = $this->_themeRegistry->getInstanceByName($parentThemeName);
     if (!$theme) {
         return $toReturn;
     }
     $fromParent = $this->_recursivelyGetFromTheme($theme, $getter);
     if (is_array($fromParent)) {
         $toReturn = array_merge($fromParent, $toReturn);
     } else {
         $toReturn = $fromParent . $toReturn;
     }
     return $toReturn;
 }
 private function _addTemplateVariableIsPro(array &$templateVariables)
 {
     $templateVariables[self::$_TEMPLATE_VAR_IS_PRO] = $this->_environment->isPro();
 }
 /**
  * {@inheritdoc}
  */
 public function getTemplateVariables(tubepress_api_media_MediaItem $mediaItem)
 {
     $dataUrl = $this->_urlFactory->fromString(sprintf('https://www.youtube.com/watch?v=%s', $mediaItem->getId()));
     return array('userContentUrl' => $this->_environment->getUserContentUrl(), 'autostart' => $this->_context->get(tubepress_api_options_Names::EMBEDDED_AUTOPLAY), tubepress_api_template_VariableNames::EMBEDDED_DATA_URL => $dataUrl, tubepress_jwplayer5_api_OptionNames::COLOR_FRONT => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_FRONT), tubepress_jwplayer5_api_OptionNames::COLOR_LIGHT => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_LIGHT), tubepress_jwplayer5_api_OptionNames::COLOR_SCREEN => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_SCREEN), tubepress_jwplayer5_api_OptionNames::COLOR_BACK => $this->_context->get(tubepress_jwplayer5_api_OptionNames::COLOR_BACK));
 }