Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/getgrav/grav into 2.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.lock
  • Loading branch information
mahagr committed Aug 16, 2017
2 parents f89fe0e + 51c3b6d commit 557a3b8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
1. [](#bugfix)
* Allow `session.timetout` field to be set to `0` via blueprints [#1598](https://github.com/getgrav/grav/issues/1598)
* Fixed `Data::exists()` and `Data::raw()` functions breaking if `Data::file()` hasn't been called with non-null value
* Fixed parent theme auto-loading in child themes of Gantry 5

# v1.3.1
## 07/19/2017
Expand Down
50 changes: 26 additions & 24 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 23 additions & 14 deletions system/src/Grav/Common/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function current()
/**
* Load current theme.
*
* @return Theme|object
* @return Theme
*/
public function load()
{
Expand Down Expand Up @@ -253,7 +253,7 @@ public function configure()
stream_wrapper_unregister($scheme);
}
$type = !empty($config['type']) ? $config['type'] : 'ReadOnlyStream';
if ($type[0] != '\\') {
if ($type[0] !== '\\') {
$type = '\\RocketTheme\\Toolbox\\StreamWrapper\\' . $type;
}

Expand Down Expand Up @@ -301,7 +301,7 @@ protected function loadLanguages(Config $config)

/** @var \DirectoryIterator $directory */
foreach ($iterator as $file) {
if ($file->getExtension() != 'yaml') {
if ($file->getExtension() !== 'yaml') {
continue;
}
$languages[$file->getBasename('.yaml')] = CompiledYamlFile::instance($file->getPathname())->content();
Expand All @@ -321,27 +321,36 @@ protected function loadLanguages(Config $config)
*/
protected function autoloadTheme($class)
{
$prefix = "Grav\\Theme";
$prefix = 'Grav\\Theme\\';
if (false !== strpos($class, $prefix)) {
// Remove prefix from class
$class = substr($class, strlen($prefix));
$locator = $this->grav['locator'];

// Try Old style theme classes
$path = strtolower(ltrim(preg_replace('#\\\|_(?!.+\\\)#', '/', $class), '/'));
$file = $this->grav['locator']->findResource("themes://{$path}/{$path}.php");
// First try lowercase version of the classname.
$path = strtolower($class);
$file = $locator("themes://{$path}/theme.php") ?: $locator("themes://{$path}/{$path}.php");

// Load class
if (file_exists($file)) {
return include_once($file);
if ($file) {
return include_once $file;
}

// Replace namespace tokens to directory separators
$path = $this->grav['inflector']->hyphenize(ltrim($class,"\\"));
$file = $this->grav['locator']->findResource("themes://{$path}/{$path}.php");
$path = $this->grav['inflector']->hyphenize($class);
$file = $locator("themes://{$path}/theme.php") ?: $locator("themes://{$path}/{$path}.php");

// Load class
if ($file) {
return include_once $file;
}

// Try Old style theme classes
$path = strtolower(preg_replace('#\\\|_(?!.+\\\)#', '/', $class));
$file = $locator("themes://{$path}/theme.php") ?: $locator("themes://{$path}/{$path}.php");

// Load class
if (file_exists($file)) {
return include_once($file);
if ($file) {
return include_once $file;
}
}

Expand Down

0 comments on commit 557a3b8

Please sign in to comment.