diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index ea22ad291..90ed324b9 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
- php: [ 8.0, 7.4, 7.3]
+ php: [ 8.1, 8.0, 7.4, 7.3]
os: [ubuntu-latest]
steps:
diff --git a/.htaccess b/.htaccess
index 83063ae2e..098c58244 100644
--- a/.htaccess
+++ b/.htaccess
@@ -59,9 +59,9 @@ RewriteRule .* index.php [L]
# Block all direct access for these folders
RewriteRule ^(\.git|cache|bin|logs|backup|webserver-configs|tests)/(.*) error [F]
# Block access to specific file types for these system folders
-RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block access to specific file types for these user folders
-RewriteRule ^(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(user)/(.*)\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block all direct access to .md files:
RewriteRule \.md$ error [F]
# Block all direct access to files and folders beginning with a dot
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc2dbf843..d2fa1f4c6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,17 +1,101 @@
+# v1.7.30
+## mm/dd/2022
+
+1. [](#new)
+ * Added twig filter `|field_parent` to get parent field name
+2. [](#bugfix)
+ * Fixed error while deleting retina image in admin
+ * Fixed "Page Authors" field in Security tab, wrongly loading and saving the value [#3525](https://github.com/getgrav/grav/issues/3525)
+ * Fixed accounts filter only matches against email address [getgrav/grav-plugin-admin#2224](https://github.com/getgrav/grav-plugin-admin/issues/2224)
+
+# v1.7.29.1
+## 01/31/2022
+
+1. [](#bugfix)
+ * Fixed `Call to undefined method` error when upgrading from Grav 1.6 [#3523](https://github.com/getgrav/grav/issues/3523)
+
+# v1.7.29
+## 01/28/2022
+
+1. [](#new)
+ * Added support for registering assets from `HtmlBlock`
+ * Added unicode-safe `Utils::basename()` and `Utils::pathinfo()` methods
+2. [](#improved)
+ * Improved `Filesystem::basename()` and `Filesystem::pathinfo()` to be unicode-safe
+ * Made path handling unicode-safe, use new `Utils::basename()` and `Utils::pathinfo()` everywhere
+3. [](#bugfix)
+ * Fixed error on thumbnail image creation
+ * Fixed MimeType for `gzip` (`application/x-gzip`)
+
+# v1.7.28
+## 01/24/2022
+
+1. [](#new)
+ * Added links and modules support to `HtmlBlock` class
+ * Added module support for twig script tag: `{% script module 'theme://js/module.mjs' %}`
+ * Added twig tag for links: `{% link icon 'theme://images/favicon.png' priority: 20 with { type: 'image/png' } %}`
+ * Added `HtmlBlock` support for `{% style %}`, `{% script %}` and `{% link %}` tags
+ * Support for page-level `redirect_default_route` frontmatter header override
+3. [](#bugfix)
+ * Fixed XSS check not detecting escaped `:`
+
+# v1.7.27.1
+## 01/12/2022
+
+3. [](#bugfix)
+ * Fixed a typo in CSS Asset pipeline that was erroneously joining files with `;`
+
+# v1.7.27
+## 01/12/2022
+
+1. [](#new)
+ * Support for `YubiKey OTP` 2-Factor authenticator
+ * Added support for generic `assets.link()` for external references. No pipeline support
+ * Added support for `assets.addJsModule()` with full pipeline support
+ * Added `Utils::getExtensionsByMime()` method to get all the registered extensions for the specific mime type
+ * Added `Media::getRoute()` and `Media::getRawRoute()` methods to get page route if available
+ * Added `Medium::getAlternatives()` to be able to list all the retina sizes
+2. [](#improved)
+ * Improved `Utils::download()` method to allow overrides on download name, mime and expires header
+ * Improved `onPageFallBackUrl` event
+ * Reorganized the Asset system configuration blueprint for clarity
+3. [](#bugfix)
+ * Fixed CLI `--env` and `--lang` options having no effect if they aren't added before all the other options
+ * Fixed scaled image medium filename when using non-existing retina file
+ * Fixed an issue with JS `imports` and pipelining Assets
+
+# v1.7.26.1
+## 01/04/2022
+
+3. [](#bugfix)
+ * Fixed `UserObject::getAccess()` after cloning the object
+
# v1.7.26
-## mm/dd/2021
+## 01/03/2022
1. [](#new)
* Made `Grav::redirect()` to accept `Route` class
* Added `translated()` method to `PageTranslateInterface`
+ * Added second parameter to `UserObject::isMyself()` method
+ * Added `UserObject::$isAuthorizedCallable` to allow `$user->isAuthorized()` customization
+ * Use secure session cookies in HTTPS by default (`system.session.secure_https: true`)
+ * Added new `Plugin::inheritedConfigOption()` function to access plugin specific functions for page overrides
2. [](#improved)
* Upgraded vendor libs for PHP 8.1 compatibility
* Upgraded to **composer v2.1.14** for PHP 8.1 compatibility
* Added third `$name` parameter to `Blueprint::flattenData()` method, useful for flattening repeating data
* `ControllerResponseTrait`: Redirect response should be json if the extension is .json
+ * When symlinking Grav install, include also tests
+ * Updated copyright year to `2022`
3. [](#bugfix)
* Fixed bad key lookup in `FlexRelatedDirectoryTrait::getCollectionByProperty()`
* Fixed RequestHandlers `NotFoundException` having empty request
+ * Block `.json` files in web server configs
+ * Disabled pretty debug info for Flex as it slows down Twig rendering
+ * Fixed Twig being very slow when template overrides do not exist
+ * Fixed `UserObject::$authorizeCallable` binding to the user object
+ * Fixed `FlexIndex::call()` to return null instead of failing to call undefined method
+ * Fixed Flex directory configuration creating environment configuration when it should not
# v1.7.25
## 11/16/2021
diff --git a/README.md b/README.md
index 31a4a7e4b..562726dfd 100644
--- a/README.md
+++ b/README.md
@@ -2,13 +2,13 @@
[](https://github.com/phpstan/phpstan)
[](https://chat.getgrav.org)
- [](https://github.com/getgrav/grav/actions?query=workflow%3A%22PHP+Tests%22) [](#backers) [](#sponsors)
+ [](https://github.com/getgrav/grav/actions?query=workflow%3A%22PHP+Tests%22) [](#backers) [](#supporters) [](#sponsors)
Grav is a **Fast**, **Simple**, and **Flexible**, file-based Web-platform. There is **Zero** installation required. Just extract the ZIP archive, and you are already up and running. It follows similar principles to other flat-file CMS platforms, but has a different design philosophy than most. Grav comes with a powerful **Package Management System** to allow for simple installation and upgrading of plugins and themes, as well as simple updating of Grav itself.
The underlying architecture of Grav is designed to use well-established and _best-in-class_ technologies to ensure that Grav is simple to use and easy to extend. Some of these key technologies include:
-* [Twig Templating](https://twig.sensiolabs.org/): for powerful control of the user interface
+* [Twig Templating](https://twig.symfony.com/): for powerful control of the user interface
* [Markdown](https://en.wikipedia.org/wiki/Markdown): for easy content creation
* [YAML](https://yaml.org): for simple configuration
* [Parsedown](https://parsedown.org/): for fast Markdown and Markdown Extra support
@@ -117,12 +117,19 @@ If you discover a possible security issue related to Grav or one of its plugins,
* More [Awesome Grav Stuff](https://github.com/getgrav/awesome-grav)
# Backers
-Support Grav with a monthly donation to help us continue development. [[Become a backer](https://opencollective.com/grav#backer)]
+Support Grav with a monthly donation to help us continue development. [[Become a backer](https://opencollective.com/grav/contribute)]
+
+# Supporters
+Support Grav with a monthly donation to help us continue development. [[Become a supporter](https://opencollective.com/grav/contribute)]
+
+
+
+
# Sponsors
-Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/grav#sponsor)]
+Support Grav with a yearly donation to help us continue development. [[Become a sponsor](https://opencollective.com/grav/contribute)]
diff --git a/assets/.gitkeep b/assets/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/assets/.gitkeep
+++ b/assets/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/backup/.gitkeep b/backup/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/backup/.gitkeep
+++ b/backup/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/bin/gpm b/bin/gpm
index a2eebc68c..9e58706f6 100755
--- a/bin/gpm
+++ b/bin/gpm
@@ -2,7 +2,7 @@
PHP %s to run.', $ver, $req));
-}
-
if (PHP_SAPI === 'cli-server') {
$symfony_server = stripos(getenv('_'), 'symfony') !== false || stripos($_SERVER['SERVER_SOFTWARE'] ?? '', 'symfony') !== false || stripos($_ENV['SERVER_SOFTWARE'] ?? '', 'symfony') !== false;
diff --git a/logs/.gitkeep b/logs/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/logs/.gitkeep
+++ b/logs/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml
index 1aeaf2bf2..b6beb41b9 100644
--- a/system/blueprints/config/system.yaml
+++ b/system/blueprints/config/system.yaml
@@ -888,9 +888,45 @@ form:
title: PLUGIN_ADMIN.ASSETS
fields:
- assets_section:
+ general_config_section:
type: section
- title: PLUGIN_ADMIN.ASSETS
+ title: PLUGIN_ADMIN.GENERAL_CONFIG
+ underline: true
+
+ assets.enable_asset_timestamp:
+ type: toggle
+ label: PLUGIN_ADMIN.ENABLED_TIMESTAMPS_ON_ASSETS
+ help: PLUGIN_ADMIN.ENABLED_TIMESTAMPS_ON_ASSETS_HELP
+ highlight: 0
+ options:
+ 1: PLUGIN_ADMIN.YES
+ 0: PLUGIN_ADMIN.NO
+ validate:
+ type: bool
+
+ assets.enable_asset_sri:
+ type: toggle
+ label: PLUGIN_ADMIN.ENABLED_SRI_ON_ASSETS
+ help: PLUGIN_ADMIN.ENABLED_SRI_ON_ASSETS_HELP
+ highlight: 0
+ options:
+ 1: PLUGIN_ADMIN.YES
+ 0: PLUGIN_ADMIN.NO
+ validate:
+ type: bool
+
+ assets.collections:
+ type: multilevel
+ label: PLUGIN_ADMIN.COLLECTIONS
+ placeholder_key: collection_name
+ placeholder_value: collection_path
+ validate:
+ type: array
+
+
+ css_assets_section:
+ type: section
+ title: PLUGIN_ADMIN.CSS_ASSETS
underline: true
assets.css_pipeline:
@@ -959,6 +995,11 @@ form:
validate:
type: bool
+ js_assets_section:
+ type: section
+ title: PLUGIN_ADMIN.JS_ASSETS
+ underline: true
+
assets.js_pipeline:
type: toggle
label: PLUGIN_ADMIN.JAVASCRIPT_PIPELINE
@@ -1003,10 +1044,15 @@ form:
validate:
type: bool
- assets.enable_asset_timestamp:
+ js_module_assets_section:
+ type: section
+ title: PLUGIN_ADMIN.JS_MODULE_ASSETS
+ underline: true
+
+ assets.js_module_pipeline:
type: toggle
- label: PLUGIN_ADMIN.ENABLED_TIMESTAMPS_ON_ASSETS
- help: PLUGIN_ADMIN.ENABLED_TIMESTAMPS_ON_ASSETS_HELP
+ label: PLUGIN_ADMIN.JAVASCRIPT_MODULE_PIPELINE
+ help: PLUGIN_ADMIN.JAVASCRIPT_MODULE_PIPELINE_HELP
highlight: 0
options:
1: PLUGIN_ADMIN.YES
@@ -1014,24 +1060,29 @@ form:
validate:
type: bool
- assets.enable_asset_sri:
+ assets.js_module_pipeline_include_externals:
type: toggle
- label: PLUGIN_ADMIN.ENABLED_SRI_ON_ASSETS
- help: PLUGIN_ADMIN.ENABLED_SRI_ON_ASSETS_HELP
- highlight: 0
+ label: PLUGIN_ADMIN.JAVASCRIPT_MODULE_PIPELINE_INCLUDE_EXTERNALS
+ help: PLUGIN_ADMIN.JAVASCRIPT_MODULE_PIPELINE_INCLUDE_EXTERNALS_HELP
+ highlight: 1
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
- assets.collections:
- type: multilevel
- label: PLUGIN_ADMIN.COLLECTIONS
- placeholder_key: collection_name
- placeholder_value: collection_path
+ assets.js_module_pipeline_before_excludes:
+ type: toggle
+ label: PLUGIN_ADMIN.JAVASCRIPT_MODULE_PIPELINE_BEFORE_EXCLUDES
+ help: PLUGIN_ADMIN.JAVASCRIPT_MODULE_PIPELINE_BEFORE_EXCLUDES_HELP
+ highlight: 1
+ options:
+ 1: PLUGIN_ADMIN.YES
+ 0: PLUGIN_ADMIN.NO
validate:
- type: array
+ type: bool
+
+
errors:
type: tab
@@ -1394,6 +1445,18 @@ form:
validate:
type: bool
+ session.secure_https:
+ type: toggle
+ label: PLUGIN_ADMIN.SESSION_SECURE_HTTPS
+ help: PLUGIN_ADMIN.SESSION_SECURE_HTTPS_HELP
+ highlight: 1
+ options:
+ 1: PLUGIN_ADMIN.YES
+ 0: PLUGIN_ADMIN.NO
+ default: true
+ validate:
+ type: bool
+
session.httponly:
type: toggle
label: PLUGIN_ADMIN.SESSION_HTTPONLY
diff --git a/system/blueprints/flex/pages.yaml b/system/blueprints/flex/pages.yaml
index 5c6ed8eb5..89dab6a56 100644
--- a/system/blueprints/flex/pages.yaml
+++ b/system/blueprints/flex/pages.yaml
@@ -104,7 +104,7 @@ config:
edit:
title:
- template: "{% if object.root %}Root ( <root> ){% else %}{{ (form.value('header.title') ?? form.value('folder'))|e }} ( {{ (object.getRoute().toString(false) ?: '/')|e }} ){% endif %}"
+ template: "{% if object.root %}Root ( <root> ){% else %}{{ (form.value('header.title') ?? form.value('folder'))|e }} ( {{ (object.getRoute().toString(false) ?: '/')|e }} ){% endif %}"
# TODO: not used yet
buttons:
diff --git a/system/blueprints/flex/user-accounts.yaml b/system/blueprints/flex/user-accounts.yaml
index 384bf97c0..8d336f993 100644
--- a/system/blueprints/flex/user-accounts.yaml
+++ b/system/blueprints/flex/user-accounts.yaml
@@ -122,6 +122,8 @@ config:
fields:
- key
- email
+ - username
+ - fullname
blueprints:
configure:
diff --git a/system/blueprints/flex/user-groups.yaml b/system/blueprints/flex/user-groups.yaml
index 05ba87b73..a5d348b5a 100644
--- a/system/blueprints/flex/user-groups.yaml
+++ b/system/blueprints/flex/user-groups.yaml
@@ -113,6 +113,7 @@ config:
fields:
- key
- groupname
+ - readableName
- description
blueprints:
diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml
index f3ef29f5e..a573a83c8 100644
--- a/system/blueprints/pages/default.yaml
+++ b/system/blueprints/pages/default.yaml
@@ -320,6 +320,18 @@ form:
fields:
+ header.redirect_default_route:
+ type: toggle
+ toggleable: true
+ label: PLUGIN_ADMIN.REDIRECT_DEFAULT_ROUTE
+ help: PLUGIN_ADMIN.REDIRECT_DEFAULT_ROUTE_HELP
+ config-highlight@: system.pages.redirect_default_route
+ options:
+ 1: PLUGIN_ADMIN.YES
+ 0: PLUGIN_ADMIN.NO
+ validate:
+ type: bool
+
header.routes.default:
type: text
toggleable: true
diff --git a/system/blueprints/pages/external.yaml b/system/blueprints/pages/external.yaml
index df1d7b0aa..d3bb57ac9 100644
--- a/system/blueprints/pages/external.yaml
+++ b/system/blueprints/pages/external.yaml
@@ -1,7 +1,7 @@
-title: PLUGIN_ADMIN:EXTERNAL
+title: PLUGIN_ADMIN.EXTERNAL
extends@:
- type: default
- context: blueprints://pages
+ type: default
+ context: blueprints://pages
form:
validation: loose
@@ -29,16 +29,16 @@ form:
unset@: true
header.external_url:
- type: text
- label: PLUGIN_ADMIN.EXTERNAL_URL
- placeholder: https://getgrav.org
- validate:
- required: true
+ type: text
+ label: PLUGIN_ADMIN.EXTERNAL_URL
+ placeholder: https://getgrav.org
+ validate:
+ required: true
+
options:
fields:
publishing:
-
fields:
header.date:
diff --git a/system/blueprints/pages/partials/security.yaml b/system/blueprints/pages/partials/security.yaml
index d7619b975..26d8c7dcb 100644
--- a/system/blueprints/pages/partials/security.yaml
+++ b/system/blueprints/pages/partials/security.yaml
@@ -51,17 +51,13 @@ form:
type: bool
header.permissions.authors:
- type: list
+ type: array
toggleable: true
+ value_only: true
+ placeholder_value: PLUGIN_ADMIN.USERNAME
label: PLUGIN_ADMIN.PAGE_AUTHORS
help: PLUGIN_ADMIN.PAGE_AUTHORS_HELP
- fields:
- value:
- type: text
- placeholder: PLUGIN_ADMIN.USERNAME
- style: vertical
-
header.permissions.groups:
ignore@: true
type: acl_picker
diff --git a/system/blueprints/user/account.yaml b/system/blueprints/user/account.yaml
index 127a99e5b..cfe537620 100644
--- a/system/blueprints/user/account.yaml
+++ b/system/blueprints/user/account.yaml
@@ -107,6 +107,12 @@ form:
label: PLUGIN_ADMIN.2FA_SECRET
sublabel: PLUGIN_ADMIN.2FA_SECRET_HELP
+ yubikey_id:
+ type: text
+ label: PLUGIN_ADMIN.YUBIKEY_ID
+ description: PLUGIN_ADMIN.YUBIKEY_HELP
+ size: small
+ maxlength: 12
diff --git a/system/config/media.yaml b/system/config/media.yaml
index b118a210e..fad5e0dcb 100644
--- a/system/config/media.yaml
+++ b/system/config/media.yaml
@@ -199,7 +199,7 @@ types:
gz:
type: file
thumb: media/thumb-gz.png
- mime: application/gzip
+ mime: application/x-gzip
tar:
type: file
thumb: media/thumb-tar.png
diff --git a/system/config/system.yaml b/system/config/system.yaml
index 652910d86..2de075b26 100644
--- a/system/config/system.yaml
+++ b/system/config/system.yaml
@@ -127,6 +127,9 @@ assets: # Configuration for Assets Mana
js_pipeline: false # The JS pipeline is the unification of multiple JS resources into one file
js_pipeline_include_externals: true # Include external URLs in the pipeline by default
js_pipeline_before_excludes: true # Render the pipeline before any excluded files
+ js_module_pipeline: false # The JS Module pipeline is the unification of multiple JS Module resources into one file
+ js_module_pipeline_include_externals: true # Include external URLs in the pipeline by default
+ js_module_pipeline_before_excludes: true # Render the pipeline before any excluded files
js_minify: true # Minify the JS during pipelining
enable_asset_timestamp: false # Enable asset timestamps
enable_asset_sri: false # Enable asset SRI
@@ -182,6 +185,7 @@ session:
name: grav-site # Name prefix of the session cookie. Use alphanumeric, dashes or underscores only. Do not use dots in the session name
uniqueness: path # Should sessions be `path` based or `security.salt` based
secure: false # Set session secure. If true, indicates that communication for this cookie must be over an encrypted transmission. Enable this only on sites that run exclusively on HTTPS
+ secure_https: true # Set session secure on HTTPS but not on HTTP. Has no effect if you have `session.secure: true`. Set to false if your site jumps between HTTP and HTTPS.
httponly: true # Set session HTTP only. If true, indicates that cookies should be used only over HTTP, and JavaScript modification is not allowed.
samesite: Lax # Set session SameSite. Possible values are Lax, Strict and None. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
split: true # Sessions should be independent between site and plugins (such as admin)
diff --git a/system/defines.php b/system/defines.php
index f5ccba900..6520711f3 100644
--- a/system/defines.php
+++ b/system/defines.php
@@ -3,13 +3,13 @@
/**
* @package Grav\Core
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
// Some standard defines
define('GRAV', true);
-define('GRAV_VERSION', '1.7.25');
+define('GRAV_VERSION', '1.7.29.1');
define('GRAV_SCHEMA', '1.7.0_2020-11-20_1');
define('GRAV_TESTING', false);
diff --git a/system/install.php b/system/install.php
index e8cd5827d..5c9440f97 100644
--- a/system/install.php
+++ b/system/install.php
@@ -2,7 +2,7 @@
/**
* @package Grav\Core
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/languages/es.yaml b/system/languages/es.yaml
index 95827ee2b..a8a47aa38 100644
--- a/system/languages/es.yaml
+++ b/system/languages/es.yaml
@@ -44,7 +44,7 @@ GRAV:
WK: sem
MO: mes
YR: año
- DEC: dic
+ DEC: déc
SECOND_PLURAL: segundos
MINUTE_PLURAL: minutos
HOUR_PLURAL: horas
@@ -64,7 +64,7 @@ GRAV:
VALIDATION_FAIL: 'Falló la validación: '
INVALID_INPUT: 'Dato inválido en: '
MISSING_REQUIRED_FIELD: 'Falta el campo requerido: '
- XSS_ISSUES: "Se detectaron problemas XSS potenciales en el campo '%s'"
+ XSS_ISSUES: "Se detectaron potenciales problemas XSS en el campo '%s'"
MONTHS_OF_THE_YEAR:
- 'Enero'
- 'Febrero'
@@ -86,7 +86,7 @@ GRAV:
- 'Viernes'
- 'Sábado'
- 'Domingo'
- YES: "Si"
+ YES: "Sí"
NO: "No"
CRON:
EVERY: cada
@@ -96,12 +96,12 @@ GRAV:
EVERY_DAY_OF_MONTH: cada día del mes
EVERY_MONTH: cada mes
TEXT_PERIOD: Cada
- TEXT_MINS: ' a minuto(s) despues de la hora'
+ TEXT_MINS: ' a minuto(s) después de la hora'
TEXT_TIME: ' a :'
TEXT_DOW: ' en '
TEXT_MONTH: ' de'
TEXT_DOM: ' en'
- ERROR1: La etiqueta %s no está soportada!
- ERROR2: El número de elementos es erroneo
+ ERROR1: '¡La etiqueta %s no está soportada!'
+ ERROR2: El número de elementos es erróneo
ERROR3: El jquery_element debería establecerse en la configuración del jqCron
ERROR4: Expresión no reconocida
diff --git a/system/router.php b/system/router.php
index d58609c83..c19f814ba 100644
--- a/system/router.php
+++ b/system/router.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Core
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,9 +22,9 @@ if ($path !== '/index.php' && is_file($root . $path)) {
// Block all direct access for these folders
|| preg_match('`^/(\.git|cache|bin|logs|backup|webserver-configs|tests)/`ui', $path)
// Block access to specific file types for these system folders
- || preg_match('`^/(system|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
+ || preg_match('`^/(system|vendor)/(.*)\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
// Block access to specific file types for these user folders
- || preg_match('`^/(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
+ || preg_match('`^/(user)/(.*)\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$`ui', $path)
// Block all direct access to .md files
|| preg_match('`\.md$`ui', $path)
// Block access to specific files in the root folder
diff --git a/system/src/DOMLettersIterator.php b/system/src/DOMLettersIterator.php
new file mode 100644
index 000000000..e3c2c4ad9
--- /dev/null
+++ b/system/src/DOMLettersIterator.php
@@ -0,0 +1,165 @@
+load('example.xml');
+ * foreach(new DOMLettersIterator($doc) as $letter) echo $letter;
+ *
+ * NB: If you only need characters without their position
+ * in the document, use DOMNode->textContent instead.
+ *
+ * @author porneL http://pornel.net
+ * @license Public Domain
+ * @url https://github.com/antoligy/dom-string-iterators
+ *
+ * @implements Iterator
+ */
+final class DOMLettersIterator implements Iterator
+{
+ /** @var DOMElement */
+ private $start;
+ /** @var DOMElement|null */
+ private $current;
+ /** @var int */
+ private $offset = -1;
+ /** @var int|null */
+ private $key;
+ /** @var array|null */
+ private $letters;
+
+ /**
+ * expects DOMElement or DOMDocument (see DOMDocument::load and DOMDocument::loadHTML)
+ *
+ * @param DOMNode $el
+ */
+ public function __construct(DOMNode $el)
+ {
+ if ($el instanceof DOMDocument) {
+ $el = $el->documentElement;
+ }
+
+ if (!$el instanceof DOMElement) {
+ throw new InvalidArgumentException('Invalid arguments, expected DOMElement or DOMDocument');
+ }
+
+ $this->start = $el;
+ }
+
+ /**
+ * Returns position in text as DOMText node and character offset.
+ * (it's NOT a byte offset, you must use mb_substr() or similar to use this offset properly).
+ * node may be NULL if iterator has finished.
+ *
+ * @return array
+ */
+ public function currentTextPosition(): array
+ {
+ return [$this->current, $this->offset];
+ }
+
+ /**
+ * Returns DOMElement that is currently being iterated or NULL if iterator has finished.
+ *
+ * @return DOMElement|null
+ */
+ public function currentElement(): ?DOMElement
+ {
+ return $this->current ? $this->current->parentNode : null;
+ }
+
+ // Implementation of Iterator interface
+
+ /**
+ * @return int|null
+ */
+ public function key(): ?int
+ {
+ return $this->key;
+ }
+
+ /**
+ * @return void
+ */
+ public function next(): void
+ {
+ if (null === $this->current) {
+ return;
+ }
+
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ if ($this->offset === -1) {
+ preg_match_all('/./us', $this->current->textContent, $m);
+ $this->letters = $m[0];
+ }
+
+ $this->offset++;
+ $this->key++;
+ if ($this->letters && $this->offset < count($this->letters)) {
+ return;
+ }
+
+ $this->offset = -1;
+ }
+
+ while ($this->current->nodeType === XML_ELEMENT_NODE && $this->current->firstChild) {
+ $this->current = $this->current->firstChild;
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ $this->next();
+ return;
+ }
+ }
+
+ while (!$this->current->nextSibling && $this->current->parentNode) {
+ $this->current = $this->current->parentNode;
+ if ($this->current === $this->start) {
+ $this->current = null;
+ return;
+ }
+ }
+
+ $this->current = $this->current->nextSibling;
+
+ $this->next();
+ }
+
+ /**
+ * Return the current element
+ * @link https://php.net/manual/en/iterator.current.php
+ *
+ * @return string|null
+ */
+ public function current(): ?string
+ {
+ return $this->letters ? $this->letters[$this->offset] : null;
+ }
+
+ /**
+ * Checks if current position is valid
+ * @link https://php.net/manual/en/iterator.valid.php
+ *
+ * @return bool
+ */
+ public function valid(): bool
+ {
+ return (bool)$this->current;
+ }
+
+ /**
+ * @return void
+ */
+ public function rewind(): void
+ {
+ $this->current = $this->start;
+ $this->offset = -1;
+ $this->key = 0;
+ $this->letters = [];
+
+ $this->next();
+ }
+}
+
diff --git a/system/src/DOMWordsIterator.php b/system/src/DOMWordsIterator.php
new file mode 100644
index 000000000..fb7c2e374
--- /dev/null
+++ b/system/src/DOMWordsIterator.php
@@ -0,0 +1,158 @@
+load('example.xml');
+ * foreach(new DOMWordsIterator($doc) as $word) echo $word;
+ *
+ * @author pjgalbraith http://www.pjgalbraith.com
+ * @author porneL http://pornel.net (based on DOMLettersIterator available at http://pornel.net/source/domlettersiterator.php)
+ * @license Public Domain
+ * @url https://github.com/antoligy/dom-string-iterators
+ *
+ * @implements Iterator
+ */
+
+final class DOMWordsIterator implements Iterator
+{
+ /** @var DOMElement */
+ private $start;
+ /** @var DOMElement|null */
+ private $current;
+ /** @var int */
+ private $offset = -1;
+ /** @var int|null */
+ private $key;
+ /** @var array>|null */
+ private $words;
+
+ /**
+ * expects DOMElement or DOMDocument (see DOMDocument::load and DOMDocument::loadHTML)
+ *
+ * @param DOMNode $el
+ */
+ public function __construct(DOMNode $el)
+ {
+ if ($el instanceof DOMDocument) {
+ $el = $el->documentElement;
+ }
+
+ if (!$el instanceof DOMElement) {
+ throw new InvalidArgumentException('Invalid arguments, expected DOMElement or DOMDocument');
+ }
+
+ $this->start = $el;
+ }
+
+ /**
+ * Returns position in text as DOMText node and character offset.
+ * (it's NOT a byte offset, you must use mb_substr() or similar to use this offset properly).
+ * node may be NULL if iterator has finished.
+ *
+ * @return array
+ */
+ public function currentWordPosition(): array
+ {
+ return [$this->current, $this->offset, $this->words];
+ }
+
+ /**
+ * Returns DOMElement that is currently being iterated or NULL if iterator has finished.
+ *
+ * @return DOMElement|null
+ */
+ public function currentElement(): ?DOMElement
+ {
+ return $this->current ? $this->current->parentNode : null;
+ }
+
+ // Implementation of Iterator interface
+
+ /**
+ * Return the key of the current element
+ * @link https://php.net/manual/en/iterator.key.php
+ * @return int|null
+ */
+ public function key(): ?int
+ {
+ return $this->key;
+ }
+
+ /**
+ * @return void
+ */
+ public function next(): void
+ {
+ if (null === $this->current) {
+ return;
+ }
+
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ if ($this->offset === -1) {
+ $this->words = preg_split("/[\n\r\t ]+/", $this->current->textContent, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_OFFSET_CAPTURE) ?: [];
+ }
+ $this->offset++;
+
+ if ($this->words && $this->offset < count($this->words)) {
+ $this->key++;
+ return;
+ }
+ $this->offset = -1;
+ }
+
+ while ($this->current->nodeType === XML_ELEMENT_NODE && $this->current->firstChild) {
+ $this->current = $this->current->firstChild;
+ if ($this->current->nodeType === XML_TEXT_NODE || $this->current->nodeType === XML_CDATA_SECTION_NODE) {
+ $this->next();
+ return;
+ }
+ }
+
+ while (!$this->current->nextSibling && $this->current->parentNode) {
+ $this->current = $this->current->parentNode;
+ if ($this->current === $this->start) {
+ $this->current = null;
+ return;
+ }
+ }
+
+ $this->current = $this->current->nextSibling;
+
+ $this->next();
+ }
+
+ /**
+ * Return the current element
+ * @link https://php.net/manual/en/iterator.current.php
+ * @return string|null
+ */
+ public function current(): ?string
+ {
+ return $this->words ? (string)$this->words[$this->offset][0] : null;
+ }
+
+ /**
+ * Checks if current position is valid
+ * @link https://php.net/manual/en/iterator.valid.php
+ * @return bool
+ */
+ public function valid(): bool
+ {
+ return (bool)$this->current;
+ }
+
+ public function rewind(): void
+ {
+ $this->current = $this->start;
+ $this->offset = -1;
+ $this->key = 0;
+ $this->words = [];
+
+ $this->next();
+ }
+}
diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php
index a9b930b13..134c62fba 100644
--- a/system/src/Grav/Common/Assets.php
+++ b/system/src/Grav/Common/Assets.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -30,14 +30,21 @@ class Assets extends PropertyObject
use TestingAssetsTrait;
use LegacyAssetsTrait;
+ const LINK = 'link';
const CSS = 'css';
const JS = 'js';
+ const JS_MODULE = 'js_module';
+ const LINK_COLLECTION = 'assets_link';
const CSS_COLLECTION = 'assets_css';
const JS_COLLECTION = 'assets_js';
+ const JS_MODULE_COLLECTION = 'assets_js_module';
+ const LINK_TYPE = Assets\Link::class;
const CSS_TYPE = Assets\Css::class;
const JS_TYPE = Assets\Js::class;
+ const JS_MODULE_TYPE = Assets\JsModule::class;
const INLINE_CSS_TYPE = Assets\InlineCss::class;
const INLINE_JS_TYPE = Assets\InlineJs::class;
+ const INLINE_JS_MODULE_TYPE = Assets\InlineJsModule::class;
/** @const Regex to match CSS and JavaScript files */
const DEFAULT_REGEX = '/.\.(css|js)$/i';
@@ -48,15 +55,24 @@ class Assets extends PropertyObject
/** @const Regex to match JavaScript files */
const JS_REGEX = '/.\.js$/i';
+ /** @const Regex to match JavaScriptModyle files */
+ const JS_MODULE_REGEX = '/.\.mjs$/i';
+
/** @var string */
protected $assets_dir;
/** @var string */
protected $assets_url;
+ /** @var array */
+ protected $assets_link = [];
/** @var array */
protected $assets_css = [];
/** @var array */
protected $assets_js = [];
+ /** @var array */
+ protected $assets_js_module = [];
+
+
// Following variables come from the configuration:
/** @var bool */
@@ -66,19 +82,17 @@ class Assets extends PropertyObject
/** @var bool */
protected $css_pipeline_before_excludes;
/** @var bool */
- protected $inlinecss_pipeline_include_externals;
- /** @var bool */
- protected $inlinecss_pipeline_before_excludes;
- /** @var bool */
protected $js_pipeline;
/** @var bool */
protected $js_pipeline_include_externals;
/** @var bool */
protected $js_pipeline_before_excludes;
/** @var bool */
- protected $inlinejs_pipeline_include_externals;
+ protected $js_module_pipeline;
/** @var bool */
- protected $inlinejs_pipeline_before_excludes;
+ protected $js_module_pipeline_include_externals;
+ /** @var bool */
+ protected $js_module_pipeline_before_excludes;
/** @var array */
protected $pipeline_options = [];
@@ -184,7 +198,7 @@ class Assets extends PropertyObject
call_user_func_array([$this, 'add'], $args);
} else {
// Get extension
- $extension = pathinfo(parse_url($asset, PHP_URL_PATH), PATHINFO_EXTENSION);
+ $extension = Utils::pathinfo(parse_url($asset, PHP_URL_PATH), PATHINFO_EXTENSION);
// JavaScript or CSS
if ($extension !== '') {
@@ -193,6 +207,8 @@ class Assets extends PropertyObject
call_user_func_array([$this, 'addCss'], $args);
} elseif ($extension === 'js') {
call_user_func_array([$this, 'addJs'], $args);
+ } elseif ($extension === 'mjs') {
+ call_user_func_array([$this, 'addJsModule'], $args);
}
}
}
@@ -222,7 +238,7 @@ class Assets extends PropertyObject
return $this;
}
- if (($type === $this::CSS_TYPE || $type === $this::JS_TYPE) && isset($this->collections[$asset])) {
+ if ($this->isValidType($type) && isset($this->collections[$asset])) {
$this->addType($collection, $type, $this->collections[$asset], $options);
return $this;
}
@@ -230,7 +246,9 @@ class Assets extends PropertyObject
// If pipeline disabled, set to position if provided, else after
if (isset($options['pipeline'])) {
if ($options['pipeline'] === false) {
- $exclude_type = ($type === $this::JS_TYPE || $type === $this::INLINE_JS_TYPE) ? $this::JS : $this::CSS;
+
+ $exclude_type = $this->getBaseType($type);
+
$excludes = strtolower($exclude_type . '_pipeline_before_excludes');
if ($this->{$excludes}) {
$default = 'after';
@@ -269,6 +287,16 @@ class Assets extends PropertyObject
return $this;
}
+ /**
+ * Add a CSS asset or a collection of assets.
+ *
+ * @return $this
+ */
+ public function addLink($asset)
+ {
+ return $this->addType($this::LINK_COLLECTION, $this::LINK_TYPE, $asset, $this->unifyLegacyArguments(func_get_args(), $this::LINK_TYPE));
+ }
+
/**
* Add a CSS asset or a collection of assets.
*
@@ -309,6 +337,25 @@ class Assets extends PropertyObject
return $this->addType($this::JS_COLLECTION, $this::INLINE_JS_TYPE, $asset, $this->unifyLegacyArguments(func_get_args(), $this::INLINE_JS_TYPE));
}
+ /**
+ * Add a JS asset or a collection of assets.
+ *
+ * @return $this
+ */
+ public function addJsModule($asset)
+ {
+ return $this->addType($this::JS_MODULE_COLLECTION, $this::JS_MODULE_TYPE, $asset, $this->unifyLegacyArguments(func_get_args(), $this::JS_MODULE_TYPE));
+ }
+
+ /**
+ * Add an Inline JS asset or a collection of assets.
+ *
+ * @return $this
+ */
+ public function addInlineJsModule($asset)
+ {
+ return $this->addType($this::JS_MODULE_COLLECTION, $this::INLINE_JS_MODULE_TYPE, $asset, $this->unifyLegacyArguments(func_get_args(), $this::INLINE_JS_MODULE_TYPE));
+ }
/**
* Add/replace collection.
@@ -400,7 +447,7 @@ class Assets extends PropertyObject
$after_assets = $this->filterAssets($group_assets, 'position', 'after', true);
// Pipeline
- if ($this->{$pipeline_enabled}) {
+ if ($this->{$pipeline_enabled} ?? false) {
$options = array_merge($this->pipeline_options, ['timestamp' => $this->timestamp]);
$pipeline = new Pipeline($options);
@@ -432,9 +479,29 @@ class Assets extends PropertyObject
* @param array $attributes
* @return string
*/
- public function css($group = 'head', $attributes = [])
+ public function css($group = 'head', $attributes = [], $include_link = true)
{
- return $this->render('css', $group, $attributes);
+ $output = '';
+
+ if ($include_link) {
+ $output = $this->link($group, $attributes);
+ }
+
+ $output .= $this->render(self::CSS, $group, $attributes);
+
+ return $output;
+ }
+
+ /**
+ * Build the CSS link tags.
+ *
+ * @param string $group name of the group
+ * @param array $attributes
+ * @return string
+ */
+ public function link($group = 'head', $attributes = [])
+ {
+ return $this->render(self::LINK, $group, $attributes);
}
/**
@@ -444,8 +511,58 @@ class Assets extends PropertyObject
* @param array $attributes
* @return string
*/
- public function js($group = 'head', $attributes = [])
+ public function js($group = 'head', $attributes = [], $include_js_module = true)
{
- return $this->render('js', $group, $attributes);
+ $output = $this->render(self::JS, $group, $attributes);
+
+ if ($include_js_module) {
+ $output .= $this->jsModule($group, $attributes);
+ }
+
+ return $output;
+ }
+
+ /**
+ * Build the Javascript Modules tags
+ *
+ * @param $group
+ * @param $attributes
+ * @return string
+ */
+ public function jsModule($group = 'head', $attributes = [])
+ {
+ return $this->render(self::JS_MODULE, $group, $attributes);
+ }
+
+ public function all($group = 'head', $attributes = [])
+ {
+ $output = $this->css($group, $attributes, false);
+ $output .= $this->link($group, $attributes);
+ $output .= $this->js($group, $attributes, false);
+ $output .= $this->jsModule($group, $attributes);
+ return $output;
+ }
+
+ protected function isValidType($type)
+ {
+ return in_array($type, [self::CSS_TYPE, self::JS_TYPE, self::JS_MODULE_TYPE]);
+ }
+
+ protected function getBaseType($type)
+ {
+ switch ($type) {
+ case $this::JS_TYPE:
+ case $this::INLINE_JS_TYPE:
+ $base_type = $this::JS;
+ break;
+ case $this::JS_MODULE_TYPE:
+ case $this::INLINE_JS_MODULE_TYPE:
+ $base_type = $this::JS_MODULE;
+ break;
+ default:
+ $base_type = $this::CSS;
+ }
+
+ return $base_type;
}
}
diff --git a/system/src/Grav/Common/Assets/BaseAsset.php b/system/src/Grav/Common/Assets/BaseAsset.php
index a80d9c6d9..d062d759b 100644
--- a/system/src/Grav/Common/Assets/BaseAsset.php
+++ b/system/src/Grav/Common/Assets/BaseAsset.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -26,8 +26,9 @@ abstract class BaseAsset extends PropertyObject
{
use AssetUtilsTrait;
- protected const CSS_ASSET = true;
- protected const JS_ASSET = false;
+ protected const CSS_ASSET = 1;
+ protected const JS_ASSET = 2;
+ protected const JS_MODULE_ASSET = 3;
/** @var string|false */
protected $asset;
@@ -69,7 +70,7 @@ abstract class BaseAsset extends PropertyObject
* @param array $elements
* @param string|null $key
*/
- public function __construct(array $elements = [], $key = null)
+ public function __construct(array $elements = [], ?string $key = null)
{
$base_config = [
'group' => 'head',
@@ -266,4 +267,17 @@ abstract class BaseAsset extends PropertyObject
{
return '';
}
+
+ /**
+ * Finds relative JS urls() and rewrites the URL with an absolute one
+ *
+ * @param string $file the css source file
+ * @param string $dir local relative path to the css file
+ * @param bool $local is this a local or remote asset
+ * @return string
+ */
+ protected function jsRewrite($file, $dir, $local)
+ {
+ return '';
+ }
}
diff --git a/system/src/Grav/Common/Assets/BlockAssets.php b/system/src/Grav/Common/Assets/BlockAssets.php
new file mode 100644
index 000000000..798bdd304
--- /dev/null
+++ b/system/src/Grav/Common/Assets/BlockAssets.php
@@ -0,0 +1,207 @@
+getAssets();
+ foreach ($types as $type => $groups) {
+ switch ($type) {
+ case 'frameworks':
+ static::registerFrameworks($assets, $groups);
+ break;
+ case 'styles':
+ static::registerStyles($assets, $groups);
+ break;
+ case 'scripts':
+ static::registerScripts($assets, $groups);
+ break;
+ case 'links':
+ static::registerLinks($assets, $groups);
+ break;
+ case 'html':
+ static::registerHtml($assets, $groups);
+ break;
+ }
+ }
+ }
+
+ /**
+ * @param Assets $assets
+ * @param array $groups
+ * @return void
+ */
+ protected static function registerFrameworks(Assets $assets, array $list): void
+ {
+ if ($list) {
+ throw new \RuntimeException('Not Implemented');
+ }
+ }
+
+ /**
+ * @param Assets $assets
+ * @param array $groups
+ * @return void
+ */
+ protected static function registerStyles(Assets $assets, array $groups): void
+ {
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ foreach ($groups as $group => $styles) {
+ foreach ($styles as $style) {
+ switch ($style[':type']) {
+ case 'file':
+ $options = [
+ 'priority' => $style[':priority'],
+ 'group' => $group,
+ 'type' => $style['type'],
+ 'media' => $style['media']
+ ] + $style['element'];
+
+ $assets->addCss(static::getRelativeUrl($style['href'], $config->get('system.assets.css_pipeline')), $options);
+ break;
+ case 'inline':
+ $options = [
+ 'priority' => $style[':priority'],
+ 'group' => $group,
+ 'type' => $style['type'],
+ ] + $style['element'];
+
+ $assets->addInlineCss($style['content'], $options);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param Assets $assets
+ * @param array $groups
+ * @return void
+ */
+ protected static function registerScripts(Assets $assets, array $groups): void
+ {
+ $grav = Grav::instance();
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ foreach ($groups as $group => $scripts) {
+ $group = $group === 'footer' ? 'bottom' : $group;
+
+ foreach ($scripts as $script) {
+ switch ($script[':type']) {
+ case 'file':
+ $options = [
+ 'group' => $group,
+ 'priority' => $script[':priority'],
+ 'src' => $script['src'],
+ 'type' => $script['type'],
+ 'loading' => $script['loading'],
+ 'defer' => $script['defer'],
+ 'async' => $script['async'],
+ 'handle' => $script['handle']
+ ] + $script['element'];
+
+ $assets->addJs(static::getRelativeUrl($script['src'], $config->get('system.assets.js_pipeline')), $options);
+ break;
+ case 'inline':
+ $options = [
+ 'priority' => $script[':priority'],
+ 'group' => $group,
+ 'type' => $script['type'],
+ 'loading' => $script['loading']
+ ] + $script['element'];
+
+ $assets->addInlineJs($script['content'], $options);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param Assets $assets
+ * @param array $groups
+ * @return void
+ */
+ protected static function registerLinks(Assets $assets, array $groups): void
+ {
+ foreach ($groups as $group => $links) {
+ foreach ($links as $link) {
+ $href = $link['href'];
+ $options = [
+ 'group' => $group,
+ 'priority' => $link[':priority'],
+ 'rel' => $link['rel'],
+ ] + $link['element'];
+
+ $assets->addLink($href, $options);
+ }
+ }
+ }
+
+ /**
+ * @param Assets $assets
+ * @param array $groups
+ * @return void
+ */
+ protected static function registerHtml(Assets $assets, array $groups): void
+ {
+ if ($groups) {
+ throw new \RuntimeException('Not Implemented');
+ }
+ }
+
+ /**
+ * @param string $url
+ * @param bool $pipeline
+ * @return string
+ */
+ protected static function getRelativeUrl($url, $pipeline)
+ {
+ $grav = Grav::instance();
+
+ $base = rtrim($grav['base_url'], '/') ?: '/';
+
+ if (strpos($url, $base) === 0) {
+ if ($pipeline) {
+ // Remove file timestamp if CSS pipeline has been enabled.
+ $url = preg_replace('|[?#].*|', '', $url);
+ }
+
+ return substr($url, strlen($base) - 1);
+ }
+ return $url;
+ }
+}
diff --git a/system/src/Grav/Common/Assets/Css.php b/system/src/Grav/Common/Assets/Css.php
index 4c6a9c9b0..ea6b388fa 100644
--- a/system/src/Grav/Common/Assets/Css.php
+++ b/system/src/Grav/Common/Assets/Css.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,7 @@ class Css extends BaseAsset
* @param array $elements
* @param string|null $key
*/
- public function __construct(array $elements = [], $key = null)
+ public function __construct(array $elements = [], ?string $key = null)
{
$base_options = [
'asset_type' => 'css',
diff --git a/system/src/Grav/Common/Assets/InlineCss.php b/system/src/Grav/Common/Assets/InlineCss.php
index f024a95a4..4984db4d1 100644
--- a/system/src/Grav/Common/Assets/InlineCss.php
+++ b/system/src/Grav/Common/Assets/InlineCss.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,7 @@ class InlineCss extends BaseAsset
* @param array $elements
* @param string|null $key
*/
- public function __construct(array $elements = [], $key = null)
+ public function __construct(array $elements = [], ?string $key = null)
{
$base_options = [
'asset_type' => 'css',
diff --git a/system/src/Grav/Common/Assets/InlineJs.php b/system/src/Grav/Common/Assets/InlineJs.php
index 6787608d6..e38a51aee 100644
--- a/system/src/Grav/Common/Assets/InlineJs.php
+++ b/system/src/Grav/Common/Assets/InlineJs.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,7 @@ class InlineJs extends BaseAsset
* @param array $elements
* @param string|null $key
*/
- public function __construct(array $elements = [], $key = null)
+ public function __construct(array $elements = [], ?string $key = null)
{
$base_options = [
'asset_type' => 'js',
diff --git a/system/src/Grav/Common/Assets/InlineJsModule.php b/system/src/Grav/Common/Assets/InlineJsModule.php
new file mode 100644
index 000000000..42ce6f14a
--- /dev/null
+++ b/system/src/Grav/Common/Assets/InlineJsModule.php
@@ -0,0 +1,46 @@
+ 'js_module',
+ 'attributes' => ['type' => 'module'],
+ 'position' => 'after'
+ ];
+
+ $merged_attributes = Utils::arrayMergeRecursiveUnique($base_options, $elements);
+
+ parent::__construct($merged_attributes, $key);
+ }
+
+ /**
+ * @return string
+ */
+ public function render()
+ {
+ return '\n";
+ }
+
+}
diff --git a/system/src/Grav/Common/Assets/Js.php b/system/src/Grav/Common/Assets/Js.php
index fc2a472fd..8687a86b1 100644
--- a/system/src/Grav/Common/Assets/Js.php
+++ b/system/src/Grav/Common/Assets/Js.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,7 @@ class Js extends BaseAsset
* @param array $elements
* @param string|null $key
*/
- public function __construct(array $elements = [], $key = null)
+ public function __construct(array $elements = [], ?string $key = null)
{
$base_options = [
'asset_type' => 'js',
diff --git a/system/src/Grav/Common/Assets/JsModule.php b/system/src/Grav/Common/Assets/JsModule.php
new file mode 100644
index 000000000..5c2a836c2
--- /dev/null
+++ b/system/src/Grav/Common/Assets/JsModule.php
@@ -0,0 +1,49 @@
+ 'js_module',
+ 'attributes' => ['type' => 'module']
+ ];
+
+ $merged_attributes = Utils::arrayMergeRecursiveUnique($base_options, $elements);
+
+ parent::__construct($merged_attributes, $key);
+ }
+
+ /**
+ * @return string
+ */
+ public function render()
+ {
+ if (isset($this->attributes['loading']) && $this->attributes['loading'] === 'inline') {
+ $buffer = $this->gatherLinks([$this], self::JS_MODULE_ASSET);
+ return '\n";
+ }
+
+ return '\n";
+ }
+}
diff --git a/system/src/Grav/Common/Assets/Link.php b/system/src/Grav/Common/Assets/Link.php
new file mode 100644
index 000000000..ecafcea90
--- /dev/null
+++ b/system/src/Grav/Common/Assets/Link.php
@@ -0,0 +1,43 @@
+ 'link',
+ ];
+
+ $merged_attributes = Utils::arrayMergeRecursiveUnique($base_options, $elements);
+
+ parent::__construct($merged_attributes, $key);
+ }
+
+ /**
+ * @return string
+ */
+ public function render()
+ {
+ return 'renderAttributes() . $this->integrityHash($this->asset) . ">\n";
+ }
+}
diff --git a/system/src/Grav/Common/Assets/Pipeline.php b/system/src/Grav/Common/Assets/Pipeline.php
index 0135e89bd..0010d7bd4 100644
--- a/system/src/Grav/Common/Assets/Pipeline.php
+++ b/system/src/Grav/Common/Assets/Pipeline.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -29,12 +29,16 @@ class Pipeline extends PropertyObject
{
use AssetUtilsTrait;
- protected const CSS_ASSET = true;
- protected const JS_ASSET = false;
+ protected const CSS_ASSET = 1;
+ protected const JS_ASSET = 2;
+ protected const JS_MODULE_ASSET = 3;
/** @const Regex to match CSS urls */
protected const CSS_URL_REGEX = '{url\(([\'\"]?)(.*?)\1\)}';
+ /** @const Regex to match JS imports */
+ protected const JS_IMPORT_REGEX = '{import.+from\s?[\'|\"](.+?)[\'|\"]}';
+
/** @const Regex to match CSS sourcemap comments */
protected const CSS_SOURCEMAP_REGEX = '{\/\*# (.*?) \*\/}';
@@ -169,7 +173,7 @@ class Pipeline extends PropertyObject
* @param array $attributes
* @return bool|string URL or generated content if available, else false
*/
- public function renderJs($assets, $group, $attributes = [])
+ public function renderJs($assets, $group, $attributes = [], $type = self::JS_ASSET)
{
// temporary list of assets to pipeline
$inline_group = false;
@@ -198,7 +202,7 @@ class Pipeline extends PropertyObject
}
// Concatenate files
- $buffer = $this->gatherLinks($assets, self::JS_ASSET);
+ $buffer = $this->gatherLinks($assets, $type);
// Minify if required
if ($this->shouldMinify('js')) {
@@ -223,6 +227,19 @@ class Pipeline extends PropertyObject
return $output;
}
+ /**
+ * Minify and concatenate JS files.
+ *
+ * @param array $assets
+ * @param string $group
+ * @param array $attributes
+ * @return bool|string URL or generated content if available, else false
+ */
+ public function renderJs_Module($assets, $group, $attributes = [])
+ {
+ $attributes['type'] = 'module';
+ return $this->renderJs($assets, $group, $attributes, self::JS_MODULE_ASSET);
+ }
/**
* Finds relative CSS urls() and rewrites the URL with an absolute one
@@ -262,6 +279,42 @@ class Pipeline extends PropertyObject
return $file;
}
+ /**
+ * Finds relative JS urls() and rewrites the URL with an absolute one
+ *
+ * @param string $file the css source file
+ * @param string $dir local relative path to the css file
+ * @param bool $local is this a local or remote asset
+ * @return string
+ */
+ protected function jsRewrite($file, $dir, $local)
+ {
+ // Find any js import elements, grab the URLs and calculate an absolute path
+ // Then replace the old url with the new one
+ $file = (string)preg_replace_callback(self::JS_IMPORT_REGEX, function ($matches) use ($dir, $local) {
+
+ $old_url = $matches[1];
+
+ // Ensure link is not rooted to web server, a data URL, or to a remote host
+ if (preg_match(self::FIRST_FORWARDSLASH_REGEX, $old_url) || $this->isRemoteLink($old_url)) {
+ return $matches[0];
+ }
+
+ // clean leading /
+ $old_url = Utils::normalizePath($dir . '/' . $old_url);
+ $old_url = str_replace('/./', '/', $old_url);
+ if (preg_match(self::FIRST_FORWARDSLASH_REGEX, $old_url)) {
+ $old_url = ltrim($old_url, '/');
+ }
+
+ $new_url = ($local ? $this->base_url : '') . $old_url;
+
+ return str_replace($matches[1], $new_url, $matches[0]);
+ }, $file);
+
+ return $file;
+ }
+
/**
* @param string $type
* @return bool
diff --git a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
index 3f5a690fb..0e3f392af 100644
--- a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
+++ b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets\Traits
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -62,13 +62,13 @@ trait AssetUtilsTrait
* Download and concatenate the content of several links.
*
* @param array $assets
- * @param bool $css
+ * @param int $type
* @return string
*/
- protected function gatherLinks(array $assets, $css = true)
+ protected function gatherLinks(array $assets, int $type = self::CSS_ASSET): string
{
$buffer = '';
- foreach ($assets as $id => $asset) {
+ foreach ($assets as $asset) {
$local = true;
$link = $asset->getAsset();
@@ -100,21 +100,25 @@ trait AssetUtilsTrait
}
// Double check last character being
- if (!$css) {
+ if ($type === self::JS_ASSET || $type === self::JS_MODULE_ASSET) {
$file = rtrim($file, ' ;') . ';';
}
// If this is CSS + the file is local + rewrite enabled
- if ($css && $this->css_rewrite) {
+ if ($type === self::CSS_ASSET && $this->css_rewrite) {
$file = $this->cssRewrite($file, $relative_dir, $local);
}
+ if ($type === self::JS_MODULE_ASSET) {
+ $file = $this->jsRewrite($file, $relative_dir, $local);
+ }
+
$file = rtrim($file) . PHP_EOL;
$buffer .= $file;
}
// Pull out @imports and move to top
- if ($css) {
+ if ($type === self::CSS_ASSET) {
$buffer = $this->moveImports($buffer);
}
diff --git a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
index 36b21522d..c1ef0a3c3 100644
--- a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
+++ b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets\Traits
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
index 15dc00e3d..b11b439b6 100644
--- a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
+++ b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Assets\Traits
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -285,6 +285,15 @@ trait TestingAssetsTrait
return $this;
}
+ // Add JavaScript Module files
+ if ($pattern === self::JS_MODULE_REGEX) {
+ foreach ($files as $file) {
+ $this->addJsModule($file);
+ }
+
+ return $this;
+ }
+
// Unknown pattern.
foreach ($files as $asset) {
$this->add($asset);
diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php
index 158e12e2f..9c23908c4 100644
--- a/system/src/Grav/Common/Backup/Backups.php
+++ b/system/src/Grav/Common/Backup/Backups.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Backup
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -105,7 +105,7 @@ class Backups
public function getBackupDownloadUrl($backup, $base_url)
{
$param_sep = $param_sep = Grav::instance()['config']->get('system.param_sep', ':');
- $download = urlencode(base64_encode(basename($backup)));
+ $download = urlencode(base64_encode(Utils::basename($backup)));
$url = rtrim(Grav::instance()['uri']->rootUrl(true), '/') . '/' . trim(
$base_url,
'/'
diff --git a/system/src/Grav/Common/Browser.php b/system/src/Grav/Common/Browser.php
index e4a6513ea..ffc8da313 100644
--- a/system/src/Grav/Common/Browser.php
+++ b/system/src/Grav/Common/Browser.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php
index a50351836..ed40a085f 100644
--- a/system/src/Grav/Common/Cache.php
+++ b/system/src/Grav/Common/Cache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -177,7 +177,7 @@ class Cache extends Getters
public function purgeOldCache()
{
$cache_dir = dirname($this->cache_dir);
- $current = basename($this->cache_dir);
+ $current = Utils::basename($this->cache_dir);
$count = 0;
foreach (new DirectoryIterator($cache_dir) as $file) {
diff --git a/system/src/Grav/Common/Composer.php b/system/src/Grav/Common/Composer.php
index f1f6e5d3e..667edf25c 100644
--- a/system/src/Grav/Common/Composer.php
+++ b/system/src/Grav/Common/Composer.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledBase.php b/system/src/Grav/Common/Config/CompiledBase.php
index 0764189d2..b462b4cfd 100644
--- a/system/src/Grav/Common/Config/CompiledBase.php
+++ b/system/src/Grav/Common/Config/CompiledBase.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledBlueprints.php b/system/src/Grav/Common/Config/CompiledBlueprints.php
index 774305425..e83859144 100644
--- a/system/src/Grav/Common/Config/CompiledBlueprints.php
+++ b/system/src/Grav/Common/Config/CompiledBlueprints.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledConfig.php b/system/src/Grav/Common/Config/CompiledConfig.php
index 22225bce5..2db6de5a6 100644
--- a/system/src/Grav/Common/Config/CompiledConfig.php
+++ b/system/src/Grav/Common/Config/CompiledConfig.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/CompiledLanguages.php b/system/src/Grav/Common/Config/CompiledLanguages.php
index 6674389ac..0a2668638 100644
--- a/system/src/Grav/Common/Config/CompiledLanguages.php
+++ b/system/src/Grav/Common/Config/CompiledLanguages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php
index 7adb523e8..ca027bf46 100644
--- a/system/src/Grav/Common/Config/Config.php
+++ b/system/src/Grav/Common/Config/Config.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/ConfigFileFinder.php b/system/src/Grav/Common/Config/ConfigFileFinder.php
index e6b1afeaf..28f9dc11a 100644
--- a/system/src/Grav/Common/Config/ConfigFileFinder.php
+++ b/system/src/Grav/Common/Config/ConfigFileFinder.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/Languages.php b/system/src/Grav/Common/Config/Languages.php
index 4a863a1b6..05798c573 100644
--- a/system/src/Grav/Common/Config/Languages.php
+++ b/system/src/Grav/Common/Config/Languages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Config/Setup.php b/system/src/Grav/Common/Config/Setup.php
index 6ff7372d0..f8ce94394 100644
--- a/system/src/Grav/Common/Config/Setup.php
+++ b/system/src/Grav/Common/Config/Setup.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Config
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -401,7 +401,7 @@ class Setup extends Data
}
// Create security.yaml salt if it doesn't exist into existing configuration environment if possible.
- $securityFile = basename(static::$securityFile);
+ $securityFile = Utils::basename(static::$securityFile);
$securityFolder = substr(static::$securityFile, 0, -\strlen($securityFile));
$securityFolder = $locator->findResource($securityFolder, true) ?: $locator->findResource($securityFolder, true, true);
$filename = "{$securityFolder}/{$securityFile}";
diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php
index e4f841921..ef6aef50d 100644
--- a/system/src/Grav/Common/Data/Blueprint.php
+++ b/system/src/Grav/Common/Data/Blueprint.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php
index c28ed7a8d..8cc63036e 100644
--- a/system/src/Grav/Common/Data/BlueprintSchema.php
+++ b/system/src/Grav/Common/Data/BlueprintSchema.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/Blueprints.php b/system/src/Grav/Common/Data/Blueprints.php
index abe153f14..dfdd46f72 100644
--- a/system/src/Grav/Common/Data/Blueprints.php
+++ b/system/src/Grav/Common/Data/Blueprints.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php
index 60ee9534d..0f09b2d26 100644
--- a/system/src/Grav/Common/Data/Data.php
+++ b/system/src/Grav/Common/Data/Data.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/DataInterface.php b/system/src/Grav/Common/Data/DataInterface.php
index b4452bb85..a4bc2140d 100644
--- a/system/src/Grav/Common/Data/DataInterface.php
+++ b/system/src/Grav/Common/Data/DataInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php
index 9c23f81c2..569ea512a 100644
--- a/system/src/Grav/Common/Data/Validation.php
+++ b/system/src/Grav/Common/Data/Validation.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Data/ValidationException.php b/system/src/Grav/Common/Data/ValidationException.php
index be6a674d7..9a3d900d1 100644
--- a/system/src/Grav/Common/Data/ValidationException.php
+++ b/system/src/Grav/Common/Data/ValidationException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Data
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php
index 15c704b44..e7b162454 100644
--- a/system/src/Grav/Common/Debugger.php
+++ b/system/src/Grav/Common/Debugger.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Errors/BareHandler.php b/system/src/Grav/Common/Errors/BareHandler.php
index 206b57e85..909382717 100644
--- a/system/src/Grav/Common/Errors/BareHandler.php
+++ b/system/src/Grav/Common/Errors/BareHandler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Errors/Errors.php b/system/src/Grav/Common/Errors/Errors.php
index 3dc99c665..92f885bfd 100644
--- a/system/src/Grav/Common/Errors/Errors.php
+++ b/system/src/Grav/Common/Errors/Errors.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Errors/SimplePageHandler.php b/system/src/Grav/Common/Errors/SimplePageHandler.php
index 0118929aa..80c4f9676 100644
--- a/system/src/Grav/Common/Errors/SimplePageHandler.php
+++ b/system/src/Grav/Common/Errors/SimplePageHandler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Errors/SystemFacade.php b/system/src/Grav/Common/Errors/SystemFacade.php
index 8a7f1ceb2..edf2b5338 100644
--- a/system/src/Grav/Common/Errors/SystemFacade.php
+++ b/system/src/Grav/Common/Errors/SystemFacade.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Errors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/File/CompiledFile.php b/system/src/Grav/Common/File/CompiledFile.php
index 66fa6201d..222842278 100644
--- a/system/src/Grav/Common/File/CompiledFile.php
+++ b/system/src/Grav/Common/File/CompiledFile.php
@@ -3,13 +3,14 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\File;
use Exception;
+use Grav\Common\Utils;
use RocketTheme\Toolbox\File\PhpFile;
use RuntimeException;
use Throwable;
@@ -88,7 +89,7 @@ trait CompiledFile
$this->content = $cache['data'];
}
} catch (Exception $e) {
- throw new RuntimeException(sprintf('Failed to read %s: %s', basename($this->filename), $e->getMessage()), 500, $e);
+ throw new RuntimeException(sprintf('Failed to read %s: %s', Utils::basename($this->filename), $e->getMessage()), 500, $e);
}
return parent::content($var);
diff --git a/system/src/Grav/Common/File/CompiledJsonFile.php b/system/src/Grav/Common/File/CompiledJsonFile.php
index dae95baaa..e8347bb07 100644
--- a/system/src/Grav/Common/File/CompiledJsonFile.php
+++ b/system/src/Grav/Common/File/CompiledJsonFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/File/CompiledMarkdownFile.php b/system/src/Grav/Common/File/CompiledMarkdownFile.php
index 1107417db..108311177 100644
--- a/system/src/Grav/Common/File/CompiledMarkdownFile.php
+++ b/system/src/Grav/Common/File/CompiledMarkdownFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/File/CompiledYamlFile.php b/system/src/Grav/Common/File/CompiledYamlFile.php
index 0fedeb717..0f0c64fd6 100644
--- a/system/src/Grav/Common/File/CompiledYamlFile.php
+++ b/system/src/Grav/Common/File/CompiledYamlFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/Archiver.php b/system/src/Grav/Common/Filesystem/Archiver.php
index 090bc13fa..4c291a569 100644
--- a/system/src/Grav/Common/Filesystem/Archiver.php
+++ b/system/src/Grav/Common/Filesystem/Archiver.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/Folder.php b/system/src/Grav/Common/Filesystem/Folder.php
index 6edd8e2e3..8dac2e578 100644
--- a/system/src/Grav/Common/Filesystem/Folder.php
+++ b/system/src/Grav/Common/Filesystem/Folder.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php b/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
index 0dac81c18..75c19bcc0 100644
--- a/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
+++ b/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php b/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
index ded0259cc..12d6c6b0f 100644
--- a/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
+++ b/system/src/Grav/Common/Filesystem/RecursiveFolderFilterIterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Filesystem/ZipArchiver.php b/system/src/Grav/Common/Filesystem/ZipArchiver.php
index 6e53e70a3..4f2a9eed6 100644
--- a/system/src/Grav/Common/Filesystem/ZipArchiver.php
+++ b/system/src/Grav/Common/Filesystem/ZipArchiver.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/FlexCollection.php b/system/src/Grav/Common/Flex/FlexCollection.php
index 6429c9e1e..704e21f5e 100644
--- a/system/src/Grav/Common/Flex/FlexCollection.php
+++ b/system/src/Grav/Common/Flex/FlexCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/FlexIndex.php b/system/src/Grav/Common/Flex/FlexIndex.php
index 44b6fdd6e..f903c88b2 100644
--- a/system/src/Grav/Common/Flex/FlexIndex.php
+++ b/system/src/Grav/Common/Flex/FlexIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/FlexObject.php b/system/src/Grav/Common/Flex/FlexObject.php
index b64aea1df..887d7a3f2 100644
--- a/system/src/Grav/Common/Flex/FlexObject.php
+++ b/system/src/Grav/Common/Flex/FlexObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php b/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php
index 29b640e75..b919b40c3 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php b/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php
index 1077e0089..9291a4257 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php b/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php
index 9d5c9e081..c34b89da9 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php b/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php
index 1d0ee5cc6..a71eb991d 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php b/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php
index 1175a3b47..3c81f07e8 100644
--- a/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php
+++ b/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php b/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php
index 6b2fbc1e6..e4ec3d459 100644
--- a/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php
+++ b/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php b/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php
index 81dbf9544..fdba5039c 100644
--- a/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php
+++ b/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php b/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php
index 4a5675287..eba642be9 100644
--- a/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php
+++ b/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
index c6a642da3..b6c5230d8 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -335,7 +335,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa
$list[$key] = $child->slug();
break;
case 'basename':
- $list[$key] = basename($key);
+ $list[$key] = Utils::basename($key);
break;
case 'folder':
$list[$key] = $child->folder();
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
index 71b407bb4..c0ca5c405 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -637,7 +637,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
$payload = [
'name' => $child->menu(),
'value' => $child->rawRoute(),
- 'item-key' => basename($child->rawRoute() ?? ''),
+ 'item-key' => Utils::basename($child->rawRoute() ?? ''),
'filename' => $child->folder(),
'extension' => $child->extension(),
'type' => 'dir',
@@ -692,7 +692,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface
$route = $child->getRoute();
$route = $route ? ($route->toString(false) ?: '/') : '';
$payload = [
- 'item-key' => htmlspecialchars(basename($child->rawRoute() ?? $child->getKey())),
+ 'item-key' => htmlspecialchars(Utils::basename($child->rawRoute() ?? $child->getKey())),
'icon' => $icon,
'title' => htmlspecialchars($child->menu()),
'route' => [
diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageObject.php b/system/src/Grav/Common/Flex/Types/Pages/PageObject.php
index 7f39d3b3b..fed11b437 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/PageObject.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/PageObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php b/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php
index ba7fa067e..f590e3661 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -16,13 +16,13 @@ use Grav\Common\Debugger;
use Grav\Common\Flex\Types\Pages\PageIndex;
use Grav\Common\Grav;
use Grav\Common\Language\Language;
+use Grav\Common\Utils;
use Grav\Framework\Filesystem\Filesystem;
use Grav\Framework\Flex\Storage\FolderStorage;
use RocketTheme\Toolbox\File\MarkdownFile;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use RuntimeException;
use SplFileInfo;
-use function assert;
use function in_array;
use function is_string;
@@ -277,7 +277,7 @@ class PageStorage extends FolderStorage
} else {
$params = $template = $language = '';
}
- $objectKey = basename($key);
+ $objectKey = Utils::basename($key);
if (preg_match('|^(\d+)\.(.+)$|', $objectKey, $matches)) {
[, $order, $folder] = $matches;
} else {
@@ -584,7 +584,7 @@ class PageStorage extends FolderStorage
$mark = $matches[2] ?? '';
$ext = $matches[1] ?? '';
$ext .= $this->dataExt;
- $markdown[$mark][basename($k, $ext)] = $timestamp;
+ $markdown[$mark][Utils::basename($k, $ext)] = $timestamp;
}
$modified = max($modified, $timestamp);
@@ -675,7 +675,7 @@ class PageStorage extends FolderStorage
/** @phpstan-var array{'storage_key': string, 'storage_timestamp': int, 'children': array} $parent */
$parent = &$list[$parentKey];
- $basename = basename($storage_key);
+ $basename = Utils::basename($storage_key);
if (isset($parent['children'][$basename])) {
$timestamp = $meta['storage_timestamp'];
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php
index 1bde7b003..9a2c7c338 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php
index 589ea881a..98f394924 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageLegacyTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php
index 3b490a596..ace74dc38 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageRoutableTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
index dff42c95b..a30ae1a3e 100644
--- a/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageTranslateTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php
index 93abbf886..3a91d77cc 100644
--- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php
+++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -27,7 +27,7 @@ class UserGroupCollection extends FlexCollection
public static function getCachedMethods(): array
{
return [
- 'authorize' => 'session',
+ 'authorize' => false,
] + parent::getCachedMethods();
}
diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php
index 4bee5ac3d..66de52e73 100644
--- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php
+++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php
index ea68fa1bf..4a59d520a 100644
--- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php
+++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -37,7 +37,7 @@ class UserGroupObject extends FlexObject implements UserGroupInterface
public static function getCachedMethods(): array
{
return [
- 'authorize' => 'session',
+ 'authorize' => false,
] + parent::getCachedMethods();
}
diff --git a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php
index f565c9f17..664f24faa 100644
--- a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php
+++ b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFileStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php
index 7d9924e0d..a037f0ef7 100644
--- a/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php
+++ b/system/src/Grav/Common/Flex/Types/Users/Storage/UserFolderStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php b/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
index e2f87f716..07acf66a5 100644
--- a/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
+++ b/system/src/Grav/Common/Flex/Types/Users/Traits/UserObjectLegacyTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/UserCollection.php b/system/src/Grav/Common/Flex/Types/Users/UserCollection.php
index 9b6490a8a..f5641e732 100644
--- a/system/src/Grav/Common/Flex/Types/Users/UserCollection.php
+++ b/system/src/Grav/Common/Flex/Types/Users/UserCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/UserIndex.php b/system/src/Grav/Common/Flex/Types/Users/UserIndex.php
index 0cbbf2dc7..4a33b7304 100644
--- a/system/src/Grav/Common/Flex/Types/Users/UserIndex.php
+++ b/system/src/Grav/Common/Flex/Types/Users/UserIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Flex/Types/Users/UserObject.php b/system/src/Grav/Common/Flex/Types/Users/UserObject.php
index 6c6d965f7..d9217917d 100644
--- a/system/src/Grav/Common/Flex/Types/Users/UserObject.php
+++ b/system/src/Grav/Common/Flex/Types/Users/UserObject.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -30,6 +30,7 @@ use Grav\Common\Flex\Types\UserGroups\UserGroupCollection;
use Grav\Common\Flex\Types\UserGroups\UserGroupIndex;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\User\Traits\UserTrait;
+use Grav\Common\Utils;
use Grav\Framework\File\Formatter\JsonFormatter;
use Grav\Framework\File\Formatter\YamlFormatter;
use Grav\Framework\Filesystem\Filesystem;
@@ -79,6 +80,8 @@ class UserObject extends FlexObject implements UserInterface, Countable
/** @var Closure|null */
static public $authorizeCallable;
+ /** @var Closure|null */
+ static public $isAuthorizedCallable;
/** @var array|null */
protected $_uploads_original;
@@ -139,6 +142,14 @@ class UserObject extends FlexObject implements UserInterface, Countable
parent::__construct($elements, $key, $directory, $validate);
}
+ public function __clone()
+ {
+ $this->_access = null;
+ $this->_groups = null;
+
+ parent::__clone();
+ }
+
/**
* @return void
*/
@@ -232,13 +243,19 @@ class UserObject extends FlexObject implements UserInterface, Countable
}
/**
+ * @param UserInterface|null $user
* @return bool
*/
- public function isMyself(): bool
+ public function isMyself(?UserInterface $user = null): bool
{
- $me = $this->getActiveUser();
+ if (null === $user) {
+ $user = $this->getActiveUser();
+ if ($user && !$user->authenticated) {
+ $user = null;
+ }
+ }
- return $me && $me->authenticated && $this->username === $me->username;
+ return $user && $this->username === $user->username;
}
/**
@@ -278,8 +295,8 @@ class UserObject extends FlexObject implements UserInterface, Countable
// Check custom application access.
$authorizeCallable = static::$authorizeCallable;
if ($authorizeCallable instanceof Closure) {
- $authorizeCallable->bindTo($this);
- $authorized = $authorizeCallable($action, $scope);
+ $callable = $authorizeCallable->bindTo($this, $this);
+ $authorized = $callable($action, $scope);
if (is_bool($authorized)) {
return $authorized;
}
@@ -629,7 +646,7 @@ class UserObject extends FlexObject implements UserInterface, Countable
$medium = MediumFactory::fromFile($path);
if ($medium) {
$media->add($path, $medium);
- $name = basename($path);
+ $name = Utils::basename($path);
if ($name !== $path) {
$media->add($name, $medium);
}
@@ -684,6 +701,16 @@ class UserObject extends FlexObject implements UserInterface, Countable
*/
protected function isAuthorizedOverride(UserInterface $user, string $action, string $scope, bool $isMe = false): ?bool
{
+ // Check custom application access.
+ $isAuthorizedCallable = static::$isAuthorizedCallable;
+ if ($isAuthorizedCallable instanceof Closure) {
+ $callable = $isAuthorizedCallable->bindTo($this, $this);
+ $authorized = $callable($user, $action, $scope, $isMe);
+ if (is_bool($authorized)) {
+ return $authorized;
+ }
+ }
+
if ($user instanceof self && $user->getStorageKey() === $this->getStorageKey()) {
// User cannot delete his own account, otherwise he has full access.
return $action !== 'delete';
@@ -788,7 +815,7 @@ class UserObject extends FlexObject implements UserInterface, Countable
}
// Calculate path without the retina scaling factor.
- $realpath = $filesystem->pathname($filepath) . str_replace(['@3x', '@2x'], '', basename($filepath));
+ $realpath = $filesystem->pathname($filepath) . str_replace(['@3x', '@2x'], '', Utils::basename($filepath));
$list[$filename] = [$file, $settings];
@@ -913,7 +940,7 @@ class UserObject extends FlexObject implements UserInterface, Countable
protected function getAccess(): Access
{
if (null === $this->_access) {
- $this->getProperty('access');
+ $this->_access = new Access($this->getProperty('access'));
}
return $this->_access;
@@ -929,8 +956,6 @@ class UserObject extends FlexObject implements UserInterface, Countable
$value = new Access($value);
}
- $this->_access = $value;
-
return $value->jsonSerialize();
}
diff --git a/system/src/Grav/Common/Form/FormFlash.php b/system/src/Grav/Common/Form/FormFlash.php
index 430f15e09..7acaf7fdc 100644
--- a/system/src/Grav/Common/Form/FormFlash.php
+++ b/system/src/Grav/Common/Form/FormFlash.php
@@ -3,13 +3,14 @@
/**
* @package Grav\Common\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Form;
use Grav\Common\Filesystem\Folder;
+use Grav\Common\Utils;
use Grav\Framework\Form\FormFlash as FrameworkFormFlash;
use function is_array;
@@ -58,7 +59,7 @@ class FormFlash extends FrameworkFormFlash
Folder::create($tmp_dir);
$tmp_file = $upload['file']['tmp_name'];
- $basename = basename($tmp_file);
+ $basename = Utils::basename($tmp_file);
if (!move_uploaded_file($tmp_file, $tmp_dir . '/' . $basename)) {
return false;
@@ -90,7 +91,7 @@ class FormFlash extends FrameworkFormFlash
Folder::create($tmp_dir);
$tmp_file = $upload['file']['tmp_name'];
- $basename = basename($tmp_file);
+ $basename = Utils::basename($tmp_file);
if (!move_uploaded_file($tmp_file, $tmp_dir . '/' . $basename)) {
return false;
diff --git a/system/src/Grav/Common/GPM/AbstractCollection.php b/system/src/Grav/Common/GPM/AbstractCollection.php
index b5b867ef7..91fa69eb4 100644
--- a/system/src/Grav/Common/GPM/AbstractCollection.php
+++ b/system/src/Grav/Common/GPM/AbstractCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
index 5d6ad9fb8..7b918e0ef 100644
--- a/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
+++ b/system/src/Grav/Common/GPM/Common/AbstractPackageCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Common/CachedCollection.php b/system/src/Grav/Common/GPM/Common/CachedCollection.php
index 172ba939f..c3b62e5cd 100644
--- a/system/src/Grav/Common/GPM/Common/CachedCollection.php
+++ b/system/src/Grav/Common/GPM/Common/CachedCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Common/Package.php b/system/src/Grav/Common/GPM/Common/Package.php
index 88f1304dd..5d960117c 100644
--- a/system/src/Grav/Common/GPM/Common/Package.php
+++ b/system/src/Grav/Common/GPM/Common/Package.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php
index 8abbd3dc3..7031945b2 100644
--- a/system/src/Grav/Common/GPM/GPM.php
+++ b/system/src/Grav/Common/GPM/GPM.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -631,7 +631,7 @@ class GPM extends Iterator
throw new \RuntimeException("Malformed GPM URL: {$package_file}");
}
- $filename = basename($package['path'] ?? '');
+ $filename = Utils::basename($package['path'] ?? '');
if (Grav::instance()['config']->get('system.gpm.official_gpm_only') && ($package['host'] ?? null) !== 'getgrav.org') {
throw new RuntimeException('Only official GPM URLs are allowed. You can modify this behavior in the System configuration.');
@@ -660,7 +660,7 @@ class GPM extends Iterator
$package_file = realpath($package_file);
if ($package_file && file_exists($package_file)) {
- $filename = basename($package_file);
+ $filename = Utils::basename($package_file);
Folder::create($tmp);
copy($package_file, $tmp . DS . $filename);
return $tmp . DS . $filename;
@@ -692,7 +692,7 @@ class GPM extends Iterator
}
// either theme or plugin
- $name = basename($source);
+ $name = Utils::basename($source);
if (Utils::contains($name, 'theme')) {
return 'theme';
}
@@ -730,7 +730,7 @@ class GPM extends Iterator
$glob = glob($source . '*.yaml') ?: [];
foreach ($glob as $filename) {
- $name = strtolower(basename($filename, '.yaml'));
+ $name = strtolower(Utils::basename($filename, '.yaml'));
if (in_array($name, $ignore_yaml_files)) {
continue;
}
diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php
index 639240be6..8a1a5303e 100644
--- a/system/src/Grav/Common/GPM/Installer.php
+++ b/system/src/Grav/Common/GPM/Installer.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -12,6 +12,7 @@ namespace Grav\Common\GPM;
use DirectoryIterator;
use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav;
+use Grav\Common\Utils;
use RuntimeException;
use ZipArchive;
use function count;
@@ -192,7 +193,7 @@ class Installer
$package_folder_name = $zip->getNameIndex(0);
if ($package_folder_name === false) {
- throw new \RuntimeException('Bad package file: ' . basename($zip_file));
+ throw new \RuntimeException('Bad package file: ' . Utils::basename($zip_file));
}
$package_folder_name = preg_replace('#\./$#', '', $package_folder_name);
$zip->close();
diff --git a/system/src/Grav/Common/GPM/Licenses.php b/system/src/Grav/Common/GPM/Licenses.php
index 825343dd8..e932bd4f7 100644
--- a/system/src/Grav/Common/GPM/Licenses.php
+++ b/system/src/Grav/Common/GPM/Licenses.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
index d1f3e4671..bc7ceab5e 100644
--- a/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
+++ b/system/src/Grav/Common/GPM/Local/AbstractPackageCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Package.php b/system/src/Grav/Common/GPM/Local/Package.php
index ffe2c63cc..08444a76d 100644
--- a/system/src/Grav/Common/GPM/Local/Package.php
+++ b/system/src/Grav/Common/GPM/Local/Package.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Packages.php b/system/src/Grav/Common/GPM/Local/Packages.php
index 0290296c4..b63b93b54 100644
--- a/system/src/Grav/Common/GPM/Local/Packages.php
+++ b/system/src/Grav/Common/GPM/Local/Packages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Plugins.php b/system/src/Grav/Common/GPM/Local/Plugins.php
index 8a6574b58..a1626f8ba 100644
--- a/system/src/Grav/Common/GPM/Local/Plugins.php
+++ b/system/src/Grav/Common/GPM/Local/Plugins.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Local/Themes.php b/system/src/Grav/Common/GPM/Local/Themes.php
index 73253ccd8..d15379439 100644
--- a/system/src/Grav/Common/GPM/Local/Themes.php
+++ b/system/src/Grav/Common/GPM/Local/Themes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php b/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
index 9e68d6660..02e98e759 100644
--- a/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
+++ b/system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/GravCore.php b/system/src/Grav/Common/GPM/Remote/GravCore.php
index f93209edd..2998975cf 100644
--- a/system/src/Grav/Common/GPM/Remote/GravCore.php
+++ b/system/src/Grav/Common/GPM/Remote/GravCore.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/Package.php b/system/src/Grav/Common/GPM/Remote/Package.php
index 1e838053d..519325551 100644
--- a/system/src/Grav/Common/GPM/Remote/Package.php
+++ b/system/src/Grav/Common/GPM/Remote/Package.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/Packages.php b/system/src/Grav/Common/GPM/Remote/Packages.php
index f55c12dc0..0ac2ef967 100644
--- a/system/src/Grav/Common/GPM/Remote/Packages.php
+++ b/system/src/Grav/Common/GPM/Remote/Packages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/Plugins.php b/system/src/Grav/Common/GPM/Remote/Plugins.php
index a134a104b..8383cd782 100644
--- a/system/src/Grav/Common/GPM/Remote/Plugins.php
+++ b/system/src/Grav/Common/GPM/Remote/Plugins.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Remote/Themes.php b/system/src/Grav/Common/GPM/Remote/Themes.php
index 160ac97ac..a8ee9fae2 100644
--- a/system/src/Grav/Common/GPM/Remote/Themes.php
+++ b/system/src/Grav/Common/GPM/Remote/Themes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/GPM/Upgrader.php b/system/src/Grav/Common/GPM/Upgrader.php
index dfa6eb133..b3e68696d 100644
--- a/system/src/Grav/Common/GPM/Upgrader.php
+++ b/system/src/Grav/Common/GPM/Upgrader.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\GPM
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Getters.php b/system/src/Grav/Common/Getters.php
index babd51629..ed03499d1 100644
--- a/system/src/Grav/Common/Getters.php
+++ b/system/src/Grav/Common/Getters.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php
index 8d05aedf4..18d490295 100644
--- a/system/src/Grav/Common/Grav.php
+++ b/system/src/Grav/Common/Grav.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -729,18 +729,36 @@ class Grav extends Container
*/
public function fallbackUrl($path)
{
- $this->fireEvent('onPageFallBackUrl');
-
/** @var Uri $uri */
$uri = $this['uri'];
/** @var Config $config */
$config = $this['config'];
+ $path_parts = Utils::pathinfo($path);
+
+ /** @var Pages $pages */
+ $pages = $this['pages'];
+ $page = $pages->find($path_parts['dirname'], true);
+
$uri_extension = strtolower($uri->extension() ?? '');
- $fallback_types = $config->get('system.media.allowed_fallback_types', null);
+ $fallback_types = $config->get('system.media.allowed_fallback_types');
$supported_types = $config->get('media.types');
+ $parsed_url = parse_url(rawurldecode($uri->basename()));
+ $media_file = $parsed_url['path'];
+
+ $event = new Event([
+ 'uri' => $uri,
+ 'page' => &$page,
+ 'filename' => &$media_file,
+ 'extension' => $uri_extension,
+ 'allowed_fallback_types' => &$fallback_types,
+ 'media_types' => &$supported_types
+ ]);
+
+ $this->fireEvent('onPageFallBackUrl', $event);
+
// Check whitelist first, then ensure extension is a valid media type
if (!empty($fallback_types) && !in_array($uri_extension, $fallback_types, true)) {
return false;
@@ -749,16 +767,8 @@ class Grav extends Container
return false;
}
- $path_parts = pathinfo($path);
-
- /** @var Pages $pages */
- $pages = $this['pages'];
- $page = $pages->find($path_parts['dirname'], true);
-
if ($page) {
$media = $page->media()->all();
- $parsed_url = parse_url(rawurldecode($uri->basename()));
- $media_file = $parsed_url['path'];
// if this is a media object, try actions first
if (isset($media[$media_file])) {
diff --git a/system/src/Grav/Common/GravTrait.php b/system/src/Grav/Common/GravTrait.php
index 463890572..541628612 100644
--- a/system/src/Grav/Common/GravTrait.php
+++ b/system/src/Grav/Common/GravTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/HTTP/Client.php b/system/src/Grav/Common/HTTP/Client.php
index cd4f8dbb2..c85d6b295 100644
--- a/system/src/Grav/Common/HTTP/Client.php
+++ b/system/src/Grav/Common/HTTP/Client.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\HTTP
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/HTTP/Response.php b/system/src/Grav/Common/HTTP/Response.php
index 4a0513667..4a5bc8bb2 100644
--- a/system/src/Grav/Common/HTTP/Response.php
+++ b/system/src/Grav/Common/HTTP/Response.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\HTTP
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/Base32.php b/system/src/Grav/Common/Helpers/Base32.php
index 825c1eca3..0d1c21ae0 100644
--- a/system/src/Grav/Common/Helpers/Base32.php
+++ b/system/src/Grav/Common/Helpers/Base32.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/Excerpts.php b/system/src/Grav/Common/Helpers/Excerpts.php
index 173850a53..a62c7e5f4 100644
--- a/system/src/Grav/Common/Helpers/Excerpts.php
+++ b/system/src/Grav/Common/Helpers/Excerpts.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/Exif.php b/system/src/Grav/Common/Helpers/Exif.php
index 36e391fe7..a7dc97330 100644
--- a/system/src/Grav/Common/Helpers/Exif.php
+++ b/system/src/Grav/Common/Helpers/Exif.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/LogViewer.php b/system/src/Grav/Common/Helpers/LogViewer.php
index f2d7d43de..cf5ffe9af 100644
--- a/system/src/Grav/Common/Helpers/LogViewer.php
+++ b/system/src/Grav/Common/Helpers/LogViewer.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/Truncator.php b/system/src/Grav/Common/Helpers/Truncator.php
index 0a701b694..03c3eeaab 100644
--- a/system/src/Grav/Common/Helpers/Truncator.php
+++ b/system/src/Grav/Common/Helpers/Truncator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Helpers/YamlLinter.php b/system/src/Grav/Common/Helpers/YamlLinter.php
index 45b5144ef..b31180f0e 100644
--- a/system/src/Grav/Common/Helpers/YamlLinter.php
+++ b/system/src/Grav/Common/Helpers/YamlLinter.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Helpers
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -11,6 +11,7 @@ namespace Grav\Common\Helpers;
use Exception;
use Grav\Common\Grav;
+use Grav\Common\Utils;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RegexIterator;
@@ -108,7 +109,7 @@ class YamlLinter
*/
protected static function extractYaml($path)
{
- $extension = pathinfo($path, PATHINFO_EXTENSION);
+ $extension = Utils::pathinfo($path, PATHINFO_EXTENSION);
if ($extension === 'md') {
$file = MarkdownFile::instance($path);
$contents = $file->frontmatter();
diff --git a/system/src/Grav/Common/Inflector.php b/system/src/Grav/Common/Inflector.php
index 50c218f1b..216b73350 100644
--- a/system/src/Grav/Common/Inflector.php
+++ b/system/src/Grav/Common/Inflector.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Iterator.php b/system/src/Grav/Common/Iterator.php
index d6a629a16..5db7bd045 100644
--- a/system/src/Grav/Common/Iterator.php
+++ b/system/src/Grav/Common/Iterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php
index c17382b69..fe006ed2c 100644
--- a/system/src/Grav/Common/Language/Language.php
+++ b/system/src/Grav/Common/Language/Language.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Language
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Language/LanguageCodes.php b/system/src/Grav/Common/Language/LanguageCodes.php
index e637bddaf..3fa494859 100644
--- a/system/src/Grav/Common/Language/LanguageCodes.php
+++ b/system/src/Grav/Common/Language/LanguageCodes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Language
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -93,7 +93,7 @@ class LanguageCodes
'la' => [ 'name' => 'Latin', 'nativeName' => 'Latina' ],
'lb' => [ 'name' => 'Luxembourgish', 'nativeName' => 'Lëtzebuergesch' ],
'lg' => [ 'name' => 'Luganda', 'nativeName' => 'Luganda' ],
- 'lo' => [ 'name' => 'Lao', 'nativeName' => 'Lao' ],
+ 'lo' => [ 'name' => 'Lao', 'nativeName' => 'Lao' ],
'lt' => [ 'name' => 'Lithuanian', 'nativeName' => 'Lietuvių' ],
'lv' => [ 'name' => 'Latvian', 'nativeName' => 'Latviešu' ],
'mai' => [ 'name' => 'Maithili', 'nativeName' => 'मैथिली মৈথিলী' ],
@@ -103,7 +103,7 @@ class LanguageCodes
'ml' => [ 'name' => 'Malayalam', 'nativeName' => 'മലയാളം' ],
'mn' => [ 'name' => 'Mongolian', 'nativeName' => 'Монгол' ],
'mr' => [ 'name' => 'Marathi', 'nativeName' => 'मराठी' ],
- 'my' => [ 'name' => 'Myanmar (Burmese)', 'nativeName' => 'ဗမာी' ],
+ 'my' => [ 'name' => 'Myanmar (Burmese)', 'nativeName' => 'ဗမာी' ],
'no' => [ 'name' => 'Norwegian', 'nativeName' => 'Norsk' ],
'nb' => [ 'name' => 'Norwegian', 'nativeName' => 'Norsk' ],
'nb-NO' => [ 'name' => 'Norwegian (Bokmål)', 'nativeName' => 'Norsk bokmål' ],
diff --git a/system/src/Grav/Common/Markdown/Parsedown.php b/system/src/Grav/Common/Markdown/Parsedown.php
index bdc5bdcd2..f0d8a48ff 100644
--- a/system/src/Grav/Common/Markdown/Parsedown.php
+++ b/system/src/Grav/Common/Markdown/Parsedown.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Markdown
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Markdown/ParsedownExtra.php b/system/src/Grav/Common/Markdown/ParsedownExtra.php
index b8e760efd..ef450feaf 100644
--- a/system/src/Grav/Common/Markdown/ParsedownExtra.php
+++ b/system/src/Grav/Common/Markdown/ParsedownExtra.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Markdown
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
index 95a8f5f23..a593dd749 100644
--- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
+++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Markdown
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php b/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php
index d9c69d281..6465d6b9c 100644
--- a/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/AudioMediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php b/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php
index 702cfda9b..eb38ea83b 100644
--- a/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/ImageManipulateInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php b/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php
index 377258c9e..cbf8f1de3 100644
--- a/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/ImageMediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
index ad9fe96c3..62c531c89 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php
index 07a5c26df..c20e4de99 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaFileInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaInterface.php
index 436fe1681..273556a6d 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php
index 4f229c2b5..41747be67 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaLinkInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
index 90c891481..4af3052b0 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -63,6 +63,14 @@ interface MediaObjectInterface extends \Grav\Framework\Media\Interfaces\MediaObj
*/
public function addAlternative($ratio, MediaObjectInterface $alternative);
+ /**
+ * Get list of image alternatives. Includes the current media image as well.
+ *
+ * @param bool $withDerived If true, include generated images as well. If false, only return existing files.
+ * @return array
+ */
+ public function getAlternatives(bool $withDerived = true): array;
+
/**
* Return string representation of the object (html).
*
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php
index 9307915c4..fbe6f656f 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php
index 8bfef845e..73625999a 100644
--- a/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/MediaUploadInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php b/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php
index ff0655a62..6d42feff2 100644
--- a/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php
+++ b/system/src/Grav/Common/Media/Interfaces/VideoMediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php b/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php
index 160837dec..a0834721d 100644
--- a/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/AudioMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php b/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php
index c0237638e..75e23cab8 100644
--- a/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php
+++ b/system/src/Grav/Common/Media/Traits/ImageLoadingTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php b/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php
index f6e22224e..c1c46dc94 100644
--- a/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/ImageMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaFileTrait.php b/system/src/Grav/Common/Media/Traits/MediaFileTrait.php
index 71981331d..63906fc4a 100644
--- a/system/src/Grav/Common/Media/Traits/MediaFileTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaFileTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php b/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php
index 705d3c83f..85ed6d224 100644
--- a/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaObjectTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -128,11 +128,29 @@ trait MediaObjectTrait
}
$alternative->set('ratio', $ratio);
- $width = $alternative->get('width');
+ $width = $alternative->get('width', 0);
$this->alternatives[$width] = $alternative;
}
+ /**
+ * @param bool $withDerived
+ * @return array
+ */
+ public function getAlternatives(bool $withDerived = true): array
+ {
+ $alternatives = [];
+ foreach ($this->alternatives + [$this->get('width', 0) => $this] as $size => $alternative) {
+ if ($withDerived || $alternative->filename === Utils::basename($alternative->filepath)) {
+ $alternatives[$size] = $alternative;
+ }
+ }
+
+ ksort($alternatives, SORT_NUMERIC);
+
+ return $alternatives;
+ }
+
/**
* Return string representation of the object (html).
*
@@ -556,11 +574,12 @@ trait MediaObjectTrait
foreach ($types as $type) {
$thumb = $this->get("thumbnails.{$type}", false);
-
if ($thumb) {
- $thumb = $thumb instanceof ThumbnailImageMedium ? $thumb : $this->createThumbnail($thumb);
- $thumb->parent = $this;
- $this->_thumbnail = $thumb;
+ $image = $thumb instanceof ThumbnailImageMedium ? $thumb : $this->createThumbnail($thumb);
+ if($image) {
+ $image->parent = $this;
+ $this->_thumbnail = $image;
+ }
break;
}
}
diff --git a/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php b/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php
index 66e9f47d9..06cb99ad9 100644
--- a/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaTrait.php b/system/src/Grav/Common/Media/Traits/MediaTrait.php
index 5faba826b..14bfa9072 100644
--- a/system/src/Grav/Common/Media/Traits/MediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php b/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php
index 7a1f55d6e..36a4503f1 100644
--- a/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php
+++ b/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -132,9 +132,9 @@ trait MediaUploadTrait
if ($folder === '.') {
$folder = '';
}
- $filename = basename($filename);
+ $filename = Utils::basename($filename);
}
- $extension = pathinfo($filename, PATHINFO_EXTENSION);
+ $extension = Utils::pathinfo($filename, PATHINFO_EXTENSION);
// Decide which filename to use.
if ($settings['random_name']) {
@@ -573,6 +573,8 @@ trait MediaUploadTrait
}
}
}
+
+ $this->hide($filename);
}
/**
diff --git a/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php b/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php
index 49d75be67..d8a4b0831 100644
--- a/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php
+++ b/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php b/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php
index eab732004..100b5321c 100644
--- a/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/ThumbnailMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php b/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php
index e03fbbd81..b16bb53c7 100644
--- a/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php
+++ b/system/src/Grav/Common/Media/Traits/VideoMediaTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php
index a2fee1b7e..987b8d931 100644
--- a/system/src/Grav/Common/Page/Collection.php
+++ b/system/src/Grav/Common/Page/Collection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Header.php b/system/src/Grav/Common/Page/Header.php
index 0ab9af407..c18b58d37 100644
--- a/system/src/Grav/Common/Page/Header.php
+++ b/system/src/Grav/Common/Page/Header.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
index 88968e5b5..493ab4398 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php b/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php
index 30db89d66..a80972b6b 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageContentInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -11,6 +11,7 @@ namespace Grav\Common\Page\Interfaces;
use Grav\Common\Data\Blueprint;
use Grav\Common\Media\Interfaces\MediaCollectionInterface;
+use Grav\Common\Page\Header;
/**
* Methods currently implemented in Flex Page emulation layer.
@@ -21,7 +22,7 @@ interface PageContentInterface
* Gets and Sets the header based on the YAML configuration at the top of the .md file
*
* @param object|array|null $var a YAML object representing the configuration for the file
- * @return object the current YAML configuration
+ * @return \stdClass|Header The current YAML configuration
*/
public function header($var = null);
diff --git a/system/src/Grav/Common/Page/Interfaces/PageInterface.php b/system/src/Grav/Common/Page/Interfaces/PageInterface.php
index e5ea20c4f..56fc891b9 100644
--- a/system/src/Grav/Common/Page/Interfaces/PageInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PageInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php b/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php
index ef5cfba11..ff4ebdae3 100644
--- a/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php
+++ b/system/src/Grav/Common/Page/Interfaces/PagesSourceInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Markdown/Excerpts.php b/system/src/Grav/Common/Page/Markdown/Excerpts.php
index 9b0b9963c..17f9cbff5 100644
--- a/system/src/Grav/Common/Page/Markdown/Excerpts.php
+++ b/system/src/Grav/Common/Page/Markdown/Excerpts.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -206,7 +206,7 @@ class Excerpts
&& (empty($url_parts['host']) || $url_parts['host'] === $grav['uri']->host());
if ($local_file) {
- $filename = basename($url_parts['path']);
+ $filename = Utils::basename($url_parts['path']);
$folder = dirname($url_parts['path']);
// Get the local path to page media if possible.
diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php
index e18201420..6c0a6c390 100644
--- a/system/src/Grav/Common/Page/Media.php
+++ b/system/src/Grav/Common/Page/Media.php
@@ -3,13 +3,14 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Page;
use FilesystemIterator;
+use Grav\Common\Config\Config;
use Grav\Common\Grav;
use Grav\Common\Media\Interfaces\MediaObjectInterface;
use Grav\Common\Yaml;
@@ -59,6 +60,46 @@ class Media extends AbstractMedia
}
}
+ /**
+ * Return raw route to the page.
+ *
+ * @return string|null Route to the page or null if media isn't for a page.
+ */
+ public function getRawRoute(): ?string
+ {
+ $path = $this->getPath();
+ if ($path) {
+ /** @var Pages $pages */
+ $pages = $this->getGrav()['pages'];
+ $page = $pages->get($path);
+ if ($page) {
+ return $page->rawRoute();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return page route.
+ *
+ * @return string|null Route to the page or null if media isn't for a page.
+ */
+ public function getRoute(): ?string
+ {
+ $path = $this->getPath();
+ if ($path) {
+ /** @var Pages $pages */
+ $pages = $this->getGrav()['pages'];
+ $page = $pages->get($path);
+ if ($page) {
+ return $page->route();
+ }
+ }
+
+ return null;
+ }
+
/**
* @param string $offset
* @return bool
@@ -86,11 +127,6 @@ class Media extends AbstractMedia
*/
protected function init()
{
- /** @var UniformResourceLocator $locator */
- $locator = Grav::instance()['locator'];
- $config = Grav::instance()['config'];
- $exif_reader = isset(Grav::instance()['exif']) ? Grav::instance()['exif']->getReader() : false;
- $media_types = array_keys(Grav::instance()['config']->get('media.types'));
$path = $this->getPath();
// Handle special cases where page doesn't exist in filesystem.
@@ -98,6 +134,17 @@ class Media extends AbstractMedia
return;
}
+ $grav = Grav::instance();
+
+ /** @var UniformResourceLocator $locator */
+ $locator = $grav['locator'];
+
+ /** @var Config $config */
+ $config = $grav['config'];
+
+ $exif_reader = isset($grav['exif']) ? $grav['exif']->getReader() : null;
+ $media_types = array_keys($config->get('media.types', []));
+
$iterator = new FilesystemIterator($path, FilesystemIterator::UNIX_PATHS | FilesystemIterator::SKIP_DOTS);
$media = [];
diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
index 4ba532749..9b3650b8d 100644
--- a/system/src/Grav/Common/Page/Medium/AbstractMedia.php
+++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/AudioMedium.php b/system/src/Grav/Common/Page/Medium/AudioMedium.php
index f34f0a9c2..cc53f8198 100644
--- a/system/src/Grav/Common/Page/Medium/AudioMedium.php
+++ b/system/src/Grav/Common/Page/Medium/AudioMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/GlobalMedia.php b/system/src/Grav/Common/Page/Medium/GlobalMedia.php
index 50d69c747..20f63ad56 100644
--- a/system/src/Grav/Common/Page/Medium/GlobalMedia.php
+++ b/system/src/Grav/Common/Page/Medium/GlobalMedia.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -11,6 +11,7 @@ namespace Grav\Common\Page\Medium;
use Grav\Common\Grav;
use Grav\Common\Media\Interfaces\MediaObjectInterface;
+use Grav\Common\Utils;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use function dirname;
@@ -89,7 +90,7 @@ class GlobalMedia extends AbstractMedia
}
$path = dirname($filename);
- [$basename, $ext,, $extra] = $this->getFileParts(basename($filename));
+ [$basename, $ext,, $extra] = $this->getFileParts(Utils::basename($filename));
$medium = MediumFactory::fromFile($filename);
if (null === $medium) {
diff --git a/system/src/Grav/Common/Page/Medium/ImageFile.php b/system/src/Grav/Common/Page/Medium/ImageFile.php
index 987918714..1aae7eeb6 100644
--- a/system/src/Grav/Common/Page/Medium/ImageFile.php
+++ b/system/src/Grav/Common/Page/Medium/ImageFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php
index 6d1e9043d..42d8f0e75 100644
--- a/system/src/Grav/Common/Page/Medium/ImageMedium.php
+++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -249,12 +249,12 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
if ($this->saved_image_path && $this->auto_sizes) {
if (!array_key_exists('height', $this->attributes) && !array_key_exists('width', $this->attributes)) {
$info = getimagesize($this->saved_image_path);
- $width = intval($info[0]);
- $height = intval($info[1]);
+ $width = (int)$info[0];
+ $height = (int)$info[1];
$scaling_factor = $this->retina_scale > 0 ? $this->retina_scale : 1;
- $attributes['width'] = intval($width / $scaling_factor);
- $attributes['height'] = intval($height / $scaling_factor);
+ $attributes['width'] = (int)($width / $scaling_factor);
+ $attributes['height'] = (int)($height / $scaling_factor);
if ($this->aspect_ratio) {
$style = ($attributes['style'] ?? ' ') . "--aspect-ratio: $width/$height;";
diff --git a/system/src/Grav/Common/Page/Medium/Link.php b/system/src/Grav/Common/Page/Medium/Link.php
index 03c15e5cb..c76d8c191 100644
--- a/system/src/Grav/Common/Page/Medium/Link.php
+++ b/system/src/Grav/Common/Page/Medium/Link.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php
index c94cf9fd0..0891c0c46 100644
--- a/system/src/Grav/Common/Page/Medium/Medium.php
+++ b/system/src/Grav/Common/Page/Medium/Medium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,14 @@ use Grav\Common\Media\Traits\MediaObjectTrait;
* Class Medium
* @package Grav\Common\Page\Medium
*
+ * @property string $filepath
+ * @property string $filename
+ * @property string $basename
* @property string $mime
+ * @property int $size
+ * @property int $modified
+ * @property array $metadata
+ * @property int|string $timestamp
*/
class Medium extends Data implements RenderableInterface, MediaFileInterface
{
@@ -99,6 +106,7 @@ class Medium extends Data implements RenderableInterface, MediaFileInterface
/**
* @param string $thumb
+ * @return Medium|null
*/
protected function createThumbnail($thumb)
{
diff --git a/system/src/Grav/Common/Page/Medium/MediumFactory.php b/system/src/Grav/Common/Page/Medium/MediumFactory.php
index 7dee4ea18..620446b70 100644
--- a/system/src/Grav/Common/Page/Medium/MediumFactory.php
+++ b/system/src/Grav/Common/Page/Medium/MediumFactory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -13,6 +13,7 @@ use Grav\Common\Grav;
use Grav\Common\Data\Blueprint;
use Grav\Common\Media\Interfaces\ImageMediaInterface;
use Grav\Common\Media\Interfaces\MediaObjectInterface;
+use Grav\Common\Utils;
use Grav\Framework\Form\FormFlashFile;
use Psr\Http\Message\UploadedFileInterface;
use function dirname;
@@ -37,7 +38,7 @@ class MediumFactory
return null;
}
- $parts = pathinfo($file);
+ $parts = Utils::pathinfo($file);
$path = $parts['dirname'];
$filename = $parts['basename'];
$ext = $parts['extension'] ?? '';
@@ -101,7 +102,7 @@ class MediumFactory
return null;
}
- $parts = pathinfo($clientName);
+ $parts = Utils::pathinfo($clientName);
$filename = $parts['basename'];
$ext = $parts['extension'] ?? '';
$basename = $parts['filename'];
@@ -193,7 +194,7 @@ class MediumFactory
$height = $medium->get('height') * $ratio;
$prev_basename = $medium->get('basename');
- $basename = str_replace('@'.$from.'x', '@'.$to.'x', $prev_basename);
+ $basename = str_replace('@' . $from . 'x', $to !== 1 ? '@' . $to . 'x' : '', $prev_basename);
$debug = $medium->get('debug');
$medium->set('debug', false);
@@ -208,6 +209,8 @@ class MediumFactory
$medium = self::fromFile($file);
if ($medium) {
+ $medium->set('basename', $basename);
+ $medium->set('filename', $basename . '.' . $medium->extension);
$medium->set('size', $size);
}
diff --git a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
index 44ab95292..4ab2fb58f 100644
--- a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
+++ b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/RenderableInterface.php b/system/src/Grav/Common/Page/Medium/RenderableInterface.php
index ac7244700..1ee6a9660 100644
--- a/system/src/Grav/Common/Page/Medium/RenderableInterface.php
+++ b/system/src/Grav/Common/Page/Medium/RenderableInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/StaticImageMedium.php b/system/src/Grav/Common/Page/Medium/StaticImageMedium.php
index ba92fa1ca..97801000a 100644
--- a/system/src/Grav/Common/Page/Medium/StaticImageMedium.php
+++ b/system/src/Grav/Common/Page/Medium/StaticImageMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -37,4 +37,12 @@ class StaticImageMedium extends Medium implements ImageMediaInterface
return ['name' => 'img', 'attributes' => $attributes];
}
+
+ /**
+ * @return $this
+ */
+ public function higherQualityAlternative()
+ {
+ return $this;
+ }
}
diff --git a/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php b/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
index d95b2d634..caaa7e2d6 100644
--- a/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
+++ b/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
index a56a20d15..1e4d862f9 100644
--- a/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
+++ b/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Medium/VideoMedium.php b/system/src/Grav/Common/Page/Medium/VideoMedium.php
index bfcf550c4..0e629dc89 100644
--- a/system/src/Grav/Common/Page/Medium/VideoMedium.php
+++ b/system/src/Grav/Common/Page/Medium/VideoMedium.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php
index 992926248..25f8ff6b6 100644
--- a/system/src/Grav/Common/Page/Page.php
+++ b/system/src/Grav/Common/Page/Page.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -196,7 +196,7 @@ class Page implements PageInterface
}
// extract page language from page extension
- $language = trim(basename($this->extension(), 'md'), '.') ?: null;
+ $language = trim(Utils::basename($this->extension(), 'md'), '.') ?: null;
$this->language($language);
$this->hide_home_route = $config->get('system.home.hide_in_urls', false);
@@ -388,7 +388,7 @@ class Page implements PageInterface
* Gets and Sets the header based on the YAML configuration at the top of the .md file
*
* @param object|array|null $var a YAML object representing the configuration for the file
- * @return object the current YAML configuration
+ * @return \stdClass the current YAML configuration
*/
public function header($var = null)
{
@@ -1465,7 +1465,7 @@ class Page implements PageInterface
$this->extension = $var;
}
if (empty($this->extension)) {
- $this->extension = '.' . pathinfo($this->name(), PATHINFO_EXTENSION);
+ $this->extension = '.' . Utils::pathinfo($this->name(), PATHINFO_EXTENSION);
}
return $this->extension;
@@ -2109,9 +2109,9 @@ class Page implements PageInterface
{
if ($var !== null) {
// Filename of the page.
- $this->name = basename($var);
+ $this->name = Utils::basename($var);
// Folder of the page.
- $this->folder = basename(dirname($var));
+ $this->folder = Utils::basename(dirname($var));
// Path to the page.
$this->path = dirname($var, 2);
}
@@ -2150,7 +2150,7 @@ class Page implements PageInterface
{
if ($var !== null) {
// Folder of the page.
- $this->folder = basename($var);
+ $this->folder = Utils::basename($var);
// Path to the page.
$this->path = dirname($var);
}
diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php
index 9e5d47db0..8ad2ccd8f 100644
--- a/system/src/Grav/Common/Page/Pages.php
+++ b/system/src/Grav/Common/Page/Pages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -2065,7 +2065,7 @@ class Pages
$list[$key] = $child->slug();
break;
case 'basename':
- $list[$key] = basename($key);
+ $list[$key] = Utils::basename($key);
break;
case 'folder':
$list[$key] = $child->folder();
diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php
index c7183680e..420c58860 100644
--- a/system/src/Grav/Common/Page/Types.php
+++ b/system/src/Grav/Common/Page/Types.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Page
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -12,6 +12,7 @@ namespace Grav\Common\Page;
use Grav\Common\Data\Blueprint;
use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav;
+use Grav\Common\Utils;
use InvalidArgumentException;
use RocketTheme\Toolbox\ArrayTraits\ArrayAccess;
use RocketTheme\Toolbox\ArrayTraits\Constructor;
@@ -144,7 +145,7 @@ class Types implements \ArrayAccess, \Iterator, \Countable
if (strpos($name, 'modular/') !== 0) {
continue;
}
- $list[$name] = ucfirst(trim(str_replace('_', ' ', basename($name))));
+ $list[$name] = ucfirst(trim(str_replace('_', ' ', Utils::basename($name))));
}
ksort($list);
diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php
index 3b0d3fb14..30e5344f6 100644
--- a/system/src/Grav/Common/Plugin.php
+++ b/system/src/Grav/Common/Plugin.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -118,7 +118,7 @@ class Plugin implements EventSubscriberInterface, ArrayAccess
*/
public function config()
{
- return null !== $this->config ? $this->config["plugins.{$this->name}"] : [];
+ return $this->config["plugins.{$this->name}"] ?? [];
}
/**
@@ -414,6 +414,30 @@ class Plugin implements EventSubscriberInterface, ArrayAccess
return true;
}
+ public static function inheritedConfigOption(string $plugin, string $var, PageInterface $page = null, $default = null)
+ {
+ if (Utils::isAdminPlugin()) {
+ $page = Grav::instance()['admin']->page() ?? null;
+ } else {
+ $page = $page ?? Grav::instance()['page'] ?? null;
+ }
+
+ // Try to find var in the page headers
+ if ($page instanceof PageInterface && $page->exists()) {
+ // Loop over pages and look for header vars
+ while ($page && !$page->root()) {
+ $header = new Data((array)$page->header());
+ $value = $header->get("$plugin.$var");
+ if (isset($value)) {
+ return $value;
+ }
+ $page = $page->parent();
+ }
+ }
+
+ return Grav::instance()['config']->get("plugins.$plugin.$var", $default);
+ }
+
/**
* Simpler getter for the plugin blueprint
*
diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php
index 88b5e524e..42b1593c2 100644
--- a/system/src/Grav/Common/Plugins.php
+++ b/system/src/Grav/Common/Plugins.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/AssetsProcessor.php b/system/src/Grav/Common/Processors/AssetsProcessor.php
index 66bb5e3ff..e460fb002 100644
--- a/system/src/Grav/Common/Processors/AssetsProcessor.php
+++ b/system/src/Grav/Common/Processors/AssetsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/BackupsProcessor.php b/system/src/Grav/Common/Processors/BackupsProcessor.php
index 6e960b493..83e8a0c21 100644
--- a/system/src/Grav/Common/Processors/BackupsProcessor.php
+++ b/system/src/Grav/Common/Processors/BackupsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
index de7cafcfc..a3d5a5152 100644
--- a/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
+++ b/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php b/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
index 32908bad7..30f6195b6 100644
--- a/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
+++ b/system/src/Grav/Common/Processors/Events/RequestHandlerEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/InitializeProcessor.php b/system/src/Grav/Common/Processors/InitializeProcessor.php
index b31530e80..04e06edf3 100644
--- a/system/src/Grav/Common/Processors/InitializeProcessor.php
+++ b/system/src/Grav/Common/Processors/InitializeProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/PagesProcessor.php b/system/src/Grav/Common/Processors/PagesProcessor.php
index 36f6718d2..3338e0c63 100644
--- a/system/src/Grav/Common/Processors/PagesProcessor.php
+++ b/system/src/Grav/Common/Processors/PagesProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/PluginsProcessor.php b/system/src/Grav/Common/Processors/PluginsProcessor.php
index 485578e49..ae8790104 100644
--- a/system/src/Grav/Common/Processors/PluginsProcessor.php
+++ b/system/src/Grav/Common/Processors/PluginsProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/ProcessorBase.php b/system/src/Grav/Common/Processors/ProcessorBase.php
index a3506f599..935339144 100644
--- a/system/src/Grav/Common/Processors/ProcessorBase.php
+++ b/system/src/Grav/Common/Processors/ProcessorBase.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/ProcessorInterface.php b/system/src/Grav/Common/Processors/ProcessorInterface.php
index 8a6edbe18..0aed19504 100644
--- a/system/src/Grav/Common/Processors/ProcessorInterface.php
+++ b/system/src/Grav/Common/Processors/ProcessorInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/RenderProcessor.php b/system/src/Grav/Common/Processors/RenderProcessor.php
index 329da22a3..e12cc45a3 100644
--- a/system/src/Grav/Common/Processors/RenderProcessor.php
+++ b/system/src/Grav/Common/Processors/RenderProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/RequestProcessor.php b/system/src/Grav/Common/Processors/RequestProcessor.php
index 971fb6747..bad410c11 100644
--- a/system/src/Grav/Common/Processors/RequestProcessor.php
+++ b/system/src/Grav/Common/Processors/RequestProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -11,6 +11,7 @@ namespace Grav\Common\Processors;
use Grav\Common\Processors\Events\RequestHandlerEvent;
use Grav\Common\Uri;
+use Grav\Common\Utils;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
@@ -42,7 +43,7 @@ class RequestProcessor extends ProcessorBase
}
$uri = $request->getUri();
- $ext = mb_strtolower(pathinfo($uri->getPath(), PATHINFO_EXTENSION));
+ $ext = mb_strtolower(Utils::pathinfo($uri->getPath(), PATHINFO_EXTENSION));
$request = $request
->withAttribute('grav', $this->container)
diff --git a/system/src/Grav/Common/Processors/SchedulerProcessor.php b/system/src/Grav/Common/Processors/SchedulerProcessor.php
index 69cc16385..722bfcc92 100644
--- a/system/src/Grav/Common/Processors/SchedulerProcessor.php
+++ b/system/src/Grav/Common/Processors/SchedulerProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/TasksProcessor.php b/system/src/Grav/Common/Processors/TasksProcessor.php
index 07e0934af..29f3458ee 100644
--- a/system/src/Grav/Common/Processors/TasksProcessor.php
+++ b/system/src/Grav/Common/Processors/TasksProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/ThemesProcessor.php b/system/src/Grav/Common/Processors/ThemesProcessor.php
index 951dc79e5..60d089e8b 100644
--- a/system/src/Grav/Common/Processors/ThemesProcessor.php
+++ b/system/src/Grav/Common/Processors/ThemesProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Processors/TwigProcessor.php b/system/src/Grav/Common/Processors/TwigProcessor.php
index 6604b5c05..ffc1032ea 100644
--- a/system/src/Grav/Common/Processors/TwigProcessor.php
+++ b/system/src/Grav/Common/Processors/TwigProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Processors
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/Cron.php b/system/src/Grav/Common/Scheduler/Cron.php
index 5127a997f..0103839d3 100644
--- a/system/src/Grav/Common/Scheduler/Cron.php
+++ b/system/src/Grav/Common/Scheduler/Cron.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on jqCron by Arnaud Buathier modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/IntervalTrait.php b/system/src/Grav/Common/Scheduler/IntervalTrait.php
index cc5c1654c..5f7406b8e 100644
--- a/system/src/Grav/Common/Scheduler/IntervalTrait.php
+++ b/system/src/Grav/Common/Scheduler/IntervalTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on peppeocchi/php-cron-scheduler modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/Job.php b/system/src/Grav/Common/Scheduler/Job.php
index 13059a572..41561192e 100644
--- a/system/src/Grav/Common/Scheduler/Job.php
+++ b/system/src/Grav/Common/Scheduler/Job.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on peppeocchi/php-cron-scheduler modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Scheduler/Scheduler.php b/system/src/Grav/Common/Scheduler/Scheduler.php
index 73a071225..19eb9eac3 100644
--- a/system/src/Grav/Common/Scheduler/Scheduler.php
+++ b/system/src/Grav/Common/Scheduler/Scheduler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Scheduler
* @author Originally based on peppeocchi/php-cron-scheduler modified for Grav integration
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Security.php b/system/src/Grav/Common/Security.php
index fe259d8ba..017720ca8 100644
--- a/system/src/Grav/Common/Security.php
+++ b/system/src/Grav/Common/Security.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -61,7 +61,7 @@ class Security
if ($clean_svg !== false ) {
file_put_contents($file, $clean_svg);
} else {
- $quarantine_file = basename($file);
+ $quarantine_file = Utils::basename($file);
$quarantine_dir = 'log://quarantine';
Folder::mkdir($quarantine_dir);
file_put_contents("$quarantine_dir/$quarantine_file", $original_svg);
@@ -214,7 +214,7 @@ class Security
'on_events' => '#(<[^>]+[[a-z\x00-\x20\"\'\/])([\s\/]on|\sxmlns)[a-z].*=>?#iUu',
// Match javascript:, livescript:, vbscript:, mocha:, feed: and data: protocols
- 'invalid_protocols' => '#(' . implode('|', array_map('preg_quote', $invalid_protocols, ['#'])) . '):\S.*?#iUu',
+ 'invalid_protocols' => '#(' . implode('|', array_map('preg_quote', $invalid_protocols, ['#'])) . ')(:|\&\#58)\S.*?#iUu',
// Match -moz-bindings
'moz_binding' => '#-moz-binding[a-z\x00-\x20]*:#u',
diff --git a/system/src/Grav/Common/Service/AccountsServiceProvider.php b/system/src/Grav/Common/Service/AccountsServiceProvider.php
index 8b158c93c..60f26e5b0 100644
--- a/system/src/Grav/Common/Service/AccountsServiceProvider.php
+++ b/system/src/Grav/Common/Service/AccountsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/AssetsServiceProvider.php b/system/src/Grav/Common/Service/AssetsServiceProvider.php
index 1e4e647ca..54a44a1c8 100644
--- a/system/src/Grav/Common/Service/AssetsServiceProvider.php
+++ b/system/src/Grav/Common/Service/AssetsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/BackupsServiceProvider.php b/system/src/Grav/Common/Service/BackupsServiceProvider.php
index 00fa9631a..58f5021a3 100644
--- a/system/src/Grav/Common/Service/BackupsServiceProvider.php
+++ b/system/src/Grav/Common/Service/BackupsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/ConfigServiceProvider.php b/system/src/Grav/Common/Service/ConfigServiceProvider.php
index 3a5c2e27b..e65e22850 100644
--- a/system/src/Grav/Common/Service/ConfigServiceProvider.php
+++ b/system/src/Grav/Common/Service/ConfigServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/ErrorServiceProvider.php b/system/src/Grav/Common/Service/ErrorServiceProvider.php
index 322736584..02d38c930 100644
--- a/system/src/Grav/Common/Service/ErrorServiceProvider.php
+++ b/system/src/Grav/Common/Service/ErrorServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/FilesystemServiceProvider.php b/system/src/Grav/Common/Service/FilesystemServiceProvider.php
index 62dad5d81..1dde5b3e5 100644
--- a/system/src/Grav/Common/Service/FilesystemServiceProvider.php
+++ b/system/src/Grav/Common/Service/FilesystemServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/FlexServiceProvider.php b/system/src/Grav/Common/Service/FlexServiceProvider.php
index 9c8cd49b1..e7b283ab0 100644
--- a/system/src/Grav/Common/Service/FlexServiceProvider.php
+++ b/system/src/Grav/Common/Service/FlexServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/InflectorServiceProvider.php b/system/src/Grav/Common/Service/InflectorServiceProvider.php
index 861a69e04..f43a4461d 100644
--- a/system/src/Grav/Common/Service/InflectorServiceProvider.php
+++ b/system/src/Grav/Common/Service/InflectorServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/LoggerServiceProvider.php b/system/src/Grav/Common/Service/LoggerServiceProvider.php
index 5043cfbd0..43a67cadf 100644
--- a/system/src/Grav/Common/Service/LoggerServiceProvider.php
+++ b/system/src/Grav/Common/Service/LoggerServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/OutputServiceProvider.php b/system/src/Grav/Common/Service/OutputServiceProvider.php
index 9a49185a8..2dbd3436f 100644
--- a/system/src/Grav/Common/Service/OutputServiceProvider.php
+++ b/system/src/Grav/Common/Service/OutputServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/PagesServiceProvider.php b/system/src/Grav/Common/Service/PagesServiceProvider.php
index 55f6a450d..fa6631eee 100644
--- a/system/src/Grav/Common/Service/PagesServiceProvider.php
+++ b/system/src/Grav/Common/Service/PagesServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -99,7 +99,8 @@ class PagesServiceProvider implements ServiceProviderInterface
/** @var Language $language */
$language = $grav['language'];
- $redirectCode = (int)$config->get('system.pages.redirect_default_route', 0);
+ $redirect_default_route = $page->header()->redirect_default_route ?? $config->get('system.pages.redirect_default_route', 0);
+ $redirectCode = (int) $redirect_default_route;
// Language-specific redirection scenarios
if ($language->enabled() && ($language->isLanguageInUrl() xor $language->isIncludeDefaultLanguage())) {
diff --git a/system/src/Grav/Common/Service/RequestServiceProvider.php b/system/src/Grav/Common/Service/RequestServiceProvider.php
index 17b3149e5..a44c73564 100644
--- a/system/src/Grav/Common/Service/RequestServiceProvider.php
+++ b/system/src/Grav/Common/Service/RequestServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/SchedulerServiceProvider.php b/system/src/Grav/Common/Service/SchedulerServiceProvider.php
index a95272544..13918fbc2 100644
--- a/system/src/Grav/Common/Service/SchedulerServiceProvider.php
+++ b/system/src/Grav/Common/Service/SchedulerServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/SessionServiceProvider.php b/system/src/Grav/Common/Service/SessionServiceProvider.php
index 88c833f26..80e24b4c7 100644
--- a/system/src/Grav/Common/Service/SessionServiceProvider.php
+++ b/system/src/Grav/Common/Service/SessionServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -40,7 +40,8 @@ class SessionServiceProvider implements ServiceProviderInterface
// Get session options.
$enabled = (bool)$config->get('system.session.enabled', false);
- $cookie_secure = (bool)$config->get('system.session.secure', false);
+ $cookie_secure = $config->get('system.session.secure', false)
+ || ($config->get('system.session.secure_https', true) && $uri->scheme(true) === 'https');
$cookie_httponly = (bool)$config->get('system.session.httponly', true);
$cookie_lifetime = (int)$config->get('system.session.timeout', 1800);
$cookie_domain = $config->get('system.session.domain');
diff --git a/system/src/Grav/Common/Service/StreamsServiceProvider.php b/system/src/Grav/Common/Service/StreamsServiceProvider.php
index edde09ad5..f501b4903 100644
--- a/system/src/Grav/Common/Service/StreamsServiceProvider.php
+++ b/system/src/Grav/Common/Service/StreamsServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Service/TaskServiceProvider.php b/system/src/Grav/Common/Service/TaskServiceProvider.php
index 49ce147e9..2989e9d27 100644
--- a/system/src/Grav/Common/Service/TaskServiceProvider.php
+++ b/system/src/Grav/Common/Service/TaskServiceProvider.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Service
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Session.php b/system/src/Grav/Common/Session.php
index 322162705..513143e09 100644
--- a/system/src/Grav/Common/Session.php
+++ b/system/src/Grav/Common/Session.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Taxonomy.php b/system/src/Grav/Common/Taxonomy.php
index 0d0a450b0..5079a2572 100644
--- a/system/src/Grav/Common/Taxonomy.php
+++ b/system/src/Grav/Common/Taxonomy.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Theme.php b/system/src/Grav/Common/Theme.php
index a5006a215..60131292a 100644
--- a/system/src/Grav/Common/Theme.php
+++ b/system/src/Grav/Common/Theme.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php
index 6126841cf..3567ccadd 100644
--- a/system/src/Grav/Common/Themes.php
+++ b/system/src/Grav/Common/Themes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Exception/TwigException.php b/system/src/Grav/Common/Twig/Exception/TwigException.php
index bc023afd7..7605de4c4 100644
--- a/system/src/Grav/Common/Twig/Exception/TwigException.php
+++ b/system/src/Grav/Common/Twig/Exception/TwigException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig\Exception
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php b/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php
index dfd5fdd90..0ae793e62 100644
--- a/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php
+++ b/system/src/Grav/Common/Twig/Extension/FilesystemExtension.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -266,24 +266,24 @@ class FilesystemExtension extends AbstractExtension
}
/**
- * @param string $file
+ * @param string $filename
* @param string|null $required_sections
* @param bool $as_arrays
* @param bool $read_thumbnail
* @return array|false
*/
- public function exif_read_data($file, ?string $required_sections, bool $as_arrays = false, bool $read_thumbnail = false)
+ public function exif_read_data($filename, ?string $required_sections, bool $as_arrays = false, bool $read_thumbnail = false)
{
- if (!Utils::functionExists('exif_read_data') || !$this->checkFilename($file)) {
+ if (!Utils::functionExists('exif_read_data') || !$this->checkFilename($filename)) {
return false;
}
- return exif_read_data($file, $required_sections, $as_arrays, $read_thumbnail);
+ return exif_read_data($filename, $required_sections, $as_arrays, $read_thumbnail);
}
/**
* @param string $filename
- * @return string|false
+ * @return int|false
*/
public function exif_imagetype($filename)
{
@@ -311,18 +311,18 @@ class FilesystemExtension extends AbstractExtension
/**
* @param string $algo
- * @param string $data
+ * @param string $filename
* @param string $key
* @param bool $binary
* @return string|false
*/
- public function hash_hmac_file(string $algo, string $data, string $key, bool $binary = false)
+ public function hash_hmac_file(string $algo, string $filename, string $key, bool $binary = false)
{
- if (!$this->checkFilename($data)) {
+ if (!$this->checkFilename($filename)) {
return false;
}
- return hash_hmac_file($algo, $data, $key, $binary);
+ return hash_hmac_file($algo, $filename, $key, $binary);
}
/**
@@ -373,11 +373,7 @@ class FilesystemExtension extends AbstractExtension
*/
public function pathinfo($path, $flags = null)
{
- if (null !== $flags) {
- return pathinfo($path, (int)$flags);
- }
-
- return pathinfo($path);
+ return Utils::pathinfo($path, $flags);
}
/**
diff --git a/system/src/Grav/Common/Twig/Extension/GravExtension.php b/system/src/Grav/Common/Twig/Extension/GravExtension.php
index 4c0d9fe46..52e2a1841 100644
--- a/system/src/Grav/Common/Twig/Extension/GravExtension.php
+++ b/system/src/Grav/Common/Twig/Extension/GravExtension.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,6 +22,7 @@ use Grav\Common\Page\Media;
use Grav\Common\Scheduler\Cron;
use Grav\Common\Security;
use Grav\Common\Twig\TokenParser\TwigTokenParserCache;
+use Grav\Common\Twig\TokenParser\TwigTokenParserLink;
use Grav\Common\Twig\TokenParser\TwigTokenParserRender;
use Grav\Common\Twig\TokenParser\TwigTokenParserScript;
use Grav\Common\Twig\TokenParser\TwigTokenParserStyle;
@@ -115,6 +116,7 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
new TwigFilter('defined', [$this, 'definedDefaultFilter']),
new TwigFilter('ends_with', [$this, 'endsWithFilter']),
new TwigFilter('fieldName', [$this, 'fieldNameFilter']),
+ new TwigFilter('parent_field', [$this, 'fieldParentFilter']),
new TwigFilter('ksort', [$this, 'ksortFilter']),
new TwigFilter('ltrim', [$this, 'ltrimFilter']),
new TwigFilter('markdown', [$this, 'markdownFunction'], ['needs_context' => true, 'is_safe' => ['html']]),
@@ -252,12 +254,17 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
new TwigTokenParserTryCatch(),
new TwigTokenParserScript(),
new TwigTokenParserStyle(),
+ new TwigTokenParserLink(),
new TwigTokenParserMarkdown(),
new TwigTokenParserSwitch(),
new TwigTokenParserCache(),
];
}
+ /**
+ * @param mixed $var
+ * @return string
+ */
public function print_r($var)
{
return print_r($var, true);
@@ -276,6 +283,20 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
return array_shift($path) . ($path ? '[' . implode('][', $path) . ']' : '');
}
+ /**
+ * Filters field name by changing dot notation into array notation.
+ *
+ * @param string $str
+ * @return string
+ */
+ public function fieldParentFilter($str)
+ {
+ $path = explode('.', rtrim($str, '.'));
+ array_pop($path);
+
+ return implode('.', $path);
+ }
+
/**
* Protects email address.
*
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
index 0ed1fff0c..e05e37248 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeLink.php b/system/src/Grav/Common/Twig/Node/TwigNodeLink.php
new file mode 100644
index 000000000..a468633ba
--- /dev/null
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeLink.php
@@ -0,0 +1,114 @@
+ $file, 'group' => $group, 'priority' => $priority, 'attributes' => $attributes];
+ $nodes = array_filter($nodes);
+
+ parent::__construct($nodes, ['rel' => $rel], $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Compiler $compiler A Twig Compiler instance
+ * @return void
+ * @throws LogicException
+ */
+ public function compile(Compiler $compiler): void
+ {
+ $compiler->addDebugInfo($this);
+ if (!$this->hasNode('file')) {
+ return;
+ }
+
+ $compiler->write('$attributes = [\'rel\' => \'' . $this->getAttribute('rel') . '\'];' . "\n");
+ if ($this->hasNode('attributes')) {
+ $compiler
+ ->write('$attributes += ')
+ ->subcompile($this->getNode('attributes'))
+ ->raw(';' . PHP_EOL)
+ ->write('if (!is_array($attributes)) {' . PHP_EOL)
+ ->indent()
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');" . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL);
+ }
+
+ if ($this->hasNode('group')) {
+ $compiler
+ ->write('$group = ')
+ ->subcompile($this->getNode('group'))
+ ->raw(';' . PHP_EOL)
+ ->write('if (!is_string($group)) {' . PHP_EOL)
+ ->indent()
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');" . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL);
+ } else {
+ $compiler->write('$group = \'head\';' . PHP_EOL);
+ }
+
+ if ($this->hasNode('priority')) {
+ $compiler
+ ->write('$priority = (int)(')
+ ->subcompile($this->getNode('priority'))
+ ->raw(');' . PHP_EOL);
+ } else {
+ $compiler->write('$priority = 10;' . PHP_EOL);
+ }
+
+ $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];" . PHP_EOL);
+ $compiler->write("\$block = \$context['block'] ?? null;" . PHP_EOL);
+
+ $compiler
+ ->write('$file = (string)(')
+ ->subcompile($this->getNode('file'))
+ ->raw(');' . PHP_EOL);
+
+ // Assets support.
+ $compiler->write('$assets->addLink($file, [\'group\' => $group, \'priority\' => $priority] + $attributes);' . PHP_EOL);
+
+ // HtmlBlock support.
+ $compiler
+ ->write('if ($block instanceof \Grav\Framework\ContentBlock\HtmlBlock) {' . PHP_EOL)
+ ->indent()
+ ->write('$block->addLink([\'href\'=> $file] + $attributes, $priority, $group);' . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL);
+ }
+}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php b/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
index 81cecaeaf..4637db774 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeRender.php b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
index 798c6baa6..dbce3c66f 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeRender.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -75,6 +75,7 @@ class TwigNodeRender extends Node implements NodeCaptureInterface
->outdent()
->write('} else {' . PHP_EOL)
->indent()
+ ->write('\Grav\Common\Assets\BlockAssets::registerAssets($html);' . PHP_EOL)
->write('echo (string)$html;' . PHP_EOL)
->outdent()
->write('}' . PHP_EOL)
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
index 46a08703b..03554bd09 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -27,6 +27,7 @@ class TwigNodeScript extends Node implements NodeCaptureInterface
/**
* TwigNodeScript constructor.
* @param Node|null $body
+ * @param string|null $type
* @param AbstractExpression|null $file
* @param AbstractExpression|null $group
* @param AbstractExpression|null $priority
@@ -34,12 +35,12 @@ class TwigNodeScript extends Node implements NodeCaptureInterface
* @param int $lineno
* @param string|null $tag
*/
- public function __construct(?Node $body, ?AbstractExpression $file, ?AbstractExpression $group, ?AbstractExpression $priority, ?AbstractExpression $attributes, $lineno = 0, $tag = null)
+ public function __construct(?Node $body, ?string $type, ?AbstractExpression $file, ?AbstractExpression $group, ?AbstractExpression $priority, ?AbstractExpression $attributes, $lineno = 0, $tag = null)
{
$nodes = ['body' => $body, 'file' => $file, 'group' => $group, 'priority' => $priority, 'attributes' => $attributes];
$nodes = array_filter($nodes);
- parent::__construct($nodes, [], $lineno, $tag);
+ parent::__construct($nodes, ['type' => $type], $lineno, $tag);
}
/**
@@ -53,52 +54,89 @@ class TwigNodeScript extends Node implements NodeCaptureInterface
{
$compiler->addDebugInfo($this);
- $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];\n");
-
if ($this->hasNode('attributes')) {
$compiler
->write('$attributes = ')
->subcompile($this->getNode('attributes'))
- ->raw(";\n")
- ->write("if (!is_array(\$attributes)) {\n")
+ ->raw(';' . PHP_EOL)
+ ->write('if (!is_array($attributes)) {' . PHP_EOL)
->indent()
- ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');\n")
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');" . PHP_EOL)
->outdent()
- ->write("}\n");
+ ->write('}' . PHP_EOL);
} else {
- $compiler->write('$attributes = [];' . "\n");
+ $compiler->write('$attributes = [];' . PHP_EOL);
}
if ($this->hasNode('group')) {
$compiler
- ->write("\$attributes['group'] = ")
+ ->write('$group = ')
->subcompile($this->getNode('group'))
- ->raw(";\n")
- ->write("if (!is_string(\$attributes['group'])) {\n")
+ ->raw(';' . PHP_EOL)
+ ->write('if (!is_string($group)) {' . PHP_EOL)
->indent()
- ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');\n")
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');" . PHP_EOL)
->outdent()
- ->write("}\n");
+ ->write('}' . PHP_EOL);
+ } else {
+ $compiler->write('$group = \'head\';' . PHP_EOL);
}
if ($this->hasNode('priority')) {
$compiler
- ->write("\$attributes['priority'] = (int)(")
+ ->write('$priority = (int)(')
->subcompile($this->getNode('priority'))
- ->raw(");\n");
+ ->raw(');' . PHP_EOL);
+ } else {
+ $compiler->write('$priority = 10;' . PHP_EOL);
}
+ $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];" . PHP_EOL);
+ $compiler->write("\$block = \$context['block'] ?? null;" . PHP_EOL);
+
if ($this->hasNode('file')) {
+ // JS file.
$compiler
- ->write('$assets->addJs(')
+ ->write('$file = (string)(')
->subcompile($this->getNode('file'))
- ->raw(", \$attributes);\n");
- } else {
+ ->raw(');' . PHP_EOL);
+
+ $method = $this->getAttribute('type') === 'module' ? 'addJsModule' : 'addJs';
+
+ // Assets support.
+ $compiler->write('$assets->' . $method . '($file, [\'group\' => $group, \'priority\' => $priority] + $attributes);' . PHP_EOL);
+
+ $method = $this->getAttribute('type') === 'module' ? 'addModule' : 'addScript';
+
+ // HtmlBlock support.
$compiler
- ->write("ob_start();\n")
+ ->write('if ($block instanceof \Grav\Framework\ContentBlock\HtmlBlock) {' . PHP_EOL)
+ ->indent()
+ ->write('$block->' . $method . '([\'src\'=> $file] + $attributes, $priority, $group);' . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL);
+
+ } else {
+ // Inline script.
+ $compiler
+ ->write('ob_start();' . PHP_EOL)
->subcompile($this->getNode('body'))
- ->write('$content = ob_get_clean();' . "\n")
- ->write("\$assets->addInlineJs(\$content, \$attributes);\n");
+ ->write('$content = ob_get_clean();' . PHP_EOL);
+
+ $method = $this->getAttribute('type') === 'module' ? 'addInlineJsModule' : 'addInlineJs';
+
+ // Assets support.
+ $compiler->write('$assets->' . $method . '($content, [\'group\' => $group, \'priority\' => $priority] + $attributes);' . PHP_EOL);
+
+ $method = $this->getAttribute('type') === 'module' ? 'addInlineModule' : 'addInlineScript';
+
+ // HtmlBlock support.
+ $compiler
+ ->write('if ($block instanceof \Grav\Framework\ContentBlock\HtmlBlock) {' . PHP_EOL)
+ ->indent()
+ ->write('$block->' . $method . '([\'content\'=> $content] + $attributes, $priority, $group);' . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL);
}
}
}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
index 05355f904..1c3568c6a 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -41,6 +41,7 @@ class TwigNodeStyle extends Node implements NodeCaptureInterface
parent::__construct($nodes, [], $lineno, $tag);
}
+
/**
* Compiles the node to PHP.
*
@@ -52,52 +53,81 @@ class TwigNodeStyle extends Node implements NodeCaptureInterface
{
$compiler->addDebugInfo($this);
- $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];\n");
-
if ($this->hasNode('attributes')) {
$compiler
->write('$attributes = ')
->subcompile($this->getNode('attributes'))
- ->raw(";\n")
- ->write("if (!is_array(\$attributes)) {\n")
+ ->raw(';' . PHP_EOL)
+ ->write('if (!is_array($attributes)) {' . PHP_EOL)
->indent()
- ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');\n")
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} with x %}: x is not an array');" . PHP_EOL)
->outdent()
- ->write("}\n");
+ ->write('}' . PHP_EOL);
} else {
- $compiler->write('$attributes = [];' . "\n");
+ $compiler->write('$attributes = [];' . PHP_EOL);
}
if ($this->hasNode('group')) {
$compiler
- ->write("\$attributes['group'] = ")
+ ->write('$group = ')
->subcompile($this->getNode('group'))
- ->raw(";\n")
- ->write("if (!is_string(\$attributes['group'])) {\n")
+ ->raw(';' . PHP_EOL)
+ ->write('if (!is_string($group)) {' . PHP_EOL)
->indent()
- ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');\n")
+ ->write("throw new UnexpectedValueException('{% {$this->tagName} in x %}: x is not a string');" . PHP_EOL)
->outdent()
- ->write("}\n");
+ ->write('}' . PHP_EOL);
+ } else {
+ $compiler->write('$group = \'head\';' . PHP_EOL);
}
if ($this->hasNode('priority')) {
$compiler
- ->write("\$attributes['priority'] = (int)(")
+ ->write('$priority = (int)(')
->subcompile($this->getNode('priority'))
- ->raw(");\n");
+ ->raw(');' . PHP_EOL);
+ } else {
+ $compiler->write('$priority = 10;' . PHP_EOL);
}
+ $compiler->write("\$assets = \\Grav\\Common\\Grav::instance()['assets'];" . PHP_EOL);
+ $compiler->write("\$block = \$context['block'] ?? null;" . PHP_EOL);
+
if ($this->hasNode('file')) {
+ // CSS file.
$compiler
- ->write('$assets->addCss(')
+ ->write('$file = (string)(')
->subcompile($this->getNode('file'))
- ->raw(", \$attributes);\n");
- } else {
+ ->raw(');' . PHP_EOL);
+
+ // Assets support.
+ $compiler->write('$assets->addCss($file, [\'group\' => $group, \'priority\' => $priority] + $attributes);' . PHP_EOL);
+
+ // HtmlBlock support.
$compiler
- ->write("ob_start();\n")
+ ->write('if ($block instanceof \Grav\Framework\ContentBlock\HtmlBlock) {' . PHP_EOL)
+ ->indent()
+ ->write('$block->addStyle([\'href\'=> $file] + $attributes, $priority, $group);' . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL);
+
+ } else {
+ // Inline style.
+ $compiler
+ ->write('ob_start();' . PHP_EOL)
->subcompile($this->getNode('body'))
- ->write('$content = ob_get_clean();' . "\n")
- ->write("\$assets->addInlineCss(\$content, \$attributes);\n");
+ ->write('$content = ob_get_clean();' . PHP_EOL);
+
+ // Assets support.
+ $compiler->write('$assets->addInlineCss($content, [\'group\' => $group, \'priority\' => $priority] + $attributes);' . PHP_EOL);
+
+ // HtmlBlock support.
+ $compiler
+ ->write('if ($block instanceof \Grav\Framework\ContentBlock\HtmlBlock) {' . PHP_EOL)
+ ->indent()
+ ->write('$block->addInlineStyle([\'content\'=> $content] + $attributes, $priority, $group);' . PHP_EOL)
+ ->outdent()
+ ->write('}' . PHP_EOL);
}
}
}
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
index 43ae56f18..7bd368e6d 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
index 3bfe6124e..41ca15dc2 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
index 40e9240f3..1213b7c64 100644
--- a/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
+++ b/system/src/Grav/Common/Twig/Node/TwigNodeTryCatch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
index 371e89ae6..1cf21918b 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserLink.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserLink.php
new file mode 100644
index 000000000..2cb0208eb
--- /dev/null
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserLink.php
@@ -0,0 +1,109 @@
+getLine();
+
+ [$rel, $file, $group, $priority, $attributes] = $this->parseArguments($token);
+
+ return new TwigNodeLink($rel, $file, $group, $priority, $attributes, $lineno, $this->getTag());
+ }
+
+ /**
+ * @param Token $token
+ * @return array
+ */
+ protected function parseArguments(Token $token): array
+ {
+ $stream = $this->parser->getStream();
+
+
+ $rel = null;
+ if ($stream->test(Token::NAME_TYPE, $this->rel)) {
+ $rel = $stream->getCurrent()->getValue();
+ $stream->next();
+ }
+
+ $file = null;
+ if (!$stream->test(Token::NAME_TYPE) && !$stream->test(Token::BLOCK_END_TYPE)) {
+ $file = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $group = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'at')) {
+ $group = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $priority = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'priority')) {
+ $stream->expect(Token::PUNCTUATION_TYPE, ':');
+ $priority = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $attributes = null;
+ if ($stream->nextIf(Token::NAME_TYPE, 'with')) {
+ $attributes = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $stream->expect(Token::BLOCK_END_TYPE);
+
+ return [$rel, $file, $group, $priority, $attributes];
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag(): string
+ {
+ return 'link';
+ }
+}
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
index 9dab4ae5c..49e34e693 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
index ab2bdde0f..de16266b0 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserRender.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
index b86063165..b943a2540 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserScript.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -15,14 +15,20 @@ use Twig\Token;
use Twig\TokenParser\AbstractTokenParser;
/**
- * Adds a script to head/bottom/custom location in the document.
+ * Adds a script to head/bottom/custom group location in the document.
*
- * {% script 'theme://js/something.js' at 'bottom' priority: 20 with { defer: true, async: true } %}
+ * {% script 'theme://js/something.js' at 'bottom' priority: 20 with { position: 'pipeline', loading: 'async defer' } %}
+ * {% script module 'theme://js/module.mjs' at 'head' %}
*
+ * {% script 'theme://js/something.js' at 'bottom' priority: 20 with { loading: 'inline' } %}
* {% script at 'bottom' priority: 20 %}
- * alert('Warning!');
+ * alert('Warning!');
+ * {% endscript %}
+ *
+ * {% script module 'theme://js/module.mjs' at 'bottom' with { loading: 'inline' } %}
+ * {% script module at 'bottom' %}
+ * ...
* {% endscript %}
-
*/
class TwigTokenParserScript extends AbstractTokenParser
{
@@ -38,7 +44,7 @@ class TwigTokenParserScript extends AbstractTokenParser
$lineno = $token->getLine();
$stream = $this->parser->getStream();
- [$file, $group, $priority, $attributes] = $this->parseArguments($token);
+ [$type, $file, $group, $priority, $attributes] = $this->parseArguments($token);
$content = null;
if ($file === null) {
@@ -46,7 +52,7 @@ class TwigTokenParserScript extends AbstractTokenParser
$stream->expect(Token::BLOCK_END_TYPE);
}
- return new TwigNodeScript($content, $file, $group, $priority, $attributes, $lineno, $this->getTag());
+ return new TwigNodeScript($content, $type, $file, $group, $priority, $attributes, $lineno, $this->getTag());
}
/**
@@ -73,6 +79,12 @@ class TwigTokenParserScript extends AbstractTokenParser
} while (true);
}
+ $type = null;
+ if ($stream->test(Token::NAME_TYPE, 'module')) {
+ $type = $stream->getCurrent()->getValue();
+ $stream->next();
+ }
+
$file = null;
if (!$stream->test(Token::NAME_TYPE) && !$stream->test(Token::OPERATOR_TYPE, 'in') && !$stream->test(Token::BLOCK_END_TYPE)) {
$file = $this->parser->getExpressionParser()->parseExpression();
@@ -96,7 +108,7 @@ class TwigTokenParserScript extends AbstractTokenParser
$stream->expect(Token::BLOCK_END_TYPE);
- return [$file, $group, $priority, $attributes];
+ return [$type, $file, $group, $priority, $attributes];
}
/**
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
index c8d9544ce..0687395ad 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
index 4540bbf7e..c63fe9565 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserSwitch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
* @origin https://gist.github.com/maxgalbu/9409182
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
index bd4adab97..41f415d2a 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
index 46af1767a..993063283 100644
--- a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
+++ b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserTryCatch.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php
index 1416dac85..39ae3c6f6 100644
--- a/system/src/Grav/Common/Twig/Twig.php
+++ b/system/src/Grav/Common/Twig/Twig.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TwigClockworkDataSource.php b/system/src/Grav/Common/Twig/TwigClockworkDataSource.php
index 11127b87c..407a05ef4 100644
--- a/system/src/Grav/Common/Twig/TwigClockworkDataSource.php
+++ b/system/src/Grav/Common/Twig/TwigClockworkDataSource.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TwigClockworkDumper.php b/system/src/Grav/Common/Twig/TwigClockworkDumper.php
index 2c1f4be02..c960cf2cd 100644
--- a/system/src/Grav/Common/Twig/TwigClockworkDumper.php
+++ b/system/src/Grav/Common/Twig/TwigClockworkDumper.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/TwigEnvironment.php b/system/src/Grav/Common/Twig/TwigEnvironment.php
index bebbdf16e..6b2a86bef 100644
--- a/system/src/Grav/Common/Twig/TwigEnvironment.php
+++ b/system/src/Grav/Common/Twig/TwigEnvironment.php
@@ -3,13 +3,16 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Twig;
use Twig\Environment;
+use Twig\Error\LoaderError;
+use Twig\Template;
+use Twig\TemplateWrapper;
/**
* Class TwigEnvironment
@@ -18,4 +21,34 @@ use Twig\Environment;
class TwigEnvironment extends Environment
{
use WriteCacheFileTrait;
+
+ /**
+ * @inheritDoc
+ */
+ public function resolveTemplate($names)
+ {
+ if (!\is_array($names)) {
+ $names = [$names];
+ }
+
+ $count = \count($names);
+ foreach ($names as $name) {
+ if ($name instanceof Template) {
+ return $name;
+ }
+ if ($name instanceof TemplateWrapper) {
+ return $name;
+ }
+
+ // Optimization: Avoid throwing an exception when it would be ignored anyway.
+ if (1 !== $count && !$this->getLoader()->exists($name)) {
+ continue;
+ }
+
+ // Throws LoaderError: Unable to find template "%s".
+ return $this->loadTemplate($name);
+ }
+
+ throw new LoaderError(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names)));
+ }
}
diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php
index 698858b56..07c442e8e 100644
--- a/system/src/Grav/Common/Twig/TwigExtension.php
+++ b/system/src/Grav/Common/Twig/TwigExtension.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Twig/WriteCacheFileTrait.php b/system/src/Grav/Common/Twig/WriteCacheFileTrait.php
index edab8e5b8..575a28163 100644
--- a/system/src/Grav/Common/Twig/WriteCacheFileTrait.php
+++ b/system/src/Grav/Common/Twig/WriteCacheFileTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Twig
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php
index 908d99f8f..76d9a9926 100644
--- a/system/src/Grav/Common/Uri.php
+++ b/system/src/Grav/Common/Uri.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -217,7 +217,7 @@ class Uri
$path = $bits['path'] ?? '/';
// remove the extension if there is one set
- $parts = pathinfo($path);
+ $parts = Utils::pathinfo($path);
// set the original basename
$this->basename = $parts['basename'];
@@ -337,9 +337,9 @@ class Uri
/**
* Get URI parameter.
*
- * @param string|null $id
- * @param string|bool|null $default
- * @return bool|string
+ * @param string $id
+ * @param string|false|null $default
+ * @return string|false|null
*/
public function param($id, $default = false)
{
@@ -854,7 +854,7 @@ class Uri
}
if ($full_path) {
- $path_info = pathinfo($full_path);
+ $path_info = Utils::pathinfo($full_path);
$page_path = $path_info['dirname'];
$filename = '';
@@ -899,7 +899,7 @@ class Uri
$routes = $pages->routes();
// if this is an image, get the proper path
- $url_bits = pathinfo($url_path);
+ $url_bits = Utils::pathinfo($url_path);
if (isset($url_bits['extension'])) {
$target_path = $url_bits['dirname'];
} else {
@@ -1046,7 +1046,7 @@ class Uri
$base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
// if absolute and starts with a base_url move on
- if (pathinfo($markdown_url, PATHINFO_DIRNAME) === '.' && $page->url() === '/') {
+ if (Utils::pathinfo($markdown_url, PATHINFO_DIRNAME) === '.' && $page->url() === '/') {
return '/' . $markdown_url;
}
// no path to convert
@@ -1085,7 +1085,7 @@ class Uri
return $normalized_url;
}
- $path_info = pathinfo($full_path);
+ $path_info = Utils::pathinfo($full_path);
$page_path = $path_info['dirname'];
$filename = '';
diff --git a/system/src/Grav/Common/User/Access.php b/system/src/Grav/Common/User/Access.php
index 6503c891f..96f4d96d6 100644
--- a/system/src/Grav/Common/User/Access.php
+++ b/system/src/Grav/Common/User/Access.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Authentication.php b/system/src/Grav/Common/User/Authentication.php
index 6ff95e7bf..c32fd62e6 100644
--- a/system/src/Grav/Common/User/Authentication.php
+++ b/system/src/Grav/Common/User/Authentication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/DataUser/User.php b/system/src/Grav/Common/User/DataUser/User.php
index 0b8a53b9e..71e7f9b35 100644
--- a/system/src/Grav/Common/User/DataUser/User.php
+++ b/system/src/Grav/Common/User/DataUser/User.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -21,6 +21,7 @@ use Grav\Common\Page\Medium\MediumFactory;
use Grav\Common\User\Authentication;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\User\Traits\UserTrait;
+use Grav\Common\Utils;
use Grav\Framework\Flex\Flex;
use function is_array;
@@ -177,7 +178,7 @@ class User extends Data implements UserInterface
if ($path && is_file($path)) {
$medium = MediumFactory::fromFile($path);
if ($medium) {
- $media->add(basename($path), $medium);
+ $media->add(Utils::basename($path), $medium);
}
}
diff --git a/system/src/Grav/Common/User/DataUser/UserCollection.php b/system/src/Grav/Common/User/DataUser/UserCollection.php
index 3da7e2dde..d0ada09c9 100644
--- a/system/src/Grav/Common/User/DataUser/UserCollection.php
+++ b/system/src/Grav/Common/User/DataUser/UserCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -114,7 +114,7 @@ class UserCollection implements UserCollectionInterface
if (!$user->exists()) {
foreach ($files as $file) {
if (Utils::endsWith($file, YAML_EXT)) {
- $find_user = $this->load(trim(pathinfo($file, PATHINFO_FILENAME)));
+ $find_user = $this->load(trim(Utils::pathinfo($file, PATHINFO_FILENAME)));
foreach ($fields as $field) {
if (isset($find_user[$field]) && $find_user[$field] === $query) {
return $find_user;
diff --git a/system/src/Grav/Common/User/Group.php b/system/src/Grav/Common/User/Group.php
index 7dd6d650c..9be619a1c 100644
--- a/system/src/Grav/Common/User/Group.php
+++ b/system/src/Grav/Common/User/Group.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php b/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php
index 3ad8d2cc5..1aeb004e6 100644
--- a/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/AuthorizeInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php b/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
index d892e820f..5bcfbc0f2 100644
--- a/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/UserCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php b/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php
index c345c4b38..c18388ce9 100644
--- a/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/UserGroupInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Interfaces/UserInterface.php b/system/src/Grav/Common/User/Interfaces/UserInterface.php
index 02827e37c..dcd014c88 100644
--- a/system/src/Grav/Common/User/Interfaces/UserInterface.php
+++ b/system/src/Grav/Common/User/Interfaces/UserInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/Traits/UserTrait.php b/system/src/Grav/Common/User/Traits/UserTrait.php
index 5a6b74938..0608caf5e 100644
--- a/system/src/Grav/Common/User/Traits/UserTrait.php
+++ b/system/src/Grav/Common/User/Traits/UserTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/User/User.php b/system/src/Grav/Common/User/User.php
index 4b2319fc5..b38c72e26 100644
--- a/system/src/Grav/Common/User/User.php
+++ b/system/src/Grav/Common/User/User.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\User
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php
index 5295a6400..64c81a927 100644
--- a/system/src/Grav/Common/Utils.php
+++ b/system/src/Grav/Common/Utils.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -653,16 +653,17 @@ abstract class Utils
* @param bool $force_download as opposed to letting browser choose if to download or render
* @param int $sec Throttling, try 0.1 for some speed throttling of downloads
* @param int $bytes Size of chunks to send in bytes. Default is 1024
+ * @param array $options Extra options: [mime, download_name, expires]
* @throws Exception
*/
- public static function download($file, $force_download = true, $sec = 0, $bytes = 1024)
+ public static function download($file, $force_download = true, $sec = 0, $bytes = 1024, array $options = [])
{
if (file_exists($file)) {
// fire download event
- Grav::instance()->fireEvent('onBeforeDownload', new Event(['file' => $file]));
+ Grav::instance()->fireEvent('onBeforeDownload', new Event(['file' => $file, 'options' => &$options]));
- $file_parts = pathinfo($file);
- $mimetype = static::getMimeByExtension($file_parts['extension']);
+ $file_parts = static::pathinfo($file);
+ $mimetype = $options['mime'] ?? static::getMimeByExtension($file_parts['extension']);
$size = filesize($file); // File size
// clean all buffers
@@ -680,7 +681,7 @@ abstract class Utils
if ($force_download) {
// output the regular HTTP headers
- header('Content-Disposition: attachment; filename="' . $file_parts['basename'] . '"');
+ header('Content-Disposition: attachment; filename="' . ($options['download_name'] ?? $file_parts['basename']) . '"');
}
// multipart-download and download resuming support
@@ -704,7 +705,7 @@ abstract class Utils
header('Content-Length: ' . $size);
if (Grav::instance()['config']->get('system.cache.enabled')) {
- $expires = Grav::instance()['config']->get('system.pages.expires');
+ $expires = $options['expires'] ?? Grav::instance()['config']->get('system.pages.expires');
if ($expires > 0) {
$expires_date = gmdate('D, d M Y H:i:s T', time() + $expires);
header('Cache-Control: max-age=' . $expires);
@@ -830,6 +831,31 @@ abstract class Utils
return $mimetypes;
}
+ /**
+ * Return all extensions for given mimetype. The first extension is the default one.
+ *
+ * @param string $mime Mime type (eg 'image/jpeg')
+ * @return string[] List of extensions eg. ['jpg', 'jpe', 'jpeg']
+ */
+ public static function getExtensionsByMime($mime)
+ {
+ $mime = strtolower($mime);
+
+ $media_types = (array)Grav::instance()['config']->get('media.types');
+
+ $list = [];
+ foreach ($media_types as $extension => $type) {
+ if ($extension === '' || $extension === 'defaults') {
+ continue;
+ }
+
+ if (isset($type['mime']) && $type['mime'] === $mime) {
+ $list[] = $extension;
+ }
+ }
+
+ return $list;
+ }
/**
* Return the mimetype based on filename extension
@@ -900,7 +926,7 @@ abstract class Utils
*/
public static function getMimeByFilename($filename, $default = 'application/octet-stream')
{
- return static::getMimeByExtension(pathinfo($filename, PATHINFO_EXTENSION), $default);
+ return static::getMimeByExtension(static::pathinfo($filename, PATHINFO_EXTENSION), $default);
}
/**
@@ -945,7 +971,7 @@ abstract class Utils
public static function checkFilename($filename)
{
$dangerous_extensions = Grav::instance()['config']->get('security.uploads_dangerous_extensions', []);
- $extension = pathinfo($filename, PATHINFO_EXTENSION);
+ $extension = static::pathinfo($filename, PATHINFO_EXTENSION);
return !(
// Empty filenames are not allowed.
@@ -959,6 +985,46 @@ abstract class Utils
);
}
+ /**
+ * Unicode-safe version of PHP’s pathinfo() function.
+ *
+ * @link https://www.php.net/manual/en/function.pathinfo.php
+ *
+ * @param string $path
+ * @param int|null $flags
+ * @return array|string
+ */
+ public static function pathinfo(string $path, int $flags = null)
+ {
+ $path = str_replace(['%2F', '%5C'], ['/', '\\'], rawurlencode($path));
+
+ if (null === $flags) {
+ $info = pathinfo($path);
+ } else {
+ $info = pathinfo($path, $flags);
+ }
+
+ if (is_array($info)) {
+ return array_map('rawurldecode', $info);
+ }
+
+ return rawurldecode($info);
+ }
+
+ /**
+ * Unicode-safe version of the PHP basename() function.
+ *
+ * @link https://www.php.net/manual/en/function.basename.php
+ *
+ * @param string $path
+ * @param string $suffix
+ * @return string
+ */
+ public static function basename(string $path, string $suffix = ''): string
+ {
+ return rawurldecode(basename(str_replace(['%2F', '%5C'], '/', rawurlencode($path)), $suffix));
+ }
+
/**
* Normalize path by processing relative `.` and `..` syntax and merging path
*
@@ -1594,8 +1660,8 @@ abstract class Utils
$route = '/' . $matches[2];
// Exclude filename from the page lookup.
- if (pathinfo($route, PATHINFO_EXTENSION)) {
- $basename = '/' . basename($route);
+ if (static::pathinfo($route, PATHINFO_EXTENSION)) {
+ $basename = '/' . static::basename($route);
$route = \dirname($route);
} else {
$basename = '';
diff --git a/system/src/Grav/Common/Yaml.php b/system/src/Grav/Common/Yaml.php
index 330b6c383..0758599dc 100644
--- a/system/src/Grav/Common/Yaml.php
+++ b/system/src/Grav/Common/Yaml.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/Application.php b/system/src/Grav/Console/Application/Application.php
index 21cea8730..873b94e4f 100644
--- a/system/src/Grav/Console/Application/Application.php
+++ b/system/src/Grav/Console/Application/Application.php
@@ -3,18 +3,21 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Console\Application;
use Grav\Common\Grav;
+use Symfony\Component\Console\ConsoleEvents;
+use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\EventDispatcher\EventDispatcher;
/**
* Class GpmApplication
@@ -29,19 +32,48 @@ class Application extends \Symfony\Component\Console\Application
/** @var bool */
protected $initialized = false;
+ /**
+ * PluginApplication constructor.
+ * @param string $name
+ * @param string $version
+ */
+ public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
+ {
+ parent::__construct($name, $version);
+
+ // Add listener to prepare environment.
+ $dispatcher = new EventDispatcher();
+ $dispatcher->addListener(ConsoleEvents::COMMAND, [$this, 'prepareEnvironment']);
+
+ $this->setDispatcher($dispatcher);
+ }
+
/**
* @param InputInterface $input
* @return string|null
*/
public function getCommandName(InputInterface $input): ?string
{
- $this->environment = $input->getOption('env');
- $this->language = $input->getOption('lang') ?? $this->language;
+ if ($input->hasParameterOption('--env', true)) {
+ $this->environment = $input->getParameterOption('--env');
+ }
+ if ($input->hasParameterOption('--lang', true)) {
+ $this->language = $input->getParameterOption('--lang');
+ }
+
$this->init();
return parent::getCommandName($input);
}
+ /**
+ * @param ConsoleCommandEvent $event
+ * @return void
+ */
+ public function prepareEnvironment(ConsoleCommandEvent $event): void
+ {
+ }
+
/**
* @return void
*/
@@ -58,7 +90,7 @@ class Application extends \Symfony\Component\Console\Application
}
/**
- * Add global a --env option.
+ * Add global --env and --lang options.
*
* @return InputDefinition
*/
@@ -67,16 +99,16 @@ class Application extends \Symfony\Component\Console\Application
$inputDefinition = parent::getDefaultInputDefinition();
$inputDefinition->addOption(
new InputOption(
- 'env',
- null,
+ '--env',
+ '',
InputOption::VALUE_OPTIONAL,
'Use environment configuration (defaults to localhost)'
)
);
$inputDefinition->addOption(
new InputOption(
- 'lang',
- null,
+ '--lang',
+ '',
InputOption::VALUE_OPTIONAL,
'Language to be used (defaults to en)'
)
diff --git a/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php b/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php
index 9b7b568d9..adf644730 100644
--- a/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php
+++ b/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/GpmApplication.php b/system/src/Grav/Console/Application/GpmApplication.php
index df383f2d2..f9e6b616e 100644
--- a/system/src/Grav/Console/Application/GpmApplication.php
+++ b/system/src/Grav/Console/Application/GpmApplication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/GravApplication.php b/system/src/Grav/Console/Application/GravApplication.php
index 739ca396b..f06dae650 100644
--- a/system/src/Grav/Console/Application/GravApplication.php
+++ b/system/src/Grav/Console/Application/GravApplication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Application/PluginApplication.php b/system/src/Grav/Console/Application/PluginApplication.php
index 75e9eb704..e365b1e08 100644
--- a/system/src/Grav/Console/Application/PluginApplication.php
+++ b/system/src/Grav/Console/Application/PluginApplication.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/BackupCommand.php b/system/src/Grav/Console/Cli/BackupCommand.php
index a8a025d2a..1fe84ea01 100644
--- a/system/src/Grav/Console/Cli/BackupCommand.php
+++ b/system/src/Grav/Console/Cli/BackupCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php
index 84b46d6cc..e6b8f9875 100644
--- a/system/src/Grav/Console/Cli/CleanCommand.php
+++ b/system/src/Grav/Console/Cli/CleanCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/ClearCacheCommand.php b/system/src/Grav/Console/Cli/ClearCacheCommand.php
index daed2a533..7550dd938 100644
--- a/system/src/Grav/Console/Cli/ClearCacheCommand.php
+++ b/system/src/Grav/Console/Cli/ClearCacheCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/ComposerCommand.php b/system/src/Grav/Console/Cli/ComposerCommand.php
index 5075d1d0f..0dc9bcd15 100644
--- a/system/src/Grav/Console/Cli/ComposerCommand.php
+++ b/system/src/Grav/Console/Cli/ComposerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php
index 22258beb3..33198cb5f 100644
--- a/system/src/Grav/Console/Cli/InstallCommand.php
+++ b/system/src/Grav/Console/Cli/InstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/LogViewerCommand.php b/system/src/Grav/Console/Cli/LogViewerCommand.php
index d3924f88c..d7e127e5f 100644
--- a/system/src/Grav/Console/Cli/LogViewerCommand.php
+++ b/system/src/Grav/Console/Cli/LogViewerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/NewProjectCommand.php b/system/src/Grav/Console/Cli/NewProjectCommand.php
index d67cb1c8d..7abbc4ed3 100644
--- a/system/src/Grav/Console/Cli/NewProjectCommand.php
+++ b/system/src/Grav/Console/Cli/NewProjectCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php b/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php
index 4d234d75d..3a6960077 100644
--- a/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php
+++ b/system/src/Grav/Console/Cli/PageSystemValidatorCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php
index d865b4ae7..0ba2850de 100644
--- a/system/src/Grav/Console/Cli/SandboxCommand.php
+++ b/system/src/Grav/Console/Cli/SandboxCommand.php
@@ -3,13 +3,14 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Console\Cli;
use Grav\Common\Filesystem\Folder;
+use Grav\Common\Utils;
use Grav\Console\GravCommand;
use RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
@@ -200,6 +201,10 @@ class SandboxCommand extends GravCommand
$io->newLine();
$io->writeln('Resetting Symbolic Links');
+ // Symlink also tests if using git.
+ if (is_dir($this->source . '/tests')) {
+ $this->mappings['/tests'] = '/tests';
+ }
foreach ($this->mappings as $source => $target) {
if ((string)(int)$source === (string)$source) {
@@ -297,7 +302,7 @@ class SandboxCommand extends GravCommand
foreach ($binaries as $bin) {
chmod($bin, $dir_perms);
- $io->writeln(' bin/' . basename($bin) . ' permissions reset to ' . decoct($dir_perms));
+ $io->writeln(' bin/' . Utils::basename($bin) . ' permissions reset to ' . decoct($dir_perms));
}
$io->newLine();
diff --git a/system/src/Grav/Console/Cli/SchedulerCommand.php b/system/src/Grav/Console/Cli/SchedulerCommand.php
index c5385aad2..91fc57d14 100644
--- a/system/src/Grav/Console/Cli/SchedulerCommand.php
+++ b/system/src/Grav/Console/Cli/SchedulerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -77,8 +77,6 @@ class SchedulerCommand extends GravCommand
$scheduler = $grav['scheduler'];
$grav->fireEvent('onSchedulerInitialized', new Event(['scheduler' => $scheduler]));
- $this->setHelp('foo');
-
$input = $this->getInput();
$io = $this->getIO();
$error = 0;
diff --git a/system/src/Grav/Console/Cli/SecurityCommand.php b/system/src/Grav/Console/Cli/SecurityCommand.php
index 7f728b69f..b6cb662e0 100644
--- a/system/src/Grav/Console/Cli/SecurityCommand.php
+++ b/system/src/Grav/Console/Cli/SecurityCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/ServerCommand.php b/system/src/Grav/Console/Cli/ServerCommand.php
index 77bce8b1d..29b423ecd 100644
--- a/system/src/Grav/Console/Cli/ServerCommand.php
+++ b/system/src/Grav/Console/Cli/ServerCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Cli/YamlLinterCommand.php b/system/src/Grav/Console/Cli/YamlLinterCommand.php
index a9628cdd1..75a75594f 100644
--- a/system/src/Grav/Console/Cli/YamlLinterCommand.php
+++ b/system/src/Grav/Console/Cli/YamlLinterCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Cli
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/ConsoleCommand.php b/system/src/Grav/Console/ConsoleCommand.php
index 044f1b0ff..c522c88b3 100644
--- a/system/src/Grav/Console/ConsoleCommand.php
+++ b/system/src/Grav/Console/ConsoleCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/ConsoleTrait.php b/system/src/Grav/Console/ConsoleTrait.php
index feb10d32e..0af4075ab 100644
--- a/system/src/Grav/Console/ConsoleTrait.php
+++ b/system/src/Grav/Console/ConsoleTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
index e5c662bcc..fbb02207c 100644
--- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php
+++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php
index ecc91feb0..367322bb9 100644
--- a/system/src/Grav/Console/Gpm/IndexCommand.php
+++ b/system/src/Grav/Console/Gpm/IndexCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php
index 5dddd32b5..c6f855208 100644
--- a/system/src/Grav/Console/Gpm/InfoCommand.php
+++ b/system/src/Grav/Console/Gpm/InfoCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php
index 92c8e07d7..d25ebe3c5 100644
--- a/system/src/Grav/Console/Gpm/InstallCommand.php
+++ b/system/src/Grav/Console/Gpm/InstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -579,7 +579,7 @@ class InstallCommand extends GpmCommand
$tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
$this->tmp = $tmp_dir . '/Grav-' . uniqid();
- $filename = $package->slug . basename($package->zipball_url);
+ $filename = $package->slug . Utils::basename($package->zipball_url);
$filename = preg_replace('/[\\\\\/:"*?&<>|]+/m', '-', $filename);
$query = '';
diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
index b84001698..a3d53ffee 100644
--- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
+++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/UninstallCommand.php b/system/src/Grav/Console/Gpm/UninstallCommand.php
index cb14c6552..a3db65709 100644
--- a/system/src/Grav/Console/Gpm/UninstallCommand.php
+++ b/system/src/Grav/Console/Gpm/UninstallCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php
index 300fe61d8..73c5c9e42 100644
--- a/system/src/Grav/Console/Gpm/UpdateCommand.php
+++ b/system/src/Grav/Console/Gpm/UpdateCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Gpm/VersionCommand.php b/system/src/Grav/Console/Gpm/VersionCommand.php
index 124aad3c0..862919648 100644
--- a/system/src/Grav/Console/Gpm/VersionCommand.php
+++ b/system/src/Grav/Console/Gpm/VersionCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Gpm
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/GpmCommand.php b/system/src/Grav/Console/GpmCommand.php
index 816e87223..a14eb4717 100644
--- a/system/src/Grav/Console/GpmCommand.php
+++ b/system/src/Grav/Console/GpmCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/GravCommand.php b/system/src/Grav/Console/GravCommand.php
index 0249f1427..7db18e219 100644
--- a/system/src/Grav/Console/GravCommand.php
+++ b/system/src/Grav/Console/GravCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/Plugin/PluginListCommand.php b/system/src/Grav/Console/Plugin/PluginListCommand.php
index 81041c0e5..022661452 100644
--- a/system/src/Grav/Console/Plugin/PluginListCommand.php
+++ b/system/src/Grav/Console/Plugin/PluginListCommand.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\Plugin
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Console/TerminalObjects/Table.php b/system/src/Grav/Console/TerminalObjects/Table.php
index a71d7c0c8..153993dcd 100644
--- a/system/src/Grav/Console/TerminalObjects/Table.php
+++ b/system/src/Grav/Console/TerminalObjects/Table.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Console\TerminalObjects
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/FlexRegisterEvent.php b/system/src/Grav/Events/FlexRegisterEvent.php
index 13aebf386..b02ed1dae 100644
--- a/system/src/Grav/Events/FlexRegisterEvent.php
+++ b/system/src/Grav/Events/FlexRegisterEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/PermissionsRegisterEvent.php b/system/src/Grav/Events/PermissionsRegisterEvent.php
index 5e63c85ab..434dcfaf2 100644
--- a/system/src/Grav/Events/PermissionsRegisterEvent.php
+++ b/system/src/Grav/Events/PermissionsRegisterEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/PluginsLoadedEvent.php b/system/src/Grav/Events/PluginsLoadedEvent.php
index 9dfd18b4a..13e22264d 100644
--- a/system/src/Grav/Events/PluginsLoadedEvent.php
+++ b/system/src/Grav/Events/PluginsLoadedEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Events/SessionStartEvent.php b/system/src/Grav/Events/SessionStartEvent.php
index e724a0922..fc4f3649c 100644
--- a/system/src/Grav/Events/SessionStartEvent.php
+++ b/system/src/Grav/Events/SessionStartEvent.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Events
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Acl/Access.php b/system/src/Grav/Framework/Acl/Access.php
index 0a6bb4102..45cf2bf9b 100644
--- a/system/src/Grav/Framework/Acl/Access.php
+++ b/system/src/Grav/Framework/Acl/Access.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Acl/Action.php b/system/src/Grav/Framework/Acl/Action.php
index ee46f55f9..6251c3c89 100644
--- a/system/src/Grav/Framework/Acl/Action.php
+++ b/system/src/Grav/Framework/Acl/Action.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Acl/Permissions.php b/system/src/Grav/Framework/Acl/Permissions.php
index 83c6179ea..e54590a0d 100644
--- a/system/src/Grav/Framework/Acl/Permissions.php
+++ b/system/src/Grav/Framework/Acl/Permissions.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Acl/PermissionsReader.php b/system/src/Grav/Framework/Acl/PermissionsReader.php
index 5e8e892bb..350fc967a 100644
--- a/system/src/Grav/Framework/Acl/PermissionsReader.php
+++ b/system/src/Grav/Framework/Acl/PermissionsReader.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Acl/RecursiveActionIterator.php b/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
index 3b0e822cd..1fb9a60ba 100644
--- a/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
+++ b/system/src/Grav/Framework/Acl/RecursiveActionIterator.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Acl
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/AbstractCache.php b/system/src/Grav/Framework/Cache/AbstractCache.php
index bfb5125ec..b6d00a3b8 100644
--- a/system/src/Grav/Framework/Cache/AbstractCache.php
+++ b/system/src/Grav/Framework/Cache/AbstractCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Adapter/ChainCache.php b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
index a5f2f582e..bca940fa0 100644
--- a/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/ChainCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
index 26819d89b..15afed380 100644
--- a/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Adapter/FileCache.php b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
index 69a112772..7f1d5e7b0 100644
--- a/system/src/Grav/Framework/Cache/Adapter/FileCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/FileCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
index c043bf9e6..21cd89c1c 100644
--- a/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/MemoryCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Adapter/SessionCache.php b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
index e189e3e7e..02fe7c9e3 100644
--- a/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
+++ b/system/src/Grav/Framework/Cache/Adapter/SessionCache.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/CacheInterface.php b/system/src/Grav/Framework/Cache/CacheInterface.php
index efd9d3122..03dfa7a14 100644
--- a/system/src/Grav/Framework/Cache/CacheInterface.php
+++ b/system/src/Grav/Framework/Cache/CacheInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/CacheTrait.php b/system/src/Grav/Framework/Cache/CacheTrait.php
index 287f92462..37dd6c955 100644
--- a/system/src/Grav/Framework/Cache/CacheTrait.php
+++ b/system/src/Grav/Framework/Cache/CacheTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Exception/CacheException.php b/system/src/Grav/Framework/Cache/Exception/CacheException.php
index 1db325694..db33883b0 100644
--- a/system/src/Grav/Framework/Cache/Exception/CacheException.php
+++ b/system/src/Grav/Framework/Cache/Exception/CacheException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php b/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php
index 08a343504..70c041885 100644
--- a/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php
+++ b/system/src/Grav/Framework/Cache/Exception/InvalidArgumentException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Cache
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/AbstractFileCollection.php b/system/src/Grav/Framework/Collection/AbstractFileCollection.php
index 77b3247f0..500aea8e4 100644
--- a/system/src/Grav/Framework/Collection/AbstractFileCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractFileCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
index 8c98a8111..02916d909 100644
--- a/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractIndexCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -145,31 +145,37 @@ abstract class AbstractIndexCollection implements CollectionInterface
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @return bool
* @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
+ /** @phpstan-ignore-next-line phpstan bug? */
return $offset !== null ? $this->containsKey($offset) : false;
}
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @return mixed
* @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
+ /** @phpstan-ignore-next-line phpstan bug? */
return $offset !== null ? $this->get($offset) : null;
}
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @param mixed $value
+ * @return void
* @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
@@ -178,6 +184,7 @@ abstract class AbstractIndexCollection implements CollectionInterface
if (null === $offset) {
$this->add($value);
} else {
+ /** @phpstan-ignore-next-line phpstan bug? */
$this->set($offset, $value);
}
}
@@ -185,13 +192,15 @@ abstract class AbstractIndexCollection implements CollectionInterface
/**
* Required by interface ArrayAccess.
*
- * {@inheritDoc}
+ * @param string|int|null $offset
+ * @return void
* @phpstan-param TKey|null $offset
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
if ($offset !== null) {
+ /** @phpstan-ignore-next-line phpstan bug? */
$this->remove($offset);
}
}
diff --git a/system/src/Grav/Framework/Collection/AbstractLazyCollection.php b/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
index 5f7ad1b12..b0a93f514 100644
--- a/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
+++ b/system/src/Grav/Framework/Collection/AbstractLazyCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/ArrayCollection.php b/system/src/Grav/Framework/Collection/ArrayCollection.php
index 892cfcb5a..cad02f26d 100644
--- a/system/src/Grav/Framework/Collection/ArrayCollection.php
+++ b/system/src/Grav/Framework/Collection/ArrayCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/CollectionInterface.php b/system/src/Grav/Framework/Collection/CollectionInterface.php
index def9427a1..e098dd6a1 100644
--- a/system/src/Grav/Framework/Collection/CollectionInterface.php
+++ b/system/src/Grav/Framework/Collection/CollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/FileCollection.php b/system/src/Grav/Framework/Collection/FileCollection.php
index f7b4f258b..bae0e7b2f 100644
--- a/system/src/Grav/Framework/Collection/FileCollection.php
+++ b/system/src/Grav/Framework/Collection/FileCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Collection/FileCollectionInterface.php b/system/src/Grav/Framework/Collection/FileCollectionInterface.php
index 45c446c63..1b56da953 100644
--- a/system/src/Grav/Framework/Collection/FileCollectionInterface.php
+++ b/system/src/Grav/Framework/Collection/FileCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Collection
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Compat/Serializable.php b/system/src/Grav/Framework/Compat/Serializable.php
index 3c9bf6a08..22e4648d8 100644
--- a/system/src/Grav/Framework/Compat/Serializable.php
+++ b/system/src/Grav/Framework/Compat/Serializable.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Compat
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/ContentBlock/ContentBlock.php b/system/src/Grav/Framework/ContentBlock/ContentBlock.php
index 95d11fd25..7259df090 100644
--- a/system/src/Grav/Framework/ContentBlock/ContentBlock.php
+++ b/system/src/Grav/Framework/ContentBlock/ContentBlock.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
index fb445a398..bb0e46f8f 100644
--- a/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
+++ b/system/src/Grav/Framework/ContentBlock/ContentBlockInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/ContentBlock/HtmlBlock.php b/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
index 5c5eb4342..69d417ca0 100644
--- a/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
+++ b/system/src/Grav/Framework/ContentBlock/HtmlBlock.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -29,6 +29,8 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
/** @var array */
protected $scripts = [];
/** @var array */
+ protected $links = [];
+ /** @var array */
protected $html = [];
/**
@@ -40,6 +42,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
$this->sortAssets($assets['styles']);
$this->sortAssets($assets['scripts']);
+ $this->sortAssets($assets['links']);
$this->sortAssets($assets['html']);
return $assets;
@@ -73,6 +76,15 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
return $this->getAssetsInLocation('scripts', $location);
}
+ /**
+ * @param string $location
+ * @return array
+ */
+ public function getLinks($location = 'head')
+ {
+ return $this->getAssetsInLocation('links', $location);
+ }
+
/**
* @param string $location
* @return array
@@ -98,6 +110,9 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
if ($this->scripts) {
$array['scripts'] = $this->scripts;
}
+ if ($this->links) {
+ $array['links'] = $this->links;
+ }
if ($this->html) {
$array['html'] = $this->html;
}
@@ -117,6 +132,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
$this->frameworks = isset($serialized['frameworks']) ? (array) $serialized['frameworks'] : [];
$this->styles = isset($serialized['styles']) ? (array) $serialized['styles'] : [];
$this->scripts = isset($serialized['scripts']) ? (array) $serialized['scripts'] : [];
+ $this->links = isset($serialized['links']) ? (array) $serialized['links'] : [];
$this->html = isset($serialized['html']) ? (array) $serialized['html'] : [];
}
@@ -199,11 +215,14 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
$content = (string) $element['content'];
$type = !empty($element['type']) ? (string) $element['type'] : 'text/css';
+ unset($element['content'], $element['type']);
+
$this->styles[$location][md5($content) . sha1($content)] = [
':type' => 'inline',
':priority' => (int) $priority,
'content' => $content,
- 'type' => $type
+ 'type' => $type,
+ 'element' => $element
];
return true;
@@ -229,18 +248,23 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
$src = $element['src'];
$type = !empty($element['type']) ? (string) $element['type'] : 'text/javascript';
- $defer = isset($element['defer']);
- $async = isset($element['async']);
+ $loading = !empty($element['loading']) ? (string) $element['loading'] : null;
+ $defer = !empty($element['defer']);
+ $async = !empty($element['async']);
$handle = !empty($element['handle']) ? (string) $element['handle'] : '';
+ unset($element['src'], $element['type'], $element['loading'], $element['defer'], $element['async'], $element['handle']);
+
$this->scripts[$location][md5($src) . sha1($src)] = [
':type' => 'file',
':priority' => (int) $priority,
'src' => $src,
'type' => $type,
+ 'loading' => $loading,
'defer' => $defer,
'async' => $async,
- 'handle' => $handle
+ 'handle' => $handle,
+ 'element' => $element
];
return true;
@@ -266,12 +290,83 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
$content = (string) $element['content'];
$type = !empty($element['type']) ? (string) $element['type'] : 'text/javascript';
+ $loading = !empty($element['loading']) ? (string) $element['loading'] : null;
+
+ unset($element['content'], $element['type'], $element['loading']);
$this->scripts[$location][md5($content) . sha1($content)] = [
':type' => 'inline',
':priority' => (int) $priority,
'content' => $content,
- 'type' => $type
+ 'type' => $type,
+ 'loading' => $loading,
+ 'element' => $element
+ ];
+
+ return true;
+ }
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addModule($element, $priority = 0, $location = 'head')
+ {
+ if (!is_array($element)) {
+ $element = ['src' => (string) $element];
+ }
+
+ $element['type'] = 'module';
+
+ return $this->addScript($element, $priority, $location);
+ }
+
+ /**
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addInlineModule($element, $priority = 0, $location = 'head')
+ {
+ if (!is_array($element)) {
+ $element = ['content' => (string) $element];
+ }
+
+ $element['type'] = 'module';
+
+ return $this->addInlineScript($element, $priority, $location);
+ }
+
+ /**
+ * @param array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addLink($element, $priority = 0, $location = 'head')
+ {
+ if (!is_array($element) || empty($element['rel']) || empty($element['href'])) {
+ return false;
+ }
+
+ if (!isset($this->links[$location])) {
+ $this->links[$location] = [];
+ }
+
+ $rel = (string) $element['rel'];
+ $href = (string) $element['href'];
+
+ unset($element['rel'], $element['href']);
+
+ $this->links[$location][md5($href) . sha1($href)] = [
+ ':type' => 'file',
+ ':priority' => (int) $priority,
+ 'href' => $href,
+ 'rel' => $rel,
+ 'element' => $element,
];
return true;
@@ -309,6 +404,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
'frameworks' => $this->frameworks,
'styles' => $this->styles,
'scripts' => $this->scripts,
+ 'links' => $this->links,
'html' => $this->html
];
@@ -333,6 +429,14 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
}
}
+ foreach ($blockAssets['links'] as $location => $links) {
+ if (!isset($assets['links'][$location])) {
+ $assets['links'][$location] = $links;
+ } elseif ($links) {
+ $assets['links'][$location] += $links;
+ }
+ }
+
foreach ($blockAssets['html'] as $location => $htmls) {
if (!isset($assets['html'][$location])) {
$assets['html'][$location] = $htmls;
@@ -391,7 +495,7 @@ class HtmlBlock extends ContentBlock implements HtmlBlockInterface
*/
protected function sortAssets(array &$array)
{
- foreach ($array as $location => &$items) {
+ foreach ($array as &$items) {
$this->sortAssetsInLocation($items);
}
}
diff --git a/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php b/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
index 616e4a2cc..b151d7b8a 100644
--- a/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
+++ b/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\ContentBlock
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -37,6 +37,13 @@ interface HtmlBlockInterface extends ContentBlockInterface
*/
public function getScripts($location = 'head');
+
+ /**
+ * @param string $location
+ * @return array
+ */
+ public function getLinks($location = 'head');
+
/**
* @param string $location
* @return array
@@ -76,7 +83,6 @@ interface HtmlBlockInterface extends ContentBlockInterface
*/
public function addScript($element, $priority = 0, $location = 'head');
-
/**
* @param string|array $element
* @param int $priority
@@ -85,6 +91,35 @@ interface HtmlBlockInterface extends ContentBlockInterface
*/
public function addInlineScript($element, $priority = 0, $location = 'head');
+
+ /**
+ * Shortcut for writing addScript(['type' => 'module', 'src' => ...]).
+ *
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addModule($element, $priority = 0, $location = 'head');
+
+ /**
+ * Shortcut for writing addInlineScript(['type' => 'module', 'content' => ...]).
+ *
+ * @param string|array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addInlineModule($element, $priority = 0, $location = 'head');
+
+ /**
+ * @param array $element
+ * @param int $priority
+ * @param string $location
+ * @return bool
+ */
+ public function addLink($element, $priority = 0, $location = 'head');
+
/**
* @param string $html
* @param int $priority
diff --git a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
index 36f5411af..24e1fc2b3 100644
--- a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
+++ b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Controller
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -97,7 +97,7 @@ trait ControllerResponseTrait
$headers = $headers ?? [];
$options = $options ?? ['force_download' => true];
- $file_parts = pathinfo($filename);
+ $file_parts = Utils::pathinfo($filename);
if (!isset($headers['Content-Type'])) {
$mimetype = Utils::getMimeByExtension($file_parts['extension']);
@@ -140,7 +140,7 @@ trait ControllerResponseTrait
$code = (int)$this->getConfig()->get('system.pages.redirect_default_code', 302);
}
- $ext = pathinfo($url, PATHINFO_EXTENSION);
+ $ext = Utils::pathinfo($url, PATHINFO_EXTENSION);
$accept = $this->getAccept(['application/json', 'text/html']);
if ($ext === 'json' || $accept === 'application/json') {
return $this->createJsonResponse(['code' => $code, 'status' => 'redirect', 'redirect' => $url]);
diff --git a/system/src/Grav/Framework/DI/Container.php b/system/src/Grav/Framework/DI/Container.php
index 76434a36a..dde0da3ca 100644
--- a/system/src/Grav/Framework/DI/Container.php
+++ b/system/src/Grav/Framework/DI/Container.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\DI
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/AbstractFile.php b/system/src/Grav/Framework/File/AbstractFile.php
index a49d79fc9..b216ea6c8 100644
--- a/system/src/Grav/Framework/File/AbstractFile.php
+++ b/system/src/Grav/Framework/File/AbstractFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/CsvFile.php b/system/src/Grav/Framework/File/CsvFile.php
index 7be6879b7..7eba91e88 100644
--- a/system/src/Grav/Framework/File/CsvFile.php
+++ b/system/src/Grav/Framework/File/CsvFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/DataFile.php b/system/src/Grav/Framework/File/DataFile.php
index 114146f94..189db53de 100644
--- a/system/src/Grav/Framework/File/DataFile.php
+++ b/system/src/Grav/Framework/File/DataFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/File.php b/system/src/Grav/Framework/File/File.php
index a6a8f3c9c..b1a1c4f67 100644
--- a/system/src/Grav/Framework/File/File.php
+++ b/system/src/Grav/Framework/File/File.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
index f5ff3f24a..6a6981bc0 100644
--- a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
index 072de1211..37ab5bb25 100644
--- a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/IniFormatter.php b/system/src/Grav/Framework/File/Formatter/IniFormatter.php
index 2e7404b9c..ecf67d1f2 100644
--- a/system/src/Grav/Framework/File/Formatter/IniFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/IniFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
index 395766718..2bd6c79ad 100644
--- a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
index a30d7a906..e36276a81 100644
--- a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
index f045d71e3..25aee813b 100644
--- a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
index 3909f6e85..31aff2c67 100644
--- a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
+++ b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File\Formatter
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/IniFile.php b/system/src/Grav/Framework/File/IniFile.php
index 64214998d..0807ee3c2 100644
--- a/system/src/Grav/Framework/File/IniFile.php
+++ b/system/src/Grav/Framework/File/IniFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php b/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
index 49eda4f1d..78714af7e 100644
--- a/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
+++ b/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/Interfaces/FileInterface.php b/system/src/Grav/Framework/File/Interfaces/FileInterface.php
index 015b1ada2..f2cc288a9 100644
--- a/system/src/Grav/Framework/File/Interfaces/FileInterface.php
+++ b/system/src/Grav/Framework/File/Interfaces/FileInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/JsonFile.php b/system/src/Grav/Framework/File/JsonFile.php
index f3b0902c8..7751e84d6 100644
--- a/system/src/Grav/Framework/File/JsonFile.php
+++ b/system/src/Grav/Framework/File/JsonFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/MarkdownFile.php b/system/src/Grav/Framework/File/MarkdownFile.php
index 881862b78..a79d5ce77 100644
--- a/system/src/Grav/Framework/File/MarkdownFile.php
+++ b/system/src/Grav/Framework/File/MarkdownFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/File/YamlFile.php b/system/src/Grav/Framework/File/YamlFile.php
index d191e3cf9..c4300ade5 100644
--- a/system/src/Grav/Framework/File/YamlFile.php
+++ b/system/src/Grav/Framework/File/YamlFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\File
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Filesystem/Filesystem.php b/system/src/Grav/Framework/Filesystem/Filesystem.php
index 2f66e54c6..ddbbab04d 100644
--- a/system/src/Grav/Framework/Filesystem/Filesystem.php
+++ b/system/src/Grav/Framework/Filesystem/Filesystem.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -15,6 +15,7 @@ use Grav\Framework\Filesystem\Interfaces\FilesystemInterface;
use RuntimeException;
use function count;
use function dirname;
+use function is_array;
use function pathinfo;
/**
@@ -150,7 +151,10 @@ class Filesystem implements FilesystemInterface
*/
public function basename(string $path, ?string $suffix = null): string
{
- return $suffix ? basename($path, $suffix) : basename($path);
+ // Escape path.
+ $path = str_replace(['%2F', '%5C'], '/', rawurlencode($path));
+
+ return rawurldecode($suffix ? basename($path, $suffix) : basename($path));
}
/**
@@ -231,14 +235,24 @@ class Filesystem implements FilesystemInterface
*/
protected function pathinfoInternal(?string $scheme, string $path, ?int $options = null)
{
- if ($options) {
- return pathinfo($path, $options);
+ $path = str_replace(['%2F', '%5C'], ['/', '\\'], rawurlencode($path));
+
+ if (null === $options) {
+ $info = pathinfo($path);
+ } else {
+ $info = pathinfo($path, $options);
}
- $info = pathinfo($path);
+ if (!is_array($info)) {
+ return rawurldecode($info);
+ }
+
+ $info = array_map('rawurldecode', $info);
if (null !== $scheme) {
$info['scheme'] = $scheme;
+
+ /** @phpstan-ignore-next-line because pathinfo('') doesn't have dirname */
$dirname = $info['dirname'] ?? '.';
if ('' !== $dirname && '.' !== $dirname) {
diff --git a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
index f80b77244..4006c8f77 100644
--- a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
+++ b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Filesystem
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -47,7 +47,7 @@ interface FilesystemInterface
public function normalize(string $path): string;
/**
- * Returns filename component of path.
+ * Unicode-safe and stream-safe `\basename()` replacement.
*
* @param string $path A filename or path, does not need to exist as a file.
* @param string|null $suffix If the filename ends in suffix this will also be cut off.
@@ -57,7 +57,7 @@ interface FilesystemInterface
public function basename(string $path, ?string $suffix = null): string;
/**
- * Stream-safe `\dirname()` replacement.
+ * Unicode-safe and stream-safe `\dirname()` replacement.
*
* @see http://php.net/manual/en/function.dirname.php
*
@@ -71,7 +71,7 @@ interface FilesystemInterface
public function dirname(string $path, int $levels = 1): string;
/**
- * Stream-safe `\pathinfo()` replacement.
+ * Unicode-safe and stream-safe `\pathinfo()` replacement.
*
* @see http://php.net/manual/en/function.pathinfo.php
*
diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php
index 28dc94345..4d662d192 100644
--- a/system/src/Grav/Framework/Flex/Flex.php
+++ b/system/src/Grav/Framework/Flex/Flex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php
index 8ad78f06a..186c60abc 100644
--- a/system/src/Grav/Framework/Flex/FlexCollection.php
+++ b/system/src/Grav/Framework/Flex/FlexCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -125,6 +125,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
*/
public function getFlexFeatures(): array
{
+ /** @var array $implements */
$implements = class_implements($this);
$list = [];
diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php
index 594c34c3f..f96633b31 100644
--- a/system/src/Grav/Framework/Flex/FlexDirectory.php
+++ b/system/src/Grav/Framework/Flex/FlexDirectory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -21,7 +21,7 @@ use Grav\Common\Utils;
use Grav\Framework\Cache\Adapter\DoctrineCache;
use Grav\Framework\Cache\Adapter\MemoryCache;
use Grav\Framework\Cache\CacheInterface;
-use Grav\Framework\Flex\Interfaces\FlexAuthorizeInterface;
+use Grav\Framework\Filesystem\Filesystem;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexDirectoryInterface;
use Grav\Framework\Flex\Interfaces\FlexFormInterface;
@@ -218,8 +218,17 @@ class FlexDirectory implements FlexDirectoryInterface
/** @var UniformResourceLocator $locator */
$locator = $grav['locator'];
- /** @var string $filename Filename is always string */
- $filename = $locator->findResource($this->getDirectoryConfigUri($name), true, true);
+
+ $filename = $this->getDirectoryConfigUri($name);
+ if (file_exists($filename)) {
+ $filename = $locator->findResource($filename, true);
+ } else {
+ $filesystem = Filesystem::getInstance();
+ $dirname = $filesystem->dirname($filename);
+ $basename = $filesystem->basename($filename);
+ $dirname = $locator->findResource($dirname, true) ?: $locator->findResource($dirname, true, true);
+ $filename = "{$dirname}/{$basename}";
+ }
$file = YamlFile::instance($filename);
if (!empty($data)) {
@@ -907,6 +916,10 @@ class FlexDirectory implements FlexDirectoryInterface
$className = $storage['class'] ?? SimpleStorage::class;
$options = $storage['options'] ?? [];
+ if (!is_a($className, FlexStorageInterface::class, true)) {
+ throw new \RuntimeException('Bad storage class: ' . $className);
+ }
+
return new $className($options);
}
diff --git a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
index 693ef120b..709f41891 100644
--- a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
+++ b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/FlexForm.php b/system/src/Grav/Framework/Flex/FlexForm.php
index 5d7221847..a1263f67f 100644
--- a/system/src/Grav/Framework/Flex/FlexForm.php
+++ b/system/src/Grav/Framework/Flex/FlexForm.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/FlexFormFlash.php b/system/src/Grav/Framework/Flex/FlexFormFlash.php
index feb7a9ee9..3f52cdb6f 100644
--- a/system/src/Grav/Framework/Flex/FlexFormFlash.php
+++ b/system/src/Grav/Framework/Flex/FlexFormFlash.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php
index 14a48f5a4..54438af51 100644
--- a/system/src/Grav/Framework/Flex/FlexIndex.php
+++ b/system/src/Grav/Framework/Flex/FlexIndex.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -118,6 +118,14 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
$this->setKeyField(null);
}
+ /**
+ * @return string
+ */
+ public function getKey()
+ {
+ return $this->_key ?: $this->getFlexType() . '@@' . spl_object_hash($this);
+ }
+
/**
* {@inheritdoc}
* @see FlexCommonInterface::hasFlexFeature()
@@ -133,6 +141,7 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
*/
public function getFlexFeatures(): array
{
+ /** @var array $implements */
$implements = class_implements($this->getFlexDirectory()->getCollectionClass());
$list = [];
@@ -493,9 +502,13 @@ class FlexIndex extends ObjectIndex implements FlexIndexInterface
}
} else {
$collection = $this->loadCollection();
- $result = $collection->{$name}(...$arguments);
- if (!isset($cachedMethods[$name])) {
- $debugger->addMessage("Call '{$flexType}:{$name}()' isn't cached", 'debug');
+ if (\is_callable([$collection, $name])) {
+ $result = $collection->{$name}(...$arguments);
+ if (!isset($cachedMethods[$name])) {
+ $debugger->addMessage("Call '{$flexType}:{$name}()' isn't cached", 'debug');
+ }
+ } else {
+ $result = null;
}
}
diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php
index f4987a43c..afc656c04 100644
--- a/system/src/Grav/Framework/Flex/FlexObject.php
+++ b/system/src/Grav/Framework/Flex/FlexObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -163,6 +163,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
*/
public function getFlexFeatures(): array
{
+ /** @var array $implements */
$implements = class_implements($this);
$list = [];
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
index 102dbf4a7..c1025a4b7 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php
index 2510e5de7..d14b69f40 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
index ed045e25f..7c1975f21 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php
index df6f7d6a6..203c76603 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryFormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php
index 1d9565745..a77df958f 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexDirectoryInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
index eaafaf01c..ba9996afc 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexFormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php
index 71dd72770..d8f8ba3c9 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
index cbd440bd2..f1376a589 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php
index 044ee612d..190a9634a 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectFormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
index a0f30c6e9..d02bc8b30 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php
index 08c433596..420992472 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php
index 28e488860..8df11fa23 100644
--- a/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php
+++ b/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
index fe7a22107..5901557d7 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -155,9 +155,10 @@ class FlexPageCollection extends FlexCollection
public function adjacentSibling($path, $direction = 1)
{
$keys = $this->getKeys();
+ $direction = (int)$direction;
$pos = array_search($path, $keys, true);
- if ($pos !== false) {
+ if (is_int($pos)) {
$pos += $direction;
if (isset($keys[$pos])) {
return $this[$keys[$pos]];
@@ -177,7 +178,7 @@ class FlexPageCollection extends FlexCollection
{
$pos = array_search($path, $this->getKeys(), true);
- return $pos !== false ? $pos : null;
+ return is_int($pos) ? $pos : null;
}
/**
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php
index 904d1f6da..5bb551797 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
index c2a2d6008..e700424b9 100644
--- a/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
+++ b/system/src/Grav/Framework/Flex/Pages/FlexPageObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php
index 5d3e96803..d0934e12c 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php
index 0fac6d608..43dfee116 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageContentTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -100,6 +100,7 @@ trait PageContentTrait
/**
* @inheritdoc
+ * @return Header
*/
public function header($var = null)
{
@@ -744,6 +745,7 @@ trait PageContentTrait
}
if ($process_twig) {
+ \assert(is_string($this->_content));
$this->_content = $this->processTwig($this->_content);
}
}
@@ -753,6 +755,8 @@ trait PageContentTrait
}
}
+ \assert(is_string($this->_content));
+
// Handle summary divider
$delimiter = $config->get('site.summary.delimiter', '===');
$divider_pos = mb_strpos($this->_content, "{$delimiter}
");
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php
index 26c66d8be..d75380373 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,6 +22,7 @@ use Grav\Framework\File\Formatter\YamlFormatter;
use Grav\Framework\Filesystem\Filesystem;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexIndexInterface;
+use Grav\Framework\Flex\Pages\FlexPageCollection;
use Grav\Framework\Flex\Pages\FlexPageIndex;
use Grav\Framework\Flex\Pages\FlexPageObject;
use InvalidArgumentException;
@@ -298,7 +299,7 @@ trait PageLegacyTrait
$parentStorageKey = ltrim($filesystem->dirname("/{$this->getMasterKey()}"), '/');
- /** @var FlexPageIndex $index */
+ /** @var FlexPageIndex> $index */
$index = $this->getFlexDirectory()->getIndex();
if ($parent) {
@@ -321,8 +322,9 @@ trait PageLegacyTrait
if ($this instanceof FlexPageObject) {
$key = trim($parentKey . '/' . $this->folder(), '/');
$key = preg_replace(static::PAGE_ORDER_PREFIX_REGEX, '', $key);
+ \assert(is_string($key));
} else {
- $key = trim($parentKey . '/' . basename($this->getKey()), '/');
+ $key = trim($parentKey . '/' . Utils::basename($this->getKey()), '/');
}
if ($index->containsKey($key)) {
@@ -334,7 +336,7 @@ trait PageLegacyTrait
} while ($index->containsKey($test));
$key = $test;
}
- $folder = basename($key);
+ $folder = Utils::basename($key);
// Get the folder name.
$order = $this->getProperty('order');
@@ -537,7 +539,7 @@ trait PageLegacyTrait
if ($language) {
$language = '.' . $language;
}
- $format = '.' . ($this->getProperty('format') ?? pathinfo($this->name(), PATHINFO_EXTENSION));
+ $format = '.' . ($this->getProperty('format') ?? Utils::pathinfo($this->name(), PATHINFO_EXTENSION));
return $language . $format;
}
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
index 90773cdda..c4c8cd7fb 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -15,10 +15,10 @@ use Grav\Common\Page\Interfaces\PageCollectionInterface;
use Grav\Common\Page\Interfaces\PageInterface;
use Grav\Common\Page\Pages;
use Grav\Common\Uri;
+use Grav\Common\Utils;
use Grav\Framework\Filesystem\Filesystem;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use RuntimeException;
-use function dirname;
use function is_string;
/**
@@ -375,7 +375,7 @@ trait PageRoutableTrait
$value = $this->getMasterKey() ?: $this->getKey();
}
- return basename($value) ?: null;
+ return Utils::basename($value) ?: null;
}
);
}
diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php
index 0ce0d7308..4bec685b4 100644
--- a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php
+++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php b/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
index 2e3132146..ee04c519d 100644
--- a/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Storage/FileStorage.php b/system/src/Grav/Framework/Flex/Storage/FileStorage.php
index eabd658fe..1864439cb 100644
--- a/system/src/Grav/Framework/Flex/Storage/FileStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/FileStorage.php
@@ -5,13 +5,14 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Storage;
use FilesystemIterator;
+use Grav\Common\Utils;
use Grav\Framework\Flex\Interfaces\FlexStorageInterface;
use RuntimeException;
use SplFileInfo;
@@ -125,7 +126,7 @@ class FileStorage extends FolderStorage
*/
protected function getKeyFromPath(string $path): string
{
- return basename($path, $this->dataFormatter->getDefaultFileExtension());
+ return Utils::basename($path, $this->dataFormatter->getDefaultFileExtension());
}
/**
diff --git a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
index b2b9533a2..600e98947 100644
--- a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -352,7 +352,7 @@ class FolderStorage extends AbstractFilesystemStorage
*/
protected function getKeyFromPath(string $path): string
{
- return basename($path);
+ return Utils::basename($path);
}
/**
@@ -688,7 +688,7 @@ class FolderStorage extends AbstractFilesystemStorage
$pattern .= '/{FILE}{EXT}';
} else {
$filesystem = Filesystem::getInstance(true);
- $this->dataFile = basename($pattern, $extension);
+ $this->dataFile = Utils::basename($pattern, $extension);
$pattern = $filesystem->dirname($pattern) . '/{FILE}{EXT}';
}
}
diff --git a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
index 78a4ad206..73e2b065d 100644
--- a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
+++ b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -13,6 +13,7 @@ namespace Grav\Framework\Flex\Storage;
use Grav\Common\Data\Data;
use Grav\Common\Filesystem\Folder;
+use Grav\Common\Utils;
use Grav\Framework\Filesystem\Filesystem;
use InvalidArgumentException;
use LogicException;
@@ -53,9 +54,9 @@ class SimpleStorage extends AbstractFilesystemStorage
$filesystem = Filesystem::getInstance(true);
$extension = $this->dataFormatter->getDefaultFileExtension();
- $pattern = basename($options['folder']);
+ $pattern = Utils::basename($options['folder']);
- $this->dataPattern = basename($pattern, $extension) . $extension;
+ $this->dataPattern = Utils::basename($pattern, $extension) . $extension;
$this->dataFolder = $filesystem->dirname($options['folder']);
$this->keyField = $options['key'] ?? 'storage_key';
$this->keyLen = (int)($options['key_len'] ?? 32);
@@ -432,7 +433,7 @@ class SimpleStorage extends AbstractFilesystemStorage
*/
protected function getKeyFromPath(string $path): string
{
- return basename($path);
+ return Utils::basename($path);
}
/**
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
index 8cbd1d542..ef4c433a2 100644
--- a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
+++ b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
index c2bc66891..ad437ebe4 100644
--- a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
+++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php
@@ -5,7 +5,7 @@ namespace Grav\Framework\Flex\Traits;
/**
* @package Grav\Framework\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -346,7 +346,7 @@ trait FlexMediaTrait
}
// Calculate path without the retina scaling factor.
- $realpath = $filesystem->pathname($filepath) . str_replace(['@3x', '@2x'], '', basename($filepath));
+ $realpath = $filesystem->pathname($filepath) . str_replace(['@3x', '@2x'], '', Utils::basename($filepath));
$list[$filename] = [$file, $settings];
@@ -508,7 +508,7 @@ trait FlexMediaTrait
user_error(__METHOD__ . '() is deprecated since Grav 1.7, use Media class that implements MediaUploadInterface instead', E_USER_DEPRECATED);
// Check the file extension.
- $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
+ $extension = strtolower(Utils::pathinfo($filename, PATHINFO_EXTENSION));
$grav = Grav::instance();
diff --git a/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php
index 37a0070dd..de98359e7 100644
--- a/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php
+++ b/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php
@@ -5,15 +5,15 @@ declare(strict_types=1);
/**
* @package Grav\Common\Flex
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Framework\Flex\Traits;
-use Grav\Framework\Flex\FlexCollection;
use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
+use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
use RuntimeException;
use function in_array;
@@ -26,7 +26,7 @@ trait FlexRelatedDirectoryTrait
/**
* @param string $type
* @param string $property
- * @return FlexCollectionInterface
+ * @return FlexCollectionInterface
*/
protected function getCollectionByProperty($type, $property)
{
@@ -34,7 +34,7 @@ trait FlexRelatedDirectoryTrait
$collection = $directory->getCollection();
$list = $this->getNestedProperty($property) ?: [];
- /** @var FlexCollection $collection */
+ /** @var FlexCollectionInterface $collection */
$collection = $collection->filter(static function ($object) use ($list) {
return in_array($object->getKey(), $list, true);
});
diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php
index 864e992f3..863eb4af6 100644
--- a/system/src/Grav/Framework/Form/FormFlash.php
+++ b/system/src/Grav/Framework/Form/FormFlash.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -343,7 +343,7 @@ class FormFlash implements FormFlashInterface
// Prepare upload data for later save
$data = [
- 'name' => basename($filename),
+ 'name' => Utils::basename($filename),
'type' => Utils::getMimeByLocalFile($filename),
'size' => filesize($filename),
];
diff --git a/system/src/Grav/Framework/Form/FormFlashFile.php b/system/src/Grav/Framework/Form/FormFlashFile.php
index 800d7c3a8..6c995993e 100644
--- a/system/src/Grav/Framework/Form/FormFlashFile.php
+++ b/system/src/Grav/Framework/Form/FormFlashFile.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
index d21d4aa05..6a85f668c 100644
--- a/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
+++ b/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php
index d51bd8d9e..44bee025c 100644
--- a/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php
+++ b/system/src/Grav/Framework/Form/Interfaces/FormFlashInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/Interfaces/FormInterface.php b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php
index 98156469d..0edfc42a9 100644
--- a/system/src/Grav/Framework/Form/Interfaces/FormInterface.php
+++ b/system/src/Grav/Framework/Form/Interfaces/FormInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Form/Traits/FormTrait.php b/system/src/Grav/Framework/Form/Traits/FormTrait.php
index 3c368d97b..f4be9e7aa 100644
--- a/system/src/Grav/Framework/Form/Traits/FormTrait.php
+++ b/system/src/Grav/Framework/Form/Traits/FormTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Form
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Interfaces/RenderInterface.php b/system/src/Grav/Framework/Interfaces/RenderInterface.php
index 7a7d9d367..5bc6e5835 100644
--- a/system/src/Grav/Framework/Interfaces/RenderInterface.php
+++ b/system/src/Grav/Framework/Interfaces/RenderInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Interfaces
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Logger/Processors/UserProcessor.php b/system/src/Grav/Framework/Logger/Processors/UserProcessor.php
index 885b4f0a8..f0ebef10c 100644
--- a/system/src/Grav/Framework/Logger/Processors/UserProcessor.php
+++ b/system/src/Grav/Framework/Logger/Processors/UserProcessor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Logger
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
index b3985f308..2bac98f15 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php
index 2c5a4b374..8688ad1c3 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php
index fef475f8b..bca9a228d 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php b/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php
index dc7f1481d..f4409c5c9 100644
--- a/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php
+++ b/system/src/Grav/Framework/Media/Interfaces/MediaObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Media
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Mime/MimeTypes.php b/system/src/Grav/Framework/Mime/MimeTypes.php
index dadcddf7a..e3a5ea8ca 100644
--- a/system/src/Grav/Framework/Mime/MimeTypes.php
+++ b/system/src/Grav/Framework/Mime/MimeTypes.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Mime
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php b/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php
index affff03b0..4b67599fb 100644
--- a/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php
+++ b/system/src/Grav/Framework/Object/Access/ArrayAccessTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php b/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
index 83658753d..d9acb104f 100644
--- a/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
+++ b/system/src/Grav/Framework/Object/Access/NestedArrayAccessTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
index 120c1a49d..561b6fec3 100644
--- a/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
+++ b/system/src/Grav/Framework/Object/Access/NestedPropertyCollectionTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
index 40395cbb0..64107e0d3 100644
--- a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
index d4dd049a8..f417fba02 100644
--- a/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Access/OverloadedPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/ArrayObject.php b/system/src/Grav/Framework/Object/ArrayObject.php
index 57b65261d..a38864c89 100644
--- a/system/src/Grav/Framework/Object/ArrayObject.php
+++ b/system/src/Grav/Framework/Object/ArrayObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php b/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
index b110c5b57..e29370add 100644
--- a/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
+++ b/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,7 @@ use function is_object;
* @package Grav\Framework\Object
*
* @template TKey as array-key
- * @template T as object
+ * @template T as ObjectInterface
*/
trait ObjectCollectionTrait
{
@@ -366,6 +366,7 @@ trait ObjectCollectionTrait
{
$collections = [];
foreach ($this->group($property) as $id => $elements) {
+ /** @phpstan-var static $collection */
$collection = $this->createFrom($elements);
$collections[$id] = $collection;
diff --git a/system/src/Grav/Framework/Object/Base/ObjectTrait.php b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
index 7b218c1b4..86df8c783 100644
--- a/system/src/Grav/Framework/Object/Base/ObjectTrait.php
+++ b/system/src/Grav/Framework/Object/Base/ObjectTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
index eaf589d86..e8b12b7f4 100644
--- a/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
+++ b/system/src/Grav/Framework/Object/Collection/ObjectExpressionVisitor.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php b/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
index a2431be31..9f00babbf 100644
--- a/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/NestedObjectCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
index 4d7a880be..c144d8e92 100644
--- a/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/NestedObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php b/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
index 8169c246e..bd25f6183 100644
--- a/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/ObjectCollectionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php b/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
index e8ec2c1e7..bc4d45df9 100644
--- a/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
+++ b/system/src/Grav/Framework/Object/Interfaces/ObjectInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/LazyObject.php b/system/src/Grav/Framework/Object/LazyObject.php
index 752c5b2d7..6be255884 100644
--- a/system/src/Grav/Framework/Object/LazyObject.php
+++ b/system/src/Grav/Framework/Object/LazyObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/ObjectCollection.php b/system/src/Grav/Framework/Object/ObjectCollection.php
index 40774fc5d..94392af89 100644
--- a/system/src/Grav/Framework/Object/ObjectCollection.php
+++ b/system/src/Grav/Framework/Object/ObjectCollection.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -22,7 +22,7 @@ use function array_slice;
* Class contains a collection of objects.
*
* @template TKey of array-key
- * @template T of object
+ * @template T of \Grav\Framework\Object\Interfaces\ObjectInterface
* @extends ArrayCollection
* @implements NestedObjectCollectionInterface
*/
diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php
index e09c0dd95..ab495bd76 100644
--- a/system/src/Grav/Framework/Object/ObjectIndex.php
+++ b/system/src/Grav/Framework/Object/ObjectIndex.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -35,7 +35,7 @@ abstract class ObjectIndex extends AbstractIndexCollection implements NestedObje
protected static $type;
/** @var string */
- private $_key;
+ protected $_key;
/**
* @param bool $prefix
diff --git a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
index 6f935fe97..8ab4c41e4 100644
--- a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
index 99ad446ea..e6892596a 100644
--- a/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/LazyPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php b/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
index 584e812f3..1b57aab05 100644
--- a/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/MixedPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
index 435220a19..bb0195d66 100644
--- a/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
+++ b/system/src/Grav/Framework/Object/Property/ObjectPropertyTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Object/PropertyObject.php b/system/src/Grav/Framework/Object/PropertyObject.php
index fcd364c6c..d9cdde83a 100644
--- a/system/src/Grav/Framework/Object/PropertyObject.php
+++ b/system/src/Grav/Framework/Object/PropertyObject.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Object
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/AbstractPagination.php b/system/src/Grav/Framework/Pagination/AbstractPagination.php
index 392bb7710..a4d902a2f 100644
--- a/system/src/Grav/Framework/Pagination/AbstractPagination.php
+++ b/system/src/Grav/Framework/Pagination/AbstractPagination.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
index 946139589..072fea767 100644
--- a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
+++ b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
index b2f5c352b..1a82147a1 100644
--- a/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
+++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php b/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
index b90594d71..26c069262 100644
--- a/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
+++ b/system/src/Grav/Framework/Pagination/Interfaces/PaginationPageInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/Pagination.php b/system/src/Grav/Framework/Pagination/Pagination.php
index e602872d1..8f2fa203c 100644
--- a/system/src/Grav/Framework/Pagination/Pagination.php
+++ b/system/src/Grav/Framework/Pagination/Pagination.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Pagination/PaginationPage.php b/system/src/Grav/Framework/Pagination/PaginationPage.php
index 63ceb5f63..e64abe9c0 100644
--- a/system/src/Grav/Framework/Pagination/PaginationPage.php
+++ b/system/src/Grav/Framework/Pagination/PaginationPage.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Pagination
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/AbstractUri.php b/system/src/Grav/Framework/Psr7/AbstractUri.php
index 771899578..145437a58 100644
--- a/system/src/Grav/Framework/Psr7/AbstractUri.php
+++ b/system/src/Grav/Framework/Psr7/AbstractUri.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Request.php b/system/src/Grav/Framework/Psr7/Request.php
index cd65fd98f..795a1a46e 100644
--- a/system/src/Grav/Framework/Psr7/Request.php
+++ b/system/src/Grav/Framework/Psr7/Request.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Response.php b/system/src/Grav/Framework/Psr7/Response.php
index 6d8e68f68..6189c4a6f 100644
--- a/system/src/Grav/Framework/Psr7/Response.php
+++ b/system/src/Grav/Framework/Psr7/Response.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/ServerRequest.php b/system/src/Grav/Framework/Psr7/ServerRequest.php
index 692e891a4..cb5bcbbd3 100644
--- a/system/src/Grav/Framework/Psr7/ServerRequest.php
+++ b/system/src/Grav/Framework/Psr7/ServerRequest.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Stream.php b/system/src/Grav/Framework/Psr7/Stream.php
index a5a104363..6546bdc3e 100644
--- a/system/src/Grav/Framework/Psr7/Stream.php
+++ b/system/src/Grav/Framework/Psr7/Stream.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
index 39e3818ce..c09a03c28 100644
--- a/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
index 13f4c6fd8..49f2a928a 100644
--- a/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
index 7b62c3c05..4bbc73614 100644
--- a/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
index 33c26e0c7..9222219e7 100644
--- a/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
index 358f18b47..448323fdb 100644
--- a/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php b/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
index e0c65bddd..eec3add23 100644
--- a/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
index 607d7571f..73adb6470 100644
--- a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
+++ b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/UploadedFile.php b/system/src/Grav/Framework/Psr7/UploadedFile.php
index bfa63cdf4..c3ed62e69 100644
--- a/system/src/Grav/Framework/Psr7/UploadedFile.php
+++ b/system/src/Grav/Framework/Psr7/UploadedFile.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Psr7/Uri.php b/system/src/Grav/Framework/Psr7/Uri.php
index bb88e937d..63fe04eff 100644
--- a/system/src/Grav/Framework/Psr7/Uri.php
+++ b/system/src/Grav/Framework/Psr7/Uri.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
/**
* @package Grav\Framework\Psr7
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
index 451e58642..2456ea1f5 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/InvalidArgumentException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
index 40c9e0a81..ce79ab2ac 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/NotFoundException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php b/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
index 1b18473f5..7b4a0e7d3 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/NotHandledException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
index 747c0ca5a..f75216722 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/PageExpiredException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
index 60799644f..678b26786 100644
--- a/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
+++ b/system/src/Grav/Framework/RequestHandler/Exception/RequestException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
index 9eadf72e3..36ef3a53f 100644
--- a/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
+++ b/system/src/Grav/Framework/RequestHandler/Middlewares/Exceptions.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/RequestHandler.php b/system/src/Grav/Framework/RequestHandler/RequestHandler.php
index edd3178ff..2ce2427f4 100644
--- a/system/src/Grav/Framework/RequestHandler/RequestHandler.php
+++ b/system/src/Grav/Framework/RequestHandler/RequestHandler.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
index 1b5a79e8d..ff82889d4 100644
--- a/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
+++ b/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\RequestHandler
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php
index 68cd6c2b3..d4d90780f 100644
--- a/system/src/Grav/Framework/Route/Route.php
+++ b/system/src/Grav/Framework/Route/Route.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Route
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Route/RouteFactory.php b/system/src/Grav/Framework/Route/RouteFactory.php
index 68baf55b6..fa1a76c30 100644
--- a/system/src/Grav/Framework/Route/RouteFactory.php
+++ b/system/src/Grav/Framework/Route/RouteFactory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Route
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Session/Exceptions/SessionException.php b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
index 5ad948b67..a07e87dc9 100644
--- a/system/src/Grav/Framework/Session/Exceptions/SessionException.php
+++ b/system/src/Grav/Framework/Session/Exceptions/SessionException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Session/Messages.php b/system/src/Grav/Framework/Session/Messages.php
index 5d854a218..37c62a9af 100644
--- a/system/src/Grav/Framework/Session/Messages.php
+++ b/system/src/Grav/Framework/Session/Messages.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Session/Session.php b/system/src/Grav/Framework/Session/Session.php
index 53f331331..108563e37 100644
--- a/system/src/Grav/Framework/Session/Session.php
+++ b/system/src/Grav/Framework/Session/Session.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Session/SessionInterface.php b/system/src/Grav/Framework/Session/SessionInterface.php
index a441791bd..fa2873d9a 100644
--- a/system/src/Grav/Framework/Session/SessionInterface.php
+++ b/system/src/Grav/Framework/Session/SessionInterface.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Session
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Uri/Uri.php b/system/src/Grav/Framework/Uri/Uri.php
index c43496ea9..6355a1fc9 100644
--- a/system/src/Grav/Framework/Uri/Uri.php
+++ b/system/src/Grav/Framework/Uri/Uri.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Uri
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Framework/Uri/UriFactory.php b/system/src/Grav/Framework/Uri/UriFactory.php
index f7724b78d..ebfec0356 100644
--- a/system/src/Grav/Framework/Uri/UriFactory.php
+++ b/system/src/Grav/Framework/Uri/UriFactory.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Uri
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
@@ -125,7 +125,7 @@ class UriFactory
$encodedUrl = preg_replace_callback(
'%[^:/@?&=#]+%u',
- function ($matches) {
+ static function ($matches) {
return rawurlencode($matches[0]);
},
$url
diff --git a/system/src/Grav/Framework/Uri/UriPartsFilter.php b/system/src/Grav/Framework/Uri/UriPartsFilter.php
index 71a5135d6..260711bf4 100644
--- a/system/src/Grav/Framework/Uri/UriPartsFilter.php
+++ b/system/src/Grav/Framework/Uri/UriPartsFilter.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Framework\Uri
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Installer/Install.php b/system/src/Grav/Installer/Install.php
index 889b1d5e6..0f23e8963 100644
--- a/system/src/Grav/Installer/Install.php
+++ b/system/src/Grav/Installer/Install.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Installer/InstallException.php b/system/src/Grav/Installer/InstallException.php
index 145b7c9cc..cdd5b7afa 100644
--- a/system/src/Grav/Installer/InstallException.php
+++ b/system/src/Grav/Installer/InstallException.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Installer/VersionUpdate.php b/system/src/Grav/Installer/VersionUpdate.php
index 3efca1f31..1fde78307 100644
--- a/system/src/Grav/Installer/VersionUpdate.php
+++ b/system/src/Grav/Installer/VersionUpdate.php
@@ -3,6 +3,7 @@
namespace Grav\Installer;
use Closure;
+use Grav\Common\Utils;
/**
* Class VersionUpdate
diff --git a/system/src/Grav/Installer/Versions.php b/system/src/Grav/Installer/Versions.php
index 03f3b0b0f..92a64ced7 100644
--- a/system/src/Grav/Installer/Versions.php
+++ b/system/src/Grav/Installer/Versions.php
@@ -3,7 +3,7 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
diff --git a/system/src/Grav/Installer/YamlUpdater.php b/system/src/Grav/Installer/YamlUpdater.php
index 9af20558f..fe1c7f1ac 100644
--- a/system/src/Grav/Installer/YamlUpdater.php
+++ b/system/src/Grav/Installer/YamlUpdater.php
@@ -3,12 +3,13 @@
/**
* @package Grav\Installer
*
- * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved.
+ * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Installer;
+use Grav\Common\Utils;
use Symfony\Component\Yaml\Yaml;
use function assert;
use function count;
diff --git a/tests/phpstan/classes/Toolbox/UniformResourceLocatorExtension.php b/tests/phpstan/classes/Toolbox/UniformResourceLocatorExtension.php
new file mode 100644
index 000000000..98bbca8a9
--- /dev/null
+++ b/tests/phpstan/classes/Toolbox/UniformResourceLocatorExtension.php
@@ -0,0 +1,51 @@
+getName() === 'findResource';
+ }
+
+ /**
+ * @param MethodReflection $methodReflection
+ * @param MethodCall $methodCall
+ * @param Scope $scope
+ * @return Type
+ */
+ public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
+ {
+ $first = $methodCall->getArgs()[2] ?? false;
+ if ($first) {
+ return new StringType();
+ }
+
+ return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
+ }
+}
diff --git a/tests/phpstan/extension.neon b/tests/phpstan/extension.neon
new file mode 100644
index 000000000..ef44d0b41
--- /dev/null
+++ b/tests/phpstan/extension.neon
@@ -0,0 +1,5 @@
+services:
+ -
+ class: PHPStan\Toolbox\UniformResourceLocatorExtension
+ tags:
+ - phpstan.broker.dynamicMethodReturnTypeExtension
diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon
index 546e2f088..7d5d7cb00 100644
--- a/tests/phpstan/phpstan.neon
+++ b/tests/phpstan/phpstan.neon
@@ -2,6 +2,7 @@
includes:
#- '../../vendor/phpstan/phpstan-strict-rules/rules.neon'
- '../../vendor/phpstan/phpstan-deprecation-rules/rules.neon'
+ - 'extension.neon'
parameters:
fileExtensions:
- php
@@ -129,6 +130,9 @@ parameters:
-
message: '#Call to deprecated method getLegacyFiles\(\)#'
path: '*/system/src/Grav/Common/Session.php'
+ -
+ message: '#Call to deprecated method \w+\(\) of class Grav\\Common\\Flex\\Types\\Users\\UserObject#'
+ path: '*/system/src/Grav/Common/Flex/Types/Users/UserObject.php'
-
message: '#Call to deprecated method \w+\(\) of class Grav\\Framework\\Flex\\FlexObject#'
path: '*/system/src/Grav/Framework/Flex/FlexObject.php'
diff --git a/tests/phpstan/plugins-bootstrap.php b/tests/phpstan/plugins-bootstrap.php
index c28f2ab8a..1c1828033 100644
--- a/tests/phpstan/plugins-bootstrap.php
+++ b/tests/phpstan/plugins-bootstrap.php
@@ -10,10 +10,6 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
$autoload = require __DIR__ . '/../../vendor/autoload.php';
-if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
- exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
-}
-
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
diff --git a/tests/phpstan/plugins.neon b/tests/phpstan/plugins.neon
index 6cf9e93c8..82570cca5 100644
--- a/tests/phpstan/plugins.neon
+++ b/tests/phpstan/plugins.neon
@@ -1,6 +1,7 @@
includes:
#- '../../vendor/phpstan/phpstan-strict-rules/rules.neon'
- '../../vendor/phpstan/phpstan-deprecation-rules/rules.neon'
+ - 'extension.neon'
parameters:
fileExtensions:
- php
@@ -37,6 +38,7 @@ parameters:
- Grav\Common\GPM\Common\Package
- Grav\Common\GPM\Local\Package
- Grav\Common\GPM\Remote\Package
+ - Grav\Common\Page\Header
- Grav\Common\Session
- Gantry\Component\Config\Config
dynamicConstantNames:
diff --git a/tmp/.gitkeep b/tmp/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/tmp/.gitkeep
+++ b/tmp/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/accounts/.gitkeep b/user/accounts/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/accounts/.gitkeep
+++ b/user/accounts/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/config/system.yaml b/user/config/system.yaml
index 7a8ffe58c..2e992778d 100644
--- a/user/config/system.yaml
+++ b/user/config/system.yaml
@@ -29,6 +29,7 @@ assets:
css_minify: true
css_rewrite: true
js_pipeline: false
+ js_module_pipeline: false
js_minify: true
errors:
diff --git a/user/data/.gitkeep b/user/data/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/data/.gitkeep
+++ b/user/data/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/plugins/.gitkeep b/user/plugins/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/plugins/.gitkeep
+++ b/user/plugins/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/user/themes/.gitkeep b/user/themes/.gitkeep
index 33a9aed71..8efbf1f12 100644
--- a/user/themes/.gitkeep
+++ b/user/themes/.gitkeep
@@ -1 +1 @@
-/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */
+/* @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved. */
diff --git a/webserver-configs/htaccess.txt b/webserver-configs/htaccess.txt
index 83063ae2e..098c58244 100644
--- a/webserver-configs/htaccess.txt
+++ b/webserver-configs/htaccess.txt
@@ -59,9 +59,9 @@ RewriteRule .* index.php [L]
# Block all direct access for these folders
RewriteRule ^(\.git|cache|bin|logs|backup|webserver-configs|tests)/(.*) error [F]
# Block access to specific file types for these system folders
-RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block access to specific file types for these user folders
-RewriteRule ^(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
+RewriteRule ^(user)/(.*)\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
# Block all direct access to .md files:
RewriteRule \.md$ error [F]
# Block all direct access to files and folders beginning with a dot
diff --git a/webserver-configs/lighttpd.conf b/webserver-configs/lighttpd.conf
index 512362fd1..f14c5a8b9 100644
--- a/webserver-configs/lighttpd.conf
+++ b/webserver-configs/lighttpd.conf
@@ -33,7 +33,7 @@ $HTTP["url"] =~ "^/grav_path/(LICENSE\.txt|composer\.json|composer\.lock|nginx\.
$HTTP["url"] =~ "^/grav_path/(\.git|cache|bin|logs|backup|tests)/(.*)" {
url.access-deny = ("")
}
-$HTTP["url"] =~ "^/grav_path/(system|user|vendor)/(.*)\.(txt|md|html|yaml|yml|php|twig|sh|bat)$" {
+$HTTP["url"] =~ "^/grav_path/(system|user|vendor)/(.*)\.(txt|md|html|json|yaml|yml|php|twig|sh|bat)$" {
url.access-deny = ("")
}
$HTTP["url"] =~ "^/grav_path/(\.(.*))" {
diff --git a/webserver-configs/nginx.conf b/webserver-configs/nginx.conf
index bbca7d32d..fc7d06b49 100644
--- a/webserver-configs/nginx.conf
+++ b/webserver-configs/nginx.conf
@@ -20,9 +20,9 @@ server {
# deny all direct access for these folders
location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
# deny running scripts inside core system folders
- location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
+ location ~* /(system|vendor)/.*\.(txt|xml|md|html|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
# deny running scripts inside user folder
- location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
+ location ~* /user/.*\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
# deny access to specific files in the root folder
location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
## End - Security
diff --git a/webserver-configs/web.config b/webserver-configs/web.config
index 892ce9282..1c351a3b3 100644
--- a/webserver-configs/web.config
+++ b/webserver-configs/web.config
@@ -18,7 +18,7 @@
-
+
@@ -26,11 +26,11 @@
-
+
-
+