diff --git a/CHANGELOG.md b/CHANGELOG.md index 0677df5..ef8e4fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,55 @@ +# v1.7.7 +## 02/23/2021 + +1. [](#new) + * Added `Utils::arrayToQueryParams()` to convert an array into query params +1. [](#improved) + * Added original image support for all flex objects and media fields + * Improved `Pagination` class to allow custom pagination query parameter +1. [](#bugfix) + * Fixed avatar of the user not being saved [grav-plugin-flex-objects#111](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/111) + * Replaced special space character with regular space in `system/blueprints/user/account_new.yaml` + +# v1.7.6 +## 02/17/2021 + +1. [](#new) + * Added `Medium::attribute()` to pass arbitrary attributes [#3065](https://github.com/getgrav/grav/pull/3065) + * Added `Plugins::getPlugins()` and `Plugins::getPlugin($name)` to make it easier to access plugin instances [#2277](https://github.com/getgrav/grav/pull/2277) + * Added `regex_match` and `regex_split` twig functions [#2788](https://github.com/getgrav/grav/pull/2788) + * Updated all languages from [Crowdin](https://crowdin.com/project/grav-core) - Please update any translations here +1. [](#improved) + * Added abstract `FlexObject`, `FlexCollection` and `FlexIndex` classes to `\Grav\Common\Flex` namespace (extend those instead of Framework or Generic classes) + * Updated bundled `composer.phar` binary to latest version `2.0.9` + * Improved session fixation handling in PHP 7.4+ (cannot fix it in PHP 7.3 due to PHP bug) + * Added optional password/database attributes for redis in `system.yaml` + * Added ability to filter enabled or disabled with bin/gpm index [#3187](https://github.com/getgrav/grav/pull/3187) + * Added `$grav->getVersion()` or `grav.version` in twig to get the current Grav version [#3142](https://github.com/getgrav/grav/issues/3142) + * Added second parameter to `$blueprint->flattenData()` to include every field, including those which have no data + * Added support for setting session domain [#2040](https://github.com/getgrav/grav/pull/2040) + * Better support inheriting languages when using child themes [#3226](https://github.com/getgrav/grav/pull/3226) + * Added option for `FlexForm` constructor to reset the form +1. [](#bugfix) + * Fixed issue with `content-security-policy` not being properly supported with `http-equiv` + support single quotes + * Fixed CLI progressbar in `backup` and `security` commands to use styled output [#3198](https://github.com/getgrav/grav/issues/3198) + * Fixed page save failing because of uploaded images [#3191](https://github.com/getgrav/grav/issues/3191) + * Fixed `Flex Pages` using only default language in frontend [#106](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/106) + * Fixed empty `route()` and `raw_route()` when getting translated pages [#3184](https://github.com/getgrav/grav/pull/3184) + * Fixed error on `bin/gpm plugin uninstall` [#3207](https://github.com/getgrav/grav/issues/3207) + * Fixed broken min/max validation for field `type: int` + * Fixed lowering uppercase characters in usernames when saving from frontend [#2565](https://github.com/getgrav/grav/pull/2565) + * Fixed save error when editing accounts that have been created with capital letters in their username [#3211](https://github.com/getgrav/grav/issues/3211) + * Fixed renaming flex objects key when using file storage + * Fixed wrong values in Admin pages list [#3214](https://github.com/getgrav/grav/issues/3214) + * Fixed pipelined asset using different hash when extra asset is added to before/after position [#2781](https://github.com/getgrav/grav/issues/2781) + * Fixed trailing slash redirect to only apply to GET/HEAD requests and use 301 status code [#3127](https://github.com/getgrav/grav/issues/3127) + * Fixed root page to always contain trailing slash [#3127](https://github.com/getgrav/grav/issues/3127) + * Fixed `` to use name instead property [#3010](https://github.com/getgrav/grav/pull/3010) + * Fixed behavior of opposite filters in `Pages::getCollection()` to match Grav 1.6 [#3216](https://github.com/getgrav/grav/pull/3216) + * Fixed modular content with missing template file ending up using non-modular template [#3218](https://github.com/getgrav/grav/issues/3218) + * Fixed broken attachment image in Flex Objects Admin when `destination: self@` used [#3225](https://github.com/getgrav/grav/issues/3225) + * Fixed bug in page content with both markdown and twig enabled [#3223](https://github.com/getgrav/grav/issues/3223) + # v1.7.5 ## 02/01/2021 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 42ef22d..99ab478 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,46 +1,133 @@ + # Contributor Covenant Code of Conduct ## Our Pledge -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to creating a positive environment include: +Examples of behavior that contributes to a positive environment for our +community include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community -Examples of unacceptable behavior by participants include: +Examples of unacceptable behavior include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting -## Our Responsibilities +## Enforcement Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. ## Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@getgrav.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available +at [https://www.contributor-covenant.org/translations][translations]. -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ +[homepage]: https://www.contributor-covenant.org +[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/README.md b/README.md index 962cb36..562349f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/cfd20465-d0f8-4a0a-8444-467f5b5f16ad/mini.png)](https://insight.sensiolabs.com/projects/cfd20465-d0f8-4a0a-8444-467f5b5f16ad) [![Discord](https://img.shields.io/discord/501836936584101899.svg?logo=discord&colorB=728ADA&label=Discord%20Chat)](https://chat.getgrav.org) - [![Build Status](https://travis-ci.org/getgrav/grav.svg?branch=develop)](https://travis-ci.org/getgrav/grav) [![OpenCollective](https://opencollective.com/grav/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/grav/sponsors/badge.svg)](#sponsors) + [![PHP Tests](https://github.com/getgrav/grav/workflows/PHP%20Tests/badge.svg?branch=develop)](https://github.com/getgrav/grav/actions?query=workflow%3A%22PHP+Tests%22) [![OpenCollective](https://opencollective.com/grav/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/grav/sponsors/badge.svg)](#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. diff --git a/assets/.gitkeep b/assets/.gitkeep index e69de29..33a9aed 100644 --- a/assets/.gitkeep +++ b/assets/.gitkeep @@ -0,0 +1 @@ +/* @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. */ diff --git a/bin/composer.phar b/bin/composer.phar index c8fa35f..3791ce3 100644 Binary files a/bin/composer.phar and b/bin/composer.phar differ diff --git a/bin/gpm b/bin/gpm index f651909..a2eebc6 100644 --- a/bin/gpm +++ b/bin/gpm @@ -1,6 +1,11 @@ #!/usr/bin/env php =5.6" + "php": "~7.2|~8.0" }, "require-dev": { - "phpunit/phpunit": "~5.7|~6|~7", - "symfony/phpunit-bridge": "~2.7|~3|~4", - "symfony/yaml": "~2.3|~3|~4" + "cucumber/cucumber": "dev-gherkin-16.0.0", + "phpunit/phpunit": "~8|~9", + "symfony/phpunit-bridge": "~3|~4|~5", + "symfony/yaml": "~3|~4|~5" }, "suggest": { "symfony/yaml": "If you want to parse features, represented in YAML files" @@ -3400,9 +3401,9 @@ ], "support": { "issues": "https://github.com/Behat/Gherkin/issues", - "source": "https://github.com/Behat/Gherkin/tree/v4.7.1" + "source": "https://github.com/Behat/Gherkin/tree/v4.8.0" }, - "time": "2021-01-26T16:24:32+00:00" + "time": "2021-02-04T12:44:21+00:00" }, { "name": "codeception/codeception", @@ -4491,16 +4492,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.70", + "version": "0.12.77", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee" + "reference": "1f10b8c8d118d01e7b492f9707999d456be5812c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee", - "reference": "07f0ef37f5f876e8cee44cc8ea0ec3fe80d499ee", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1f10b8c8d118d01e7b492f9707999d456be5812c", + "reference": "1f10b8c8d118d01e7b492f9707999d456be5812c", "shasum": "" }, "require": { @@ -4531,7 +4532,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.70" + "source": "https://github.com/phpstan/phpstan/tree/0.12.77" }, "funding": [ { @@ -4547,7 +4548,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T17:06:47+00:00" + "time": "2021-02-17T16:22:19+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -4920,16 +4921,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.1", + "version": "9.5.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360" + "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7bdf4085de85a825f4424eae52c99a1cec2f360", - "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f661659747f2f87f9e72095bb207bceb0f151cb4", + "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4", "shasum": "" }, "require": { @@ -5007,7 +5008,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.1" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.2" }, "funding": [ { @@ -5019,7 +5020,7 @@ "type": "github" } ], - "time": "2021-01-17T07:42:25+00:00" + "time": "2021-02-02T14:45:58+00:00" }, { "name": "psr/http-client", @@ -6039,7 +6040,7 @@ }, { "name": "symfony/browser-kit", - "version": "v5.2.2", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", @@ -6090,7 +6091,7 @@ "description": "Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/browser-kit/tree/v5.2.2" + "source": "https://github.com/symfony/browser-kit/tree/v5.2.3" }, "funding": [ { @@ -6110,7 +6111,7 @@ }, { "name": "symfony/css-selector", - "version": "v5.2.2", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -6155,7 +6156,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v5.2.2" + "source": "https://github.com/symfony/css-selector/tree/v5.2.3" }, "funding": [ { @@ -6175,7 +6176,7 @@ }, { "name": "symfony/dom-crawler", - "version": "v5.2.2", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -6229,7 +6230,7 @@ "description": "Eases DOM navigation for HTML and XML documents", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dom-crawler/tree/v5.2.2" + "source": "https://github.com/symfony/dom-crawler/tree/v5.2.3" }, "funding": [ { @@ -6249,16 +6250,16 @@ }, { "name": "symfony/finder", - "version": "v5.2.2", + "version": "v5.2.3", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "196f45723b5e618bf0e23b97e96d11652696ea9e" + "reference": "4adc8d172d602008c204c2e16956f99257248e03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/196f45723b5e618bf0e23b97e96d11652696ea9e", - "reference": "196f45723b5e618bf0e23b97e96d11652696ea9e", + "url": "https://api.github.com/repos/symfony/finder/zipball/4adc8d172d602008c204c2e16956f99257248e03", + "reference": "4adc8d172d602008c204c2e16956f99257248e03", "shasum": "" }, "require": { @@ -6290,7 +6291,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.2.2" + "source": "https://github.com/symfony/finder/tree/v5.2.3" }, "funding": [ { @@ -6306,7 +6307,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:01:46+00:00" + "time": "2021-01-28T22:06:19+00:00" }, { "name": "theseer/tokenizer", diff --git a/index.php b/index.php index 1737a24..9842952 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ /** * @package Grav.Core * - * @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 9fa9f01..538fd08 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -741,6 +741,16 @@ form: size: small label: PLUGIN_ADMIN.REDIS_PASSWORD + cache.redis.database: + type: text + size: medium + label: PLUGIN_ADMIN.REDIS_DATABASE + help: PLUGIN_ADMIN.REDIS_DATABASE_HELP + placeholder: "0" + validate: + type: number + min: 0 + flex_caching: type: section title: PLUGIN_ADMIN.FLEX_CACHING @@ -1338,6 +1348,12 @@ form: validate: type: bool + session.domain: + type: text + size: small + label: PLUGIN_ADMIN.SESSION_DOMAIN + help: PLUGIN_ADMIN.SESSION_DOMAIN_HELP + session.path: type: text size: small diff --git a/system/blueprints/user/account_new.yaml b/system/blueprints/user/account_new.yaml index 7a92518..1b22f93 100644 --- a/system/blueprints/user/account_new.yaml +++ b/system/blueprints/user/account_new.yaml @@ -13,6 +13,6 @@ form: label: PLUGIN_ADMIN.USERNAME help: PLUGIN_ADMIN.USERNAME_HELP unset-disabled@: true - unset-readonly@: true + unset-readonly@: true validate: required: true diff --git a/system/config/system.yaml b/system/config/system.yaml index 46398e1..5c29a78 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -103,6 +103,8 @@ cache: allow_webserver_gzip: false # If true, `content-encoding: identity` but connection isn't closed before `onShutDown()` event redis: socket: false # Path to redis unix socket (e.g. /var/run/redis/redis.sock), false = use server and port to connect + password: # Optional password + database: # Optional database ID twig: cache: true # Set to true to enable Twig caching @@ -170,7 +172,8 @@ session: 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) - path: + domain: # Domain used by sessions. + path: # Path used by sessions. gpm: releases: stable # Set to either 'stable' or 'testing' diff --git a/system/defines.php b/system/defines.php index a2e7a77..d0fd873 100644 --- a/system/defines.php +++ b/system/defines.php @@ -2,13 +2,13 @@ /** * @package Grav\Core * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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.5'); +define('GRAV_VERSION', '1.7.7'); 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 fd8aefb..e8cd582 100644 --- a/system/install.php +++ b/system/install.php @@ -2,7 +2,7 @@ /** * @package Grav\Core * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/languages/ar.yaml b/system/languages/ar.yaml index 04e63f9..9605405 100644 --- a/system/languages/ar.yaml +++ b/system/languages/ar.yaml @@ -1,6 +1,17 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\nالعنوان: %1$s\n---\n# خطأ: مادة أمامية غير صحيحة\n\nمسار: '%2$s'\n\n**%3$s**\n\n, , ,\n\n%4$s\n, , ," + INFLECTOR_UNCOUNTABLE: + - 'معدّات' + - 'معلومات' + - 'أرز' + - 'مال' + - 'نوع' + - 'سلسلة' + - 'سمك' + - 'خروف' + INFLECTOR_IRREGULAR: + 'person': 'أشخاص' NICETIME: NO_DATE_PROVIDED: لم يتم تقديم التاريخ BAD_DATE: تاريخ خاطئ @@ -37,8 +48,8 @@ GRAV: YR_PLURAL: سنوات DEC_PLURAL: عقود FORM: - VALIDATION_FAIL: فشل التحقق من صحة: - INVALID_INPUT: إدخال غير صحيح في + VALIDATION_FAIL: 'فشل التحقق من صحة:' + INVALID_INPUT: 'إدخال غير صحيح في' MISSING_REQUIRED_FIELD: 'حقل مطلوب مفقود:' MONTHS_OF_THE_YEAR: - 'كانون الثاني' @@ -61,3 +72,11 @@ GRAV: - 'الجمعة' - 'السبت' - 'الأحد' + CRON: + EVERY: كل + EVERY_HOUR: كل ساعة + EVERY_MINUTE: كل دقيقة + EVERY_DAY_OF_WEEK: كل يوم في الأسبوع + EVERY_DAY_OF_MONTH: كل يوم في الشهر + EVERY_MONTH: ' كل شهر' + TEXT_PERIOD: كل diff --git a/system/languages/bg.yaml b/system/languages/bg.yaml index 48daceb..174b3a4 100644 --- a/system/languages/bg.yaml +++ b/system/languages/bg.yaml @@ -36,8 +36,8 @@ GRAV: YR_PLURAL: г DEC_PLURAL: дстлт FORM: - VALIDATION_FAIL: Неуспешна проверка: - INVALID_INPUT: Невалидно въвеждане в + VALIDATION_FAIL: 'Неуспешна проверка:' + INVALID_INPUT: 'Невалидно въвеждане в' MISSING_REQUIRED_FIELD: 'Липсва задължително поле:' MONTHS_OF_THE_YEAR: - 'януари' diff --git a/system/languages/ca.yaml b/system/languages/ca.yaml index bd04474..7795aef 100644 --- a/system/languages/ca.yaml +++ b/system/languages/ca.yaml @@ -1,6 +1,15 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\ntitle: %1$s\n---\n\n# S'ha produït un error: Frontmatter invàlid\n\nRuta: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_UNCOUNTABLE: + - 'equipment' + - 'informació' + - 'rice' + - 'money' + - 'species' + - 'series' + - 'fish' + - 'sheep' NICETIME: NO_DATE_PROVIDED: No s'ha proporcionat data BAD_DATE: Data invàlida @@ -36,8 +45,8 @@ GRAV: YR_PLURAL: anys DEC_PLURAL: dèc. FORM: - VALIDATION_FAIL: Ha fallat la validació: - INVALID_INPUT: Entrada no vàlida a + VALIDATION_FAIL: 'Ha fallat la validació:' + INVALID_INPUT: 'Entrada no vàlida a' MISSING_REQUIRED_FIELD: 'Falta camp obligatori:' MONTHS_OF_THE_YEAR: - 'Gener' diff --git a/system/languages/cs.yaml b/system/languages/cs.yaml index 80844c9..bfad423 100644 --- a/system/languages/cs.yaml +++ b/system/languages/cs.yaml @@ -101,9 +101,10 @@ GRAV: YR_PLURAL: r DEC_PLURAL: dek FORM: - VALIDATION_FAIL: Ověření se nezdařilo: - INVALID_INPUT: Neplatný vstup v + VALIDATION_FAIL: 'Ověření se nezdařilo:' + INVALID_INPUT: 'Neplatný vstup v' MISSING_REQUIRED_FIELD: 'Chybí požadované pole:' + XSS_ISSUES: "Byly zjištěny možné problémy XSS v poli '%s'" MONTHS_OF_THE_YEAR: - 'leden' - 'únor' @@ -125,6 +126,8 @@ GRAV: - 'pátek' - 'sobota' - 'neděle' + YES: "Ano" + NO: "Ne" CRON: EVERY: každý EVERY_HOUR: každou hodinu diff --git a/system/languages/da.yaml b/system/languages/da.yaml index 17ce683..f23477c 100644 --- a/system/languages/da.yaml +++ b/system/languages/da.yaml @@ -1,11 +1,27 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\nTitel: %1$s\n---\n\n# Fejl: Ugyldigt frontmatter\n\nSti: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_UNCOUNTABLE: + - 'udstyr' + - 'information' + - 'ris' + - 'penge' + - 'arter' + - 'Serier' + - 'fisk' + - 'får' + INFLECTOR_IRREGULAR: + 'person': 'personer' + 'man': 'mænd' + 'child': 'børn' + 'sex': 'køn' + 'move': 'flyt' NICETIME: NO_DATE_PROVIDED: Ingen dato angivet BAD_DATE: Ugyldig dato AGO: siden FROM_NOW: fra nu + JUST_NOW: lige nu SECOND: sekund MINUTE: minut HOUR: time @@ -15,6 +31,7 @@ GRAV: YEAR: år DECADE: årti SEC: sek + MIN: min. HR: t WK: u MO: md @@ -36,8 +53,8 @@ GRAV: YR_PLURAL: år DEC_PLURAL: årtier FORM: - VALIDATION_FAIL: Validering mislykkedes: - INVALID_INPUT: Ugyldigt input i + VALIDATION_FAIL: 'Validering mislykkedes:' + INVALID_INPUT: 'Ugyldigt input i' MISSING_REQUIRED_FIELD: 'Mangler obligatorisk felt:' MONTHS_OF_THE_YEAR: - 'januar' @@ -60,3 +77,14 @@ GRAV: - 'fredag' - 'lørdag' - 'søndag' + CRON: + EVERY: hver + EVERY_HOUR: hver time + EVERY_MINUTE: hvert minut + EVERY_DAY_OF_WEEK: alle ugens dage + EVERY_DAY_OF_MONTH: alle dage i måneden + EVERY_MONTH: hver måned + TEXT_PERIOD: Hver + TEXT_MINS: ' ved minut(ter) over timen' + ERROR1: Tagget %s understøttes ikke! + ERROR2: Ugyldigt antal elementer diff --git a/system/languages/de.yaml b/system/languages/de.yaml index 533cf89..45c24e7 100644 --- a/system/languages/de.yaml +++ b/system/languages/de.yaml @@ -101,9 +101,10 @@ GRAV: YR_PLURAL: Jahre DEC_PLURAL: Jahrzehnten FORM: - VALIDATION_FAIL: Überprüfung fehlgeschlagen: - INVALID_INPUT: Ungültige Eingabe in + VALIDATION_FAIL: 'Überprüfung fehlgeschlagen:' + INVALID_INPUT: 'Ungültige Eingabe in' MISSING_REQUIRED_FIELD: 'Erforderliches Feld fehlt:' + XSS_ISSUES: "Potenzielle XSS-Probleme im Feld '%s' erkannt" MONTHS_OF_THE_YEAR: - 'Januar' - 'Februar' @@ -125,8 +126,8 @@ GRAV: - 'Freitag' - 'Samstag' - 'Sonntag' - YES: 'Ja' - NO: 'Nein' + YES: "Ja" + NO: "Nein" CRON: EVERY: jede EVERY_HOUR: jede Stunde diff --git a/system/languages/el.yaml b/system/languages/el.yaml index 1faa8dd..28619f8 100644 --- a/system/languages/el.yaml +++ b/system/languages/el.yaml @@ -1,11 +1,75 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\nΤίτλος: %1$s\n---\n\n# Σφάλμα: Μη έγκυρη διαδρομή Frontmatter\n\nΔιαδρομή: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1zes' + '/^(ox)$/i': '\1en' + '/([m|l])ouse$/i': '\1ice' + '/(matr|vert|ind)ix|ex$/i': '\1ices' + '/(x|ch|ss|sh)$/i': '\1es' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([^aeiouy]|qu)y$/i': '\1ies' + '/(hive)$/i': '\1s' + '/(?:([^f])fe|([lr])f)$/i': '\1\2ves' + '/sis$/i': 'ses' + '/([ti])um$/i': '\1a' + '/(buffal|tomat)o$/i': '\1oes' + '/(bu)s$/i': '\1ses' + '/(alias|status)/i': '\1es' + '/(octop|vir)us$/i': '\1i' + '/(ax|test)is$/i': '\1es' + '/s$/i': 's' + '/$/': 's' + INFLECTOR_SINGULAR: + '/(quiz)zes$/i': '\1' + '/(matr)ices$/i': '\1ix' + '/(vert|ind)ices$/i': '\1ex' + '/^(ox)en/i': '\1' + '/(alias|status)es$/i': '\1' + '/([octop|vir])i$/i': '\1us' + '/(cris|ax|test)es$/i': '\1is' + '/(shoe)s$/i': '\1' + '/(o)es$/i': '\1' + '/(bus)es$/i': '\1' + '/([m|l])ice$/i': '\1ouse' + '/(x|ch|ss|sh)es$/i': '\1' + '/(m)ovies$/i': '\1ovie' + '/(s)eries$/i': '\1eries' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([lr])ves$/i': '\1f' + '/(tive)s$/i': '\1' + '/(hive)s$/i': '\1' + '/([^f])ves$/i': '\1fe' + '/(^analy)ses$/i': '\1sis' + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i': '\1\2sis' + '/([ti])a$/i': '\1um' + '/(n)ews$/i': '\1ews' + INFLECTOR_UNCOUNTABLE: + - 'εξοπλισμός' + - 'πληροφοριες' + - 'rice' + - 'χρήματα' + - 'είδη' + - 'σειρές' + - 'ψάρι' + - 'πρόβατο' + INFLECTOR_IRREGULAR: + 'person': 'άνθρωποι' + 'man': 'άνδρες' + 'child': 'παιδιά' + 'sex': 'φύλο' + 'move': 'κινήσεις' + INFLECTOR_ORDINALS: + 'default': 'th' + 'first': 'st' + 'second': 'nd' + 'third': 'rd' NICETIME: NO_DATE_PROVIDED: Δεν δόθηκε καμία ημερομηνία BAD_DATE: Εσφαλμένη ημερομηνία AGO: πρίν FROM_NOW: από τώρα + JUST_NOW: μόλις τώρα SECOND: δευτερόλεπτο MINUTE: λεπτό HOUR: ώρα @@ -37,8 +101,8 @@ GRAV: YR_PLURAL: έτη DEC_PLURAL: δεκαετίες FORM: - VALIDATION_FAIL: Η επικύρωση απέτυχε: - INVALID_INPUT: Μη έγκυρα δεδομένα σε + VALIDATION_FAIL: 'Η επικύρωση απέτυχε:' + INVALID_INPUT: 'Μη έγκυρα δεδομένα σε' MISSING_REQUIRED_FIELD: 'Λείπει το απαιτούμενο πεδίο:' MONTHS_OF_THE_YEAR: - 'Ιανουάριος' @@ -61,3 +125,20 @@ GRAV: - 'Παρασκευή' - 'Σάββατο' - 'Κυριακή' + CRON: + EVERY: κάθε + EVERY_HOUR: κάθε ώρα + EVERY_MINUTE: κάθε λεπτό + EVERY_DAY_OF_WEEK: κάθε μέρα της εβδομάδος + EVERY_DAY_OF_MONTH: κάθε μέρα του μήνα + EVERY_MONTH: κάθε μήνα + TEXT_PERIOD: Κάθε + TEXT_MINS: ' κατά λεπτό(ά) μετά την ώρα' + TEXT_TIME: ' στο :' + TEXT_DOW: ' στις ' + TEXT_MONTH: ' από ' + TEXT_DOM: ' στις ' + ERROR1: Η ετικέτα %s δεν υποστηρίζεται! + ERROR2: Μη έγκυρος αριθμός στοιχείων + ERROR3: Το jquery_element θα έπρεπε να οριστεί στις ρυθμίσεις του jqCron + ERROR4: Μη αναγνωρισμένη έκφραση diff --git a/system/languages/es.yaml b/system/languages/es.yaml index 7bacfeb..95827ee 100644 --- a/system/languages/es.yaml +++ b/system/languages/es.yaml @@ -1,19 +1,25 @@ --- GRAV: - FRONTMATTER_ERROR_PAGE: "---\ntítulo: %1$s\n---\n\n# Error: Frontmatter no válido\n\nRuta: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + FRONTMATTER_ERROR_PAGE: "---\ntítulo: %1$s\n---\n\n# Error: Prefacio no válido\n\nRuta: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1ios' + '/s$/i': 's' + '/$/': 's' INFLECTOR_UNCOUNTABLE: - - 'equipo' + - 'equipamiento' - 'información' - - 'rice' + - 'arroz' - 'dinero' - - 'species' + - 'especies' - 'series' - 'pescado' - 'oveja' INFLECTOR_IRREGULAR: + 'person': 'personas' 'man': 'hombres' 'child': 'niños' 'sex': 'sexos' + 'move': 'movido' INFLECTOR_ORDINALS: 'first': 'ro' 'second': 'do' @@ -33,10 +39,12 @@ GRAV: YEAR: año DECADE: década SEC: seg + MIN: min HR: h WK: sem MO: mes YR: año + DEC: dic SECOND_PLURAL: segundos MINUTE_PLURAL: minutos HOUR_PLURAL: horas @@ -46,6 +54,7 @@ GRAV: YEAR_PLURAL: años DECADE_PLURAL: décadas SEC_PLURAL: segs + MIN_PLURAL: mins HR_PLURAL: hs WK_PLURAL: sem MO_PLURAL: mes @@ -55,6 +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'" MONTHS_OF_THE_YEAR: - 'Enero' - 'Febrero' @@ -76,6 +86,8 @@ GRAV: - 'Viernes' - 'Sábado' - 'Domingo' + YES: "Si" + NO: "No" CRON: EVERY: cada EVERY_HOUR: cada hora diff --git a/system/languages/et.yaml b/system/languages/et.yaml index 619aa1a..e5659d3 100644 --- a/system/languages/et.yaml +++ b/system/languages/et.yaml @@ -1,11 +1,22 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\npealkiri: %1$s\n---\n\n# Viga: vigane Frontmatter'i\n\nasukoht: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(octop|vir)us$/i': '\1i' + INFLECTOR_SINGULAR: + '/^(ox)en/i': '\1' + '/(alias|status)es$/i': '\1' + '/(shoe)s$/i': '\1' + '/(o)es$/i': '\1' + '/(bus)es$/i': '\1' + '/(x|ch|ss|sh)es$/i': '\1' + '/(tive)s$/i': '\1' + '/(hive)s$/i': '\1' INFLECTOR_UNCOUNTABLE: - 'equipment' - 'informatsioon' - - 'rice' - - 'money' + - 'riis' + - 'raha' - 'species' - 'series' - 'kala' @@ -34,6 +45,7 @@ GRAV: YEAR: aasta DECADE: 10 aastat SEC: sek + MIN: min HR: t WK: näd MO: k. @@ -55,7 +67,7 @@ GRAV: YR_PLURAL: aastat DEC_PLURAL: dek. FORM: - VALIDATION_FAIL: Kinnitamine nurjus: + VALIDATION_FAIL: 'Kinnitamine nurjus:' INVALID_INPUT: 'Vigane sisend:' MISSING_REQUIRED_FIELD: 'Nõutud väli puudub:' MONTHS_OF_THE_YEAR: @@ -81,5 +93,12 @@ GRAV: - 'pühapäev' CRON: EVERY: iga + EVERY_HOUR: iga tund + EVERY_MINUTE: iga minut + EVERY_DAY_OF_WEEK: iga nädala päev EVERY_MONTH: iga kuu TEXT_PERIOD: Iga + ERROR1: Silt %s pole toetatud! + ERROR2: Vale elementide arv + ERROR3: jqCron seadetes peaks olema määratud jquery_element + ERROR4: Tundmatu väljend diff --git a/system/languages/eu.yaml b/system/languages/eu.yaml index 4a9a58e..91c3c8e 100644 --- a/system/languages/eu.yaml +++ b/system/languages/eu.yaml @@ -36,8 +36,8 @@ GRAV: YR_PLURAL: urt DEC_PLURAL: ham FORM: - VALIDATION_FAIL: Balidazioak huts egin du - INVALID_INPUT: Baliogabeko sarrera + VALIDATION_FAIL: 'Balidazioak huts egin du' + INVALID_INPUT: 'Baliogabeko sarrera' MISSING_REQUIRED_FIELD: 'Derrigorrezko eremua bete gabe:' MONTHS_OF_THE_YEAR: - 'Urtarrila' diff --git a/system/languages/fa.yaml b/system/languages/fa.yaml index 186f79d..96b96dc 100644 --- a/system/languages/fa.yaml +++ b/system/languages/fa.yaml @@ -36,8 +36,8 @@ GRAV: YR_PLURAL: سال DEC_PLURAL: دهه FORM: - VALIDATION_FAIL: سنجش اعتبار ناموفق بود - INVALID_INPUT: ورودی نامعتبر در + VALIDATION_FAIL: 'سنجش اعتبار ناموفق بود' + INVALID_INPUT: 'ورودی نامعتبر در' MISSING_REQUIRED_FIELD: 'قسمت ضروری جا افتاده:' MONTHS_OF_THE_YEAR: - 'ژانویه' diff --git a/system/languages/fi.yaml b/system/languages/fi.yaml index e84c19f..4cb547c 100644 --- a/system/languages/fi.yaml +++ b/system/languages/fi.yaml @@ -100,8 +100,8 @@ GRAV: YR_PLURAL: v DEC_PLURAL: vuosikymmentä FORM: - VALIDATION_FAIL: Vahvistus epäonnistui: - INVALID_INPUT: Syöte ei kelpaa + VALIDATION_FAIL: 'Vahvistus epäonnistui:' + INVALID_INPUT: 'Syöte ei kelpaa' MISSING_REQUIRED_FIELD: 'Puuttuva pakollinen kenttä:' MONTHS_OF_THE_YEAR: - 'Tammikuu' diff --git a/system/languages/fr.yaml b/system/languages/fr.yaml index 9284f7e..d9fa177 100644 --- a/system/languages/fr.yaml +++ b/system/languages/fr.yaml @@ -16,6 +16,7 @@ GRAV: '/(buffal|tomat)o$/i': '\1es' '/(bu)s$/i': 'Bus' '/(alias|status)/i': 'alias|status' + '/(octop|vir)us$/i': 'virus' '/(ax|test)is$/i': '\1s' '/s$/i': 's' '/$/': 's' @@ -80,30 +81,30 @@ GRAV: YR_PLURAL: a DEC_PLURAL: décs FORM: - VALIDATION_FAIL: La validation a échoué : - INVALID_INPUT: Saisie non valide + VALIDATION_FAIL: 'La validation a échoué :' + INVALID_INPUT: 'Saisie non valide' MISSING_REQUIRED_FIELD: 'Champ obligatoire manquant :' MONTHS_OF_THE_YEAR: - - 'Janvier' - - 'Février' - - 'Mars' - - 'Avril' - - 'Mai' - - 'Juin' - - 'Juillet' - - 'Août' - - 'Septembre' - - 'Octobre' - - 'Novembre' - - 'Décembre' + - 'janvier' + - 'février' + - 'mars' + - 'avril' + - 'mai' + - 'juin' + - 'juillet' + - 'août' + - 'septembre' + - 'octobre' + - 'novembre' + - 'décembre' DAYS_OF_THE_WEEK: - - 'Lundi' - - 'Mardi' - - 'Mercredi' - - 'Jeudi' - - 'Vendredi' - - 'Samedi' - - 'Dimanche' + - 'lundi' + - 'mardi' + - 'mercredi' + - 'jeudi' + - 'vendredi' + - 'samedi' + - 'dimanche' CRON: EVERY: chaque EVERY_HOUR: toutes les heures diff --git a/system/languages/gl.yaml b/system/languages/gl.yaml new file mode 100644 index 0000000..b016c59 --- /dev/null +++ b/system/languages/gl.yaml @@ -0,0 +1,144 @@ +--- +GRAV: + FRONTMATTER_ERROR_PAGE: "---\ntítulo: %1$s\n---\n\n# Erro: Limiar incorrecto\n\nRuta: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1zes' + '/^(ox)$/i': '\1en' + '/([m|l])ouse$/i': '\1ice' + '/(matr|vert|ind)ix|ex$/i': '\1ices' + '/(x|ch|ss|sh)$/i': '\1es' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([^aeiouy]|qu)y$/i': '\1ies' + '/(hive)$/i': '\1s' + '/(?:([^f])fe|([lr])f)$/i': '\1\2ves' + '/sis$/i': 'ses' + '/([ti])um$/i': '\1a' + '/(buffal|tomat)o$/i': '\1oes' + '/(bu)s$/i': '\1ses' + '/(alias|status)/i': '\1' + '/(octop|vir)us$/i': '\1' + '/(ax|test)is$/i': '\1es' + '/s$/i': 's' + '/$/': 's' + INFLECTOR_SINGULAR: + '/(quiz)zes$/i': '\1ces' + '/(matr)ices$/i': '\1ix' + '/(vert|ind)ices$/i': '\1ex' + '/^(ox)en/i': '\1' + '/(alias|status)es$/i': '\1' + '/([octop|vir])i$/i': '\1' + '/(cris|ax|test)es$/i': '\1es' + '/(shoe)s$/i': '\1' + '/(o)es$/i': '\1' + '/(bus)es$/i': '\1' + '/([m|l])ice$/i': '\1ouse' + '/(x|ch|ss|sh)es$/i': '\1' + '/(m)ovies$/i': '\1ovie' + '/(s)eries$/i': '\1eries' + '/([^aeiouy]|qu)ies$/i': '\1' + '/([lr])ves$/i': '\1f' + '/(tive)s$/i': '\1' + '/(hive)s$/i': '\1' + '/([^f])ves$/i': '\1fe' + '/(^analy)ses$/i': '\1se' + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i': '\1\2se' + '/([ti])a$/i': '\1um' + '/(n)ews$/i': '\1ews' + INFLECTOR_UNCOUNTABLE: + - 'equipo' + - 'información' + - 'arroz' + - 'diñeiro' + - 'especies' + - 'series' + - 'peixe' + - 'ovella' + INFLECTOR_IRREGULAR: + 'person': 'xente' + 'man': 'home' + 'child': 'neno' + 'sex': 'sexos' + 'move': 'move' + INFLECTOR_ORDINALS: + 'default': 'º' + 'first': 'º' + 'second': 'º' + 'third': 'º' + NICETIME: + NO_DATE_PROVIDED: Non fornece unha data + BAD_DATE: Data errada + AGO: hai + FROM_NOW: dende agora + JUST_NOW: xusto agora + SECOND: segundo + MINUTE: minuto + HOUR: hora + DAY: día + WEEK: semana + MONTH: mes + YEAR: ano + DECADE: década + SEC: seg + MIN: min + HR: hr + WK: Sem + MO: m + YR: a + DEC: dec + SECOND_PLURAL: segundos + MINUTE_PLURAL: minutos + HOUR_PLURAL: horas + DAY_PLURAL: días + WEEK_PLURAL: semanas + MONTH_PLURAL: meses + YEAR_PLURAL: anos + DECADE_PLURAL: décadas + SEC_PLURAL: segs + MIN_PLURAL: mins + HR_PLURAL: hrs + WK_PLURAL: sem + MO_PLURAL: mes + YR_PLURAL: a + DEC_PLURAL: deca + FORM: + VALIDATION_FAIL: 'Fallou a validación:' + INVALID_INPUT: 'Entrada incorrecta en' + MISSING_REQUIRED_FIELD: 'Falta un campo requirido:' + MONTHS_OF_THE_YEAR: + - 'xaneiro' + - 'febreiro' + - 'marzo' + - 'abril' + - 'maio' + - 'xuño' + - 'xullo' + - 'agosto' + - 'setembro' + - 'outubro' + - 'novembro' + - 'decembro' + DAYS_OF_THE_WEEK: + - 'luns' + - 'martes' + - 'mércores' + - 'xoves' + - 'venres' + - 'sábado' + - 'domingo' + CRON: + EVERY: cada + EVERY_HOUR: Cada hora + EVERY_MINUTE: Cada minuto + EVERY_DAY_OF_WEEK: cada día da semana + EVERY_DAY_OF_MONTH: cada día do mes + EVERY_MONTH: cada mes + TEXT_PERIOD: Cada + TEXT_MINS: ' dentro de minuto(s) despois da hora' + TEXT_TIME: ' dentro :' + TEXT_DOW: ' o ' + TEXT_MONTH: ' de ' + TEXT_DOM: ' o ' + ERROR1: A etiqueta %s non é compatíbel! + ERROR2: Mal número de elementos + ERROR3: O jquery_element debería estar determinado na configuración de jqCron + ERROR4: Expresión non recoñecida diff --git a/system/languages/he.yaml b/system/languages/he.yaml index afb63d7..d7f4318 100644 --- a/system/languages/he.yaml +++ b/system/languages/he.yaml @@ -37,8 +37,8 @@ GRAV: YR_PLURAL: שני' DEC_PLURAL: עש' FORM: - VALIDATION_FAIL: האימות נכשל: - INVALID_INPUT: קלט לא חוקי + VALIDATION_FAIL: 'האימות נכשל:' + INVALID_INPUT: 'קלט לא חוקי' MISSING_REQUIRED_FIELD: 'שדות חובה חסרים:' MONTHS_OF_THE_YEAR: - 'ינואר' diff --git a/system/languages/hr.yaml b/system/languages/hr.yaml index 1b530b5..4827d3e 100644 --- a/system/languages/hr.yaml +++ b/system/languages/hr.yaml @@ -50,8 +50,8 @@ GRAV: YR_PLURAL: g DEC_PLURAL: des FORM: - VALIDATION_FAIL: Validacija nije uspjela: - INVALID_INPUT: Pogrešan unos u + VALIDATION_FAIL: 'Validacija nije uspjela:' + INVALID_INPUT: 'Pogrešan unos u' MISSING_REQUIRED_FIELD: 'Nedostaje obavezno polje:' MONTHS_OF_THE_YEAR: - 'Siječanj' diff --git a/system/languages/hu.yaml b/system/languages/hu.yaml index a834c45..2624cf9 100644 --- a/system/languages/hu.yaml +++ b/system/languages/hu.yaml @@ -58,7 +58,7 @@ GRAV: YR_PLURAL: év DEC_PLURAL: évt FORM: - VALIDATION_FAIL: Érvényesítés nem sikerült: + VALIDATION_FAIL: 'Érvényesítés nem sikerült:' INVALID_INPUT: 'A megadott érték érvénytelen:' MISSING_REQUIRED_FIELD: 'Ez a kötelező mező nincs kitöltve:' MONTHS_OF_THE_YEAR: diff --git a/system/languages/id.yaml b/system/languages/id.yaml index 41431f1..690959d 100644 --- a/system/languages/id.yaml +++ b/system/languages/id.yaml @@ -1,6 +1,8 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\ntitle: %1$s\n---\n\n# Error: Frontmatter tidak valid\n\nLokasi: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1zes' INFLECTOR_UNCOUNTABLE: - 'peralatan' - 'informasi' @@ -53,8 +55,8 @@ GRAV: YR_PLURAL: thn DEC_PLURAL: dekade FORM: - VALIDATION_FAIL: Validasi gagal: - INVALID_INPUT: Input tidak valid di + VALIDATION_FAIL: 'Validasi gagal:' + INVALID_INPUT: 'Input tidak valid di' MISSING_REQUIRED_FIELD: 'Data yang diperlukan belum terisi:' MONTHS_OF_THE_YEAR: - 'Januari' diff --git a/system/languages/is.yaml b/system/languages/is.yaml index 6f9761c..00d42ee 100644 --- a/system/languages/is.yaml +++ b/system/languages/is.yaml @@ -46,8 +46,8 @@ GRAV: YR_PLURAL: árum DEC_PLURAL: árat FORM: - VALIDATION_FAIL: Sannvottun mistókst: - INVALID_INPUT: Ógilt inntak í + VALIDATION_FAIL: 'Sannvottun mistókst:' + INVALID_INPUT: 'Ógilt inntak í' MISSING_REQUIRED_FIELD: 'Vantar nauðsynlegan reit:' MONTHS_OF_THE_YEAR: - 'janúar' diff --git a/system/languages/it.yaml b/system/languages/it.yaml index 741f721..f366eb6 100644 --- a/system/languages/it.yaml +++ b/system/languages/it.yaml @@ -1,6 +1,49 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---Titolo: %1$s---# Errore: Frontmatter non valido: '%2$s' * *%3$s * * ' '%4$s ' '" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1' + '/^(ox)$/i': '\1en' + '/([m|l])ouse$/i': '\1ice' + '/(matr|vert|ind)ix|ex$/i': '\1ices' + '/(x|ch|ss|sh)$/i': '\1es' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([^aeiouy]|qu)y$/i': '\1ies' + '/(hive)$/i': '\1s' + '/(?:([^f])fe|([lr])f)$/i': '\1\2ves' + '/sis$/i': 'ses' + '/([ti])um$/i': '\1a' + '/(buffal|tomat)o$/i': '\1oes' + '/(bu)s$/i': '\1ses' + '/(alias|status)/i': '\1es' + '/(octop|vir)us$/i': '\1i' + '/(ax|test)is$/i': '\1es' + '/s$/i': 's' + '/$/': 's' + INFLECTOR_SINGULAR: + '/(quiz)zes$/i': '\1' + '/(matr)ices$/i': '\1ix' + '/(vert|ind)ices$/i': '\1ex' + '/^(ox)en/i': '\1' + '/(alias|status)es$/i': '\1' + '/([octop|vir])i$/i': '\1us' + '/(cris|ax|test)es$/i': '\1is' + '/(shoe)s$/i': '\1' + '/(o)es$/i': '\1' + '/(bus)es$/i': '\1' + '/([m|l])ice$/i': '\1ouse' + '/(x|ch|ss|sh)es$/i': '\1' + '/(m)ovies$/i': '\1ovie' + '/(s)eries$/i': '\1eries' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([lr])ves$/i': '\1f' + '/(tive)s$/i': '\1' + '/(hive)s$/i': '\1' + '/([^f])ves$/i': '\1fe' + '/(^analy)ses$/i': '\1sis' + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i': '\1\2sis' + '/([ti])a$/i': '\1um' + '/(n)ews$/i': '\1ews' INFLECTOR_UNCOUNTABLE: - 'dotazione' - 'informazione' @@ -58,9 +101,10 @@ GRAV: YR_PLURAL: anni DEC_PLURAL: decenni FORM: - VALIDATION_FAIL: Validazione fallita: - INVALID_INPUT: Input non valido in + VALIDATION_FAIL: 'Validazione fallita:' + INVALID_INPUT: 'Input non valido in' MISSING_REQUIRED_FIELD: 'Campo richiesto mancante:' + XSS_ISSUES: "Rilevati potenziali problemi di XSS nel campo '%s'" MONTHS_OF_THE_YEAR: - 'Gennaio' - 'Febbraio' @@ -82,6 +126,8 @@ GRAV: - 'Venerdì' - 'Sabato' - 'Domenica' + YES: "Sì" + NO: "No" CRON: EVERY: ogni EVERY_HOUR: ogni ora diff --git a/system/languages/ja.yaml b/system/languages/ja.yaml index 0e3fa16..701d8e7 100644 --- a/system/languages/ja.yaml +++ b/system/languages/ja.yaml @@ -1,11 +1,22 @@ --- GRAV: + INFLECTOR_UNCOUNTABLE: + - 'equipment' + - '情報' + - 'rice' + - 'お金' + - 'species' + - 'series' + - '魚' + - 'ヒツジ' INFLECTOR_IRREGULAR: 'person': 'みんな' 'man': '人' 'child': '子供' 'sex': '性別' 'move': '移動' + INFLECTOR_ORDINALS: + 'first': '番目' NICETIME: NO_DATE_PROVIDED: 日付が設定されていません BAD_DATE: 不正な日付 @@ -40,8 +51,8 @@ GRAV: YR_PLURAL: 年 DEC_PLURAL: 10年 FORM: - VALIDATION_FAIL: バリデーション失敗 : - INVALID_INPUT: 不正な入力: + VALIDATION_FAIL: 'バリデーション失敗 :' + INVALID_INPUT: '不正な入力:' MISSING_REQUIRED_FIELD: '必須項目が入力されていません:' MONTHS_OF_THE_YEAR: - '1月' @@ -64,3 +75,7 @@ GRAV: - '金' - '土' - '日' + CRON: + EVERY: 毎 + EVERY_MONTH: 毎月 + ERROR1: 共有タイプ %s はサポートされていません diff --git a/system/languages/ko.yaml b/system/languages/ko.yaml index 6676a6d..15aee8e 100644 --- a/system/languages/ko.yaml +++ b/system/languages/ko.yaml @@ -37,8 +37,8 @@ GRAV: YR_PLURAL: 년 DEC_PLURAL: 년간 FORM: - VALIDATION_FAIL: 유효성 검사 실패: - INVALID_INPUT: 잘못된 입력 + VALIDATION_FAIL: '유효성 검사 실패:' + INVALID_INPUT: '잘못된 입력' MISSING_REQUIRED_FIELD: '누락 된 필수 필드:' MONTHS_OF_THE_YEAR: - '일월' diff --git a/system/languages/lt.yaml b/system/languages/lt.yaml index aca0fc3..d894b96 100644 --- a/system/languages/lt.yaml +++ b/system/languages/lt.yaml @@ -52,8 +52,8 @@ GRAV: YR_PLURAL: m. DEC_PLURAL: dešimtmečiai FORM: - VALIDATION_FAIL: Patvirtinimas nepavyko: - INVALID_INPUT: Neteisingai įvesta į + VALIDATION_FAIL: 'Patvirtinimas nepavyko:' + INVALID_INPUT: 'Neteisingai įvesta į' MISSING_REQUIRED_FIELD: 'Būtina užpildyti laukelį:' MONTHS_OF_THE_YEAR: - 'Sausis' diff --git a/system/languages/nl.yaml b/system/languages/nl.yaml index 9706d03..bd0aed9 100644 --- a/system/languages/nl.yaml +++ b/system/languages/nl.yaml @@ -101,8 +101,8 @@ GRAV: YR_PLURAL: jaren DEC_PLURAL: decennia FORM: - VALIDATION_FAIL: Validatie mislukt: - INVALID_INPUT: Ongeldige invoer in + VALIDATION_FAIL: 'Validatie mislukt:' + INVALID_INPUT: 'Ongeldige invoer in' MISSING_REQUIRED_FIELD: 'Ontbrekend verplicht veld:' MONTHS_OF_THE_YEAR: - 'Januari' diff --git a/system/languages/no.yaml b/system/languages/no.yaml index 5b57938..2a93e6e 100644 --- a/system/languages/no.yaml +++ b/system/languages/no.yaml @@ -21,6 +21,7 @@ GRAV: BAD_DATE: Ugyldig dato AGO: siden FROM_NOW: fra nå + JUST_NOW: akkurat nå SECOND: sekund MINUTE: minutt HOUR: time @@ -51,8 +52,8 @@ GRAV: YR_PLURAL: år DEC_PLURAL: årtier FORM: - VALIDATION_FAIL: Godkjenning mislyktes: - INVALID_INPUT: Ugyldig innhold i + VALIDATION_FAIL: 'Godkjenning mislyktes:' + INVALID_INPUT: 'Ugyldig innhold i' MISSING_REQUIRED_FIELD: 'Mangler påkrevd felt:' MONTHS_OF_THE_YEAR: - 'januar' @@ -75,3 +76,7 @@ GRAV: - 'fredag' - 'lørdag' - 'søndag' + CRON: + EVERY: hver + EVERY_HOUR: hver time + EVERY_MINUTE: hvert minutt diff --git a/system/languages/pl.yaml b/system/languages/pl.yaml index bf6fe37..6da24e5 100644 --- a/system/languages/pl.yaml +++ b/system/languages/pl.yaml @@ -1,11 +1,32 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\ntitle: %1$s\n---\n\n# Error: Nieprawidłowy Frontmatter\n\nPath: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_SINGULAR: + '/(alias|status)es$/i': '\1' + INFLECTOR_UNCOUNTABLE: + - 'wyposażenie' + - 'informacja' + - 'rice' + - 'pieniądze' + - 'species' + - 'series' + - 'ryba' + - 'owca' + INFLECTOR_IRREGULAR: + 'person': 'człowiek' + 'man': 'mężczyźni' + 'child': 'dzieci' + 'sex': 'płci' + INFLECTOR_ORDINALS: + 'first': 'pierwszy' + 'second': 'drugi' + 'third': 'trzeci' NICETIME: NO_DATE_PROVIDED: Nie podano daty BAD_DATE: Zła data AGO: temu FROM_NOW: od teraz + JUST_NOW: właśnie teraz SECOND: sekunda MINUTE: minuta HOUR: godzina @@ -15,6 +36,7 @@ GRAV: YEAR: rok DECADE: dekada SEC: sek + MIN: minuta HR: godz WK: tydz MO: m-c @@ -36,9 +58,10 @@ GRAV: YR_PLURAL: lat DEC_PLURAL: dekad FORM: - VALIDATION_FAIL: Weryfikacja nie powiodła się: - INVALID_INPUT: Nieprawidłowe dane wejściowe + VALIDATION_FAIL: 'Weryfikacja nie powiodła się:' + INVALID_INPUT: 'Nieprawidłowe dane wejściowe' MISSING_REQUIRED_FIELD: 'Opuszczono wymagane pole:' + XSS_ISSUES: "Potencjalne problemy XSS wykryte w polu '%s'" MONTHS_OF_THE_YEAR: - 'Styczeń' - 'Luty' @@ -60,3 +83,18 @@ GRAV: - 'Piątek' - 'Sobota' - 'Niedziela' + YES: "Tak" + NO: "Nie" + CRON: + EVERY: każdy + EVERY_HOUR: każdą godzinę + EVERY_MINUTE: każdą minutę + EVERY_DAY_OF_WEEK: każdego dnia tygodnia + EVERY_DAY_OF_MONTH: każdego dnia miesiące + EVERY_MONTH: każdego miesiąca + TEXT_PERIOD: Każdego + TEXT_MINS: 'o minut po godzinie' + TEXT_TIME: 'o :' + ERROR1: Znacznik %s nie jest wspierany! + ERROR2: Nieprawidłowa liczba elementów + ERROR4: Wyrażenie nierozpoznane diff --git a/system/languages/pt.yaml b/system/languages/pt.yaml index 590b5e5..2da6944 100644 --- a/system/languages/pt.yaml +++ b/system/languages/pt.yaml @@ -1,8 +1,75 @@ --- GRAV: + FRONTMATTER_ERROR_PAGE: "---\ntitle: %1$s\n---\n\n# Erro: Frontmatter Inválido\n\nLocalização: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1zes' + '/^(ox)$/i': '\1en' + '/([m|l])ouse$/i': '\1ice' + '/(matr|vert|ind)ix|ex$/i': '\1ices' + '/(x|ch|ss|sh)$/i': '\1es' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([^aeiouy]|qu)y$/i': '\1ies' + '/(hive)$/i': '\1s' + '/(?:([^f])fe|([lr])f)$/i': '\1\2ves' + '/sis$/i': 'ses' + '/([ti])um$/i': '\1a' + '/(buffal|tomat)o$/i': '\1oes' + '/(bu)s$/i': '\1ses' + '/(alias|status)/i': '\1es' + '/(octop|vir)us$/i': '\1i' + '/(ax|test)is$/i': '\1es' + '/s$/i': 's' + '/$/': 's' + INFLECTOR_SINGULAR: + '/(quiz)zes$/i': '\1' + '/(matr)ices$/i': '\1ix' + '/(vert|ind)ices$/i': '\1ex' + '/^(ox)en/i': '\1' + '/(alias|status)es$/i': '\1' + '/([octop|vir])i$/i': '\1us' + '/(cris|ax|test)es$/i': '\1is' + '/(shoe)s$/i': '\1' + '/(o)es$/i': '\1' + '/(bus)es$/i': '\1' + '/([m|l])ice$/i': '\1ouse' + '/(x|ch|ss|sh)es$/i': '\1' + '/(m)ovies$/i': '\1ovie' + '/(s)eries$/i': '\1eries' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([lr])ves$/i': '\1f' + '/(tive)s$/i': '\1' + '/(hive)s$/i': '\1' + '/([^f])ves$/i': '\1fe' + '/(^analy)ses$/i': '\1sis' + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i': '\1\2sis' + '/([ti])a$/i': '\1um' + '/(n)ews$/i': '\1ews' + INFLECTOR_UNCOUNTABLE: + - 'equipamento' + - 'informação' + - 'arroz' + - 'dinheiro' + - 'espécie' + - 'série' + - 'peixe' + - 'ovelha' + INFLECTOR_IRREGULAR: + 'person': 'pessoas' + 'man': 'homens' + 'child': 'crianças' + 'sex': 'sexos' + 'move': 'movimentos' + INFLECTOR_ORDINALS: + 'default': 'º' + 'first': 'º' + 'second': 'º' + 'third': 'º' NICETIME: NO_DATE_PROVIDED: Nenhuma data fornecida + BAD_DATE: Data inválida AGO: atrás + FROM_NOW: a partir de agora + JUST_NOW: mesmo agora SECOND: segundo MINUTE: minuto HOUR: hora @@ -11,17 +78,32 @@ GRAV: MONTH: mês YEAR: ano DECADE: década - SEC: segundos - MIN: minutos + SEC: seg + MIN: min + HR: hora + WK: semana + MO: mês + YR: ano + DEC: década + SECOND_PLURAL: segundos MINUTE_PLURAL: minutos + HOUR_PLURAL: horas DAY_PLURAL: dias WEEK_PLURAL: semanas MONTH_PLURAL: meses YEAR_PLURAL: anos - DECADE_PLURAL: decadas + DECADE_PLURAL: décadas + SEC_PLURAL: segs + MIN_PLURAL: mins + HR_PLURAL: hrs + WK_PLURAL: sems + MO_PLURAL: meses + YR_PLURAL: anos + DEC_PLURAL: décadas FORM: - VALIDATION_FAIL: Falha na validação! - MISSING_REQUIRED_FIELD: 'Campo obrigatório requerido:' + VALIDATION_FAIL: 'Falha na validação:' + INVALID_INPUT: 'Dados inseridos são inválidos em' + MISSING_REQUIRED_FIELD: 'Campo obrigatório em falta:' MONTHS_OF_THE_YEAR: - 'Janeiro' - 'Fevereiro' @@ -35,12 +117,28 @@ GRAV: - 'Outubro' - 'Novembro' - 'Dezembro' - INFLECTOR_UNCOUNTABLE: - - 'equipment' - - 'information' - - 'arroz' - - 'money' - - 'species' - - 'series' - - 'fish' - - 'sheep' + DAYS_OF_THE_WEEK: + - 'Segunda-feira' + - 'Terça-feira' + - 'Quarta-feira' + - 'Quinta-feira' + - 'Sexta-feira' + - 'Sábado' + - 'Domingo' + CRON: + EVERY: cada + EVERY_HOUR: cada hora + EVERY_MINUTE: cada minuto + EVERY_DAY_OF_WEEK: todos os dias da semana + EVERY_DAY_OF_MONTH: todos os dias do mês + EVERY_MONTH: todos os meses + TEXT_PERIOD: Cada + TEXT_MINS: ' em minuto(s) após a hora' + TEXT_TIME: ' em :' + TEXT_DOW: ' em ' + TEXT_MONTH: ' de ' + TEXT_DOM: ' em ' + ERROR1: A tag %s não é suportada! + ERROR2: Número de elementos inválido + ERROR3: O jquery_element deve ser definido nas configurações do jqCron + ERROR4: Expressão não reconhecida diff --git a/system/languages/ro.yaml b/system/languages/ro.yaml index 5bee578..dc22b20 100644 --- a/system/languages/ro.yaml +++ b/system/languages/ro.yaml @@ -53,8 +53,8 @@ GRAV: YR_PLURAL: ani DEC_PLURAL: decenii FORM: - VALIDATION_FAIL: Validare nereușită - INVALID_INPUT: Date incorecte în + VALIDATION_FAIL: 'Validare nereușită' + INVALID_INPUT: 'Date incorecte în' MISSING_REQUIRED_FIELD: 'Câmp obligatoriu lipsă:' MONTHS_OF_THE_YEAR: - 'Ianuarie' diff --git a/system/languages/ru.yaml b/system/languages/ru.yaml index 78c5963..2097ada 100644 --- a/system/languages/ru.yaml +++ b/system/languages/ru.yaml @@ -13,7 +13,7 @@ GRAV: INFLECTOR_IRREGULAR: 'person': 'люди' 'man': 'человек' - 'child': 'ребенок' + 'child': 'дети' 'sex': 'пол' 'move': 'движется' INFLECTOR_ORDINALS: @@ -58,9 +58,10 @@ GRAV: YR_PLURAL: г DEC_PLURAL: дстлт FORM: - VALIDATION_FAIL: Проверка не удалась: - INVALID_INPUT: Неверный ввод в + VALIDATION_FAIL: 'Проверка не удалась:' + INVALID_INPUT: 'Неверный ввод в' MISSING_REQUIRED_FIELD: 'Отсутствует необходимое поле:' + XSS_ISSUES: "Обнаружены потенциальные XSS проблемы в поле '%s'" MONTHS_OF_THE_YEAR: - 'январь' - 'февраль' @@ -68,12 +69,12 @@ GRAV: - 'апрель' - 'май' - 'июнь' - - 'Июль' - - 'Август' - - 'Сентябрь' - - 'Октябрь' - - 'Ноябрь' - - 'Декабрь' + - 'июль' + - 'август' + - 'сентябрь' + - 'октябрь' + - 'ноябрь' + - 'декабрь' DAYS_OF_THE_WEEK: - 'понедельник' - 'вторник' @@ -82,6 +83,8 @@ GRAV: - 'пятница' - 'суббота' - 'воскресенье' + YES: "Да" + NO: "Нет" CRON: EVERY: раз в EVERY_HOUR: раз в час diff --git a/system/languages/sk.yaml b/system/languages/sk.yaml index 89a7f56..9543239 100644 --- a/system/languages/sk.yaml +++ b/system/languages/sk.yaml @@ -101,8 +101,8 @@ GRAV: YR_PLURAL: rokov DEC_PLURAL: dekád FORM: - VALIDATION_FAIL: Overenie zlyhalo: - INVALID_INPUT: Neplatný vstup v + VALIDATION_FAIL: 'Overenie zlyhalo:' + INVALID_INPUT: 'Neplatný vstup v' MISSING_REQUIRED_FIELD: 'Chýba vyžadované pole:' MONTHS_OF_THE_YEAR: - 'Január' diff --git a/system/languages/sl.yaml b/system/languages/sl.yaml index ae6032c..879fe1b 100644 --- a/system/languages/sl.yaml +++ b/system/languages/sl.yaml @@ -36,8 +36,8 @@ GRAV: YR_PLURAL: l DEC_PLURAL: des FORM: - VALIDATION_FAIL: Preverjanje veljavnosti ni uspelo: - INVALID_INPUT: Neveljaven vnos v + VALIDATION_FAIL: 'Preverjanje veljavnosti ni uspelo:' + INVALID_INPUT: 'Neveljaven vnos v' MISSING_REQUIRED_FIELD: 'Manjka obvezno polje:' MONTHS_OF_THE_YEAR: - 'Januar' diff --git a/system/languages/sr.yaml b/system/languages/sr.yaml new file mode 100644 index 0000000..3368bdf --- /dev/null +++ b/system/languages/sr.yaml @@ -0,0 +1,144 @@ +--- +GRAV: + FRONTMATTER_ERROR_PAGE: "---\nнаслов: %1$s\n---\n\n# Грешка: неисправан Frontmatter\n\nПутања: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1zes' + '/^(ox)$/i': '\1en' + '/([m|l])ouse$/i': '\1ice' + '/(matr|vert|ind)ix|ex$/i': '\1ices' + '/(x|ch|ss|sh)$/i': '\1es' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([^aeiouy]|qu)y$/i': '\1ies' + '/(hive)$/i': '\1s' + '/(?:([^f])fe|([lr])f)$/i': '\1\2ves' + '/sis$/i': 'ses' + '/([ti])um$/i': '\1a' + '/(buffal|tomat)o$/i': '\1oes' + '/(bu)s$/i': '\1ses' + '/(alias|status)/i': '\1es' + '/(octop|vir)us$/i': '\1i' + '/(ax|test)is$/i': '\1es' + '/s$/i': 's' + '/$/': 's' + INFLECTOR_SINGULAR: + '/(quiz)zes$/i': '\1' + '/(matr)ices$/i': '\1ix' + '/(vert|ind)ices$/i': '\1ex' + '/^(ox)en/i': '\1' + '/(alias|status)es$/i': '\1' + '/([octop|vir])i$/i': '\1us' + '/(cris|ax|test)es$/i': '\1is' + '/(shoe)s$/i': '\1' + '/(o)es$/i': '\1' + '/(bus)es$/i': '\1' + '/([m|l])ice$/i': '\1ouse' + '/(x|ch|ss|sh)es$/i': '\1' + '/(m)ovies$/i': '\1ovie' + '/(s)eries$/i': '\1eries' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([lr])ves$/i': '\1f' + '/(tive)s$/i': '\1' + '/(hive)s$/i': '\1' + '/([^f])ves$/i': '\1fe' + '/(^analy)ses$/i': '\1sis' + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i': '\1\2sis' + '/([ti])a$/i': '\1um' + '/(n)ews$/i': '\1ews' + INFLECTOR_UNCOUNTABLE: + - 'опрема' + - 'информација' + - 'пиринач' + - 'новац' + - 'врсте' + - 'серије' + - 'риба' + - 'овца' + INFLECTOR_IRREGULAR: + 'person': 'особе' + 'man': 'људи' + 'child': 'деца' + 'sex': 'полови' + 'move': 'помери' + INFLECTOR_ORDINALS: + 'default': 'ти' + 'first': 'први' + 'second': 'други' + 'third': 'трећи' + NICETIME: + NO_DATE_PROVIDED: Нема датума + BAD_DATE: Погрешан датум + AGO: од пре + FROM_NOW: од сада + JUST_NOW: управо сада + SECOND: секунда + MINUTE: минута + HOUR: сат + DAY: дан + WEEK: недеља + MONTH: месец + YEAR: година + DECADE: декада + SEC: сек + MIN: мин + HR: сат + WK: нед + MO: мес + YR: год + DEC: дек + SECOND_PLURAL: секунди + MINUTE_PLURAL: минута + HOUR_PLURAL: сати + DAY_PLURAL: дана + WEEK_PLURAL: недеља + MONTH_PLURAL: месеци + YEAR_PLURAL: године(а) + DECADE_PLURAL: декаде(а) + SEC_PLURAL: сек + MIN_PLURAL: мин + HR_PLURAL: сати + WK_PLURAL: недеља + MO_PLURAL: месеци + YR_PLURAL: година + DEC_PLURAL: декада + FORM: + VALIDATION_FAIL: 'Провера неуспела:' + INVALID_INPUT: 'Неисправан унос у' + MISSING_REQUIRED_FIELD: 'Недостаје обавезн поље:' + MONTHS_OF_THE_YEAR: + - 'Јануар' + - 'Фебруар' + - 'Март' + - 'Април' + - 'Мај' + - 'Јуни' + - 'Јули' + - 'Август' + - 'Септембар' + - 'Октобар' + - 'Новембар' + - 'Децембар' + DAYS_OF_THE_WEEK: + - 'Понедељак' + - 'Уторак' + - 'Среда' + - 'Четвртак' + - 'Петак' + - 'Субота' + - 'Недеља' + CRON: + EVERY: сваки + EVERY_HOUR: сваки сат + EVERY_MINUTE: сваки минут + EVERY_DAY_OF_WEEK: сваки дан у недељи + EVERY_DAY_OF_MONTH: сваки дан у месецу + EVERY_MONTH: сваки месец + TEXT_PERIOD: Сваки + TEXT_MINS: ' у минути(а) прошлог сата' + TEXT_TIME: ' у :' + TEXT_DOW: ' на ' + TEXT_MONTH: ' од ' + TEXT_DOM: ' на ' + ERROR1: Таг %s није подржан! + ERROR2: Погрешан број елемената + ERROR3: јquery_element би требао да буде постављен у jqCron подешавању + ERROR4: Непрепознат израз diff --git a/system/languages/sv.yaml b/system/languages/sv.yaml index 16afa16..bf76bef 100644 --- a/system/languages/sv.yaml +++ b/system/languages/sv.yaml @@ -12,11 +12,21 @@ GRAV: - 'får' INFLECTOR_IRREGULAR: 'person': 'personer' + 'man': 'män' + 'child': 'barn' + 'sex': 'kön' + 'move': 'flytta' + INFLECTOR_ORDINALS: + 'default': ':e' + 'first': ':a' + 'second': ':a' + 'third': ':e' NICETIME: NO_DATE_PROVIDED: Inget datum har angivits BAD_DATE: Ogiltigt datum AGO: sedan FROM_NOW: fr.o.m nu + JUST_NOW: just nu SECOND: sekund MINUTE: minut HOUR: timme @@ -26,10 +36,12 @@ GRAV: YEAR: år DECADE: årtionde SEC: sek + MIN: min HR: t WK: v MO: m YR: år + DEC: dec SECOND_PLURAL: sekunder MINUTE_PLURAL: minuter HOUR_PLURAL: timmar @@ -46,8 +58,8 @@ GRAV: YR_PLURAL: år DEC_PLURAL: dec FORM: - VALIDATION_FAIL: Kontrollen misslyckades: - INVALID_INPUT: Ogiltig indata i + VALIDATION_FAIL: 'Kontrollen misslyckades:' + INVALID_INPUT: 'Ogiltig indata i' MISSING_REQUIRED_FIELD: 'Obligatoriskt fält måste fyllas i:' MONTHS_OF_THE_YEAR: - 'Januari' @@ -70,3 +82,19 @@ GRAV: - 'Fredag' - 'Lördag' - 'Söndag' + CRON: + EVERY: varje + EVERY_HOUR: varje timme + EVERY_MINUTE: varje minut + EVERY_DAY_OF_WEEK: varje veckodag + EVERY_DAY_OF_MONTH: alla månadens dagar + EVERY_MONTH: varje månad + TEXT_PERIOD: Varje + TEXT_MINS: ' timmens :e minut' + TEXT_TIME: ' kl :' + TEXT_DOW: ' ' + TEXT_MONTH: ' ' + TEXT_DOM: ' ' + ERROR1: Taggen %s stöds inte! + ERROR2: Ogiltigt antal element + ERROR4: Uttrycket känns inte igen diff --git a/system/languages/th.yaml b/system/languages/th.yaml index e6ccfab..f71b037 100644 --- a/system/languages/th.yaml +++ b/system/languages/th.yaml @@ -31,7 +31,7 @@ GRAV: YR_PLURAL: ปี FORM: VALIDATION_FAIL: 'ตรวจสอบล้มเหลว: ' - INVALID_INPUT: ป้อนข้อมูลไม่ถูกต้องใน + INVALID_INPUT: 'ป้อนข้อมูลไม่ถูกต้องใน' MISSING_REQUIRED_FIELD: 'ขาดข้อมูลที่จำเป็น:' MONTHS_OF_THE_YEAR: - 'มกราคม' diff --git a/system/languages/tr.yaml b/system/languages/tr.yaml index 2143f31..783674d 100644 --- a/system/languages/tr.yaml +++ b/system/languages/tr.yaml @@ -1,11 +1,32 @@ --- GRAV: FRONTMATTER_ERROR_PAGE: "---\nBaşlık: %1$s\n---\n\n# Hata: Geçersiz Önbölüm\n\nYol: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_UNCOUNTABLE: + - 'ekipman' + - 'bilgi' + - 'pirinç' + - 'para' + - 'türler' + - 'seriler' + - 'balık' + - 'koyun' + INFLECTOR_IRREGULAR: + 'person': 'kişi' + 'man': 'erkek' + 'child': 'çocuklar' + 'sex': 'cinsiyet' + 'move': 'taşınmış' + INFLECTOR_ORDINALS: + 'default': '#F' + 'first': ' 1.' + 'second': ' 2.' + 'third': ' 3.' NICETIME: NO_DATE_PROVIDED: Sağlanan tarih yok BAD_DATE: Yanlış tarih AGO: önce FROM_NOW: şu andan itibaren + JUST_NOW: şimdi SECOND: saniye MINUTE: dakika HOUR: saat @@ -37,8 +58,8 @@ GRAV: YR_PLURAL: yıl DEC_PLURAL: onyl FORM: - VALIDATION_FAIL: Doğrulama başarısız: - INVALID_INPUT: Geçersiz bilgi girişi + VALIDATION_FAIL: 'Doğrulama başarısız:' + INVALID_INPUT: 'Geçersiz bilgi girişi' MISSING_REQUIRED_FIELD: 'Gerekli alan eksik:' MONTHS_OF_THE_YEAR: - 'Ocak' @@ -61,3 +82,17 @@ GRAV: - 'Cuma' - 'Cumartesi' - 'Pazar' + CRON: + EVERY: her + EVERY_HOUR: saatte bir + EVERY_MINUTE: dakikada bir + EVERY_DAY_OF_WEEK: haftanın her günü + EVERY_DAY_OF_MONTH: ayın her günü + EVERY_MONTH: her ay + TEXT_PERIOD: Her + TEXT_MINS: ' saatin dakikasında' + TEXT_TIME: ' da' + ERROR1: Etiket %s desteklenmiyor! + ERROR2: Kötü eleman sayısı + ERROR3: jquery_element jqCron ayarları içinde tanımlanmalı + ERROR4: Tanınmayan ifade diff --git a/system/languages/uk.yaml b/system/languages/uk.yaml index d264fba..8a138a4 100644 --- a/system/languages/uk.yaml +++ b/system/languages/uk.yaml @@ -37,8 +37,8 @@ GRAV: YR_PLURAL: рр. DEC_PLURAL: рр. FORM: - VALIDATION_FAIL: Перевірка не вдалася: - INVALID_INPUT: Невірне введення в + VALIDATION_FAIL: 'Перевірка не вдалася:' + INVALID_INPUT: 'Невірне введення в' MISSING_REQUIRED_FIELD: 'Відсутнє обов''язкове поле:' MONTHS_OF_THE_YEAR: - 'Січень' diff --git a/system/languages/vi.yaml b/system/languages/vi.yaml index 0dc7e92..9e3a0f4 100644 --- a/system/languages/vi.yaml +++ b/system/languages/vi.yaml @@ -37,8 +37,8 @@ GRAV: YR_PLURAL: năm DEC_PLURAL: thập kỷ FORM: - VALIDATION_FAIL: Xác nhận thất bại: - INVALID_INPUT: Dữ liệu nhập không hợp lệ cho + VALIDATION_FAIL: 'Xác nhận thất bại:' + INVALID_INPUT: 'Dữ liệu nhập không hợp lệ cho' MISSING_REQUIRED_FIELD: 'Thiếu trường bắt buộc:' MONTHS_OF_THE_YEAR: - 'Tháng 1' diff --git a/system/languages/zh-cn.yaml b/system/languages/zh-cn.yaml new file mode 100644 index 0000000..334b0b4 --- /dev/null +++ b/system/languages/zh-cn.yaml @@ -0,0 +1,144 @@ +--- +GRAV: + FRONTMATTER_ERROR_PAGE: "---\n标题: %1$s\n---\n\n# 错误:无效参数\n\n位置: `%2$s`\n\n**%3$s**\n\n```\n%4$s\n```" + INFLECTOR_PLURALS: + '/(quiz)$/i': '\1zes' + '/^(ox)$/i': '\1en' + '/([m|l])ouse$/i': '\1ice' + '/(matr|vert|ind)ix|ex$/i': '\1ices' + '/(x|ch|ss|sh)$/i': '\1es' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([^aeiouy]|qu)y$/i': '\1ies' + '/(hive)$/i': '\1s' + '/(?:([^f])fe|([lr])f)$/i': '\1\2ves' + '/sis$/i': 'ses' + '/([ti])um$/i': '\1a' + '/(buffal|tomat)o$/i': '\1oes' + '/(bu)s$/i': '\1ses' + '/(alias|status)/i': '\1es' + '/(octop|vir)us$/i': '\1i' + '/(ax|test)is$/i': '\1es' + '/s$/i': 's' + '/$/': 's' + INFLECTOR_SINGULAR: + '/(quiz)zes$/i': '\1' + '/(matr)ices$/i': '\1ix' + '/(vert|ind)ices$/i': '\1ex' + '/^(ox)en/i': '\1' + '/(alias|status)es$/i': '\1' + '/([octop|vir])i$/i': '\1us' + '/(cris|ax|test)es$/i': '\1is' + '/(shoe)s$/i': '\1' + '/(o)es$/i': '\1' + '/(bus)es$/i': '\1' + '/([m|l])ice$/i': '\1ouse' + '/(x|ch|ss|sh)es$/i': '\1' + '/(m)ovies$/i': '\1ovie' + '/(s)eries$/i': '\1eries' + '/([^aeiouy]|qu)ies$/i': '\1y' + '/([lr])ves$/i': '\1f' + '/(tive)s$/i': '\1' + '/(hive)s$/i': '\1' + '/([^f])ves$/i': '\1fe' + '/(^analy)ses$/i': '\1sis' + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i': '\1\2sis' + '/([ti])a$/i': '\1um' + '/(n)ews$/i': '\1ews' + INFLECTOR_UNCOUNTABLE: + - '装备' + - '信息' + - '大米' + - '钱' + - '物种' + - '系列' + - '鱼' + - '羊' + INFLECTOR_IRREGULAR: + 'person': '人员' + 'man': '男人' + 'child': '儿童' + 'sex': '性别' + 'move': '移动' + INFLECTOR_ORDINALS: + 'default': 'th' + 'first': 'st' + 'second': 'md' + 'third': 'rd' + NICETIME: + NO_DATE_PROVIDED: 无日期信息 + BAD_DATE: 无效日期 + AGO: 前 + FROM_NOW: 距今 + JUST_NOW: 刚刚 + SECOND: 秒 + MINUTE: 分钟 + HOUR: 小时 + DAY: 天 + WEEK: 周 + MONTH: 月 + YEAR: 年 + DECADE: 十年 + SEC: 秒 + MIN: 分钟 + HR: 小时 + WK: 周 + MO: 月 + YR: 年 + DEC: 年代 + SECOND_PLURAL: 秒 + MINUTE_PLURAL: 分 + HOUR_PLURAL: 小时 + DAY_PLURAL: 天 + WEEK_PLURAL: 周 + MONTH_PLURAL: 月 + YEAR_PLURAL: 年 + DECADE_PLURAL: 十年 + SEC_PLURAL: 秒 + MIN_PLURAL: 分 + HR_PLURAL: 时 + WK_PLURAL: 周 + MO_PLURAL: 月 + YR_PLURAL: 年 + DEC_PLURAL: 年代 + FORM: + VALIDATION_FAIL: '验证失败:' + INVALID_INPUT: '无效输入' + MISSING_REQUIRED_FIELD: '必填字段缺失:' + MONTHS_OF_THE_YEAR: + - '1月' + - '2月' + - '3月' + - '4月' + - '5月' + - '6月' + - '7月' + - '8月' + - '9月' + - '10月' + - '11月' + - '12月' + DAYS_OF_THE_WEEK: + - '星期一' + - '星期二' + - '星期三' + - '星期四' + - '星期五' + - '星期六' + - '星期日' + CRON: + EVERY: 每隔 + EVERY_HOUR: 每小时 + EVERY_MINUTE: 每分钟 + EVERY_DAY_OF_WEEK: 一周中的每一天 + EVERY_DAY_OF_MONTH: 月份中的每一天 + EVERY_MONTH: 每月 + TEXT_PERIOD: 所有 + TEXT_MINS: ' 在 小时过后的分钟' + TEXT_TIME: ' 在 :' + TEXT_DOW: ' on ' + TEXT_MONTH: ' of ' + TEXT_DOM: ' on ' + ERROR1: 不支持分享类型 %s + ERROR2: 无效数字 + ERROR3: 请在 jqCron 设置中设定 jquery_element + ERROR4: 无法识别表达式 diff --git a/system/languages/zh.yaml b/system/languages/zh.yaml index 4912aa9..334b0b4 100644 --- a/system/languages/zh.yaml +++ b/system/languages/zh.yaml @@ -101,9 +101,9 @@ GRAV: YR_PLURAL: 年 DEC_PLURAL: 年代 FORM: - VALIDATION_FAIL: 验证失败: - INVALID_INPUT: 无效输入 - MISSING_REQUIRED_FIELD: 必填字段缺失: + VALIDATION_FAIL: '验证失败:' + INVALID_INPUT: '无效输入' + MISSING_REQUIRED_FIELD: '必填字段缺失:' MONTHS_OF_THE_YEAR: - '1月' - '2月' diff --git a/system/router.php b/system/router.php index 02d3321..187d4d8 100644 --- a/system/router.php +++ b/system/router.php @@ -3,7 +3,7 @@ /** * @package Grav\Core * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 69dd70a..51a2531 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -92,6 +92,8 @@ class Assets extends PropertyObject protected $collections; /** @var string */ protected $timestamp; + /** @var array Keeping track for order counts (for sorting) */ + protected $order = []; /** * Initialization called in the Grav lifecycle to initialize the Assets with appropriate configuration @@ -232,7 +234,15 @@ protected function addType($collection, $type, $asset, $options) $options['timestamp'] = $this->timestamp; // Set order - $options['order'] = count($this->$collection); + $group = $options['group'] ?? 'head'; + $position = $options['position'] ?? 'pipeline'; + + $orderKey = "{$type}|{$group}|{$position}"; + if (!isset($this->order[$orderKey])) { + $this->order[$orderKey] = 0; + } + + $options['order'] = $this->order[$orderKey]++; // Create asset of correct type $asset_object = new $type(); diff --git a/system/src/Grav/Common/Assets/BaseAsset.php b/system/src/Grav/Common/Assets/BaseAsset.php index 3b01086..579b1f9 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets/Css.php b/system/src/Grav/Common/Assets/Css.php index c167e15..b1f0a48 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets/InlineCss.php b/system/src/Grav/Common/Assets/InlineCss.php index b659f4b..f024a95 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets/InlineJs.php b/system/src/Grav/Common/Assets/InlineJs.php index 81c0ce5..6787608 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets/Js.php b/system/src/Grav/Common/Assets/Js.php index fca1c6d..9946bd8 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets/Pipeline.php b/system/src/Grav/Common/Assets/Pipeline.php index 7502391..9b44fd8 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php index 34152a5..a2dad4f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php index cfe5a08..36b2152 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 829a240..cb8de18 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -189,6 +189,7 @@ public function reset() $this->resetJs(); $this->setCssPipeline(false); $this->setJsPipeline(false); + $this->order = []; return $this; } diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php index 4ced4e5..9483b15 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Browser.php b/system/src/Grav/Common/Browser.php index 36faf3a..e4a6513 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 499c7fe..24f1d40 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -296,6 +296,7 @@ public function getCacheDriver() $redis = new \Redis(); $socket = $this->config->get('system.cache.redis.socket', false); $password = $this->config->get('system.cache.redis.password', false); + $databaseId = $this->config->get('system.cache.redis.database', 0); if ($socket) { $redis->connect($socket); @@ -310,6 +311,11 @@ public function getCacheDriver() if ($password && !$redis->auth($password)) { throw new \RedisException('Redis authentication failed'); } + + // Select alternate ( !=0 ) database ID if set + if ($databaseId && !$redis->select($databaseId)) { + throw new \RedisException('Could not select alternate Redis database ID'); + } $driver = new DoctrineCache\RedisCache(); $driver->setRedis($redis); diff --git a/system/src/Grav/Common/Composer.php b/system/src/Grav/Common/Composer.php index 66a06c6..f1f6e5d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 48990c1..0764189 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9c59b2b..7743054 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d6f89ec..22225bc 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9608b9e..6674389 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e43e1d2..7adb523 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 c4ce51a..e6b1afe 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 2b05136..4a863a1 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 96c9683..ef2176a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index e1ac0be..25c4266 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -294,13 +294,14 @@ public function filter(array $data, bool $missingValuesAsNull = false, bool $kee * Flatten data by using blueprints. * * @param array $data + * @param bool $includeAll * @return array */ - public function flattenData(array $data) + public function flattenData(array $data, bool $includeAll = false) { $this->initInternals(); - return $this->blueprintSchema->flattenData($data); + return $this->blueprintSchema->flattenData($data, $includeAll); } diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php index 4bc9892..a50bf23 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -107,11 +107,22 @@ public function filter(array $data, $missingValuesAsNull = false, $keepEmptyValu * Flatten data by using blueprints. * * @param array $data Data to be flattened. + * @param bool $includeAll * @return array */ - public function flattenData(array $data) + public function flattenData(array $data, bool $includeAll = false) { - return $this->flattenArray($data, $this->nested, ''); + $list = []; + if ($includeAll) { + foreach ($this->items as $key => $rules) { + $type = $rules['type'] ?? ''; + if (!str_starts_with($type, '_') && !str_contains($key, '*')) { + $list[$key] = null; + } + } + } + + return array_replace($list, $this->flattenArray($data, $this->nested, '')); } /** @@ -139,6 +150,7 @@ protected function flattenArray(array $data, array $rules, string $prefix) $array[$prefix.$key] = $field; } } + return $array; } diff --git a/system/src/Grav/Common/Data/Blueprints.php b/system/src/Grav/Common/Data/Blueprints.php index 41e1264..abe153f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 dabe40f..67fb0a8 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 025a2f9..b4452bb 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f6ea88f..3e0ba32 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -1116,6 +1116,21 @@ public static function validateHex($value, $params) return ctype_xdigit($value); } + /** + * Custom input: int + * + * @param mixed $value Value to be validated. + * @param array $params Validation parameters. + * @param array $field Blueprint for the field. + * @return bool True if validation succeeded. + */ + public static function typeInt($value, array $params, array $field) + { + $params['step'] = max(1, (int)($params['step'] ?? 0)); + + return self::typeNumber($value, $params, $field); + } + /** * @param mixed $value * @param mixed $params diff --git a/system/src/Grav/Common/Data/ValidationException.php b/system/src/Grav/Common/Data/ValidationException.php index be9846b..2d94ab8 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8e1db0a..6a1e256 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5b1742b..206b57e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0b27667..3dc99c6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6ade016..0118929 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f8d290e..8a7f1ce 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 023eadf..66fa620 100644 --- a/system/src/Grav/Common/File/CompiledFile.php +++ b/system/src/Grav/Common/File/CompiledFile.php @@ -3,7 +3,7 @@ /** * @package Grav\Common\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/File/CompiledJsonFile.php b/system/src/Grav/Common/File/CompiledJsonFile.php index 8086cb3..dae95ba 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3704a80..1107417 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1f8b091..0fedeb7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 474be8e..96aaa0e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 91a2e63..ef09cee 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1e0da0e..0dac81c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 2731afe..ded0259 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 2eb9f5a..450a581 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 new file mode 100644 index 0000000..a4d1bbe --- /dev/null +++ b/system/src/Grav/Common/Flex/FlexCollection.php @@ -0,0 +1,29 @@ + + */ +abstract class FlexCollection extends \Grav\Framework\Flex\FlexCollection +{ + use FlexGravTrait; + use FlexCollectionTrait; +} diff --git a/system/src/Grav/Common/Flex/FlexIndex.php b/system/src/Grav/Common/Flex/FlexIndex.php new file mode 100644 index 0000000..d73f010 --- /dev/null +++ b/system/src/Grav/Common/Flex/FlexIndex.php @@ -0,0 +1,30 @@ + + */ +abstract class FlexIndex extends \Grav\Framework\Flex\FlexIndex +{ + use FlexGravTrait; + use FlexIndexTrait; +} diff --git a/system/src/Grav/Common/Flex/FlexObject.php b/system/src/Grav/Common/Flex/FlexObject.php new file mode 100644 index 0000000..2a43eaa --- /dev/null +++ b/system/src/Grav/Common/Flex/FlexObject.php @@ -0,0 +1,73 @@ +getNestedProperty($name, null, $separator); + + // Handle media order field. + if (null === $value && $name === 'media_order') { + return implode(',', $this->getMediaOrder()); + } + + // Handle media fields. + $settings = $this->getFieldSettings($name); + if ($settings['media_field'] ?? false === true) { + return $this->parseFileProperty($value, $settings); + } + + return $value ?? $default; + } + + /** + * {@inheritdoc} + * @see FlexObjectInterface::prepareStorage() + */ + public function prepareStorage(): array + { + // Remove extra content from media fields. + $fields = $this->getMediaFields(); + foreach ($fields as $field) { + $data = $this->getNestedProperty($field); + if (is_array($data)) { + foreach ($data as $name => &$image) { + unset($image['image_url'], $image['thumb_url']); + } + unset($image); + $this->setNestedProperty($field, $data); + } + } + + return parent::prepareStorage(); + } +} diff --git a/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php b/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php index 25c8b40..29b640e 100644 --- a/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php +++ b/system/src/Grav/Common/Flex/Traits/FlexCollectionTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5bd662a..1077e00 100644 --- a/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php +++ b/system/src/Grav/Common/Flex/Traits/FlexCommonTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4da7aa1..9d5c9e0 100644 --- a/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php +++ b/system/src/Grav/Common/Flex/Traits/FlexGravTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e1d9ac4..1d0ee5c 100644 --- a/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php +++ b/system/src/Grav/Common/Flex/Traits/FlexIndexTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f523390..1175a3b 100644 --- a/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php +++ b/system/src/Grav/Common/Flex/Traits/FlexObjectTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e5451cb..2a6767b 100644 --- a/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php +++ b/system/src/Grav/Common/Flex/Types/Generic/GenericCollection.php @@ -5,24 +5,20 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ namespace Grav\Common\Flex\Types\Generic; -use Grav\Common\Flex\Traits\FlexCollectionTrait; -use Grav\Common\Flex\Traits\FlexGravTrait; -use Grav\Framework\Flex\FlexCollection; +use Grav\Common\Flex\FlexCollection; /** * Class GenericCollection * @package Grav\Common\Flex\Generic * - * @extends FLexCollection + * @extends FlexCollection */ class GenericCollection extends FlexCollection { - use FlexGravTrait; - use FlexCollectionTrait; } diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php b/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php index 56c8244..4b0c400 100644 --- a/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php +++ b/system/src/Grav/Common/Flex/Types/Generic/GenericIndex.php @@ -5,25 +5,20 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ namespace Grav\Common\Flex\Types\Generic; -use Grav\Common\Flex\Traits\FlexGravTrait; -use Grav\Common\Flex\Traits\FlexIndexTrait; -use Grav\Framework\Flex\FlexIndex; +use Grav\Common\Flex\FlexIndex; /** * Class GenericIndex * @package Grav\Common\Flex\Generic * - * @extends FLexIndex - * @mixin GenericCollection + * @extends FlexIndex */ class GenericIndex extends FlexIndex { - use FlexGravTrait; - use FlexIndexTrait; } diff --git a/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php b/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php index e7dccf2..4a56752 100644 --- a/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php +++ b/system/src/Grav/Common/Flex/Types/Generic/GenericObject.php @@ -5,16 +5,13 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ namespace Grav\Common\Flex\Types\Generic; -use Grav\Common\Flex\Traits\FlexGravTrait; -use Grav\Common\Flex\Traits\FlexObjectTrait; -use Grav\Framework\Flex\FlexObject; -use Grav\Framework\Flex\Traits\FlexMediaTrait; +use Grav\Common\Flex\FlexObject; /** * Class GenericObject @@ -22,7 +19,4 @@ */ class GenericObject extends FlexObject { - use FlexGravTrait; - use FlexObjectTrait; - use FlexMediaTrait; } diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php index 0732cf9..1811a0e 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php index 12d7f9f..fbf0df4 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -36,7 +36,6 @@ * @package Grav\Plugin\FlexObjects\Types\GravPages * * @extends FlexPageIndex - * @mixin PageCollection * * @method PageIndex withModules(bool $bool = true) * @method PageIndex withPages(bool $bool = true) @@ -449,6 +448,10 @@ protected function getLevelListingRecurse(array $options): array 'has-children' => $child_count > 0 ]; } else { + $lang = $child->findTranslation($language) ?? 'n/a'; + /** @var PageObject $child */ + $child = $child->getTranslation($language) ?? $child; + // TODO: all these features are independent from each other, we cannot just have one icon/color to catch all. // TODO: maybe icon by home/modular/page/folder (or even from blueprints) and color by visibility etc.. if ($child->home()) { @@ -468,9 +471,6 @@ protected function getLevelListingRecurse(array $options): array $child->visible() ? 'visible' : 'non-visible', $child->routable() ? 'routable' : 'non-routable' ]; - $lang = $child->findTranslation($language) ?? 'n/a'; - /** @var PageObject $child */ - $child = $child->getTranslation($language) ?? $child; $extras = [ 'template' => $child->template(), 'lang' => $lang ?: null, diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageObject.php b/system/src/Grav/Common/Flex/Types/Pages/PageObject.php index 1d4f9b9..56c0527 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -25,7 +25,6 @@ use Grav\Common\Utils; use Grav\Framework\Filesystem\Filesystem; use Grav\Framework\Flex\FlexObject; -use Grav\Framework\Flex\Interfaces\FlexCollectionInterface; use Grav\Framework\Flex\Interfaces\FlexObjectInterface; use Grav\Framework\Flex\Pages\FlexPageObject; use Grav\Framework\Route\Route; @@ -35,7 +34,6 @@ use RuntimeException; use stdClass; use function array_key_exists; -use function assert; use function count; use function func_get_args; use function in_array; 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 a619fb1..a235174 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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/PageContentTrait.php b/system/src/Grav/Common/Flex/Types/Pages/Traits/PageContentTrait.php index ac1c58b..1bde7b0 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 75ca381..d8193df 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e2045ec..341ac4d 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 2362fa9..e2de494 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 20dea64..b1443a8 100644 --- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php +++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupCollection.php @@ -5,15 +5,13 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ namespace Grav\Common\Flex\Types\UserGroups; -use Grav\Common\Flex\Traits\FlexCollectionTrait; -use Grav\Common\Flex\Traits\FlexGravTrait; -use Grav\Framework\Flex\FlexCollection; +use Grav\Common\Flex\FlexCollection; /** * Class UserGroupCollection @@ -23,9 +21,6 @@ */ class UserGroupCollection extends FlexCollection { - use FlexGravTrait; - use FlexCollectionTrait; - /** * @return array */ diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php index 211296f..effd27f 100644 --- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php +++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupIndex.php @@ -5,25 +5,20 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ namespace Grav\Common\Flex\Types\UserGroups; -use Grav\Common\Flex\Traits\FlexGravTrait; -use Grav\Common\Flex\Traits\FlexIndexTrait; -use Grav\Framework\Flex\FlexIndex; +use Grav\Common\Flex\FlexIndex; /** * Class GroupIndex * @package Grav\Common\User\FlexUser * * @extends FlexIndex - * @mixin UserGroupCollection */ class UserGroupIndex extends FlexIndex { - use FlexGravTrait; - use FlexIndexTrait; } diff --git a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php index 7665283..fb69eab 100644 --- a/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php +++ b/system/src/Grav/Common/Flex/Types/UserGroups/UserGroupObject.php @@ -5,18 +5,15 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ namespace Grav\Common\Flex\Types\UserGroups; -use Grav\Common\Flex\Traits\FlexGravTrait; -use Grav\Common\Flex\Traits\FlexObjectTrait; +use Grav\Common\Flex\FlexObject; use Grav\Common\User\Access; use Grav\Common\User\Interfaces\UserGroupInterface; -use Grav\Framework\Flex\FlexObject; -use Grav\Framework\Flex\Traits\FlexMediaTrait; use function is_bool; /** @@ -29,10 +26,6 @@ */ class UserGroupObject extends FlexObject implements UserGroupInterface { - use FlexGravTrait; - use FlexObjectTrait; - use FlexMediaTrait; - /** @var Access */ protected $_access; /** @var array|null */ 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 9f9633e..f565c9f 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -19,22 +19,6 @@ */ class UserFileStorage extends FileStorage { - /** @var bool */ - public $caseSensitive; - - /** - * @param string $key - * @return string - */ - public function normalizeKey(string $key): string - { - if ($this->caseSensitive === true) { - return $key; - } - - return mb_strtolower($key); - } - /** * {@inheritdoc} * @see FlexStorageInterface::getMediaPath() @@ -60,15 +44,4 @@ protected function prepareRow(array &$row): void $row['access'] = $access; } } - - /** - * @param array $options - * @return void - */ - protected function initOptions(array $options): void - { - parent::initOptions($options); - - $this->caseSensitive = $options['case_sensitive'] ?? false; - } } 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 e11fa8f..7d9924e 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -19,22 +19,6 @@ */ class UserFolderStorage extends FolderStorage { - /** @var bool */ - public $caseSensitive; - - /** - * @param string $key - * @return string - */ - public function normalizeKey(string $key): string - { - if ($this->caseSensitive === true) { - return $key; - } - - return mb_strtolower($key); - } - /** * Prepares the row for saving and returns the storage key for the record. * @@ -50,15 +34,4 @@ protected function prepareRow(array &$row): void $row['access'] = $access; } } - - /** - * @param array $options - * @return void - */ - protected function initOptions(array $options): void - { - parent::initOptions($options); - - $this->caseSensitive = $options['case_sensitive'] ?? false; - } } 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 82f1bf7..b0fc0c4 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f07be1c..e4e252c 100644 --- a/system/src/Grav/Common/Flex/Types/Users/UserCollection.php +++ b/system/src/Grav/Common/Flex/Types/Users/UserCollection.php @@ -5,17 +5,15 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ namespace Grav\Common\Flex\Types\Users; -use Grav\Common\Flex\Traits\FlexCollectionTrait; -use Grav\Common\Flex\Traits\FlexGravTrait; +use Grav\Common\Flex\FlexCollection; use Grav\Common\User\Interfaces\UserCollectionInterface; use Grav\Common\User\Interfaces\UserInterface; -use Grav\Framework\Flex\FlexCollection; use function is_string; /** @@ -26,9 +24,6 @@ */ class UserCollection extends FlexCollection implements UserCollectionInterface { - use FlexGravTrait; - use FlexCollectionTrait; - /** * @return array */ diff --git a/system/src/Grav/Common/Flex/Types/Users/UserIndex.php b/system/src/Grav/Common/Flex/Types/Users/UserIndex.php index eaa1338..4735c93 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -13,11 +13,9 @@ use Grav\Common\Debugger; use Grav\Common\File\CompiledYamlFile; -use Grav\Common\Flex\Traits\FlexGravTrait; -use Grav\Common\Flex\Traits\FlexIndexTrait; +use Grav\Common\Flex\FlexIndex; use Grav\Common\Grav; use Grav\Common\User\Interfaces\UserInterface; -use Grav\Framework\Flex\FlexIndex; use Grav\Framework\Flex\Interfaces\FlexStorageInterface; use Monolog\Logger; use function count; @@ -29,15 +27,11 @@ * @package Grav\Common\Flex\Types\Users * * @extends FlexIndex - * @mixin UserCollection */ class UserIndex extends FlexIndex { public const VERSION = parent::VERSION . '.1'; - use FlexGravTrait; - use FlexIndexTrait; - /** * @param FlexStorageInterface $storage * @return array @@ -152,11 +146,7 @@ public function find($query, $fields = ['username', 'email']): UserInterface */ protected static function filterUsername(string $key, FlexStorageInterface $storage): string { - if (method_exists($storage, 'normalizeKey')) { - return $storage->normalizeKey($key); - } - - return mb_strtolower($key); + return $storage->normalizeKey($key); } /** diff --git a/system/src/Grav/Common/Flex/Types/Users/UserObject.php b/system/src/Grav/Common/Flex/Types/Users/UserObject.php index a897820..26da6a0 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 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -14,6 +14,7 @@ use Countable; use Grav\Common\Config\Config; use Grav\Common\Data\Blueprint; +use Grav\Common\Flex\FlexObject; use Grav\Common\Flex\Traits\FlexGravTrait; use Grav\Common\Flex\Traits\FlexObjectTrait; use Grav\Common\Flex\Types\Users\Traits\UserObjectLegacyTrait; @@ -33,7 +34,6 @@ use Grav\Framework\File\Formatter\YamlFormatter; use Grav\Framework\Flex\Flex; use Grav\Framework\Flex\FlexDirectory; -use Grav\Framework\Flex\FlexObject; use Grav\Framework\Flex\Storage\FileStorage; use Grav\Framework\Flex\Traits\FlexMediaTrait; use Grav\Framework\Form\FormFlashFile; @@ -42,7 +42,6 @@ use RocketTheme\Toolbox\File\FileInterface; use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; use RuntimeException; -use function assert; use function is_array; use function is_bool; use function is_object; @@ -121,11 +120,22 @@ public function __construct(array $elements, $key, FlexDirectory $directory, boo // User can only be authenticated via login. unset($elements['authenticated'], $elements['authorized']); - parent::__construct($elements, $key, $directory, $validate); + // Define username if it's not set. + if (!isset($elements['username'])) { + $storageKey = $elements['__META']['storage_key'] ?? null; + if (null !== $storageKey && $key === $directory->getStorage()->normalizeKey($storageKey)) { + $elements['username'] = $storageKey; + } else { + $elements['username'] = $key; + } + } + + // Define state if it isn't set. + if (!isset($elements['state'])) { + $elements['state'] = 'enabled'; + } - // Define username and state if they aren't set. - $this->defProperty('username', $key); - $this->defProperty('state', 'enabled'); + parent::__construct($elements, $key, $directory, $validate); } /** @@ -270,32 +280,6 @@ public function authorize(string $action, string $scope = null): ?bool return $this->getGroups()->authorize($action, $scope); } - /** - * Get value from a page variable (used mostly for creating edit forms). - * - * @param string $name Variable name. - * @param mixed $default - * @param string|null $separator - * @return mixed - */ - public function getFormValue(string $name, $default = null, string $separator = null) - { - $value = parent::getFormValue($name, null, $separator); - - $settings = $this->getFieldSettings($name); - if ($settings['media_field'] ?? false === true) { - return $this->parseFileProperty($value); - } - - if (null === $value) { - if ($name === 'media_order') { - return implode(',', $this->getMediaOrder()); - } - } - - return $value ?? $default; - } - /** * @param string $property * @param mixed $default @@ -306,7 +290,8 @@ public function getProperty($property, $default = null) $value = parent::getProperty($property, $default); if ($property === 'avatar') { - $value = $this->parseFileProperty($value); + $settings = $this->getMediaFieldSettings($property); + $value = $this->parseFileProperty($value, $settings); } return $value; @@ -320,7 +305,9 @@ public function getProperty($property, $default = null) public function toArray() { $array = $this->jsonSerialize(); - $array['avatar'] = $this->parseFileProperty($array['avatar'] ?? null); + + $settings = $this->getMediaFieldSettings('avatar'); + $array['avatar'] = $this->parseFileProperty($array['avatar'] ?? null, $settings); return $array; } @@ -536,7 +523,7 @@ public function isValid(): bool } /** - * Save user without the username + * Save user * * @return static */ @@ -824,45 +811,6 @@ protected function saveUpdatedMedia(): void $this->clearMediaCache(); } - /** - * @param array|mixed $value - * @return array|mixed - */ - protected function parseFileProperty($value) - { - if (!is_array($value)) { - return $value; - } - - $originalMedia = $this->getOriginalMedia(); - $resizedMedia = $this->getMedia(); - - $list = []; - foreach ($value as $filename => $info) { - if (!is_array($info)) { - continue; - } - - /** @var Medium|null $thumbFile */ - $thumbFile = $resizedMedia[$filename]; - /** @var Medium|null $imageFile */ - $imageFile = $originalMedia[$filename] ?? $thumbFile; - if ($thumbFile && $imageFile) { - $list[$filename] = [ - 'name' => $info['name'] ?? null, - 'type' => $info['type'] ?? null, - 'size' => $info['size'] ?? null, - 'path' => $info['path'] ?? null, - 'image_url' => $imageFile->url(), - 'thumb_url' => $thumbFile->url(), - 'cropData' => (object)($imageFile->metadata()['upload']['crop'] ?? []) - ]; - } - } - - return $list; - } - /** * @return array */ diff --git a/system/src/Grav/Common/Form/FormFlash.php b/system/src/Grav/Common/Form/FormFlash.php index 6f0a2c3..430f15e 100644 --- a/system/src/Grav/Common/Form/FormFlash.php +++ b/system/src/Grav/Common/Form/FormFlash.php @@ -3,7 +3,7 @@ /** * @package Grav\Common\Form * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/GPM/AbstractCollection.php b/system/src/Grav/Common/GPM/AbstractCollection.php index 6d1c914..b5b867e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 99f8ef0..5d6ad9f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b094488..172ba93 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 2f49e45..e06ebb6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 80fea08..1b15e5d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -139,13 +139,27 @@ public function getInstalledPlugins() return $this->installed['plugins']; } + + /** + * Returns the plugin's enabled state + * + * @param string $slug + * @return bool True if the Plugin is Enabled. False if manually set to enable:false. Null otherwise. + */ + public function isPluginEnabled($slug): bool + { + $grav = Grav::instance(); + + return ($grav['config']['plugins'][$slug]['enabled'] ?? false) === true; + } + /** * Checks if a Plugin is installed * * @param string $slug The slug of the Plugin * @return bool True if the Plugin has been installed. False otherwise */ - public function isPluginInstalled($slug) + public function isPluginInstalled($slug): bool { return isset($this->installed['plugins'][$slug]); } @@ -182,13 +196,28 @@ public function getInstalledThemes() return $this->installed['themes']; } + /** + * Checks if a Theme is enabled + * + * @param string $slug The slug of the Theme + * @return bool True if the Theme has been set to the default theme. False if installed, but not enabled. Null otherwise. + */ + public function isThemeEnabled($slug): bool + { + $grav = Grav::instance(); + + $current_theme = $grav['config']['system']['pages']['theme'] ?? null; + + return $current_theme === $slug; + } + /** * Checks if a Theme is installed * * @param string $slug The slug of the Theme * @return bool True if the Theme has been installed. False otherwise */ - public function isThemeInstalled($slug) + public function isThemeInstalled($slug): bool { return isset($this->installed['themes'][$slug]); } @@ -1023,7 +1052,6 @@ private function calculateMergedDependenciesOfPackage($packageName, $dependencie //Factor in the package dependencies too $dependencies = $this->calculateMergedDependenciesOfPackage($dependencyName, $dependencies); - } elseif ($dependencyVersion !== '*') { // Dependency already added by another package // If this package requires a version higher than the currently stored one, store this requirement instead @@ -1059,7 +1087,7 @@ private function calculateMergedDependenciesOfPackage($packageName, $dependencie $dependencies[$dependencyName] = $dependencyVersion; } } else { - $compatible = $this->checkNextSignificantReleasesAreCompatible($currently_stored_version_number,$current_package_version_number); + $compatible = $this->checkNextSignificantReleasesAreCompatible($currently_stored_version_number, $current_package_version_number); if (!$compatible) { throw new RuntimeException("Dependency {$dependencyName} is required in two incompatible versions", 2); } diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index 9b9f905..9cdea52 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/GPM/Licenses.php b/system/src/Grav/Common/GPM/Licenses.php index c8a5fbc..662a146 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 dce33bd..d1f3e46 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 573ec54..ffe2c63 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9a1384e..0290296 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 37f6b60..8a6574b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6dda784..73253cc 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 28449e0..9e68d66 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 892aa9f..f93209e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8dd82b7..c37d6a0 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 16be487..f55c12d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 bde0f75..a134a10 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 194fc88..160ac97 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/GPM/Response.php b/system/src/Grav/Common/GPM/Response.php index 29665f0..6f3ae4e 100644 --- a/system/src/Grav/Common/GPM/Response.php +++ b/system/src/Grav/Common/GPM/Response.php @@ -3,7 +3,7 @@ /** * @package Grav\Common\GPM * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3164ed8..dfa6eb1 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e70401a..8f3a73a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 78896af..048f7d4 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -162,6 +162,19 @@ public static function instance(array $values = []) return self::$instance; } + /** + * Get Grav version. + * + * @return string + */ + public function getVersion(): string + { + return GRAV_VERSION; + } + + /** + * @return bool + */ public function isSetup(): bool { return isset($this->initialized['setup']); diff --git a/system/src/Grav/Common/GravTrait.php b/system/src/Grav/Common/GravTrait.php index b43dfb9..4638905 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 11898ef..825c1ec 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 aa5e6d1..cd285cf 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6e2fa60..36e391f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f450a6e..1e3e8d2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 fd9fd28..0a701b6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a5bc9b5..45b5144 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Inflector.php b/system/src/Grav/Common/Inflector.php index c97dad3..50c218f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5b076c3..cc7cf92 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6f954d4..6709754 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -39,7 +39,7 @@ class Language /** @var array */ protected $fallback_extensions = []; /** @var array */ - protected $page_extesions = []; + protected $page_extensions = []; /** @var string|false */ protected $default; /** @var string|false */ @@ -400,7 +400,7 @@ public function resetFallbackPageExtensions() { $this->fallback_languages = []; $this->fallback_extensions = []; - $this->page_extesions = []; + $this->page_extensions = []; } /** diff --git a/system/src/Grav/Common/Language/LanguageCodes.php b/system/src/Grav/Common/Language/LanguageCodes.php index e89ad16..9282070 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Markdown/Parsedown.php b/system/src/Grav/Common/Markdown/Parsedown.php index 6a6666f..bdc5bdc 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 af4ee67..b8e760e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 28ececa..7c2b0d6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a2122c7..d9c69d2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f603b72..702cfda 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 99b59fb..377258c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 28d0fd4..ad9fe96 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0f0700e..07a5c26 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1e73dd3..436fe16 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ee19fa3..4f229c2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a3cce1b..6438881 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -115,6 +115,15 @@ public function parsedownElement($title = null, $alt = null, $class = null, $id */ public function reset(); + /** + * Add custom attribute to medium. + * + * @param string $attribute + * @param string $value + * @return $this + */ + public function attribute($attribute = null, $value = ''); + /** * Switch display mode. * diff --git a/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php b/system/src/Grav/Common/Media/Interfaces/MediaPlayerInterface.php index d008eea..9307915 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 feb79ee..8bfef84 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d78b4ce..ff0655a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 16dbbc3..160837d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 344df7e..c023763 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1acf441..ad168a3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 24578d4..7198133 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 7fa6c2a..3c2a38b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -303,6 +303,21 @@ public function reset() return $this; } + /** + * Add custom attribute to medium. + * + * @param string $attribute + * @param string $value + * @return $this + */ + public function attribute($attribute = null, $value = '') + { + if (!empty($attribute)) { + $this->attributes[$attribute] = $value; + } + return $this; + } + /** * Switch display mode. * diff --git a/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php b/system/src/Grav/Common/Media/Traits/MediaPlayerTrait.php index 2a0620c..66e9f47 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 df842b4..5faba82 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 60d83e6..3a0181a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php b/system/src/Grav/Common/Media/Traits/StaticResizeTrait.php index 4d0899e..49d75be 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3ba5aa1..eab7320 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3878215..e03fbbd 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3b06a60..e67ff04 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 38032a6..71c7b16 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 cca287f..67c5b1e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ed53b65..5156ede 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Interfaces/PageInterface.php b/system/src/Grav/Common/Page/Interfaces/PageInterface.php index db4fc48..e5ea20c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 25a9971..ef5cfba 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 792c0d3..1a36602 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index 528ced7..9201e66 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -3,7 +3,7 @@ /** * @package Grav\Common\Page * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php index 96bc9d9..06b44a7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ca0061f..f34f0a9 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 51a739e..4097c8f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Medium/ImageFile.php b/system/src/Grav/Common/Page/Medium/ImageFile.php index f9a5c1d..bd853bf 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9c88ef1..70ab128 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Medium/Link.php b/system/src/Grav/Common/Page/Medium/Link.php index fa0a0a7..2bb857b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3c95006..87009ac 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Medium/MediumFactory.php b/system/src/Grav/Common/Page/Medium/MediumFactory.php index e8fa4ab..7dee4ea 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php b/system/src/Grav/Common/Page/Medium/ParsedownHtmlTrait.php index bc34753..44ab952 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 2f9bba9..ac72447 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0794034..ba92fa1 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php b/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php index 575aa1d..d95b2d6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 642eab0..a56a20d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 77efd7f..bfcf550 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 344a7ba..9d037d2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -24,6 +24,7 @@ use Grav\Common\Media\Traits\MediaTrait; use Grav\Common\Page\Markdown\Excerpts; use Grav\Common\Page\Traits\PageFormTrait; +use Grav\Common\Twig\Twig; use Grav\Common\Uri; use Grav\Common\Utils; use Grav\Common\Yaml; @@ -271,7 +272,8 @@ public function translatedLanguages($onlyPublished = false) if ($exists) { $aPage = new Page(); $aPage->init(new SplFileInfo($path), $languageExtension); - + $aPage->route($this->route()); + $aPage->rawRoute($this->rawRoute()); $route = $aPage->header()->routes['default'] ?? $aPage->rawRoute(); if (!$route) { $route = $aPage->route(); @@ -908,20 +910,25 @@ protected function processMarkdown(bool $keepTwig = false) $content = $this->content; if ($keepTwig) { + $token = [ + '/' . Utils::generateRandomString(3), + Utils::generateRandomString(3) . '/' + ]; // Base64 encode any twig. $content = preg_replace_callback( - ['/({#)(.*?)(#})/mu', '/({{)(.*?)(}})/mu', '/({%)(.*?)(%})/mu'], - static function ($matches) { return $matches[1] . base64_encode($matches[2]) . $matches[3]; }, + ['/({#.*?#})/mu', '/({{.*?}})/mu', '/({%.*?%})/mu'], + static function ($matches) use ($token) { return $token[0] . base64_encode($matches[1]) . $token[1]; }, $content ); } + $content = $parsedown->text($content); if ($keepTwig) { // Base64 decode the encoded twig. $content = preg_replace_callback( - ['/({#)(.*?)(#})/mu', '/({{)(.*?)(}})/mu', '/({%)(.*?)(%})/mu'], - static function ($matches) { return $matches[1] . base64_decode($matches[2]) . $matches[3]; }, + ['`' . $token[0] . '([A-Za-z0-9+/]+={0,2})' . $token[1] . '`mu'], + static function ($matches) { return base64_decode($matches[1]); }, $content ); } @@ -937,6 +944,7 @@ static function ($matches) { return $matches[1] . base64_decode($matches[2]) . $ */ private function processTwig() { + /** @var Twig $twig */ $twig = Grav::instance()['twig']; $this->content = $twig->processPage($this, $this->content); } @@ -948,6 +956,7 @@ private function processTwig() */ public function cachePageContent() { + /** @var Cache $cache */ $cache = Grav::instance()['cache']; $cache_id = md5('page' . $this->getCacheKey()); $cache->save($cache_id, ['content' => $this->content, 'content_meta' => $this->content_meta]); @@ -1665,7 +1674,7 @@ public function metadata($var = null) // if not metadata yet, process it. if (null === $this->metadata) { - $header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible']; + $header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible', 'content-security-policy']; $this->metadata = []; @@ -1698,7 +1707,7 @@ public function metadata($var = null) $this->metadata[$prop_key] = [ 'name' => $prop_key, 'property' => $prop_key, - 'content' => $escape ? htmlspecialchars($prop_value, ENT_QUOTES, 'UTF-8') : $prop_value + 'content' => $escape ? htmlspecialchars($prop_value, ENT_QUOTES | ENT_HTML5, 'UTF-8') : $prop_value ]; } } else { @@ -1707,19 +1716,19 @@ public function metadata($var = null) if (in_array($key, $header_tag_http_equivs, true)) { $this->metadata[$key] = [ 'http_equiv' => $key, - 'content' => $escape ? htmlspecialchars($value, ENT_QUOTES, 'UTF-8') : $value + 'content' => $escape ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : $value ]; } elseif ($key === 'charset') { - $this->metadata[$key] = ['charset' => $escape ? htmlspecialchars($value, ENT_QUOTES, 'UTF-8') : $value]; + $this->metadata[$key] = ['charset' => $escape ? htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8') : $value]; } else { // if it's a social metadata with separator, render as property $separator = strpos($key, ':'); $hasSeparator = $separator && $separator < strlen($key) - 1; $entry = [ - 'content' => $escape ? htmlspecialchars($value, ENT_QUOTES, 'UTF-8') : $value + 'content' => $escape ? htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8') : $value ]; - if ($hasSeparator && !Utils::startsWith($key, 'twitter')) { + if ($hasSeparator && !Utils::startsWith($key, ['twitter', 'flattr'])) { $entry['property'] = $key; } else { $entry['name'] = $key; @@ -1858,11 +1867,6 @@ public function url($include_host = false, $canonical = false, $include_base = t $uri = $grav['uri']; $url = $uri->rootUrl($include_host) . '/' . trim($route, '/') . $this->urlExtension(); - // trim trailing / if not root - if ($url !== '/') { - $url = rtrim($url, '/'); - } - return Uri::filterPath($url); } diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 6913115..0c430fd 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -449,7 +449,6 @@ public function getCollection(array $params = [], array $context = []) } } - // Remove any inclusive sets from filter. $filters = $params['filter'] ?? []; // Assume published=true if not set. @@ -457,8 +456,27 @@ public function getCollection(array $params = [], array $context = []) $filters['published'] = true; } + // Remove any inclusive sets from filter. + $sets = ['published', 'visible', 'modular', 'routable']; + foreach ($sets as $type) { + $nonType = "non-{$type}"; + if (isset($filters[$type], $filters[$nonType]) && $filters[$type] === $filters[$nonType]) { + if (!$filters[$type]) { + // Both options are false, return empty collection as nothing can match the filters. + return new Collection(); + } + + // Both options are true, remove opposite filters as all pages will match the filters. + unset($filters[$type], $filters[$nonType]); + } + } + // Filter the collection foreach ($filters as $type => $filter) { + if (null === $filter) { + continue; + } + // Convert non-type to type. if (str_starts_with($type, 'non-')) { $type = substr($type, 4); @@ -759,6 +777,12 @@ public function get($path) $instance = $this->index[$path] ?? null; if (is_string($instance)) { + /** @var Language $language */ + $language = $this->grav['language']; + $lang = $language->getActive(); + if ($lang) { + $instance .= ':' . $lang; + } $instance = $this->directory ? $this->directory->getObject($instance, 'flex_key') : null; if ($instance) { if ($this->fire_events && method_exists($instance, 'initialize')) { diff --git a/system/src/Grav/Common/Page/Types.php b/system/src/Grav/Common/Page/Types.php index c76798f..051610f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index 14af4dd..d075860 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php index 99a1d70..f1d7b8e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -170,6 +170,33 @@ public function __debugInfo(): array return $array; } + /** + * @return Plugin[] Index of all plugins by plugin name. + */ + public static function getPlugins(): array + { + $grav = Grav::instance(); + $plugins = $grav['plugins']; + + $list = []; + foreach ($plugins as $instance) { + $list[$instance->name] = $instance; + } + + return $list; + } + + /** + * @param string $name Plugin name + * @return Plugin|null Plugin object or null if plugin cannot be found. + */ + public static function getPlugin(string $name) + { + $list = static::getPlugins(); + + return $list[$name] ?? null; + } + /** * Return list of all plugin data with their blueprints. * diff --git a/system/src/Grav/Common/Processors/AssetsProcessor.php b/system/src/Grav/Common/Processors/AssetsProcessor.php index 2570cfd..66bb5e3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 fa92bbd..6e960b4 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 141a8c8..de7cafc 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a94d311..32908ba 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f416709..a6a606c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -30,6 +30,7 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function defined; +use function in_array; /** * Class InitializeProcessor @@ -414,13 +415,18 @@ protected function initializeUri(Config $config): void protected function handleRedirectRequest(RequestInterface $request): ?ResponseInterface { + if (!in_array($request->getMethod(), ['GET', 'HEAD'])) { + return null; + } + // Redirect pages with trailing slash if configured to do so. $uri = $request->getUri(); $path = $uri->getPath() ?: '/'; $root = $this->container['uri']->rootUrl(); if ($path !== $root && $path !== $root . '/' && Utils::endsWith($path, '/')) { - return $this->container->getRedirectResponse((string)$uri->withPath(rtrim($path, '/'))); + // Use permanent redirect for SEO reasons. + return $this->container->getRedirectResponse((string)$uri->withPath(rtrim($path, '/')), 301); } return null; diff --git a/system/src/Grav/Common/Processors/PagesProcessor.php b/system/src/Grav/Common/Processors/PagesProcessor.php index 8d1377b..33b483f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 412acc4..485578e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1b455f4..a3506f5 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ccc4de3..8a6edbe 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1dac5fd..32f48e7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9385682..971fb67 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Processors/SchedulerProcessor.php b/system/src/Grav/Common/Processors/SchedulerProcessor.php index a07f814..69cc163 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ea42dc9..07e0934 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 77c8f13..951dc79 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b4dd28c..6604b5c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 48a1384..5127a99 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3692224..cc5c165 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0a6fd9f..f21c26d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 c22d00e..73a0712 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ede8741..21d059e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Service/AccountsServiceProvider.php b/system/src/Grav/Common/Service/AccountsServiceProvider.php index d39925e..8b158c9 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d5b39b1..1e4e647 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 fb09d8c..00fa963 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 38d933c..a423f6e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1a19445..3227365 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 38914e1..62dad5d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4aebf12..9c8cd49 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 77870c9..861a69e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 7890d5c..5043cfb 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 19072bd..9a49185 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 836598c..4acf370 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Service/RequestServiceProvider.php b/system/src/Grav/Common/Service/RequestServiceProvider.php index 69bd1c9..1cc03ed 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 016cc8e..a952725 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e5b7257..88c833f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -43,19 +43,23 @@ public function register(Container $container) $cookie_secure = (bool)$config->get('system.session.secure', false); $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'); $cookie_path = $config->get('system.session.path'); $cookie_samesite = $config->get('system.session.samesite', 'Lax'); + + if (null === $cookie_domain) { + $cookie_domain = $uri->host(); + if ($cookie_domain === 'localhost') { + $cookie_domain = ''; + } + } + if (null === $cookie_path) { $cookie_path = '/' . trim(Uri::filterPath($uri->rootUrl(false)), '/'); } // Session cookie path requires trailing slash. $cookie_path = rtrim($cookie_path, '/') . '/'; - $cookie_domain = $uri->host(); - if ($cookie_domain === 'localhost') { - $cookie_domain = ''; - } - // Activate admin if we're inside the admin path. $is_admin = false; if ($config->get('plugins.admin.enabled')) { diff --git a/system/src/Grav/Common/Service/StreamsServiceProvider.php b/system/src/Grav/Common/Service/StreamsServiceProvider.php index e0f9a20..2099d06 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0336253..9afab59 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ee86080..6ff080a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b21c82f..de3c452 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d08ab3b..2b807b6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 687ae42..6adeea0 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -318,6 +318,7 @@ protected function loadConfiguration($name, Config $config) /** * Load theme languages. + * Reads ALL language files from theme stream and merges them. * * @param Config $config Configuration class * @return void @@ -328,13 +329,13 @@ protected function loadLanguages(Config $config) $locator = $this->grav['locator']; if ($config->get('system.languages.translations', true)) { - $language_file = $locator->findResource('theme://languages' . YAML_EXT); - if ($language_file) { + $language_files = array_reverse($locator->findResources('theme://languages' . YAML_EXT)); + foreach ($language_files as $language_file) { $language = CompiledYamlFile::instance($language_file)->content(); $this->grav['languages']->mergeRecursive($language); } - $languages_folder = $locator->findResource('theme://languages'); - if (file_exists($languages_folder)) { + $languages_folders = array_reverse($locator->findResources('theme://languages')); + foreach ($languages_folders as $languages_folder) { $languages = []; $iterator = new DirectoryIterator($languages_folder); foreach ($iterator as $file) { diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeCache.php b/system/src/Grav/Common/Twig/Node/TwigNodeCache.php index 930e597..0ed1fff 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php b/system/src/Grav/Common/Twig/Node/TwigNodeMarkdown.php index 93504c7..38194e6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 38f67e4..798c6ba 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeScript.php b/system/src/Grav/Common/Twig/Node/TwigNodeScript.php index 60bb3cf..46a0870 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php b/system/src/Grav/Common/Twig/Node/TwigNodeStyle.php index 87c80dd..05355f9 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php b/system/src/Grav/Common/Twig/Node/TwigNodeSwitch.php index 535d01c..43ae56f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 669af51..1a32a91 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f31a07c..da95a1d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 bf00ce8..371e89a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserMarkdown.php index 8533e87..9dab4ae 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b65126b..ab2bdde 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 42c78fb..b860631 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php b/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php index 0134491..c8d9544 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 24e555e..4540bbf 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 02fb7c8..bd4adab 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4cfab55..46af176 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 7284fb6..d4f710b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -289,8 +289,7 @@ public function processPage(PageInterface $item, $content = null) $output = ''; try { - // Process Modular Twig - if ($item->modularTwig()) { + if ($item->isModule()) { $twig_vars['content'] = $content; $template = $this->getPageTwigTemplate($item); $output = $content = $local_twig->render($template, $twig_vars); @@ -452,6 +451,7 @@ public function template($template) public function getPageTwigTemplate($page, &$format = null) { $template = $page->template(); + $default = $page->isModule() ? 'modular/default' : 'default'; $extension = $format ?: $page->templateFormat(); $twig_extension = $extension ? '.'. $extension .TWIG_EXT : TEMPLATE_EXT; $template_file = $this->template($page->template() . $twig_extension); @@ -459,26 +459,21 @@ public function getPageTwigTemplate($page, &$format = null) $page_template = null; $loader = $this->twig->getLoader(); - if ($loader instanceof ExistsLoaderInterface ) { - + if ($loader instanceof ExistsLoaderInterface) { if ($loader->exists($template_file)) { + // template.xxx.twig $page_template = $template_file; + } elseif ($twig_extension !== TEMPLATE_EXT && $loader->exists($template . TEMPLATE_EXT)) { + // template.html.twig + $page_template = $template . TEMPLATE_EXT; + $format = 'html'; + } elseif ($loader->exists($default . $twig_extension)) { + // default.xxx.twig + $page_template = $default . $twig_extension; } else { - // Try with template + html.twig - if ($twig_extension !== TEMPLATE_EXT && $loader->exists($template . TEMPLATE_EXT)) { - $page_template = $template . TEMPLATE_EXT; - $format = 'html'; - // Try with default and original extension - } elseif ($loader->exists('default' . $twig_extension)) { - $page_template = 'default' . $twig_extension; - // Else try default + default extension - } elseif (!$page->isModule() && $loader->exists('default' . TEMPLATE_EXT)) { - $page_template = 'default' . TEMPLATE_EXT; - $format = 'html'; - } else { - $page_template = 'modular/default' . TEMPLATE_EXT; - $format = 'html'; - } + // default.html.twig + $page_template = $default . TEMPLATE_EXT; + $format = 'html'; } } diff --git a/system/src/Grav/Common/Twig/TwigClockworkDataSource.php b/system/src/Grav/Common/Twig/TwigClockworkDataSource.php index b8eb0ee..11127b8 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a63cba8..2c1f4be 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ef4b31e..bebbdf1 100644 --- a/system/src/Grav/Common/Twig/TwigEnvironment.php +++ b/system/src/Grav/Common/Twig/TwigEnvironment.php @@ -3,7 +3,7 @@ /** * @package Grav\Common\Twig * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index 9996618..4c6fa9e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -192,6 +192,8 @@ public function getFunctions() new TwigFunction('repeat', [$this, 'repeatFunc']), new TwigFunction('regex_replace', [$this, 'regexReplace']), new TwigFunction('regex_filter', [$this, 'regexFilter']), + new TwigFunction('regex_match', [$this, 'regexMatch']), + new TwigFunction('regex_split', [$this, 'regexSplit']), new TwigFunction('string', [$this, 'stringFilter']), new TwigFunction('url', [$this, 'urlFunc']), new TwigFunction('json_decode', [$this, 'jsonDecodeFilter']), @@ -1157,6 +1159,38 @@ public function regexFilter($array, $regex, $flags = 0) return preg_grep($regex, $array, $flags); } + /** + * Twig wrapper for PHP's preg_match method + * + * @param string $subject the content to perform the match on + * @param string $pattern the regex pattern to use for match + * @param int $flags + * @param int $offset + * @return array|false returns the matches if there is at least one match in the subject for a given pattern or null if not. + */ + public function regexMatch($subject, $pattern, $flags = 0, $offset = 0) + { + if (preg_match($pattern, $subject, $matches, $flags, $offset) === false) { + return false; + } + + return $matches; + } + + /** + * Twig wrapper for PHP's preg_split method + * + * @param string $subject the content to perform the split on + * @param string $pattern the regex pattern to use for split + * @param int $limit the maximum possible splits for the given pattern + * @param int $flags + * @return array|false the resulting array after performing the split operation + */ + public function regexSplit($subject, $pattern, $limit = -1, $flags = 0) + { + return preg_split($pattern, $subject, $limit, $flags); + } + /** * redirect browser from twig * diff --git a/system/src/Grav/Common/Twig/WriteCacheFileTrait.php b/system/src/Grav/Common/Twig/WriteCacheFileTrait.php index 1b7e479..edab8e5 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ec842b5..dd98b16 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/User/Access.php b/system/src/Grav/Common/User/Access.php index 34766f4..6503c89 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 db89e9b..6ff95e7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 917e30e..d813817 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -110,7 +110,7 @@ public function update(array $data, array $files = []) } /** - * Save user without the username + * Save user * * @return void */ @@ -138,7 +138,10 @@ public function save() } $data = $this->items; - unset($data['username'], $data['authenticated'], $data['authorized']); + if ($username === $data['username']) { + unset($data['username']); + } + unset($data['authenticated'], $data['authorized']); $file->save($data); diff --git a/system/src/Grav/Common/User/DataUser/UserCollection.php b/system/src/Grav/Common/User/DataUser/UserCollection.php index 5be5001..3da7e2d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Common/User/Group.php b/system/src/Grav/Common/User/Group.php index 4043857..5be5386 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8f530be..3ad8d2c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e9b99d5..d892e82 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 56f0f8a..c345c4b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 c6af3b1..02827e3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0c71d26..5a6b749 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 58d1f7d..4b2319f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4e02d57..a076f0a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -1086,6 +1086,29 @@ public static function arrayFilterRecursive(Array $source, $fn) return $result; } + /** + * Flatten a multi-dimensional associative array into query params. + * + * @param array $array + * @param string $prepend + * @return array + */ + public static function arrayToQueryParams($array, $prepend = '') + { + $results = []; + foreach ($array as $key => $value) { + $name = $prepend ? $prepend . '[' . $key . ']' : $key; + + if (is_array($value)) { + $results = array_merge($results, static::arrayToQueryParams($value, $name)); + } else { + $results[$name] = $value; + } + } + + return $results; + } + /** * Flatten an array * @@ -1196,7 +1219,6 @@ public static function pathPrefixedByLangCode($string) if (count($parts) > 0 && in_array($parts[0], $languages_enabled)) { return $parts[0]; } - return false; } diff --git a/system/src/Grav/Common/Yaml.php b/system/src/Grav/Common/Yaml.php index f9dde79..5adbd0c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 be4e3c8..21cea87 100644 --- a/system/src/Grav/Console/Application/Application.php +++ b/system/src/Grav/Console/Application/Application.php @@ -3,7 +3,7 @@ /** * @package Grav\Console * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php b/system/src/Grav/Console/Application/CommandLoader/PluginCommandLoader.php index bff1e98..9b7b568 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 69bb234..df383f2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 45c8b13..739ca39 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 dd23d93..75e9eb7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8dbf5b6..a8a025d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -66,9 +66,9 @@ protected function serve(): int ProgressBar::setFormatDefinition('zip', 'Archiving %current% files [%bar%] %percent:3s%% %elapsed:6s% %message%'); - $this->progress = $io->createProgressBar(); + $this->progress = new ProgressBar($this->output, 100); $this->progress->setFormat('zip'); - $this->progress->setBarWidth(100); + /** @var Backups $backups */ $backups = Grav::instance()['backups']; diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php index fd4bbdb..8aa019c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9a61b04..daed2a5 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 99fdf35..5075d1d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b75a47f..08bc714 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 7eecbc2..d3924f8 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d8ba08c..d67cb1c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 06abbbd..4d234d7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 356e3dc..d865b4a 100644 --- a/system/src/Grav/Console/Cli/SandboxCommand.php +++ b/system/src/Grav/Console/Cli/SandboxCommand.php @@ -3,7 +3,7 @@ /** * @package Grav\Console\Cli * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Console/Cli/SchedulerCommand.php b/system/src/Grav/Console/Cli/SchedulerCommand.php index 8783407..c5385aa 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Console/Cli/SecurityCommand.php b/system/src/Grav/Console/Cli/SecurityCommand.php index fcf200a..7f728b6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -46,7 +46,7 @@ protected function serve(): int /** @var Grav $grav */ $grav = Grav::instance(); - $this->progress = $io->createProgressBar(count($grav['pages']->routes()) - 1); + $this->progress = new ProgressBar($this->output, count($grav['pages']->routes()) - 1); $this->progress->setFormat('Scanning %current% pages [%bar%] %percent:3s%% %elapsed:6s%'); $this->progress->setBarWidth(100); diff --git a/system/src/Grav/Console/Cli/ServerCommand.php b/system/src/Grav/Console/Cli/ServerCommand.php index 80bbe2a..77bce8b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 db6e573..a9628cd 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6c79632..044f1b0 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4c239e9..feb10d3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a79bd6a..e5c662b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9f46344..64d3597 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -90,6 +90,18 @@ protected function configure(): void InputOption::VALUE_NONE, 'Reverses the order of the output.' ) + ->addOption( + 'enabled', + 'e', + InputOption::VALUE_NONE, + 'Filters the results to only enabled Themes and Plugins.' + ) + ->addOption( + 'disabled', + 'd', + InputOption::VALUE_NONE, + 'Filters the results to only disabled Themes and Plugins.' + ) ->setDescription('Lists the plugins and themes available for installation') ->setHelp('The index command lists the plugins and themes available for installation') ; @@ -129,7 +141,7 @@ protected function serve(): int if (!empty($packages)) { $io->section('Packages table'); $table = new Table($io); - $table->setHeaders(['Count', 'Name', 'Slug', 'Version', 'Installed']); + $table->setHeaders(['Count', 'Name', 'Slug', 'Version', 'Installed', 'Enabled']); $index = 0; foreach ($packages as $slug => $package) { @@ -138,7 +150,8 @@ protected function serve(): int 'Name' => '' . Utils::truncate($package->name, 20, false, ' ', '...') . ' ', 'Slug' => $slug, 'Version'=> $this->version($package), - 'Installed' => $this->installed($package) + 'Installed' => $this->installed($package), + 'Enabled' => $this->enabled($package), ]; $table->addRow($row); @@ -195,6 +208,31 @@ private function installed(Package $package): string return !$installed ? 'not installed' : 'installed'; } + /** + * @param Package $package + * @return string + */ + private function enabled(Package $package): string + { + $package = $list[$package->slug] ?? $package; + $type = ucfirst(preg_replace('/s$/', '', $package->package_type)); + $method = 'is' . $type . 'Installed'; + $installed = $this->gpm->{$method}($package->slug); + + $result = ''; + if ($installed) { + $method = 'is' . $type . 'Enabled'; + $enabled = $this->gpm->{$method}($package->slug); + if ($enabled === true) { + $result = 'enabled'; + } elseif ($enabled === false) { + $result = 'disabled'; + } + } + + return $result; + } + /** * @param Packages $data * @return Packages @@ -210,10 +248,12 @@ public function filter(Packages $data): Packages } $filter = [ + $this->options['desc'], + $this->options['disabled'], + $this->options['enabled'], $this->options['filter'], $this->options['installed-only'], $this->options['updates-only'], - $this->options['desc'] ]; if (count(array_filter($filter))) { @@ -227,7 +267,7 @@ public function filter(Packages $data): Packages } // Filtering updatables only - if ($filter && $this->options['installed-only']) { + if ($filter && ($this->options['installed-only'] || $this->options['enabled'] || $this->options['disabled'])) { $method = ucfirst(preg_replace('/s$/', '', $package->package_type)); $function = 'is' . $method . 'Installed'; $filter = $this->gpm->{$function}($package->slug); @@ -240,6 +280,29 @@ public function filter(Packages $data): Packages $filter = $this->gpm->{$function}($package->slug); } + // Filtering enabled only + if ($filter && $this->options['enabled']) { + $method = ucfirst(preg_replace('/s$/', '', $package->package_type)); + + // Check if packaged is enabled. + $function = 'is' . $method . 'Enabled'; + $filter = $this->gpm->{$function}($package->slug); + } + + // Filtering disabled only + if ($filter && $this->options['disabled']) { + $method = ucfirst(preg_replace('/s$/', '', $package->package_type)); + + // Check if package is disabled. + $function = 'is' . $method . 'Enabled'; + $enabled_filter = $this->gpm->{$function}($package->slug); + + // Apply filtering results. + if (!( $enabled_filter === false)) { + $filter = false; + } + } + if (!$filter) { unset($data[$type][$slug]); } diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php index d7b9e94..5dddd32 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 706013e..202427c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index ac8d4d9..b840016 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 850c28a..ff91719 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -11,12 +11,14 @@ use Grav\Common\GPM\GPM; use Grav\Common\GPM\Installer; -use Grav\Common\GPM\Local\Package; +use Grav\Common\GPM\Local; +use Grav\Common\GPM\Remote; use Grav\Common\Grav; use Grav\Console\GpmCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Question\ConfirmationQuestion; +use Throwable; use function count; use function in_array; use function is_array; @@ -113,7 +115,7 @@ protected function serve(): int // Plugins need to be initialized in order to make clear-cache to work. try { $this->initializePlugins(); - } catch (\Throwable $e) { + } catch (Throwable $e) { $io->writeln("Some plugins failed to initialize: {$e->getMessage()}"); } @@ -148,11 +150,11 @@ protected function serve(): int /** * @param string $slug - * @param Package $package + * @param Local\Package|Remote\Package $package * @param bool $is_dependency * @return bool */ - private function uninstallPackage($slug, Package $package, $is_dependency = false): bool + private function uninstallPackage($slug, $package, $is_dependency = false): bool { $io = $this->getIO(); @@ -255,10 +257,10 @@ private function uninstallPackage($slug, Package $package, $is_dependency = fals /** * @param string $slug - * @param Package $package + * @param Local\Package|Remote\Package $package * @return bool */ - private function checkDestination(string $slug, Package $package): bool + private function checkDestination(string $slug, $package): bool { $io = $this->getIO(); @@ -297,10 +299,10 @@ private function checkDestination(string $slug, Package $package): bool * Check if package exists * * @param string $slug - * @param Package $package + * @param Local\Package|Remote\Package $package * @return int */ - private function packageExists(string $slug, Package $package): int + private function packageExists(string $slug, $package): int { $path = Grav::instance()['locator']->findResource($package->package_type . '://' . $slug); Installer::isValidDestination($path); diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index d5e90a8..300fe61 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0880ddd..124aad3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 685049e..816e872 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4634a1f..0249f14 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 df8301e..81041c0 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 bf0ac52..a71d7c0 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ae2c930..13aebf3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5fa1dbc..5e63c85 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 bd9d708..9dfd18b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 aeca40b..e724a09 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1717daa..ccc22cf 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4bce7c5..1f883a0 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b9aa5e1..0375716 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8de6df9..2c38afb 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 05574db..ac219da 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 177db0b..bfb5125 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0c995f2..76f5185 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b6fcd35..29e9e3b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 597f434..1995e15 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f8bb9bd..c043bf9 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 96ceab5..e189e3e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8b19366..efd9d31 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 dc00712..287f924 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6a8ab2a..1db3256 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 657f726..08a3435 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 82a5c20..50e9051 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e3900a5..190f422 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Collection/AbstractLazyCollection.php b/system/src/Grav/Framework/Collection/AbstractLazyCollection.php index 90b5048..af7ffe1 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 78e0dd5..474a3fb 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8273ce7..e024366 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 41ffacf..5dd8d55 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b259049..ce6e18f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 35bbfbe..3c9bf6a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 bd6a248..efcd5f3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6af9aa2..fb445a3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1853e7c..5c5eb43 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php b/system/src/Grav/Framework/ContentBlock/HtmlBlockInterface.php index d9fd161..616e4a2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php b/system/src/Grav/Framework/Controller/Traits/ControllerResponseTrait.php index 551301c..1c9181b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/DI/Container.php b/system/src/Grav/Framework/DI/Container.php index bd0c336..76434a3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6b53d12..b82bb33 100644 --- a/system/src/Grav/Framework/File/AbstractFile.php +++ b/system/src/Grav/Framework/File/AbstractFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 25c0c02..999f88a 100644 --- a/system/src/Grav/Framework/File/CsvFile.php +++ b/system/src/Grav/Framework/File/CsvFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8bf4ad5..114146f 100644 --- a/system/src/Grav/Framework/File/DataFile.php +++ b/system/src/Grav/Framework/File/DataFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ce431c4..1d4055a 100644 --- a/system/src/Grav/Framework/File/File.php +++ b/system/src/Grav/Framework/File/File.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 49ec9bb..f5ff3f2 100644 --- a/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/AbstractFormatter.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File\Formatter * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1f7158a..9d0a9a8 100644 --- a/system/src/Grav/Framework/File/Formatter/CsvFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/CsvFormatter.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File\Formatter * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 81b4f84..ec16959 100644 --- a/system/src/Grav/Framework/File/Formatter/IniFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/IniFormatter.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File\Formatter * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 88899fe..6b19690 100644 --- a/system/src/Grav/Framework/File/Formatter/JsonFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/JsonFormatter.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File\Formatter * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1ab36a2..8a624df 100644 --- a/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File\Formatter * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f22eed4..f045d71 100644 --- a/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/SerializeFormatter.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File\Formatter * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 316e7c4..32d4d29 100644 --- a/system/src/Grav/Framework/File/Formatter/YamlFormatter.php +++ b/system/src/Grav/Framework/File/Formatter/YamlFormatter.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File\Formatter * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 34c2bd9..6cda609 100644 --- a/system/src/Grav/Framework/File/IniFile.php +++ b/system/src/Grav/Framework/File/IniFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 cce51b2..49eda4f 100644 --- a/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php +++ b/system/src/Grav/Framework/File/Interfaces/FileFormatterInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 fb63cee..015b1ad 100644 --- a/system/src/Grav/Framework/File/Interfaces/FileInterface.php +++ b/system/src/Grav/Framework/File/Interfaces/FileInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 604ce7b..f3b0902 100644 --- a/system/src/Grav/Framework/File/JsonFile.php +++ b/system/src/Grav/Framework/File/JsonFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ddfd8c2..4ae3aa0 100644 --- a/system/src/Grav/Framework/File/MarkdownFile.php +++ b/system/src/Grav/Framework/File/MarkdownFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a10dd81..29224ce 100644 --- a/system/src/Grav/Framework/File/YamlFile.php +++ b/system/src/Grav/Framework/File/YamlFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\File * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ca82639..9b077d7 100644 --- a/system/src/Grav/Framework/Filesystem/Filesystem.php +++ b/system/src/Grav/Framework/Filesystem/Filesystem.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Filesystem * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php index 130f696..0e280a8 100644 --- a/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php +++ b/system/src/Grav/Framework/Filesystem/Interfaces/FilesystemInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Filesystem * - * @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Flex/Flex.php b/system/src/Grav/Framework/Flex/Flex.php index b1ca46a..8739282 100644 --- a/system/src/Grav/Framework/Flex/Flex.php +++ b/system/src/Grav/Framework/Flex/Flex.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3c95679..ee56ba4 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Flex/FlexDirectory.php b/system/src/Grav/Framework/Flex/FlexDirectory.php index c8efd24..0930748 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Flex/FlexDirectoryForm.php b/system/src/Grav/Framework/Flex/FlexDirectoryForm.php index 4339124..ba26b63 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 34fe2dc..83c98d6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -122,6 +122,10 @@ public function __construct(string $name, FlexObjectInterface $object, array $op $this->setFlashLookupFolder($directory->getBlueprint()->get('form/flash_folder') ?? 'tmp://forms/[SESSIONID]'); $this->form = $options['form'] ?? null; + if (!empty($options['reset'])) { + $this->getFlash()->delete(); + } + $this->initialize(); } diff --git a/system/src/Grav/Framework/Flex/FlexFormFlash.php b/system/src/Grav/Framework/Flex/FlexFormFlash.php index 94c26de..feb7a9e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d3e800a..98f6c8b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -38,6 +38,7 @@ * @template C of FlexCollectionInterface * @extends ObjectIndex * @implements FlexIndexInterface + * @mixin C */ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexIndexInterface { diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index f8abb73..9011745 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php index 27ab775..102dbf4 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexAuthorizeInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ff36d0d..6fd81fe 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCollectionInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 333f35a..ed045e2 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0e666bb..df6f7d6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 47203d9..7523241 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 45d5b33..9539a15 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ed1c691..91bf148 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexIndexInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b87bf08..3c5a103 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 eece60e..044ee61 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 74fb4e1..a1e3e3b 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexObjectInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0dca5ee..08c4335 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexStorageInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f3652ef..28e4888 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexTranslateInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 326e829..d553208 100644 --- a/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php +++ b/system/src/Grav/Framework/Flex/Pages/FlexPageCollection.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php index 08e6335..47a5e06 100644 --- a/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php +++ b/system/src/Grav/Framework/Flex/Pages/FlexPageIndex.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 af41415..09f9e60 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -354,8 +354,9 @@ public function setProperty($property, $value) */ public function setNestedProperty($property, $value, $separator = null) { - if (strpos($property, 'header.') === 0) { - $this->getProperty('header')->set(str_replace('header.', '', $property), $value, $separator); + $separator = $separator ?: '.'; + if (strpos($property, 'header' . $separator) === 0) { + $this->getProperty('header')->set(str_replace('header' . $separator, '', $property), $value, $separator); return $this; } @@ -372,8 +373,9 @@ public function setNestedProperty($property, $value, $separator = null) */ public function unsetNestedProperty($property, $separator = null) { - if (strpos($property, 'header.') === 0) { - $this->getProperty('header')->undef(str_replace('header.', '', $property), $separator); + $separator = $separator ?: '.'; + if (strpos($property, 'header' . $separator) === 0) { + $this->getProperty('header')->undef(str_replace('header' . $separator, '', $property), $separator); return $this; } diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageAuthorsTrait.php index b775edb..d7af40f 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 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f17f276..6aff732 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -810,10 +810,14 @@ protected function processMarkdown($content, array $options = []): string $keepTwig = (bool)($options['keep_twig'] ?? false); if ($keepTwig) { + $token = [ + '/' . Utils::generateRandomString(3), + Utils::generateRandomString(3) . '/' + ]; // Base64 encode any twig. $content = preg_replace_callback( - ['/({#)(.*?)(#})/mu', '/({{)(.*?)(}})/mu', '/({%)(.*?)(%})/mu'], - static function ($matches) { return $matches[1] . base64_encode($matches[2]) . $matches[3]; }, + ['/({#.*?#})/mu', '/({{.*?}})/mu', '/({%.*?%})/mu'], + static function ($matches) use ($token) { return $token[0] . base64_encode($matches[1]) . $token[1]; }, $content ); } @@ -823,8 +827,8 @@ static function ($matches) { return $matches[1] . base64_encode($matches[2]) . $ if ($keepTwig) { // Base64 decode the encoded twig. $content = preg_replace_callback( - ['/({#)(.*?)(#})/mu', '/({{)(.*?)(}})/mu', '/({%)(.*?)(%})/mu'], - static function ($matches) { return $matches[1] . base64_decode($matches[2]) . $matches[3]; }, + ['`' . $token[0] . '([A-Za-z0-9+/]+={0,2})' . $token[1] . '`mu'], + static function ($matches) { return base64_decode($matches[1]); }, $content ); } diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php index c6a9475..ba81d8f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -619,7 +619,7 @@ public function metadata($var = null): array // Get initial metadata for the page $metadata = array_merge($defaultMetadata, $siteMetadata, $headerMetadata); - $header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible']; + $header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible', 'content-security-policy']; $escape = !$config->get('system.strict_mode.twig_compat', false) || $config->get('system.twig.autoescape', true); // Build an array of meta objects.. @@ -643,7 +643,7 @@ public function metadata($var = null): array if (in_array($key, $header_tag_http_equivs, true)) { $this->_metadata[$key] = [ 'http_equiv' => $key, - 'content' => $escape ? htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8') : $value + 'content' => $escape ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : $value ]; } elseif ($key === 'charset') { $this->_metadata[$key] = ['charset' => $escape ? htmlspecialchars($value, ENT_QUOTES | ENT_HTML5, 'UTF-8') : $value]; diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageRoutableTrait.php index 26b3b60..0029739 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -150,11 +150,6 @@ public function url($include_host = false, $canonical = false, $include_base = t $uri = $grav['uri']; $url = $uri->rootUrl($include_host) . '/' . trim($route, '/') . $this->urlExtension(); - // trim trailing / if not root - if ($url !== '/') { - $url = rtrim($url, '/'); - } - return Uri::filterPath($url); } diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageTranslateTrait.php index a1aa054..877fec1 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 45b9a9e..97384ab 100644 --- a/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -20,7 +20,6 @@ use Grav\Framework\File\Formatter\YamlFormatter; use Grav\Framework\File\Interfaces\FileFormatterInterface; use Grav\Framework\Flex\Interfaces\FlexStorageInterface; -use RocketTheme\Toolbox\File\File; use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; use RuntimeException; use function is_array; @@ -37,6 +36,8 @@ abstract class AbstractFilesystemStorage implements FlexStorageInterface protected $keyField = 'storage_key'; /** @var int */ protected $keyLen = 32; + /** @var bool */ + protected $caseSensitive = true; /** * @return bool @@ -98,7 +99,7 @@ public function buildStorageKeyParams(array $keys): string public function extractKeysFromRow(array $row): array { return [ - 'key' => $row[$this->keyField] ?? '' + 'key' => $this->normalizeKey($row[$this->keyField] ?? '') ]; } @@ -201,6 +202,19 @@ protected function generateKey(): string return substr(hash('sha256', random_bytes($this->keyLen)), 0, $this->keyLen); } + /** + * @param string $key + * @return string + */ + public function normalizeKey(string $key): string + { + if ($this->caseSensitive === true) { + return $key; + } + + return mb_strtolower($key); + } + /** * Checks if a key is valid. * diff --git a/system/src/Grav/Framework/Flex/Storage/FileStorage.php b/system/src/Grav/Framework/Flex/Storage/FileStorage.php index b854555..2dc0757 100644 --- a/system/src/Grav/Framework/Flex/Storage/FileStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/FileStorage.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -13,6 +13,7 @@ use FilesystemIterator; use Grav\Framework\Flex\Interfaces\FlexStorageInterface; +use RuntimeException; use SplFileInfo; /** @@ -50,6 +51,73 @@ public function getMediaPath(string $key = null): ?string return $key ? "{$path}/{$key}" : $path; } + /** + * @param string $src + * @param string $dst + * @return bool + */ + public function copyRow(string $src, string $dst): bool + { + if ($this->hasKey($dst)) { + throw new RuntimeException("Cannot copy object: key '{$dst}' is already taken"); + } + + if (!$this->hasKey($src)) { + return false; + } + + return true; + } + + /** + * {@inheritdoc} + * @see FlexStorageInterface::renameRow() + */ + public function renameRow(string $src, string $dst): bool + { + if (!$this->hasKey($src)) { + return false; + } + + // Remove old file. + $path = $this->getPathFromKey($src); + $file = $this->getFile($path); + $file->delete(); + + return true; + } + + /** + * @param string $src + * @param string $dst + * @return bool + */ + protected function copyFolder(string $src, string $dst): bool + { + // Nothing to copy. + return true; + } + + /** + * @param string $src + * @param string $dst + * @return bool + */ + protected function moveFolder(string $src, string $dst): bool + { + // Nothing to move. + return true; + } + + /** + * @param string $key + * @return bool + */ + protected function canDeleteFolder(string $key): bool + { + return false; + } + /** * {@inheritdoc} */ diff --git a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php index f6da141..acdab78 100644 --- a/system/src/Grav/Framework/Flex/Storage/FolderStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/FolderStorage.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -242,7 +242,6 @@ public function copyRow(string $src, string $dst): bool return $this->copyFolder($srcPath, $dstPath); } - /** * {@inheritdoc} * @see FlexStorageInterface::renameRow() @@ -360,7 +359,12 @@ protected function getKeyFromPath(string $path): string */ protected function prepareRow(array &$row): void { - unset($row[$this->keyField]); + if (array_key_exists($this->keyField, $row)) { + $key = $row[$this->keyField]; + if ($key === $this->normalizeKey($key)) { + unset($row[$this->keyField]); + } + } } /** @@ -401,6 +405,8 @@ protected function saveRow(string $key, array $row): array $key = $this->getNewKey(); } + $key = $this->normalizeKey($key); + // Check if the row already exists and if the key has been changed. $oldKey = $row['__META']['storage_key'] ?? null; if (is_string($oldKey) && $oldKey !== $key) { @@ -679,6 +685,7 @@ protected function initOptions(array $options): void $this->indexed = (bool)($options['indexed'] ?? false); $this->keyField = $options['key'] ?? 'storage_key'; $this->keyLen = (int)($options['key_len'] ?? 32); + $this->caseSensitive = (bool)($options['case_sensitive'] ?? true); $variables = ['FOLDER' => '%1$s', 'KEY' => '%2$s', 'KEY:2' => '%3$s', 'FILE' => '%4$s', 'EXT' => '%5$s']; $pattern = Utils::simpleTemplate($pattern, $variables); diff --git a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php index ee4393f..df889ce 100644 --- a/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php +++ b/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php index 0e6351b..8cbd1d5 100644 --- a/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php +++ b/system/src/Grav/Framework/Flex/Traits/FlexAuthorizeTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4277471..c03a23d 100644 --- a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php +++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -25,6 +25,8 @@ use RuntimeException; use function in_array; use function is_array; +use function is_callable; +use function is_int; use function is_object; use function is_string; use function strpos; @@ -73,6 +75,10 @@ public function getMedia() return $media; } + /** + * @param string $field + * @return array|null + */ protected function getFieldSettings(string $field): ?array { if ($field === '') { @@ -109,6 +115,71 @@ protected function getMediaFieldSettings(string $field): array return $settings + ['accept' => '*', 'limit' => 1000, 'self' => true]; } + + protected function getMediaFields(): array + { + // Load settings for the field. + $schema = $this->getBlueprint()->schema(); + + $list = []; + foreach ($schema->getState()['items'] as $field => $settings) { + if (isset($settings['type']) && (in_array($settings['type'], ['avatar', 'file', 'pagemedia']) || !empty($settings['destination']))) { + $list[] = $field; + } + } + + return $list; + } + + /** + * @param array|mixed $value + * @param array $settings + * @return array|mixed + */ + protected function parseFileProperty($value, array $settings = []) + { + if (!is_array($value)) { + return $value; + } + + $media = $this->getMedia(); + $originalMedia = is_callable([$this, 'getOriginalMedia']) ? $this->getOriginalMedia() : null; + + $list = []; + foreach ($value as $filename => $info) { + if (!is_array($info)) { + $list[$filename] = $info; + continue; + } + + if (is_int($filename)) { + $filename = $info['path'] ?? $info['name']; + } + + /** @var Medium|null $thumbFile */ + $imageFile = $media[$filename]; + + /** @var Medium|null $thumbFile */ + $originalFile = $originalMedia ? $originalMedia[$filename] : null; + + $url = $imageFile ? $imageFile->url() : null; + $originalUrl = $originalFile ? $originalFile->url() : null; + $list[$filename] = [ + 'name' => $info['name'] ?? null, + 'type' => $info['type'] ?? null, + 'size' => $info['size'] ?? null, + 'path' => $filename, + 'thumb_url' => $url, + 'image_url' => $originalUrl ?? $url + ]; + if ($originalFile) { + $list[$filename]['cropData'] = (object)($originalFile->metadata()['upload']['crop'] ?? []); + } + } + + return $list; + } + /** * @param UploadedFileInterface $uploadedFile * @param string|null $filename diff --git a/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php index 0adfff7..9f7380c 100644 --- a/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php +++ b/system/src/Grav/Framework/Flex/Traits/FlexRelatedDirectoryTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Common\Flex * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Form/FormFlash.php b/system/src/Grav/Framework/Form/FormFlash.php index def7e5e..00aab28 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Form/FormFlashFile.php b/system/src/Grav/Framework/Form/FormFlashFile.php index 108852c..dc510e2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 edf8e36..d21d4aa 100644 --- a/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php +++ b/system/src/Grav/Framework/Form/Interfaces/FormFactoryInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Form * - * @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 61fd290..d51bd8d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f2d7992..9815646 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 - 2018 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b5256f8..8dfed19 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 af3efb5..7a7d9d3 100644 --- a/system/src/Grav/Framework/Interfaces/RenderInterface.php +++ b/system/src/Grav/Framework/Interfaces/RenderInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Interfaces * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 846e368..a3587d8 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 20ecb3e..2c5a4b3 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 56994ac..fef475f 100644 --- a/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php +++ b/system/src/Grav/Framework/Media/Interfaces/MediaManipulationInterface.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Media * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e22f246..dc7f148 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a76dcc2..de5cc7a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 c805678..e048565 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 96b2811..120c1a4 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 707359a..7409f4c 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 c88591e..0f0f89f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 216421f..2bbe937 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 81a3a25..fa0920b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Object/Base/ObjectTrait.php b/system/src/Grav/Framework/Object/Base/ObjectTrait.php index be29579..d4e324b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 be733b2..d8f1524 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3071d8e..0e2373e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 bc008a2..4d7a880 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8768826..3a43981 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 be81731..e8ec2c1 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 47a105a..309c0d6 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5e34684..0d82434 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Object/ObjectIndex.php b/system/src/Grav/Framework/Object/ObjectIndex.php index 3d44239..2c13765 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php b/system/src/Grav/Framework/Object/Property/ArrayPropertyTrait.php index df8e3c7..fa3fed1 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 7d5b90c..d5baddb 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 eb2e791..584e812 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 a397392..435220a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 c05414d..dbeb5c4 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e98027e..0be21ec 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -47,7 +47,9 @@ class AbstractPagination implements PaginationInterface 'display' => 5, 'opening' => 0, 'ending' => 0, - 'url' => null + 'url' => null, + 'param' => null, + 'use_query_param' => false ]; /** @var array */ private $items; @@ -126,14 +128,23 @@ public function getPage(int $page, string $label = null): ?PaginationPage } $start = ($page - 1) * $this->limit; - if ($this->getOptions()['type'] === 'page') { - $name = 'page'; + $type = $this->getOptions()['type']; + $param = $this->getOptions()['param']; + $useQuery = $this->getOptions()['use_query_param']; + if ($type === 'page') { + $param = $param ?? 'page'; $offset = $page; } else { - $name = 'start'; + $param = $param ?? 'start'; $offset = $start; } + if ($useQuery) { + $route = $this->route->withQueryParam($param, $offset); + } else { + $route = $this->route->withGravParam($param, $offset); + } + return new PaginationPage( [ 'label' => $label ?? (string)$page, @@ -142,7 +153,7 @@ public function getPage(int $page, string $label = null): ?PaginationPage 'offset_end' => min($start + $this->limit, $this->total) - 1, 'enabled' => $page !== $this->page || $this->viewAll, 'active' => $page === $this->page, - 'route' => $this->route->withGravParam($name, $offset) + 'route' => $route ] ); } diff --git a/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php b/system/src/Grav/Framework/Pagination/AbstractPaginationPage.php index e66cf85..95ff8af 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 184ec4b..56d3361 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ca90143..b90594d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e585277..e602872 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 27fadd2..63ceb5f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5e8797c..85d802f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b92c0d4..cd65fd9 100644 --- a/system/src/Grav/Framework/Psr7/Request.php +++ b/system/src/Grav/Framework/Psr7/Request.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 737fe78..6cb67e0 100644 --- a/system/src/Grav/Framework/Psr7/Response.php +++ b/system/src/Grav/Framework/Psr7/Response.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 de29a15..4084834 100644 --- a/system/src/Grav/Framework/Psr7/ServerRequest.php +++ b/system/src/Grav/Framework/Psr7/ServerRequest.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 c27191d..a5a1043 100644 --- a/system/src/Grav/Framework/Psr7/Stream.php +++ b/system/src/Grav/Framework/Psr7/Stream.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 17310b9..39e3818 100644 --- a/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/MessageDecoratorTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 b842550..13f4c6f 100644 --- a/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5a8e1d1..7b62c3c 100644 --- a/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/ResponseDecoratorTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1d92ce9..33c26e0 100644 --- a/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/ServerRequestDecoratorTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d083759..db1e746 100644 --- a/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/StreamDecoratorTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 acb6aa6..e0c65bd 100644 --- a/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/UploadedFileDecoratorTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 6f61fb3..607d757 100644 --- a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d058f9a..f136742 100644 --- a/system/src/Grav/Framework/Psr7/UploadedFile.php +++ b/system/src/Grav/Framework/Psr7/UploadedFile.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 95cafc7..c920b33 100644 --- a/system/src/Grav/Framework/Psr7/Uri.php +++ b/system/src/Grav/Framework/Psr7/Uri.php @@ -5,7 +5,7 @@ /** * @package Grav\Framework\Psr7 * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 3ff8f2e..451e586 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 42eaa0e..28a226a 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 8817ce5..1b18473 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 ab56ba1..747c0ca 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 2ae3101..6079964 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 dba0b43..a9935ee 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 97d5c0c..5b03805 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 e890585..1b5a79e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d7554b7..f9a7fa7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 9d8213c..68baf55 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 f24df0a..5ad948b 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 83d8c8f..5d854a2 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 5b656e9..ddab08d 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ @@ -11,6 +11,8 @@ use ArrayIterator; use Exception; +use Grav\Common\Debugger; +use Grav\Common\Grav; use Grav\Common\User\Interfaces\UserInterface; use Grav\Framework\Session\Exceptions\SessionException; use RuntimeException; @@ -28,6 +30,7 @@ class Session implements SessionInterface protected $options = []; /** @var bool */ protected $started = false; + /** @var Session */ protected static $instance; @@ -216,12 +219,22 @@ public function start($readonly = false) // Should not happen usually. This could be attack or due to unstable network. Destroy this session. $this->invalidate(); - throw new RuntimeException('Your session was destroyed.', 500); + throw new RuntimeException('Obsolete session access.', 500); } // Not fully expired yet. Could be lost cookie by unstable network. Start session with new session id. session_write_close(); + + // Start session with new session id. + $useStrictMode = $options['use_strict_mode'] ?? 0; + if ($useStrictMode) { + ini_set('session.use_strict_mode', '0'); + } session_id($newId); + if ($useStrictMode) { + ini_set('session.use_strict_mode', '1'); + } + $success = @session_start($options); if (!$success) { $last = error_get_last(); @@ -246,22 +259,7 @@ public function start($readonly = false) // Extend the lifetime of the session. if ($sessionExists) { - $params = session_get_cookie_params(); - - $cookie_options = array ( - 'expires' => time() + $params['lifetime'], - 'path' => $params['path'], - 'domain' => $params['domain'], - 'secure' => $params['secure'], - 'httponly' => $params['httponly'], - 'samesite' => $params['samesite'] - ); - - setcookie( - $sessionName, - session_id(), - $cookie_options - ); + $this->setCookie(); } return $this; @@ -281,20 +279,29 @@ public function regenerateId() return $this; } - // TODO: session_create_id() segfaults in PHP 7.3 (PHP bug #73461), remove phpstan rule when fixing this one. - $newId = 0; // session_create_id(); + // TODO: session_create_id() segfaults in PHP 7.3 (PHP bug #73461), remove phpstan rule when removing this one. + if (PHP_VERSION_ID < 70400) { + $newId = 0; + } else { + // Session id creation may fail with some session storages. + $newId = @session_create_id() ?: 0; + } // Set destroyed timestamp for the old session as well as pointer to the new id. $this->__set('session_destroyed', time()); $this->__set('session_new_id', $newId); // Keep the old session alive to avoid lost sessions by unstable network. - // TODO: remove session_regenerate_id() and use session_create_id() from above when not in PHP 7.3 (PHP bug #73461). - session_regenerate_id(false); - session_write_close(); + if (!$newId) { + /** @var Debugger $debugger */ + $debugger = Grav::instance()['debugger']; + $debugger->addMessage('Session fixation lost session detection is turned of due to server limitations.', 'warning'); + + session_regenerate_id(false); + } else { + session_write_close(); - // Start session with new session id. - if ($newId) { + // Start session with new session id. $useStrictMode = $this->options['use_strict_mode'] ?? 0; if ($useStrictMode) { ini_set('session.use_strict_mode', '0'); @@ -303,8 +310,19 @@ public function regenerateId() if ($useStrictMode) { ini_set('session.use_strict_mode', '1'); } + + $this->removeCookie(); + + $success = @session_start($this->options); + if (!$success) { + $last = error_get_last(); + $error = $last ? $last['message'] : 'Unknown error'; + + throw new RuntimeException($error); + } + + $this->onSessionStart(); } - session_start(); // New session does not have these. $this->__unset('session_destroyed'); @@ -331,6 +349,8 @@ public function invalidate() 'samesite' => $params['samesite'] ); + $this->removeCookie(); + setcookie( session_name(), '', @@ -442,6 +462,61 @@ protected function onSessionStart(): void { } + /** + * @return void + */ + protected function setCookie(): void + { + $params = session_get_cookie_params(); + + $cookie_options = array ( + 'expires' => time() + $params['lifetime'], + 'path' => $params['path'], + 'domain' => $params['domain'], + 'secure' => $params['secure'], + 'httponly' => $params['httponly'], + 'samesite' => $params['samesite'] + ); + + $this->removeCookie(); + + setcookie( + session_name(), + session_id(), + $cookie_options + ); + } + + protected function removeCookie(): void + { + $search = " {$this->getName()}="; + $cookies = []; + $found = false; + + foreach (headers_list() as $header) { + // Identify cookie headers + if (strpos($header, 'Set-Cookie:') === 0) { + // Add all but session cookie(s). + if (!str_contains($header, $search)) { + $cookies[] = $header; + } else { + $found = true; + } + } + } + + // Nothing to do. + if (false === $found) { + return; + } + + // Remove all cookies and put back all but session cookie. + header_remove('Set-Cookie'); + foreach($cookies as $cookie) { + header($cookie, false); + } + } + /** * @param string $key * @param mixed $value diff --git a/system/src/Grav/Framework/Session/SessionInterface.php b/system/src/Grav/Framework/Session/SessionInterface.php index 91ca9ce..43ca40f 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 1ec86c6..c43496e 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 237aa0a..f7724b7 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Framework/Uri/UriPartsFilter.php b/system/src/Grav/Framework/Uri/UriPartsFilter.php index 4761f2d..71a5135 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 d104274..def3446 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 4471107..145b7c9 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/src/Grav/Installer/Versions.php b/system/src/Grav/Installer/Versions.php index c66b344..cc26875 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 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 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 0747854..9af2055 100644 --- a/system/src/Grav/Installer/YamlUpdater.php +++ b/system/src/Grav/Installer/YamlUpdater.php @@ -3,7 +3,7 @@ /** * @package Grav\Installer * - * @copyright Copyright (C) 2015 - 2020 Trilby Media, LLC. All rights reserved. + * @copyright Copyright (c) 2015 - 2021 Trilby Media, LLC. All rights reserved. * @license MIT License; see LICENSE file for details. */ diff --git a/system/templates/partials/metadata.html.twig b/system/templates/partials/metadata.html.twig index bf323e7..fcf1217 100644 --- a/system/templates/partials/metadata.html.twig +++ b/system/templates/partials/metadata.html.twig @@ -1,3 +1,3 @@ {% for meta in page.metadata %} - -{% endfor %} \ No newline at end of file + +{% endfor %}