Exemplo n.º 1
0
 protected function getOptionalProperty($propertyName, $default)
 {
     if (!$this->_properties->containsKey($propertyName)) {
         return $default;
     }
     return $this->_properties->get($propertyName);
 }
 private function _getUrls($cacheKey, $themeGetter, $eventName)
 {
     if (!$this->_cache->containsKey($cacheKey)) {
         $currentTheme = $this->_currentThemeService->getCurrentTheme();
         $themeScripts = $this->_recursivelyGetFromTheme($currentTheme, $themeGetter);
         $urls = $this->_fireEventAndReturnSubject($eventName, $themeScripts);
         $this->_cache->put($cacheKey, $urls);
     }
     return $this->_cache->get($cacheKey);
 }
 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);
 }
Exemplo n.º 4
0
 public function toHtmlSafeArray()
 {
     $allNames = $this->_properties->keySet();
     $toReturn = array();
     foreach ($allNames as $name) {
         $toReturn[$name] = $this->_properties->get($name);
     }
     $toReturn = array_filter($toReturn, array($this, '__toJsonFilter'));
     return array_map(array($this, '__makeItSafe'), $toReturn);
 }
Exemplo n.º 5
0
 /**
  * @return array An associative array of filenames to template display names.
  */
 public function getPageTemplates()
 {
     if (!$this->_cache->containsKey('templates')) {
         $wpTheme = $this->_wpFunctions->wp_get_theme();
         /* @noinspection PhpUndefinedMethodInspection */
         $toReturn = $wpTheme->get_page_templates();
         $toReturn['index.php'] = 'default';
         asort($toReturn);
         $this->_cache->put('templates', $toReturn);
     }
     return $this->_cache->get('templates');
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function setProperty($name, $value)
 {
     $this->_properties->put($name, $value);
 }
Exemplo n.º 7
0
 public function markAsPro()
 {
     $this->_properties->put(self::$_PROPERTY_IS_PRO, true);
 }