mirror of
https://github.com/getgrav/grav.git
synced 2025-11-02 11:26:02 +01:00
Merge branch 'develop' into feature/gpm
This commit is contained in:
@@ -300,7 +300,7 @@ class Pages
|
|||||||
$list[$current->route()] = str_repeat(' ', ($level-1)*2) . $current->title();
|
$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));
|
$list = array_merge($list, $this->getList($next, $level + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,17 +426,13 @@ class Pages
|
|||||||
throw new \RuntimeException('Fatal error when creating page instances.');
|
throw new \RuntimeException('Fatal error when creating page instances.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_modified = 0;
|
// set current modified of page
|
||||||
|
$last_modified = $page->modified();
|
||||||
|
|
||||||
/** @var \DirectoryIterator $file */
|
/** @var \DirectoryIterator $file */
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
$name = $file->getFilename();
|
$name = $file->getFilename();
|
||||||
|
|
||||||
$date = $file->getMTime();
|
|
||||||
if ($date > $last_modified) {
|
|
||||||
$last_modified = $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($file->isFile() && Utils::endsWith($name, CONTENT_EXT)) {
|
if ($file->isFile() && Utils::endsWith($name, CONTENT_EXT)) {
|
||||||
|
|
||||||
$page->init($file);
|
$page->init($file);
|
||||||
@@ -471,12 +467,16 @@ class Pages
|
|||||||
if ($config->get('system.pages.events.page')) {
|
if ($config->get('system.pages.events.page')) {
|
||||||
$this->grav->fireEvent('onFolderProcessed', new Event(['page' => $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
|
// Override the modified and ID so that it takes the latest change into account
|
||||||
// into account
|
|
||||||
$page->modified($last_modified);
|
$page->modified($last_modified);
|
||||||
$page->id($last_modified.md5($page->filePath()));
|
$page->id($last_modified.md5($page->filePath()));
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ use Grav\Component\Filesystem\ResourceLocator;
|
|||||||
class Themes extends Iterator
|
class Themes extends Iterator
|
||||||
{
|
{
|
||||||
protected $grav;
|
protected $grav;
|
||||||
|
protected $config;
|
||||||
|
|
||||||
public function __construct(Grav $grav) {
|
public function __construct(Grav $grav) {
|
||||||
$this->grav = $grav;
|
$this->grav = $grav;
|
||||||
|
$this->config = $grav['config'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,10 +25,10 @@ class Themes extends Iterator
|
|||||||
*
|
*
|
||||||
* @return array|Data[]
|
* @return array|Data[]
|
||||||
*/
|
*/
|
||||||
public static function all()
|
public function all()
|
||||||
{
|
{
|
||||||
$list = array();
|
$list = array();
|
||||||
$iterator = new \DirectoryIterator('themes:///');
|
$iterator = new \DirectoryIterator('theme:///');
|
||||||
|
|
||||||
/** @var \DirectoryIterator $directory */
|
/** @var \DirectoryIterator $directory */
|
||||||
foreach ($iterator as $directory) {
|
foreach ($iterator as $directory) {
|
||||||
@@ -50,7 +52,7 @@ class Themes extends Iterator
|
|||||||
* @return Data
|
* @return Data
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public static function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
throw new \RuntimeException('Theme name not provided.');
|
throw new \RuntimeException('Theme name not provided.');
|
||||||
@@ -60,13 +62,11 @@ class Themes extends Iterator
|
|||||||
$blueprint = $blueprints->get('blueprints');
|
$blueprint = $blueprints->get('blueprints');
|
||||||
$blueprint->name = $name;
|
$blueprint->name = $name;
|
||||||
|
|
||||||
/** @var Config $config */
|
|
||||||
$config = $this->grav['config'];
|
|
||||||
|
|
||||||
// Find thumbnail.
|
// Find thumbnail.
|
||||||
$thumb = "theme://{$name}/thumbnail.jpg";
|
$thumb = "theme:///{$name}/thumbnail.jpg";
|
||||||
|
|
||||||
if (file_exists($thumb)) {
|
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.
|
// Load default configuration.
|
||||||
@@ -85,24 +85,19 @@ class Themes extends Iterator
|
|||||||
|
|
||||||
public function current($name = null)
|
public function current($name = null)
|
||||||
{
|
{
|
||||||
/** @var Config $config */
|
|
||||||
$config = $this->grav['config'];
|
|
||||||
|
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
$name = $config->get('system.pages.theme');
|
$name = $this->config->get('system.pages.theme');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load($name = null)
|
function load($name = null)
|
||||||
{
|
{
|
||||||
$name = $this->current($name);
|
$name = $this->current($name);
|
||||||
$grav = $this->grav;
|
$grav = $this->grav;
|
||||||
|
|
||||||
/** @var Config $config */
|
|
||||||
$config = $grav['config'];
|
|
||||||
|
|
||||||
/** @var ResourceLocator $locator */
|
/** @var ResourceLocator $locator */
|
||||||
$locator = $grav['locator'];
|
$locator = $grav['locator'];
|
||||||
|
|
||||||
@@ -115,13 +110,13 @@ class Themes extends Iterator
|
|||||||
$className = '\\Grav\\Theme\\' . ucfirst($name);
|
$className = '\\Grav\\Theme\\' . ucfirst($name);
|
||||||
|
|
||||||
if (class_exists($className)) {
|
if (class_exists($className)) {
|
||||||
$class = new $className($grav, $config, $name);
|
$class = new $className($grav, $this->config, $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($class)) {
|
if (empty($class)) {
|
||||||
$class = new Theme($grav, $config, $name);
|
$class = new Theme($grav, $this->config, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $class;
|
return $class;
|
||||||
@@ -131,7 +126,7 @@ class Themes extends Iterator
|
|||||||
$name = $this->current($name);
|
$name = $this->current($name);
|
||||||
|
|
||||||
/** @var Config $config */
|
/** @var Config $config */
|
||||||
$config = $this->grav['config'];
|
$config = $this->config;
|
||||||
|
|
||||||
$themeConfig = File\Yaml::instance("theme://{$name}/{$name}" . YAML_EXT)->content();
|
$themeConfig = File\Yaml::instance("theme://{$name}/{$name}" . YAML_EXT)->content();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
title: Test
|
|
||||||
---
|
|
||||||
|
|
||||||
# Testing
|
|
||||||
Reference in New Issue
Block a user