Merge branch 'develop' into feature/gpm

This commit is contained in:
Djamil Legato
2014-09-05 22:33:50 -07:00
3 changed files with 22 additions and 32 deletions

View File

@@ -300,7 +300,7 @@ class Pages
$list[$current->route()] = str_repeat('  ', ($level-1)*2) . $current->title();
}
foreach ($current as $next) {
foreach ($current->children() as $next) {
$list = array_merge($list, $this->getList($next, $level + 1));
}
@@ -426,17 +426,13 @@ class Pages
throw new \RuntimeException('Fatal error when creating page instances.');
}
$last_modified = 0;
// set current modified of page
$last_modified = $page->modified();
/** @var \DirectoryIterator $file */
foreach ($iterator as $file) {
$name = $file->getFilename();
$date = $file->getMTime();
if ($date > $last_modified) {
$last_modified = $date;
}
if ($file->isFile() && Utils::endsWith($name, CONTENT_EXT)) {
$page->init($file);
@@ -471,12 +467,16 @@ class Pages
if ($config->get('system.pages.events.page')) {
$this->grav->fireEvent('onFolderProcessed', new Event(['page' => $page]));
}
} else {
$date = $file->getMTime();
if ($date > $last_modified) {
$last_modified = $date;
}
}
}
// Override the modified and ID so that it takes the latest change
// into account
// Override the modified and ID so that it takes the latest change into account
$page->modified($last_modified);
$page->id($last_modified.md5($page->filePath()));

View File

@@ -13,9 +13,11 @@ use Grav\Component\Filesystem\ResourceLocator;
class Themes extends Iterator
{
protected $grav;
protected $config;
public function __construct(Grav $grav) {
$this->grav = $grav;
$this->config = $grav['config'];
}
/**
@@ -23,10 +25,10 @@ class Themes extends Iterator
*
* @return array|Data[]
*/
public static function all()
public function all()
{
$list = array();
$iterator = new \DirectoryIterator('themes:///');
$iterator = new \DirectoryIterator('theme:///');
/** @var \DirectoryIterator $directory */
foreach ($iterator as $directory) {
@@ -50,7 +52,7 @@ class Themes extends Iterator
* @return Data
* @throws \RuntimeException
*/
public static function get($name)
public function get($name)
{
if (!$name) {
throw new \RuntimeException('Theme name not provided.');
@@ -60,13 +62,11 @@ class Themes extends Iterator
$blueprint = $blueprints->get('blueprints');
$blueprint->name = $name;
/** @var Config $config */
$config = $this->grav['config'];
// Find thumbnail.
$thumb = "theme://{$name}/thumbnail.jpg";
$thumb = "theme:///{$name}/thumbnail.jpg";
if (file_exists($thumb)) {
$blueprint->set('thumbnail', $config->get('system.base_url_relative') . "/user/themes/{$name}/thumbnail.jpg");
$blueprint->set('thumbnail', $this->config->get('system.base_url_relative') . "/user/themes/{$name}/thumbnail.jpg");
}
// Load default configuration.
@@ -85,24 +85,19 @@ class Themes extends Iterator
public function current($name = null)
{
/** @var Config $config */
$config = $this->grav['config'];
if (!$name) {
$name = $config->get('system.pages.theme');
$name = $this->config->get('system.pages.theme');
}
return $name;
}
public function load($name = null)
function load($name = null)
{
$name = $this->current($name);
$grav = $this->grav;
/** @var Config $config */
$config = $grav['config'];
/** @var ResourceLocator $locator */
$locator = $grav['locator'];
@@ -115,13 +110,13 @@ class Themes extends Iterator
$className = '\\Grav\\Theme\\' . ucfirst($name);
if (class_exists($className)) {
$class = new $className($grav, $config, $name);
$class = new $className($grav, $this->config, $name);
}
}
}
if (empty($class)) {
$class = new Theme($grav, $config, $name);
$class = new Theme($grav, $this->config, $name);
}
return $class;
@@ -131,7 +126,7 @@ class Themes extends Iterator
$name = $this->current($name);
/** @var Config $config */
$config = $this->grav['config'];
$config = $this->config;
$themeConfig = File\Yaml::instance("theme://{$name}/{$name}" . YAML_EXT)->content();

View File

@@ -1,5 +0,0 @@
---
title: Test
---
# Testing