Example #1
0
 /**
  * Load current theme.
  *
  * @return Theme|object
  */
 public function load()
 {
     // NOTE: ALL THE LOCAL VARIABLES ARE USED INSIDE INCLUDED FILE, DO NOT REMOVE THEM!
     $grav = $this->grav;
     $config = $this->config;
     $name = $this->current();
     /** @var UniformResourceLocator $locator */
     $locator = $grav['locator'];
     $file = $locator('theme://theme.php') ?: $locator("theme://{$name}.php");
     $inflector = $grav['inflector'];
     if ($file) {
         // Local variables available in the file: $grav, $config, $name, $file
         $class = (include $file);
         if (!is_object($class)) {
             $themeClassFormat = ['Grav\\Theme\\' . ucfirst($name), 'Grav\\Theme\\' . $inflector->camelize($name)];
             foreach ($themeClassFormat as $themeClass) {
                 if (class_exists($themeClass)) {
                     $themeClassName = $themeClass;
                     $class = new $themeClassName($grav, $config, $name);
                     break;
                 }
             }
         }
     } elseif (!$locator('theme://') && !defined('GRAV_CLI')) {
         exit("Theme '{$name}' does not exist, unable to display page.");
     }
     $this->config->set('theme', $config->get('themes.' . $name));
     if (empty($class)) {
         $class = new Theme($grav, $config, $name);
     }
     return $class;
 }
Example #2
0
 public function testInvalidLinksSubDirAbsoluteUrl()
 {
     $this->config->set('system.absolute_urls', true);
     $this->uri->initializeWithUrlAndRootPath('http://testing.dev/subdir/item2/item2-2', '/subdir')->init();
     $this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/no-page">Non Existent Page</a></p>', $this->parsedown->text('[Non Existent Page](no-page)'));
     $this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/existing-file.zip">Existent File</a></p>', $this->parsedown->text('[Existent File](existing-file.zip)'));
     $this->assertSame('<p><a href="http://testing.dev/subdir/item2/item2-2/missing-file.zip">Non Existent File</a></p>', $this->parsedown->text('[Non Existent File](missing-file.zip)'));
 }
Example #3
0
 protected function _after()
 {
     $this->config->set('system.home.alias', $this->old_home);
 }