public function tearDown()
 {
     ThemeResourceLoader::set_instance($this->_oldLoader);
     i18n::set_locale($this->originalLocale);
     Config::inst()->update('Director', 'alternate_base_folder', null);
     Config::inst()->update('SSViewer', 'theme', $this->_oldTheme);
     i18n::register_translator($this->origAdapter, 'core');
     parent::tearDown();
 }
 public function testFindThemedJavascript()
 {
     $this->assertEquals("myproject/javascript/project.js", $this->loader->findThemedJavascript('project', ['$default', 'theme']));
     $this->assertEquals("themes/theme/javascript/project.js", $this->loader->findThemedJavascript('project', ['theme', '$default']));
     $this->assertEmpty($this->loader->findThemedJavascript('nofile', ['theme', '$default']));
     $this->assertEquals('module/javascript/content.js', $this->loader->findThemedJavascript('content', ['/module', 'theme']));
     $this->assertEquals('module/javascript/content.js', $this->loader->findThemedJavascript('content', ['/module', 'theme', '$default']));
     $this->assertEquals('module/javascript/content.js', $this->loader->findThemedJavascript('content', ['$default', '/module', 'theme']));
 }
 public function tearDown()
 {
     ThemeResourceLoader::set_instance($this->_oldLoader);
     // Pop if added during testing
     if (ClassLoader::instance()->getManifest() === $this->manifest) {
         ClassLoader::instance()->popManifest();
     }
     parent::tearDown();
 }
 /**
  * @param string $identifier A template name without '.ss' extension or path
  * @param string $type The template type, either "main", "Includes" or "Layout"
  *
  * @return string Full system path to a template file
  */
 public static function getTemplateFileByType($identifier, $type = null)
 {
     return ThemeResourceLoader::instance()->findTemplate(['type' => $type, $identifier], self::get_themes());
 }
 /**
  * Pushes a class and template manifest instance that include tests onto the
  * top of the loader stacks.
  */
 public static function use_test_manifest()
 {
     $flush = true;
     if (isset($_GET['flush']) && $_GET['flush'] === '0') {
         $flush = false;
     }
     $classManifest = new SS_ClassManifest(BASE_PATH, true, $flush);
     SS_ClassLoader::instance()->pushManifest($classManifest, false);
     SapphireTest::set_test_class_manifest($classManifest);
     ThemeResourceLoader::instance()->addSet('$default', new ThemeManifest(BASE_PATH, project(), true, $flush));
     Config::inst()->pushConfigStaticManifest(new SS_ConfigStaticManifest(BASE_PATH, true, $flush));
     // Invalidate classname spec since the test manifest will now pull out new subclasses for each internal class
     // (e.g. Member will now have various subclasses of DataObjects that implement TestOnly)
     DataObject::reset();
 }
 /**
  * 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 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;
 }