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);
 }
Пример #2
0
 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);
 }
Пример #3
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);
 }
Пример #4
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);
 }
Пример #5
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 _addTemplateVariableTubePressBaseUrl(array &$templateVariables)
 {
     $templateVariables[self::$_TEMPLATE_VAR_BASEURL] = $this->_environment->getBaseUrl();
 }