From 41bf943f49812ba611e8379bb8bb611f226ad4ae Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 30 Sep 2018 21:11:46 -0600 Subject: [PATCH 1/3] get raw content for all pages --- system/src/Grav/Common/Security.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php index 9b345cb18..f7b247643 100644 --- a/system/src/Grav/Common/Security.php +++ b/system/src/Grav/Common/Security.php @@ -26,7 +26,7 @@ class Security // 'steps' => count($routes), // ]); - foreach ($routes as $route => $path) { + foreach ($routes as $path) { $status && $status([ 'type' => 'progress', @@ -37,13 +37,13 @@ class Security // call the content to load/cache it $header = (array) $page->header(); - $content = $page->content(); + $content = $page->value('content'); $data = ['header' => $header, 'content' => $content]; $results = Security::detectXssFromArray($data); if (!empty($results)) { - $list[$route] = $results; + $list[$page->filePathClean()] = $results; } } catch (\Exception $e) { From 46715184091c06fac7329969deb3f6d585444a13 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 1 Oct 2018 21:02:04 +0300 Subject: [PATCH 2/3] Fixed missing slug in Page::init() --- system/src/Grav/Common/Page/Page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 67a59a064..3024cc394 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -137,7 +137,7 @@ class Page implements PageInterface $this->metadata(); $this->url(); $this->visible(); - $this->modularTwig($this->slug[0] === '_'); + $this->modularTwig(strpos($this->slug(), '_') === 0); $this->setPublishState(); $this->published(); $this->urlExtension(); From 920b0fcb2ebadfe8cc7597f6571a12ca2650f6ab Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 1 Oct 2018 21:26:36 +0300 Subject: [PATCH 3/3] Register all page types into `blueprint://pages` stream --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Pages.php | 13 ++++++++++++- system/src/Grav/Common/Page/Types.php | 10 +++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 215186a42..20537b707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * Added support for hiding form fields in blueprints by using dynamic property like `security@: admin.foobar`, `scope@: object` or `scope-ignore@: object` to any field 1. [](#improved) * Doctrine filecache is now namespaced with prefix to support purging + * Register all page types into `blueprint://pages` stream # v1.5.2 ## mm/dd/2018 diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index ac0e41cb0..57f2fb4f2 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -710,7 +710,6 @@ class Pages public static function getTypes() { if (!self::$types) { - $grav = Grav::instance(); $scanBlueprintsAndTemplates = function () use ($grav) { @@ -748,6 +747,18 @@ class Pages $scanBlueprintsAndTemplates(); } + // Register custom paths to the locator. + $locator = $grav['locator']; + foreach (self::$types as $type => $paths) { + foreach ($paths as $k => $path) { + if (strpos($path, 'blueprints://') === 0) { + unset($paths[$k]); + } + } + if ($paths) { + $locator->addPath('blueprints', "pages/$type.yaml", $paths); + } + } } return self::$types; diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php index 436d4f835..10b07beda 100644 --- a/system/src/Grav/Common/Page/Types.php +++ b/system/src/Grav/Common/Page/Types.php @@ -33,7 +33,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable } if (!$blueprint && $this->systemBlueprints) { - $blueprint = isset($this->systemBlueprints[$type]) ? $this->systemBlueprints[$type] : $this->systemBlueprints['default']; + $blueprint = $this->systemBlueprints[$type] ?? $this->systemBlueprints['default']; } if ($blueprint) { @@ -43,7 +43,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable public function scanBlueprints($uri) { - if (!is_string($uri)) { + if (!\is_string($uri)) { throw new \InvalidArgumentException('First parameter must be URI'); } @@ -63,7 +63,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable public function scanTemplates($uri) { - if (!is_string($uri)) { + if (!\is_string($uri)) { throw new \InvalidArgumentException('First parameter must be URI'); } @@ -96,7 +96,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable if (strpos($name, '/')) { continue; } - $list[$name] = ucfirst(strtr($name, '_', ' ')); + $list[$name] = ucfirst(str_replace('_', ' ', $name)); } ksort($list); return $list; @@ -109,7 +109,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable if (strpos($name, 'modular/') !== 0) { continue; } - $list[$name] = trim(ucfirst(strtr(basename($name), '_', ' '))); + $list[$name] = ucfirst(trim(str_replace('_', ' ', basename($name)))); } ksort($list); return $list;