/**
  * Get all active themes
  *
  * @param string $baseDir
  *
  * @return array
  */
 public function getAvailableThemes($baseDir = null)
 {
     $themes = SSViewer::get_themes($baseDir);
     $disabled = (array) Config::inst()->forClass('SiteConfig')->disabled_themes;
     return array_filter($themes, function ($theme) use($disabled) {
         return !array_key_exists($theme, $disabled);
     });
 }
Пример #2
0
 /**
  * Get all available themes that haven't been marked as disabled.
  * @param string $baseDir Optional alternative theme base directory for testing
  * @return array of theme directory names
  */
 public function getAvailableThemes($baseDir = null)
 {
     $themes = SSViewer::get_themes($baseDir);
     foreach (self::$disabled_themes as $theme) {
         if (isset($themes[$theme])) {
             unset($themes[$theme]);
         }
     }
     return $themes;
 }
 /**
  * Get all available themes that haven't been marked as disabled.
  * @param string $baseDir Optional alternative theme base directory for testing
  * @return array of theme directory names
  */
 public function getAvailableThemes($baseDir = null)
 {
     $themes = SSViewer::get_themes($baseDir);
     $disabled = (array) $this->config()->disabled_themes;
     foreach ($disabled as $theme) {
         if (isset($themes[$theme])) {
             unset($themes[$theme]);
         }
     }
     return $themes;
 }
Пример #4
0
 /**
  * @covers SSViewer::get_themes()
  */
 public function testThemeRetrieval()
 {
     $ds = DIRECTORY_SEPARATOR;
     $testThemeBaseDir = TEMP_FOLDER . $ds . 'test-themes';
     if (file_exists($testThemeBaseDir)) {
         Filesystem::removeFolder($testThemeBaseDir);
     }
     mkdir($testThemeBaseDir);
     mkdir($testThemeBaseDir . $ds . 'blackcandy');
     mkdir($testThemeBaseDir . $ds . 'blackcandy_blog');
     mkdir($testThemeBaseDir . $ds . 'darkshades');
     mkdir($testThemeBaseDir . $ds . 'darkshades_blog');
     $this->assertEquals(array('blackcandy' => 'blackcandy', 'darkshades' => 'darkshades'), SSViewer::get_themes($testThemeBaseDir), 'Our test theme directory contains 2 themes');
     $this->assertEquals(array('blackcandy' => 'blackcandy', 'blackcandy_blog' => 'blackcandy_blog', 'darkshades' => 'darkshades', 'darkshades_blog' => 'darkshades_blog'), SSViewer::get_themes($testThemeBaseDir, true), 'Our test theme directory contains 2 themes and 2 sub-themes');
     // Remove all the test themes we created
     Filesystem::removeFolder($testThemeBaseDir);
 }
 /**
  * Registers the given themeable javascript as required.
  *
  * A javascript file in the current theme path name 'themename/javascript/$name.js' is first searched for,
  * and it that doesn't exist and the module parameter is set then a javascript file with that name in
  * the module is used.
  *
  * @param string $name   The name of the file - eg '/js/File.js' would have the name 'File'
  * @param string $type  Comma-separated list of types to use in the script tag
  *                       (e.g. 'text/javascript,text/ecmascript')
  */
 public function themedJavascript($name, $type = null)
 {
     $path = ThemeResourceLoader::instance()->findThemedJavascript($name, SSViewer::get_themes());
     if ($path) {
         $opts = [];
         if ($type) {
             $opts['type'] = $type;
         }
         $this->javascript($path, $opts);
     } else {
         throw new \InvalidArgumentException("The javascript file doesn't exists. Please check if the file {$name}.js exists in any " . "context or search for themedJavascript references calling this file in your templates.");
     }
 }
 /**
  * Get all available themes that haven't been marked as disabled.
  * @param string $baseDir Optional alternative theme base directory for testing
  * @return array of theme directory names
  */
 public function getAvailableThemesExtended($baseDir = null)
 {
     if (class_exists('Subsite') && Subsite::currentSubsiteID()) {
         $subsiteThemes = Subsite::config()->allowed_themes;
         // Make sure set theme is allowed
         $subsite = Subsite::currentSubsite();
         if ($subsite->Theme && !in_array($subsite->Theme, $subsiteThemes)) {
             $subsiteThemes[] = $subsite->Theme;
         }
         // Make sure default theme is allowed
         $theme = Config::inst()->get('SSViewer', 'theme');
         if ($theme && !in_array($theme, $subsiteThemes)) {
             $subsiteThemes[] = $theme;
         }
         return array_combine($subsiteThemes, $subsiteThemes);
     }
     $themes = SSViewer::get_themes($baseDir);
     $disabled = (array) $this->owner->config()->disabled_themes;
     foreach ($disabled as $theme) {
         if (isset($themes[$theme])) {
             unset($themes[$theme]);
         }
     }
     return $themes;
 }
 /**
  * Get location of all editor.css files
  *
  * @return array
  */
 protected function getEditorCSS()
 {
     $editor = array();
     // Add standard editor.css
     $editor[] = Director::absoluteURL(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/editor.css');
     // Themed editor.css
     $themedEditor = ThemeResourceLoader::instance()->findThemedCSS('editor', SSViewer::get_themes());
     if ($themedEditor) {
         $editor[] = Director::absoluteURL($themedEditor, Director::BASE);
     }
     return $editor;
 }