init with kirby, vue and pagedjs interactive
This commit is contained in:
commit
dc0ae26464
968 changed files with 211706 additions and 0 deletions
32
public/kirby/.editorconfig
Normal file
32
public/kirby/.editorconfig
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
# PHP PSR-12 Coding Standards
|
||||
# https://www.php-fig.org/psr/psr-12/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.php]
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
|
||||
[*.vue.php]
|
||||
indent_size = 2
|
||||
insert_final_newline = false
|
||||
|
||||
[views/**/*.php]
|
||||
indent_size = 2
|
||||
insert_final_newline = false
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
101
public/kirby/CONTRIBUTING.md
Normal file
101
public/kirby/CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
# Contributing
|
||||
|
||||
:+1::tada: First off, yes, you can contribute and thanks already for taking the time if you do! :tada::+1:
|
||||
|
||||
## How we organize code
|
||||
|
||||
To keep track of different states of our code (current release, bugfixes, features) we use branches:
|
||||
|
||||
| Branch | Used for | PRs allowed? |
|
||||
| --------------- | ------------------------------------------------------------------------ | --------------------------- |
|
||||
| `main` | Latest released version | ❌ |
|
||||
| `develop-patch` | Working branch for next patch release, e.g. `4.0.x` | ✅ |
|
||||
| `develop-minor` | Working branch for next minor release, e.g. `4.x.0` | ✅ |
|
||||
| `v5/develop` | Working branch for next major release, e.g. `5.0.0` | ✅ |
|
||||
| `fix/*` | Temporary branches for single bugfix | - |
|
||||
| `feature/*` | Temporary branches for single feature | - |
|
||||
| `release/*` | Pre-releases in testing before they are merged into `main` when released | only during release testing |
|
||||
|
||||
We will review all pull requests (PRs) to `develop-patch`, `develop-minor` and `v5/develop` and merge them if accepted, once an appropriate version is upcoming. Please understand that this might not be the immediate next release and might take some time.
|
||||
|
||||
## How you can contribute
|
||||
|
||||
### Report a bug
|
||||
|
||||
When you find a bug, the first step to fixing it is to help us understand and reproduce the bug as best as possible. When you create a bug report, please include as many details as possible. Fill out [the template](https://github.com/getkirby/kirby/issues/new?template=bug_report.md) because the requested information helps us resolve issues so much faster.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
For bug fixes, please create a new branch following the name scheme: `fix/issue_number-bug-x`, e.g. `fix/234-this-nasty-bug`. Limit bug fix PRs to a single bug. **Do not mix multiple bug fixes in a single PR.** This will make it easier for us to review the fix and merge it.
|
||||
|
||||
- Always send bug fix PRs against the `develop-patch` branch––not `main`.
|
||||
- Add a helpful description of what the PR does if it is not 100% self-explanatory.
|
||||
- Every bug fix should include a [unit test](#tests) to avoid future regressions. Let us know if you need help with that.
|
||||
- Make sure your code [style](#style) matches ours and includes [comments/in-code documentation](#documentation).
|
||||
- Make sure your branch is up to date with the latest state on the `develop-patch` branch. [Rebase](https://help.github.com/articles/about-pull-request-merges/) changes before you send the PR.
|
||||
- Please *don't* commit updated dist files in the `panel/dist` folder to avoid merge conflicts. We only build the dist files on release. Your branch should only contain changes to the source files.
|
||||
|
||||
### Features
|
||||
|
||||
For features create a new branch following the name scheme: `feature/issue_number-feature-x`, e.g. `feature/123-awesome-function`. Our [feedback platform](https://feedback.getkirby.com) can be a good source of highly requested features. Maybe your feature idea already exists and you can get valuable feedback from other Kirby users. Focus on a single feature per PR. Don't mix features!
|
||||
|
||||
- Always send feature PRs against the `develop-minor` branch––not `main`.
|
||||
- Add a helpful description of what the PR does.
|
||||
- New features should include [unit tests](#tests). Let us know if you need help with that.
|
||||
- Make your code [style](#style) matches ours and includes [comments/in-code documentation](#documentation).
|
||||
- Make sure your branch is up to date with the latest state on the `develop-minor` branch. [Rebase](https://help.github.com/articles/about-pull-request-merges/) changes before you send the PR.
|
||||
- Please *don't* commit updated dist files in the `panel/dist` folder to avoid merge conflicts. We only build the dist files on release. Your branch should only contain changes to the source files.
|
||||
|
||||
We try to bundle features in our major releases, e.g. `5.0`. That is why we might only review and, if accepted, merge your PR once an appropriate release is upcoming. Please understand that we cannot merge all feature ideas or that it might take a while. Check out the [roadmap](https://roadmap.getkirby.com) to see upcoming releases.
|
||||
|
||||
### Translations
|
||||
|
||||
We are really happy about any help with translations. Please do not directly translate JSON files, though. We use a service called Transifex to handle [all translations](https://translation.getkirby.com/). Create an account there and send us a request to join our translator group. Additionally, also send an email to <support@getkirby.com>. Unfortunately, we don't get notified properly about new translator requests.
|
||||
|
||||
## How we write code
|
||||
|
||||
### Style
|
||||
|
||||
#### Backend (PHP)
|
||||
|
||||
We use [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to ensure a consistent style for our PHP code. It is mainly based on [PSR-12](https://www.php-fig.org/psr/psr-12/). [Install PHP CS Fixer globally](https://github.com/FriendsOfPHP/PHP-CS-Fixer#globally-composer) via Composer and then run `composer fix` in the `kirby` folder to check for inconsistencies and fix them. Our automated PR checks will fail if there are code style issues with your code.
|
||||
|
||||
#### Frontend/Panel (JavaScript, Vue)
|
||||
|
||||
We use [Prettier](https://prettier.io) to ensure a consistent style for our JavaScript and Vue code. After running `npm install` in the `kirby/panel` folder, you can run `npm run format` to check for inconsistencies and fix them. We also use [ESLint](https://eslint.org) which you can use by running `npm run lint` and/or `npm run lint:fix`.
|
||||
|
||||
### Documentation
|
||||
|
||||
In-code documentation and comments help us understand each other's code - or our own code after some months. Especially when matters get more complicated, we try to add a lot of comments to explain what the code does or why we implemented it like this. Even better than good comments is good code that is easy to understand.
|
||||
|
||||
#### Backend (PHP)
|
||||
|
||||
We use PHP [DocBlocks](https://docs.phpdoc.org/guide/references/phpdoc/basic-syntax.html#what-is-a-docblock) for classes and methods.
|
||||
|
||||
#### Frontend/Panel (JavaScript, Vue)
|
||||
|
||||
We use [JSDoc](https://jsdoc.app) for documenting JavaScript code, especially for [Vue components](https://vue-styleguidist.github.io/docs/Documenting.html).
|
||||
|
||||
#### Public documentation
|
||||
|
||||
We also document Kirby on the Kirby website at <https://getkirby.com>. However we recommend to wait with writing public documentation until the feature PR is merged. If you don't know where the documentation for a feature best belongs, don't worry. We can take care of writing the docs.
|
||||
|
||||
### Tests
|
||||
|
||||
Unit and integration tests help us prevent regressions when we make changes to the code. Every bug fix should also add a unit test for the fixed bug to make sure we won't re-introduce the same problem later down the road. Every new feature should be accompanied by unit tests to protect it from breaking through future changes.
|
||||
|
||||
#### Backend (PHP)
|
||||
|
||||
We use [PHPUnit](https://phpunit.de) for unit test for our PHP code. You can find all existing tests in the [`kirby/tests` subfolders](https://github.com/getkirby/kirby/tree/main/tests). Take a look to see how we usually structure our tests.
|
||||
|
||||
#### Frontend/Panel (JavaScript, Vue)
|
||||
|
||||
The Panel doesn't have extensive test coverage yet. That's an area we are still trying to improve.
|
||||
|
||||
We use [vitest](https://vitest.dev) for unit tests for JavaScript and Vue components - `.test.js` files next to the actual JavaScript/Vue file.
|
||||
|
||||
## And last…
|
||||
|
||||
Let us know [in the forum](https://forum.getkirby.com) if you have questions.
|
||||
|
||||
**And once more: thank you!** :+1::tada:
|
||||
308
public/kirby/LICENSE.md
Normal file
308
public/kirby/LICENSE.md
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
# Kirby License Agreement
|
||||
|
||||
Published: March 18, 2025
|
||||
Source: https://getkirby.com/license/2025-03-18
|
||||
|
||||
## About this Agreement
|
||||
|
||||
While Kirby's source code is publicly available, Kirby is **not free**. To use Kirby in production, you need to [purchase a license](https://getkirby.com/buy).
|
||||
|
||||
This End User License Agreement (the **"Agreement"**) is fundamental to the relationship between you and us. Therefore we recommend to read this Agreement carefully before you download, install or use Kirby.
|
||||
|
||||
If you do not agree to this Agreement, please do not download, install or use Kirby. Installation or use of Kirby signifies that you have read, understood, and agreed to be bound by this Agreement.
|
||||
|
||||
## Summary
|
||||
|
||||
This section summarizes the most important conditions of this Agreement to give you a quick overview:
|
||||
|
||||
- With your purchase you obtain a license. A license allows you to use Kirby according to this Agreement.
|
||||
- Each project (defined by its URL) needs its own license. You need to purchase the right license for your project and/or client. You can find our license variants on <https://getkirby.com/buy>.
|
||||
- In some explicitly listed cases, you can use Kirby without having to purchase a license. In these cases, this Agreement grants you the license directly. There are also cases where you can request a free or discounted license from us.
|
||||
- Each license includes any Kirby version that gets released within three years from the date when you first activated your license. We also provide free security updates for older versions that may protect your project beyond three years.
|
||||
- After those three years, you can continue to use Kirby for your project with any of these versions as long as you want.
|
||||
- To use any newer version released after this time, you will need to upgrade your license.
|
||||
- Upgrading your license extends the timeframe for an additional three years during which you can use new releases. You can perform the upgrade at any time.
|
||||
- You have the right to transfer or reassign a license to another person or project if needed.
|
||||
- There are some restrictions for use of Kirby that you can find below.
|
||||
|
||||
For the full license details, please read the Agreement in full. Only the following sections are legally binding.
|
||||
|
||||
## Definitions
|
||||
|
||||
Before we get started with the conditions of the Agreement, let's define the terms that will be used throughout it:
|
||||
|
||||
- When we refer to **"You"**, we mean the licensee. Before purchasing Kirby, that's the individual or company that has downloaded and/or installed Kirby for a Development Installation or Private Installation. When used for a Public Site, the licensee is the individual or company that has purchased the Kirby license or received a free license from Us on request. If you work on a client project and have purchased the Kirby license for your client, you (and _not_ the client) are the licensee.
|
||||
- When we refer to **"We"**/**"Us"**/**"Our"**, we mean the licensor, the Content Folder GmbH & Co. KG. You can find Our company and contact information on Our [contact page](https://getkirby.com/contact).
|
||||
- **"Client"** refers to the individual or company that is primarily responsible for and benefits from the Website, unless they are the licensee. You might create or work on the Website on behalf of the Client, either directly or through other intermediaries (e.g. as a freelancer for an agency that works on a client website).
|
||||
- A **"Website"** is a single Kirby project that is defined by its domain name and root directory (e.g. `https://sub.example.com` or `https://example.com/example/`). Each (sub)domain and root directory is a separate Website, even if the projects are related in any way. Exception: If You use the cross-domain multi-language feature with the same `content` folder, these domains count as the same Website.
|
||||
You may use Kirby as a headless backend or as a static site generator. In these cases the Website is defined by the domain and root directory of the user- or visitor-facing frontend(s).
|
||||
- A **"Development Installation"** is a Website that is installed purely for the purposes of development and client preview. It must only be accessible by a restricted number of users (like on a personal computer, on a server in a network with restricted access or when protecting a staging website with a password that only a restricted number of users know).
|
||||
- A **"Private Installation"** is a Website that is installed purely for personal use. It must only be accessible by You and Your family.
|
||||
- A **"Public Site"** is a Website that is _neither_ a Development Installation nor a Private Installation.
|
||||
- A **"Minor Release"** is a stable Kirby release which adds smaller new features, minor functionality enhancements or bug fixes. This class of release is identified by the change of the revision to the right of the first decimal point, e.g. 4.1 to 4.2, 4.X.1 to 4.X.2.
|
||||
- A **"Major Release"** is a stable Kirby release which incorporates major new features or enhancements that increase or change the core functionality of Kirby to a larger extent. It may also deprecate existing parts of the Source Code or change them in a breaking way. This class of release is identified by the change of the revision to the left of the first decimal point, e.g. 4.X to 5.0.
|
||||
- A **"Major Generation"** is defined as all releases that share the revision to the left of the first decimal point, e.g. 4.0.0, 4.0.X, 4.X.0 and 4.X.X.
|
||||
- The **"Source Code"** is defined as the contents of all files that are provided with Kirby and that make Kirby work. This includes (but is not limited to) all PHP, JavaScript, JSON, HTML and CSS files as well as all related image and other media files.
|
||||
- The **"MIT-licensed Source Code Parts"** are defined as the parts of the Source Code for which a file header or code comment inside the same source file explicitly states the applicability of the MIT license.
|
||||
- The **"Activation Date"** determines the included updates. It is defined like this:
|
||||
- For a newly purchased or granted license, it is the date when the license was first activated for use with a Public Site.
|
||||
- When You upgrade an already activated license, it is the date on which the upgrade was performed in Our [license hub](https://hub.getkirby.com). If the license is still within the Included Updates Period, the Activation Date of the upgrade license will be set to the end of the Included Updates Period of the existing license.
|
||||
- When You upgrade a license that had _not_ been activated before, the upgrade license adopts the unactivated state of the existing license. The Activation Date is set on first activation for use with a Public Site.
|
||||
- The **"Included Updates Period"** is the time span of three (3) years after the Activation Date.
|
||||
- Licensees (You), Clients and Websites are **"Qualified"** if they satisfy the purchase requirements from the ["Order Process" section](#order-process) of this Agreement.
|
||||
|
||||
Every time you see one of these capitalized terms in the following text, it has the meaning that has been explained above.
|
||||
|
||||
## Usage for a Public Site
|
||||
|
||||
Installing Kirby on or using it for a Public Site requires a [paid license](https://getkirby.com/buy). Once a paid license is needed, the license must be immediately activated to the Public Site’s domain name and root directory via our [license hub](https://hub.getkirby.com) or the activation feature in the Kirby Panel.
|
||||
|
||||
As Kirby is software and software is intangible, We don't sell it as such. Instead, this Agreement grants a license for each purchase to install and use a single instance of Kirby on a **specific Website**. Additional Kirby licenses must be purchased in order to install and use Kirby on **additional Websites**.
|
||||
|
||||
The license is **non-exclusive** (meaning that You are not the only one to whom We will issue a license) and **generally non-transferable** (meaning that the one who purchases the license is the licensee).
|
||||
|
||||
On request, We will **transfer** a license to anyone who would be allowed and Qualified to purchase the license by law and this Agreement. The new licensee will take over all rights and obligations of this Agreement from You at the moment We confirm the license transfer.
|
||||
|
||||
We will also **reassign** a license to another Qualified Website domain and root directory, if You confirm that the previous Website is no longer in operation and will not be operated with the same license in the future.
|
||||
|
||||
If the new licensee, Website or Client in a transfer or reassignment is not Qualified for the existing license, You or the new licensee need to **upgrade the license to the qualifying terms and conditions** before the transfer or reassignment can be performed.
|
||||
|
||||
> [!NOTE]
|
||||
> If you need to transfer your Kirby license to another individual or company (for example to your client or a new agency) or reassign it to a different project, please get in touch directly at <support@getkirby.com>.
|
||||
|
||||
A license is valid for all Major Releases that We publish before the end of the Included Updates Period. It is also valid for all releases in those Major Generations independent of their release date. Whether a release is a Minor Release or Major Release is at Our sole discretion.
|
||||
|
||||
The use of releases in Major Generations that We publish after the Included Updates Period requires a **paid license upgrade**. An upgrade license replaces the existing license.
|
||||
|
||||
## Order Process
|
||||
|
||||
Our order process is conducted by Our online reseller [Paddle.com](https://paddle.com). Paddle.com is the Merchant of Record for all Our orders. Paddle provides all customer service inquiries and handles returns.
|
||||
|
||||
When purchasing a license, You are **responsible to choose the right license** based on You and the Website project. Different license variants can come with certain requirements towards You and/or the Website project. We publish all such requirements on <https://getkirby.com/buy> in a way that makes them clearly visible before the purchase. With Your purchase, You confirm that You and the Website project qualify for the selected license variant.
|
||||
|
||||
If the Website is created for a Client, You need to make sure that the **Client qualifies for the selected license**.
|
||||
|
||||
If You purchase licenses **in advance**, You need to ensure to only use the license(s) for projects that satisfy the requirements for the selected license variant(s).
|
||||
|
||||
We **reserve the right to verify** at any time after the purchase whether You, the Website and (if applicable) the Client are Qualified. Changes to the situation of You, the Website or the Client as well as changes to the published information on Our "Buy" page after the purchase or after the assignment to a Client do _not_ take effect on an existing license unless You upgrade the license or We transfer or reassign the license on Your request.
|
||||
|
||||
## Free Licenses
|
||||
|
||||
Kirby can be used **for free in the following cases**.
|
||||
|
||||
> [!NOTE]
|
||||
> Please note that the restrictions and all other clauses of this Agreement also apply to free licenses. You may especially _not_ alter or circumvent the licensing features.
|
||||
|
||||
### Usage for a Development Installation
|
||||
|
||||
We believe that it should be possible to test and evaluate software before having to purchase a license. Also, We understand that a web project first needs to be built in a protected environment before it can be published.
|
||||
|
||||
Therefore, installing and using Kirby on a personal computer (like a desktop PC, notebook or tablet) or server for a Development Installation is **free** for as long as You need. If You have already purchased a license, You do *not* need to activate it to the development domain(s) of the project.
|
||||
|
||||
> [!NOTE]
|
||||
> The usage of Kirby in production (with the intention to handle production data or content) is _never_ considered a Development Installation, even in internal apps or systems.
|
||||
|
||||
### Usage for a Private Installation
|
||||
|
||||
You may also install and use Kirby for **free** in Private Installations as long as they are not accessible by anyone except You and Your family.
|
||||
|
||||
> [!NOTE]
|
||||
> Our [definition](#definitions) of a Private Installation allows the following use cases:
|
||||
>
|
||||
> - Private sites for personal use, for example:
|
||||
> - Apps for You personally (like a personal diary)
|
||||
> - Apps for You as a freelancer (like a bookkeeping, invoicing or project management app)
|
||||
> - Apps for Your family (like a private photo gallery)
|
||||
> - Experimental local Kirby setups for Your personal use (for example to try out Kirby features)
|
||||
>
|
||||
> However, the following use cases are _not_ covered and need a **[paid license](#usage-for-a-public-site)**:
|
||||
>
|
||||
> - Intranets for companies, authorities or organizations, no matter if on a local or public server
|
||||
> - (Internal) apps for teams or entire companies, authorities or organizations
|
||||
> - Websites that are accessible by the public, even for personal/non-commercial purposes
|
||||
> - Use of Kirby as a local CMS for a static or headless site without a license for the frontend domain(s)
|
||||
|
||||
### Free Licenses on Request
|
||||
|
||||
We provide free or discounted licenses for specific purposes:
|
||||
|
||||
- students,
|
||||
- selected educational projects, social and environmental organizations, charities and non-profits with insufficient funding and
|
||||
- demo sites showcasing a Kirby extension (plugin or theme).
|
||||
|
||||
Unlike licenses for Development Installations or Private Installations, these free or discounted licenses are not granted by this Agreement directly. You need to request them from Us via email to <support@getkirby.com>. Any discounts or free licenses are at Our sole discretion.
|
||||
|
||||
Should We grant a free or discounted license under the terms of this section, You will receive a license code for use with a Public Site. The [section "Usage for a Public Site"](#usage-for-a-public-site) as well as all other terms of this Agreement apply with the following modifications:
|
||||
|
||||
- We will only transfer or reassign free or discounted licenses if the new licensee or project qualifies for the free or discounted license at Our sole discretion.
|
||||
- You may upgrade free or discounted licenses to future Major Generations like paid licenses. We will grant free or discounted upgrades under the terms of this section.
|
||||
|
||||
## Restrictions
|
||||
|
||||
### Legal Restrictions
|
||||
|
||||
You may only use Kirby in a manner that complies with any and all **applicable laws** in the jurisdictions in which You use Kirby. Please respect all applicable restrictions concerning **privacy and intellectual property rights**.
|
||||
|
||||
### Making Copies
|
||||
|
||||
You may make **copies of Kirby** in any machine readable form solely for the **following purposes**, provided that You reproduce Kirby in its original form and with all proprietary notices on the copy:
|
||||
|
||||
- when deploying a Website to a server,
|
||||
- when developing a Website on a personal computer or server,
|
||||
- when working on code contributions to Kirby or
|
||||
- as a backup.
|
||||
|
||||
You may _not_ reproduce Kirby or its Source Code, in whole or in part, for **any other purpose**, except if granted below.
|
||||
|
||||
### Modification of the Source Code
|
||||
|
||||
You may **alter, modify or extend the Source Code** for Your own use or with the intention to contribute Your changes back to Kirby. You may also **commission a third party** to perform those modifications for You.
|
||||
|
||||
However You may _not_:
|
||||
|
||||
- **alter or circumvent the licensing features**, including (but not limited to) the license validation and payment prompts,
|
||||
- **remove or alter any proprietary notices** on Kirby or
|
||||
- **resell, redistribute or transfer** the modified or derivative version.
|
||||
|
||||
> [!NOTE]
|
||||
> Please note that We **can't provide technical support** for modified or derivative versions of the Source Code.
|
||||
|
||||
### Your Relationship to Third Parties
|
||||
|
||||
You are generally _not_ allowed to **sell, assign, license, disclose, distribute, or otherwise transfer or make available** Kirby or its Source Code, in whole or in part, in any form to any third parties.
|
||||
|
||||
The following cases are exempted from this restriction:
|
||||
|
||||
- Kirby licenses may be transferred to a new licensee by requesting the transfer from Us ([see above](#usage-for-a-public-site)).
|
||||
- You may create Websites for third parties (e.g. as an agency or freelancer for a client). Together with this Website, You may bill Your client for the used Kirby license. You may also include the license price in a flat rate. Please note that the licensee in both of these cases is still You unless You request to transfer the license to Your client. If Your price exceeds the price You paid to Us, You need to give Your client the option to purchase the license directly from Us.
|
||||
- You may make Kirby available to customers via a Software-as-a-Service (SaaS) offering, provided You ensure that each Website has a valid Kirby license purchased either by You or Your customer. If multiple customers share a Website, each customer needs at least one license. Your offering _must not_ appear to be provided or officially endorsed by Us.
|
||||
- You may make a Kirby installation available to employees or partners of You or Your Website client. You may also disclose and distribute Kirby’s Source Code to Your client together with the source code of the Website You created for them.
|
||||
- You may disclose the Source Code to individuals or companies that are involved in the development or operation of Your Website (e.g. agencies, design or development freelancers, hosting providers or administrators).
|
||||
- You may disclose, distribute and make available extracted parts of the Source Code according to the conditions of the following section "Extraction of Source Code parts".
|
||||
|
||||
> [!NOTE]
|
||||
> E.g. the following cases are explicitly **_not_ allowed**:
|
||||
>
|
||||
> - Selling, licensing or distributing a new product based on Kirby that modifies or hides Kirby’s identity as a Content Management System (CMS)
|
||||
> - Forking Kirby and selling the modified version ([see above](#modification-of-the-source-code))
|
||||
> - Buying licenses in bulk and reselling them in your own shop
|
||||
> - Bundling or including Kirby’s full Source Code in the publication and/or distribution of a Website’s source code or a (free or paid) theme or plugin (please use Git submodules or Composer or provide a link to Our repository or website instead)
|
||||
|
||||
### Extraction of Source Code parts
|
||||
|
||||
We provide the Source Code as a complete unit for use according to this Agreement.
|
||||
|
||||
Reuse of code parts in other programs or projects is _only_ permitted in the cases stated in the following sections. You may _not_ extract the Source Code or parts of the Source Code in any other way or for any other purpose.
|
||||
|
||||
#### Extraction of MIT-licensed Source Code Parts
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of MIT-licensed Source Code Parts, to deal in the MIT-licensed Source Code Parts without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the MIT-licensed Source Code Parts, and to permit persons to whom the MIT-licensed Source Code Parts is furnished to do so, subject to the following conditions:
|
||||
|
||||
The copyright notice to Bastian Allgeier and this permission notice shall be included in all copies or substantial portions of the MIT-licensed Source Code Parts.
|
||||
|
||||
THE MIT-LICENSED SOURCE CODE PARTS ARE PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MIT-LICENSED SOURCE CODE PARTS OR THE USE OR OTHER DEALINGS IN THE MIT-LICENSED SOURCE CODE PARTS.
|
||||
|
||||
#### Extraction for Extensions
|
||||
|
||||
You may extract, use, disclose and distribute copies or adapted copies of individual parts of the Source Code (such as component templates), including those not licensed under the terms of the MIT license but excluding those covered by third-party licenses, if both of the following conditions are met:
|
||||
|
||||
- You use the code parts in or disclose/distribute them as part of an extension (plugin or theme) that You solely intend to be used with Kirby.
|
||||
- Every copied or adapted code part carries a clear note that references these conditions as well as Our copyright and this Agreement. You may use the following example as a template:
|
||||
```
|
||||
/**
|
||||
* The following code was copied or adapted from the source code of
|
||||
* Kirby CMS and may not be used outside of licensed Kirby projects.
|
||||
*
|
||||
* @copyright Bastian Allgeier
|
||||
* @license https://getkirby.com/license
|
||||
*/
|
||||
```
|
||||
|
||||
### Disallowed Uses
|
||||
|
||||
The following uses of Kirby are _not_ covered by this Agreement and will result in the termination of the license:
|
||||
|
||||
- Direct or indirect use of Kirby in **critical infrastructure** (e.g. water and energy services, public health, financial services, public security services) or **high-risk environments** (e.g. handling of harmful or dangerous materials). The use in Websites without connection to core processes is allowed.
|
||||
- Use of Kirby for Websites that contain **misinformation, hate speech or discriminating content** based on age, gender, gender identity, race, sexuality, religion, nationality, serious illnesses or disabilities, no matter who authored this content. Misinformation is defined as content that is false or misleading and may lead to significant risk of physical or societal harm.
|
||||
- Use of Kirby by **companies or individuals who**:
|
||||
- lobby for, promote, derive a majority of income from or are significantly invested in:
|
||||
- the production of tobacco or weapons,
|
||||
- any prison or jail operated for profit,
|
||||
- any action or facility that supports or contributes to:
|
||||
- gambling, adversely addictive behaviours or
|
||||
- deforestation.
|
||||
- lobby against, or derive a majority of income from actions that discourage or frustrate:
|
||||
- peace,
|
||||
- access to the rights set out in the Universal Declaration of Human Rights and the Convention on the Rights of the Child,
|
||||
- peaceful assembly and association (including worker associations),
|
||||
- a safe environment or action to curtail the use of fossil fuels or to prevent climate change or
|
||||
- democratic processes.
|
||||
|
||||
## Technical Support
|
||||
|
||||
Technical support is **provided as described on Our website** at <https://getkirby.com>. **No representations or guarantees** are made regarding the response time in which support questions are answered, however We will do Our best to respond quickly.
|
||||
|
||||
For each Major Generation, We aim to provide **security support for three (3) years** after the Major Release. Security support means that We will provide free security updates for the supported releases, which will include fixes for security vulnerabilities according to the following rules:
|
||||
- We published a security advisory on <https://getkirby.com/security> within the respective security support period. We will publish vulnerabilities on this page as soon as they are known to Us and an official fix for any supported release is available.
|
||||
- The latest release of the supported Major Generation is affected by the vulnerability.
|
||||
|
||||
With each vulnerability, We aim to publish the security advisory and security updates for all supported Major Generations at the same time.
|
||||
|
||||
> [!NOTE]
|
||||
> You can find up-to-date information on our currently supported versions in our [public security policy](https://getkirby.com/security).
|
||||
|
||||
We reserve the right to **limit technical support for free licenses**.
|
||||
|
||||
## Refund Policy
|
||||
|
||||
We offer a **14-day**, money back refund policy if Kirby didn't work out for Your project.
|
||||
|
||||
> [!NOTE]
|
||||
> If you need a refund, please get in touch directly at <support@getkirby.com>.
|
||||
|
||||
## No Warranty
|
||||
|
||||
KIRBY IS OFFERED ON AN **"AS-IS" BASIS** AND **NO WARRANTY**, EITHER EXPRESSED OR IMPLIED, IS GIVEN. WE EXPRESSLY DISCLAIM ALL WARRANTIES OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. YOU ASSUME ALL RISK ASSOCIATED WITH THE QUALITY, PERFORMANCE, INSTALLATION AND USE OF KIRBY INCLUDING, BUT NOT LIMITED TO, THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS. **YOU ARE SOLELY RESPONSIBLE** FOR DETERMINING THE APPROPRIATENESS OF USE OF KIRBY AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE. THIS PARAGRAPH ALSO APPLIES TO YOU IF YOU ARE NOT THE LICENSEE (E.G. IF YOU USE KIRBY WHILE SOMEONE ELSE IS THE LICENSEE).
|
||||
|
||||
## Term, Termination and Modification
|
||||
|
||||
You may **indefinitely use** all Kirby versions that are covered by Your license under this Agreement until either party **terminates this Agreement** as described in this section.
|
||||
|
||||
**You** may terminate the Agreement at any time.
|
||||
|
||||
**We** may only terminate the Agreement if You or any individual or company who works with Kirby or uses it on Your behalf has violated or failed to comply with terms of this Agreement. If Your compliance with the Agreement can be restored by fixing the violation or non-compliance, We will first contact You with information on the specific term that was violated or not complied with and will allow reasonable time of at least 14 days before We will decide on a license termination. Should We be in the position to terminate a license according to this paragraph, other or all licenses granted to You may be terminated for the same reason(s) at the same time or at any later date.
|
||||
|
||||
Termination takes effect upon notice to the other party in textual form (via email or letter). Upon termination, the specified **licenses granted to You will terminate**, and You will **immediately uninstall and cease all use** of Kirby. If not all licenses are terminated, You may continue to use Kirby for the Websites with active licenses. The sections entitled "No Warranty", "Indemnification" and "Limitation of Liability" will **survive any termination** of this Agreement.
|
||||
|
||||
We may **modify Kirby and this Agreement** with notice to You either via email or by publishing content on the Kirby website at https://getkirby.com, including but not limited to changing the functionality or appearance of Kirby. Any such modification will **become binding on You** unless You terminate this Agreement. Changes to this Agreement that constrain Your rights to a great extent will only become effective with Your approval in textual or electronic form.
|
||||
|
||||
## Indemnification
|
||||
|
||||
By accepting the Agreement, you **agree to indemnify and otherwise hold harmless** Us as well as Our officers, employees, agents, subsidiaries, affiliates and other partners from any direct, indirect, incidental, special, consequential or exemplary damages arising out of, relating to, or resulting from your use of Kirby or any other matter relating to Kirby. This paragraph also applies to you if you are not the licensee (e.g. if you use Kirby while someone else is the licensee).
|
||||
|
||||
## Limitation of Liability
|
||||
|
||||
YOU EXPRESSLY UNDERSTAND AND AGREE THAT **WE SHALL NOT BE LIABLE** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER INTANGIBLE LOSSES (EVEN IF WE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES). SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF THE LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES. ACCORDINGLY, **SOME OF THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU**. **IN NO EVENT WILL OUR TOTAL CUMULATIVE DAMAGES EXCEED** THE FEES YOU PAID TO US UNDER THIS AGREEMENT IN THE MOST RECENT TWELVE-MONTH PERIOD. THIS PARAGRAPH ALSO APPLIES TO YOU IF YOU ARE NOT THE LICENSEE (E.G. IF YOU USE KIRBY WHILE SOMEONE ELSE IS THE LICENSEE).
|
||||
|
||||
## All Rights Reserved
|
||||
|
||||
Bastian Allgeier **owns all rights**, title and interest to Kirby (including all intellectual property rights) and **reserves all rights to Kirby** that are not expressly granted in this Agreement.
|
||||
|
||||
In the event that Kirby will no longer be actively maintained, Bastian Allgeier will provide the Source Code under the terms of a free and open source software (FOSS) license as far as legally and contractually possible.
|
||||
|
||||
## Applicable Law & Place of Jurisdiction
|
||||
|
||||
1. For all disputes arising out of or in connection with this Agreement, the courts competent for Neckargemünd, Germany, shall have exclusive jurisdiction. However, We shall have the choice to file lawsuits against You before the courts competent for Your place of business.
|
||||
2. If You reside in Germany, para. 1 shall only apply if You are a merchant, a legal entity under public law or a special fund under public law.
|
||||
3. If You don't reside in Germany, but in a different member state of the European Union, para. 1 shall only apply if You are not a consumer under Art. 17 of the regulation (EU) No. 1215/2012. In that case, You shall be entitled to file actions against Us either at Our place of business or at the courts competent at the place where You usually reside. We, on the other hand, are only entitled to bring proceedings against You in the courts of the Member State in which You are domiciled.
|
||||
4. If You neither reside in Germany nor in a member state of the EU, the applicability of para. 1 remains unaffected.
|
||||
|
||||
## Severability Clause
|
||||
|
||||
Should any provision of this Agreement be or become invalid, void or unenforceable, in whole or in part, at present or in the future, this shall not affect the validity of the remaining provisions of this Agreement. The same shall apply if a gap requiring supplementation arises after conclusion of this Agreement. The parties shall replace the invalid, void or unenforceable provision or gap requiring filling by a valid provision which in its legal or economic content takes account of the invalid, void provision and the overall content of the agreement. § Section 139 of the German Civil Code (partial invalidity) is expressly waived.
|
||||
|
||||
## Questions?
|
||||
|
||||
Due to Kirby's flexibility, you may have special use cases or requirements that don't fit this Agreement.
|
||||
|
||||
If that's the case or if you have any questions, feel free to [get in touch](mailto:support@getkirby.com). We are happy to think outside the box and find custom license solutions for your creative application of Kirby.
|
||||
49
public/kirby/README.md
Normal file
49
public/kirby/README.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
[<img src="https://getkirby.com/assets/images/github/kirby.jpg" width="300">](https://getkirby.com)
|
||||
|
||||
[](https://github.com/getkirby/kirby/releases/latest)
|
||||
[](https://github.com/getkirby/kirby/actions?query=workflow%3ACI+branch%3Amain)
|
||||
[](https://codecov.io/gh/getkirby/kirby)
|
||||
[](https://github.com/getkirby/kirby/releases/latest)
|
||||
|
||||
**Kirby: the CMS that adapts to any project, loved by developers and editors alike.**
|
||||
With Kirby, you build your own ideal interface. Combine forms, galleries, articles, spreadsheets and more into an amazing editing experience. You can learn more about Kirby at [getkirby.com](https://getkirby.com).
|
||||
|
||||
This is Kirby's core application folder. Get started with one of the following repositories instead:
|
||||
|
||||
- [Starterkit](https://github.com/getkirby/starterkit)
|
||||
- [Plainkit](https://github.com/getkirby/plainkit)
|
||||
|
||||
<img src="https://getkirby.com/assets/images/github/kirby-screen.png" />
|
||||
|
||||
### Try Kirby for free
|
||||
|
||||
Kirby is not free software. However, you can try Kirby and the Starterkit on your local machine or on a test server as long as you need to make sure it is the right tool for your next project. … and when you’re convinced, [buy your license](https://getkirby.com/buy).
|
||||
|
||||
### Contribute
|
||||
|
||||
**Found a bug?**
|
||||
Please post all bugs as individual reports in our [issue tracker](https://github.com/getkirby/kirby/issues).
|
||||
|
||||
**Suggest a feature**
|
||||
If you have ideas for a feature or enhancement for Kirby, please use our [feedback platform](https://feedback.getkirby.com).
|
||||
|
||||
**Translations, bug fixes, code contributions ...**
|
||||
Read about how to contribute to the development in our [contributing guide](/CONTRIBUTING.md).
|
||||
|
||||
## What's Kirby?
|
||||
|
||||
- **[getkirby.com](https://getkirby.com)** – Get to know the CMS.
|
||||
- **[Try it](https://getkirby.com/try)** – Take a test ride with our online demo. Or download one of our kits to get started.
|
||||
- **[Documentation](https://getkirby.com/docs/guide)** – Read the official guide, reference and cookbook recipes.
|
||||
- **[Issues](https://github.com/getkirby/kirby/issues)** – Report bugs and other problems.
|
||||
- **[Feedback](https://feedback.getkirby.com)** – You have an idea for Kirby? Share it.
|
||||
- **[Forum](https://forum.getkirby.com)** – Whenever you get stuck, don't hesitate to reach out for questions and support.
|
||||
- **[Discord](https://chat.getkirby.com)** – Hang out and meet the community.
|
||||
- **[YouTube](https://youtube.com/kirbyCasts)** - Watch the latest video tutorials visually with Bastian.
|
||||
- **[Mastodon](https://mastodon.social/@getkirby)** – Spread the word.
|
||||
- **[Bluesky](https://bsky.app/profile/getkirby.com)** – Tell a friend.
|
||||
|
||||
---
|
||||
|
||||
© 2009 Bastian Allgeier
|
||||
[getkirby.com](https://getkirby.com) · [License agreement](https://getkirby.com/license)
|
||||
27
public/kirby/SECURITY.md
Normal file
27
public/kirby/SECURITY.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Security Policy
|
||||
|
||||
## Supported versions and past security incidents
|
||||
|
||||
You can find up-to-date information on the security status of each version on <https://getkirby.com/security>.
|
||||
|
||||
## Security of your Kirby site
|
||||
|
||||
We have a detailed [security guide](https://getkirby.com/docs/guide/security) with information on how to keep your Kirby installation secure.
|
||||
|
||||
## Reporting a vulnerability
|
||||
|
||||
If you have spotted a vulnerability in Kirby's core or the Panel, please make sure to let us know immediately. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
|
||||
|
||||
You can always contact us directly at **<security@getkirby.com>**.
|
||||
If you want to encrypt your message, our GPG key is [6E6B 057A F491 FFAD 363F 6F49 9101 10FA A459 E120](https://getkirby.com/pgp.asc).
|
||||
|
||||
You can also use the [security advisory form on GitHub](https://github.com/getkirby/kirby/security/advisories/new) to securely and privately report a vulnerability to us.
|
||||
|
||||
We will send you a response as soon as possible and will keep you informed on our progress towards a fix and announcement.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Please do not write to us publicly, e.g. in the forum, on Discord or in a GitHub issue. A public report can give attackers valuable time to exploit the issue before it is fixed.
|
||||
>
|
||||
> By letting us know directly and coordinating the disclosure with us, you can help to protect other Kirby users from such attacks.
|
||||
>
|
||||
> Also please do *not* request a CVE ID from organizations like MITRE. The responsible CVE Numbering Authority (CNA) for Kirby is GitHub. We can and will request a CVE ID for each confirmed vulnerability and will provide it to you in advance of the coordinated release.
|
||||
83
public/kirby/assets/whoops.css
Normal file
83
public/kirby/assets/whoops.css
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
body {
|
||||
background: #efefef;
|
||||
font: normal normal 400 12px/1.5 -apple-system, BlinkMacSystemFont, Segoe UI,
|
||||
Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: #313740;
|
||||
}
|
||||
|
||||
.exc-title-primary {
|
||||
color: hsl(0, 71%, 55%);
|
||||
}
|
||||
|
||||
.frame.active {
|
||||
color: hsl(0, 71%, 55%);
|
||||
box-shadow: inset -5px 0 0 0 #d16464;
|
||||
}
|
||||
|
||||
.frame:not(.active):hover {
|
||||
background: rgba(203, 215, 229, 0.5);
|
||||
}
|
||||
|
||||
.rightButton {
|
||||
color: #999;
|
||||
box-shadow: inset 0 0 0 1px #777;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.rightButton:hover {
|
||||
box-shadow: inset 0 0 0 1px #555;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.details-heading {
|
||||
color: #7e9abf;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.frame-code {
|
||||
background: #000;
|
||||
}
|
||||
|
||||
pre.code-block,
|
||||
code.code-block,
|
||||
.frame-args.code-block,
|
||||
.frame-args.code-block samp {
|
||||
background: #16171a;
|
||||
}
|
||||
|
||||
.linenums li.current {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.linenums li.current.active {
|
||||
background: rgba(209, 100, 100, 0.3);
|
||||
}
|
||||
|
||||
pre .atv,
|
||||
code .atv,
|
||||
pre .str,
|
||||
code .str {
|
||||
color: #a7bd68;
|
||||
}
|
||||
|
||||
pre .tag,
|
||||
code .tag {
|
||||
color: #d16464;
|
||||
}
|
||||
|
||||
pre .kwd,
|
||||
code .kwd {
|
||||
color: #8abeb7;
|
||||
}
|
||||
|
||||
pre .atn,
|
||||
code .atn {
|
||||
color: #de935f;
|
||||
}
|
||||
35
public/kirby/bootstrap.php
Normal file
35
public/kirby/bootstrap.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Validate the PHP version to already
|
||||
* stop at older or too recent versions
|
||||
*/
|
||||
if (
|
||||
version_compare(PHP_VERSION, '8.2.0', '>=') === false ||
|
||||
version_compare(PHP_VERSION, '8.5.0', '<') === false
|
||||
) {
|
||||
die(include __DIR__ . '/views/php.php');
|
||||
}
|
||||
|
||||
if (is_file($autoloader = dirname(__DIR__) . '/vendor/autoload.php')) {
|
||||
/**
|
||||
* Always prefer a site-wide Composer autoloader
|
||||
* if it exists, it means that the user has probably
|
||||
* installed additional packages
|
||||
*
|
||||
* @psalm-suppress MissingFile
|
||||
*/
|
||||
include $autoloader;
|
||||
} elseif (is_file($autoloader = __DIR__ . '/vendor/autoload.php')) {
|
||||
/**
|
||||
* Fall back to the local autoloader if that exists
|
||||
*
|
||||
* @psalm-suppress MissingFile
|
||||
*/
|
||||
include $autoloader;
|
||||
}
|
||||
/**
|
||||
* If neither one exists, don't bother searching;
|
||||
* it's a custom directory setup and the users need to
|
||||
* load the autoloader themselves
|
||||
*/
|
||||
3601
public/kirby/cacert.pem
Normal file
3601
public/kirby/cacert.pem
Normal file
File diff suppressed because it is too large
Load diff
117
public/kirby/composer.json
Normal file
117
public/kirby/composer.json
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
{
|
||||
"name": "getkirby/cms",
|
||||
"description": "The Kirby core",
|
||||
"license": "proprietary",
|
||||
"type": "kirby-cms",
|
||||
"version": "5.1.4",
|
||||
"keywords": [
|
||||
"kirby",
|
||||
"cms",
|
||||
"core"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kirby Team",
|
||||
"email": "support@getkirby.com",
|
||||
"homepage": "https://getkirby.com"
|
||||
}
|
||||
],
|
||||
"homepage": "https://getkirby.com",
|
||||
"support": {
|
||||
"email": "support@getkirby.com",
|
||||
"issues": "https://github.com/getkirby/kirby/issues",
|
||||
"forum": "https://forum.getkirby.com",
|
||||
"source": "https://github.com/getkirby/kirby"
|
||||
},
|
||||
"require": {
|
||||
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
|
||||
"ext-SimpleXML": "*",
|
||||
"ext-ctype": "*",
|
||||
"ext-curl": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-filter": "*",
|
||||
"ext-hash": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-json": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-openssl": "*",
|
||||
"christian-riesen/base32": "1.6.0",
|
||||
"claviska/simpleimage": "4.2.1",
|
||||
"composer/semver": "3.4.4",
|
||||
"filp/whoops": "2.18.4",
|
||||
"getkirby/composer-installer": "^1.2.1",
|
||||
"laminas/laminas-escaper": "2.18.0",
|
||||
"michelf/php-smartypants": "1.8.1",
|
||||
"phpmailer/phpmailer": "6.10.0",
|
||||
"symfony/polyfill-intl-idn": "1.33.0",
|
||||
"symfony/polyfill-mbstring": "1.33.0",
|
||||
"symfony/yaml": "7.3.5"
|
||||
},
|
||||
"replace": {
|
||||
"symfony/polyfill-php72": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-PDO": "Support for using databases",
|
||||
"ext-apcu": "Support for the Apcu cache driver",
|
||||
"ext-exif": "Support for exif information from images",
|
||||
"ext-fileinfo": "Improved mime type detection for files",
|
||||
"ext-imagick": "Improved thumbnail generation",
|
||||
"ext-intl": "Improved i18n number formatting",
|
||||
"ext-memcached": "Support for the Memcached cache driver",
|
||||
"ext-redis": "Support for the Redis cache driver",
|
||||
"ext-sodium": "Support for the crypto class and more robust session handling",
|
||||
"ext-zip": "Support for ZIP archive file functions",
|
||||
"ext-zlib": "Sanitization and validation for svgz files"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Kirby\\": "src/"
|
||||
},
|
||||
"classmap": [
|
||||
"dependencies/"
|
||||
],
|
||||
"files": [
|
||||
"config/setup.php",
|
||||
"config/helpers.php"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"getkirby/composer-installer": true
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"platform": {
|
||||
"php": "8.2.0"
|
||||
},
|
||||
"platform-check": false
|
||||
},
|
||||
"extra": {
|
||||
"unused": [
|
||||
"symfony/polyfill-intl-idn"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"post-update-cmd": "curl -o cacert.pem https://curl.se/ca/cacert.pem",
|
||||
"analyze": [
|
||||
"@analyze:composer",
|
||||
"@analyze:psalm",
|
||||
"@analyze:phpmd"
|
||||
],
|
||||
"analyze:composer": "composer validate --strict --no-check-version --no-check-all",
|
||||
"analyze:phpmd": "phpmd . ansi phpmd.xml.dist --exclude 'dependencies/*,tests/*,vendor/*'",
|
||||
"analyze:psalm": "psalm",
|
||||
"bench": "phpbench run --report=aggregate --ref baseline",
|
||||
"bench:baseline": "phpbench run --report=aggregate --tag baseline",
|
||||
"build": "./scripts/build",
|
||||
"ci": [
|
||||
"@fix",
|
||||
"@analyze",
|
||||
"@test"
|
||||
],
|
||||
"fix": "php-cs-fixer fix",
|
||||
"test": "phpunit",
|
||||
"test:coverage": "XDEBUG_MODE=coverage phpunit --coverage-html=tests/coverage",
|
||||
"zip": "composer archive --format=zip --file=dist"
|
||||
}
|
||||
}
|
||||
1132
public/kirby/composer.lock
generated
Normal file
1132
public/kirby/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
97
public/kirby/config/aliases.php
Normal file
97
public/kirby/config/aliases.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
// cms classes
|
||||
'collection' => 'Kirby\Cms\Collection',
|
||||
'file' => 'Kirby\Cms\File',
|
||||
'files' => 'Kirby\Cms\Files',
|
||||
'find' => 'Kirby\Cms\Find',
|
||||
'helpers' => 'Kirby\Cms\Helpers',
|
||||
'html' => 'Kirby\Cms\Html',
|
||||
'kirby' => 'Kirby\Cms\App',
|
||||
'page' => 'Kirby\Cms\Page',
|
||||
'pages' => 'Kirby\Cms\Pages',
|
||||
'pagination' => 'Kirby\Cms\Pagination',
|
||||
'r' => 'Kirby\Cms\R',
|
||||
'response' => 'Kirby\Cms\Response',
|
||||
's' => 'Kirby\Cms\S',
|
||||
'sane' => 'Kirby\Sane\Sane',
|
||||
'site' => 'Kirby\Cms\Site',
|
||||
'structure' => 'Kirby\Cms\Structure',
|
||||
'url' => 'Kirby\Cms\Url',
|
||||
'user' => 'Kirby\Cms\User',
|
||||
'users' => 'Kirby\Cms\Users',
|
||||
'visitor' => 'Kirby\Cms\Visitor',
|
||||
|
||||
// content classes
|
||||
'field' => 'Kirby\Content\Field',
|
||||
|
||||
// data handler
|
||||
'data' => 'Kirby\Data\Data',
|
||||
'json' => 'Kirby\Data\Json',
|
||||
'yaml' => 'Kirby\Data\Yaml',
|
||||
|
||||
// file classes
|
||||
'asset' => 'Kirby\Filesystem\Asset',
|
||||
'dir' => 'Kirby\Filesystem\Dir',
|
||||
'f' => 'Kirby\Filesystem\F',
|
||||
'mime' => 'Kirby\Filesystem\Mime',
|
||||
|
||||
// data classes
|
||||
'database' => 'Kirby\Database\Database',
|
||||
'db' => 'Kirby\Database\Db',
|
||||
|
||||
// exceptions
|
||||
'errorpageexception' => 'Kirby\Exception\ErrorPageException',
|
||||
|
||||
// http classes
|
||||
'cookie' => 'Kirby\Http\Cookie',
|
||||
'header' => 'Kirby\Http\Header',
|
||||
'remote' => 'Kirby\Http\Remote',
|
||||
|
||||
// image classes
|
||||
'dimensions' => 'Kirby\Image\Dimensions',
|
||||
|
||||
// panel classes
|
||||
'panel' => 'Kirby\Panel\Panel',
|
||||
|
||||
// template classes
|
||||
'snippet' => 'Kirby\Template\Snippet',
|
||||
'slot' => 'Kirby\Template\Slot',
|
||||
|
||||
// toolkit classes
|
||||
'a' => 'Kirby\Toolkit\A',
|
||||
'c' => 'Kirby\Toolkit\Config',
|
||||
'config' => 'Kirby\Toolkit\Config',
|
||||
'escape' => 'Kirby\Toolkit\Escape',
|
||||
'i18n' => 'Kirby\Toolkit\I18n',
|
||||
'obj' => 'Kirby\Toolkit\Obj',
|
||||
'str' => 'Kirby\Toolkit\Str',
|
||||
'tpl' => 'Kirby\Toolkit\Tpl',
|
||||
'v' => 'Kirby\Toolkit\V',
|
||||
'xml' => 'Kirby\Toolkit\Xml',
|
||||
|
||||
// Deprecated aliases:
|
||||
// Any of these might be removed at any point in the future
|
||||
'kirby\cms\asset' => 'Kirby\Filesystem\Asset',
|
||||
'kirby\cms\content' => 'Kirby\Content\Content',
|
||||
'kirby\cms\dir' => 'Kirby\Filesystem\Dir',
|
||||
'kirby\cms\filename' => 'Kirby\Filesystem\Filename',
|
||||
'kirby\cms\filefoundation' => 'Kirby\Filesystem\IsFile',
|
||||
'kirby\cms\field' => 'Kirby\Content\Field',
|
||||
'kirby\cms\form' => 'Kirby\Form\Form',
|
||||
'kirby\cms\kirbytag' => 'Kirby\Text\KirbyTag',
|
||||
'kirby\cms\kirbytags' => 'Kirby\Text\KirbyTags',
|
||||
'kirby\cms\plugin' => 'Kirby\Plugin\Plugin',
|
||||
'kirby\cms\pluginasset' => 'Kirby\Plugin\Asset',
|
||||
'kirby\cms\pluginassets' => 'Kirby\Plugin\Assets',
|
||||
'kirby\cms\template' => 'Kirby\Template\Template',
|
||||
'kirby\form\options' => 'Kirby\Option\Options',
|
||||
'kirby\form\optionsapi' => 'Kirby\Option\OptionsApi',
|
||||
'kirby\form\optionsquery' => 'Kirby\Option\OptionsQuery',
|
||||
'kirby\toolkit\dir' => 'Kirby\Filesystem\Dir',
|
||||
'kirby\toolkit\f' => 'Kirby\Filesystem\F',
|
||||
'kirby\toolkit\file' => 'Kirby\Filesystem\File',
|
||||
'kirby\toolkit\mime' => 'Kirby\Filesystem\Mime',
|
||||
'kirby\toolkit\query' => 'Kirby\Query\Query',
|
||||
];
|
||||
27
public/kirby/config/api/authentication.php
Normal file
27
public/kirby/config/api/authentication.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Exception\AuthException;
|
||||
|
||||
return function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
$allowImpersonation = $this->kirby()->option('api.allowImpersonation') ?? false;
|
||||
|
||||
// csrf token check
|
||||
if (
|
||||
$auth->type($allowImpersonation) === 'session' &&
|
||||
$auth->csrf() === false
|
||||
) {
|
||||
throw new AuthException(message: 'Unauthenticated');
|
||||
}
|
||||
|
||||
// get user from session or basic auth
|
||||
if ($user = $auth->user(null, $allowImpersonation)) {
|
||||
if ($user->role()->permissions()->for('access', 'panel') === false) {
|
||||
throw new AuthException(key: 'access.panel');
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
throw new AuthException(message: 'Unauthenticated');
|
||||
};
|
||||
78
public/kirby/config/api/collections.php
Normal file
78
public/kirby/config/api/collections.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Api Collection Definitions
|
||||
*/
|
||||
|
||||
use Kirby\Cms\Files;
|
||||
use Kirby\Cms\Languages;
|
||||
use Kirby\Cms\Pages;
|
||||
use Kirby\Cms\Roles;
|
||||
use Kirby\Cms\Translations;
|
||||
use Kirby\Cms\Users;
|
||||
|
||||
return [
|
||||
|
||||
/**
|
||||
* Children
|
||||
*/
|
||||
'children' => [
|
||||
'model' => 'page',
|
||||
'type' => Pages::class,
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Files
|
||||
*/
|
||||
'files' => [
|
||||
'model' => 'file',
|
||||
'type' => Files::class,
|
||||
],
|
||||
|
||||
/**
|
||||
* Languages
|
||||
*/
|
||||
'languages' => [
|
||||
'model' => 'language',
|
||||
'type' => Languages::class,
|
||||
],
|
||||
|
||||
/**
|
||||
* Pages
|
||||
*/
|
||||
'pages' => [
|
||||
'model' => 'page',
|
||||
'type' => Pages::class,
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Roles
|
||||
*/
|
||||
'roles' => [
|
||||
'model' => 'role',
|
||||
'type' => Roles::class,
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Translations
|
||||
*/
|
||||
'translations' => [
|
||||
'model' => 'translation',
|
||||
'type' => Translations::class,
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Users
|
||||
*/
|
||||
'users' => [
|
||||
'default' => fn () => $this->users(),
|
||||
'model' => 'user',
|
||||
'type' => Users::class,
|
||||
'view' => 'compact'
|
||||
]
|
||||
|
||||
];
|
||||
21
public/kirby/config/api/models.php
Normal file
21
public/kirby/config/api/models.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Api Model Definitions
|
||||
*/
|
||||
return [
|
||||
'File' => include __DIR__ . '/models/File.php',
|
||||
'FileBlueprint' => include __DIR__ . '/models/FileBlueprint.php',
|
||||
'FileVersion' => include __DIR__ . '/models/FileVersion.php',
|
||||
'Language' => include __DIR__ . '/models/Language.php',
|
||||
'License' => include __DIR__ . '/models/License.php',
|
||||
'Page' => include __DIR__ . '/models/Page.php',
|
||||
'PageBlueprint' => include __DIR__ . '/models/PageBlueprint.php',
|
||||
'Role' => include __DIR__ . '/models/Role.php',
|
||||
'Site' => include __DIR__ . '/models/Site.php',
|
||||
'SiteBlueprint' => include __DIR__ . '/models/SiteBlueprint.php',
|
||||
'System' => include __DIR__ . '/models/System.php',
|
||||
'Translation' => include __DIR__ . '/models/Translation.php',
|
||||
'User' => include __DIR__ . '/models/User.php',
|
||||
'UserBlueprint' => include __DIR__ . '/models/UserBlueprint.php',
|
||||
];
|
||||
119
public/kirby/config/api/models/File.php
Normal file
119
public/kirby/config/api/models/File.php
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\File;
|
||||
use Kirby\Form\Form;
|
||||
|
||||
/**
|
||||
* File
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'blueprint' => fn (File $file) => $file->blueprint(),
|
||||
'content' => fn (File $file) => Form::for($file)->values(),
|
||||
'dimensions' => fn (File $file) => $file->dimensions()->toArray(),
|
||||
'dragText' => fn (File $file) => $file->panel()->dragText(),
|
||||
'exists' => fn (File $file) => $file->exists(),
|
||||
'extension' => fn (File $file) => $file->extension(),
|
||||
'filename' => fn (File $file) => $file->filename(),
|
||||
'id' => fn (File $file) => $file->id(),
|
||||
'link' => fn (File $file) => $file->panel()->url(true),
|
||||
'mime' => fn (File $file) => $file->mime(),
|
||||
'modified' => fn (File $file) => $file->modified('c'),
|
||||
'name' => fn (File $file) => $file->name(),
|
||||
'next' => fn (File $file) => $file->next(),
|
||||
'nextWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sorted();
|
||||
$index = $files->indexOf($file);
|
||||
|
||||
return $files->nth($index + 1);
|
||||
},
|
||||
'niceSize' => fn (File $file) => $file->niceSize(),
|
||||
'options' => fn (File $file) => $file->panel()->options(),
|
||||
'panelImage' => fn (File $file) => $file->panel()->image(),
|
||||
'panelUrl' => fn (File $file) => $file->panel()->url(true),
|
||||
'prev' => fn (File $file) => $file->prev(),
|
||||
'prevWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sorted();
|
||||
$index = $files->indexOf($file);
|
||||
|
||||
return $files->nth($index - 1);
|
||||
},
|
||||
'parent' => fn (File $file) => $file->parent(),
|
||||
'parents' => fn (File $file) => $file->parents()->flip(),
|
||||
'size' => fn (File $file) => $file->size(),
|
||||
'template' => fn (File $file) => $file->template(),
|
||||
'thumbs' => function ($file) {
|
||||
if ($file->isResizable() === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'tiny' => $file->resize(128)->url(),
|
||||
'small' => $file->resize(256)->url(),
|
||||
'medium' => $file->resize(512)->url(),
|
||||
'large' => $file->resize(768)->url(),
|
||||
'huge' => $file->resize(1024)->url(),
|
||||
];
|
||||
},
|
||||
'type' => fn (File $file) => $file->type(),
|
||||
'url' => fn (File $file) => $file->url(),
|
||||
'uuid' => fn (File $file) => $file->uuid()?->toString()
|
||||
],
|
||||
'type' => File::class,
|
||||
'views' => [
|
||||
'default' => [
|
||||
'content',
|
||||
'dimensions',
|
||||
'exists',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'next' => 'compact',
|
||||
'niceSize',
|
||||
'parent' => 'compact',
|
||||
'options',
|
||||
'prev' => 'compact',
|
||||
'size',
|
||||
'template',
|
||||
'type',
|
||||
'url',
|
||||
'uuid'
|
||||
],
|
||||
'compact' => [
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'type',
|
||||
'url',
|
||||
'uuid'
|
||||
],
|
||||
'panel' => [
|
||||
'blueprint',
|
||||
'content',
|
||||
'dimensions',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'nextWithTemplate' => 'compact',
|
||||
'niceSize',
|
||||
'options',
|
||||
'panelIcon',
|
||||
'panelImage',
|
||||
'parent' => 'compact',
|
||||
'parents' => ['id', 'slug', 'title'],
|
||||
'prevWithTemplate' => 'compact',
|
||||
'template',
|
||||
'type',
|
||||
'url',
|
||||
'uuid'
|
||||
]
|
||||
],
|
||||
];
|
||||
17
public/kirby/config/api/models/FileBlueprint.php
Normal file
17
public/kirby/config/api/models/FileBlueprint.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\FileBlueprint;
|
||||
|
||||
/**
|
||||
* FileBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (FileBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (FileBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (FileBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (FileBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => FileBlueprint::class,
|
||||
'views' => [],
|
||||
];
|
||||
59
public/kirby/config/api/models/FileVersion.php
Normal file
59
public/kirby/config/api/models/FileVersion.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\FileVersion;
|
||||
|
||||
/**
|
||||
* FileVersion
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'dimensions' => fn (FileVersion $file) => $file->dimensions()->toArray(),
|
||||
'exists' => fn (FileVersion $file) => $file->exists(),
|
||||
'extension' => fn (FileVersion $file) => $file->extension(),
|
||||
'filename' => fn (FileVersion $file) => $file->filename(),
|
||||
'id' => fn (FileVersion $file) => $file->id(),
|
||||
'mime' => fn (FileVersion $file) => $file->mime(),
|
||||
'modified' => fn (FileVersion $file) => $file->modified('c'),
|
||||
'name' => fn (FileVersion $file) => $file->name(),
|
||||
'niceSize' => fn (FileVersion $file) => $file->niceSize(),
|
||||
'size' => fn (FileVersion $file) => $file->size(),
|
||||
'type' => fn (FileVersion $file) => $file->type(),
|
||||
'url' => fn (FileVersion $file) => $file->url(),
|
||||
],
|
||||
'type' => FileVersion::class,
|
||||
'views' => [
|
||||
'default' => [
|
||||
'dimensions',
|
||||
'exists',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'niceSize',
|
||||
'size',
|
||||
'type',
|
||||
'url'
|
||||
],
|
||||
'compact' => [
|
||||
'filename',
|
||||
'id',
|
||||
'type',
|
||||
'url',
|
||||
],
|
||||
'panel' => [
|
||||
'dimensions',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'niceSize',
|
||||
'template',
|
||||
'type',
|
||||
'url'
|
||||
]
|
||||
],
|
||||
];
|
||||
30
public/kirby/config/api/models/Language.php
Normal file
30
public/kirby/config/api/models/Language.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Language;
|
||||
|
||||
/**
|
||||
* Language
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'code' => fn (Language $language) => $language->code(),
|
||||
'default' => fn (Language $language) => $language->isDefault(),
|
||||
'direction' => fn (Language $language) => $language->direction(),
|
||||
'locale' => fn (Language $language) => $language->locale(),
|
||||
'name' => fn (Language $language) => $language->name(),
|
||||
'rules' => fn (Language $language) => $language->rules(),
|
||||
'url' => fn (Language $language) => $language->url(),
|
||||
],
|
||||
'type' => Language::class,
|
||||
'views' => [
|
||||
'default' => [
|
||||
'code',
|
||||
'default',
|
||||
'direction',
|
||||
'locale',
|
||||
'name',
|
||||
'rules',
|
||||
'url'
|
||||
]
|
||||
]
|
||||
];
|
||||
17
public/kirby/config/api/models/License.php
Normal file
17
public/kirby/config/api/models/License.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\License;
|
||||
|
||||
/**
|
||||
* Page
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'status' => fn (License $license) => $license->status()->value(),
|
||||
'code' => function (License $license) {
|
||||
return $this->kirby()->user()->isAdmin() ? $license->code() : $license->code(true);
|
||||
},
|
||||
'type' => fn (License $license) => $license->type()->label(),
|
||||
],
|
||||
'type' => License::class,
|
||||
];
|
||||
96
public/kirby/config/api/models/Page.php
Normal file
96
public/kirby/config/api/models/Page.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Form\Form;
|
||||
|
||||
/**
|
||||
* Page
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'blueprint' => fn (Page $page) => $page->blueprint(),
|
||||
'blueprints' => fn (Page $page) => $page->blueprints(),
|
||||
'children' => fn (Page $page) => $page->children(),
|
||||
'content' => fn (Page $page) => Form::for($page)->values(),
|
||||
'drafts' => fn (Page $page) => $page->drafts(),
|
||||
'errors' => fn (Page $page) => $page->errors(),
|
||||
'files' => fn (Page $page) => $page->files()->sorted(),
|
||||
'hasChildren' => fn (Page $page) => $page->hasChildren(),
|
||||
'hasDrafts' => fn (Page $page) => $page->hasDrafts(),
|
||||
'hasFiles' => fn (Page $page) => $page->hasFiles(),
|
||||
'id' => fn (Page $page) => $page->id(),
|
||||
'isSortable' => fn (Page $page) => $page->isSortable(),
|
||||
'num' => fn (Page $page) => $page->num(),
|
||||
'options' => fn (Page $page) => $page->panel()->options(['preview']),
|
||||
'panelImage' => fn (Page $page) => $page->panel()->image(),
|
||||
'parent' => fn (Page $page) => $page->parent(),
|
||||
'parents' => fn (Page $page) => $page->parents()->flip(),
|
||||
'previewUrl' => fn (Page $page) => $page->previewUrl(),
|
||||
'siblings' => function (Page $page) {
|
||||
if ($page->isDraft() === true) {
|
||||
return $page->parentModel()->children()->not($page);
|
||||
}
|
||||
|
||||
return $page->siblings();
|
||||
},
|
||||
'slug' => fn (Page $page) => $page->slug(),
|
||||
'status' => fn (Page $page) => $page->status(),
|
||||
'template' => fn (Page $page) => $page->intendedTemplate()->name(),
|
||||
'title' => fn (Page $page) => $page->title()->value(),
|
||||
'url' => fn (Page $page) => $page->url(),
|
||||
'uuid' => fn (Page $page) => $page->uuid()?->toString()
|
||||
],
|
||||
'type' => Page::class,
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'id',
|
||||
'title',
|
||||
'url',
|
||||
'num',
|
||||
'uuid'
|
||||
],
|
||||
'default' => [
|
||||
'content',
|
||||
'id',
|
||||
'status',
|
||||
'num',
|
||||
'options',
|
||||
'parent' => 'compact',
|
||||
'slug',
|
||||
'template',
|
||||
'title',
|
||||
'url',
|
||||
'uuid'
|
||||
],
|
||||
'panel' => [
|
||||
'id',
|
||||
'blueprint',
|
||||
'content',
|
||||
'status',
|
||||
'options',
|
||||
'next' => ['id', 'slug', 'title'],
|
||||
'parents' => ['id', 'slug', 'title'],
|
||||
'prev' => ['id', 'slug', 'title'],
|
||||
'previewUrl',
|
||||
'slug',
|
||||
'title',
|
||||
'url',
|
||||
'uuid'
|
||||
],
|
||||
'selector' => [
|
||||
'id',
|
||||
'title',
|
||||
'parent' => [
|
||||
'id',
|
||||
'title'
|
||||
],
|
||||
'children' => [
|
||||
'hasChildren',
|
||||
'id',
|
||||
'panelIcon',
|
||||
'panelImage',
|
||||
'title',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
20
public/kirby/config/api/models/PageBlueprint.php
Normal file
20
public/kirby/config/api/models/PageBlueprint.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\PageBlueprint;
|
||||
|
||||
/**
|
||||
* PageBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (PageBlueprint $blueprint) => $blueprint->name(),
|
||||
'num' => fn (PageBlueprint $blueprint) => $blueprint->num(),
|
||||
'options' => fn (PageBlueprint $blueprint) => $blueprint->options(),
|
||||
'preview' => fn (PageBlueprint $blueprint) => $blueprint->preview(),
|
||||
'status' => fn (PageBlueprint $blueprint) => $blueprint->status(),
|
||||
'tabs' => fn (PageBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (PageBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => PageBlueprint::class,
|
||||
'views' => [],
|
||||
];
|
||||
23
public/kirby/config/api/models/Role.php
Normal file
23
public/kirby/config/api/models/Role.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Role;
|
||||
|
||||
/**
|
||||
* Role
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'description' => fn (Role $role) => $role->description(),
|
||||
'name' => fn (Role $role) => $role->name(),
|
||||
'permissions' => fn (Role $role) => $role->permissions()->toArray(),
|
||||
'title' => fn (Role $role) => $role->title(),
|
||||
],
|
||||
'type' => Role::class,
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'description',
|
||||
'name',
|
||||
'title'
|
||||
]
|
||||
]
|
||||
];
|
||||
52
public/kirby/config/api/models/Site.php
Normal file
52
public/kirby/config/api/models/Site.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Site;
|
||||
use Kirby\Form\Form;
|
||||
|
||||
/**
|
||||
* Site
|
||||
*/
|
||||
return [
|
||||
'default' => fn () => $this->site(),
|
||||
'fields' => [
|
||||
'blueprint' => fn (Site $site) => $site->blueprint(),
|
||||
'children' => fn (Site $site) => $site->children(),
|
||||
'content' => fn (Site $site) => Form::for($site)->values(),
|
||||
'drafts' => fn (Site $site) => $site->drafts(),
|
||||
'files' => fn (Site $site) => $site->files()->sorted(),
|
||||
'options' => fn (Site $site) => $site->permissions()->toArray(),
|
||||
'previewUrl' => fn (Site $site) => $site->previewUrl(),
|
||||
'title' => fn (Site $site) => $site->title()->value(),
|
||||
'url' => fn (Site $site) => $site->url(),
|
||||
],
|
||||
'type' => Site::class,
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'default' => [
|
||||
'content',
|
||||
'options',
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'panel' => [
|
||||
'title',
|
||||
'blueprint',
|
||||
'content',
|
||||
'options',
|
||||
'previewUrl',
|
||||
'url'
|
||||
],
|
||||
'selector' => [
|
||||
'title',
|
||||
'children' => [
|
||||
'id',
|
||||
'title',
|
||||
'panelIcon',
|
||||
'hasChildren'
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
17
public/kirby/config/api/models/SiteBlueprint.php
Normal file
17
public/kirby/config/api/models/SiteBlueprint.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\SiteBlueprint;
|
||||
|
||||
/**
|
||||
* SiteBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (SiteBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (SiteBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (SiteBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (SiteBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => SiteBlueprint::class,
|
||||
'views' => [],
|
||||
];
|
||||
91
public/kirby/config/api/models/System.php
Normal file
91
public/kirby/config/api/models/System.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\System;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* System
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'ascii' => fn () => Str::$ascii,
|
||||
'authStatus' => fn () => $this->kirby()->auth()->status()->toArray(),
|
||||
'defaultLanguage' => fn () => $this->kirby()->panelLanguage(),
|
||||
'isOk' => fn (System $system) => $system->isOk(),
|
||||
'isInstallable' => fn (System $system) => $system->isInstallable(),
|
||||
'isInstalled' => fn (System $system) => $system->isInstalled(),
|
||||
'isLocal' => fn (System $system) => $system->isLocal(),
|
||||
'multilang' => fn () => $this->kirby()->option('languages', false) !== false,
|
||||
'languages' => fn () => $this->kirby()->languages(),
|
||||
'license' => fn (System $system) => $system->license(),
|
||||
'locales' => function () {
|
||||
$locales = [];
|
||||
$translations = $this->kirby()->translations();
|
||||
foreach ($translations as $translation) {
|
||||
$locales[$translation->code()] = $translation->locale();
|
||||
}
|
||||
return $locales;
|
||||
},
|
||||
'loginMethods' => fn (System $system) => array_keys($system->loginMethods()),
|
||||
'requirements' => fn (System $system) => $system->toArray(),
|
||||
'site' => fn (System $system) => $system->title(),
|
||||
'slugs' => fn () => Str::$language,
|
||||
'title' => fn () => $this->site()->title()->value(),
|
||||
'translation' => function () {
|
||||
$code = $this->user()?->language() ??
|
||||
$this->kirby()->panelLanguage();
|
||||
|
||||
return
|
||||
$this->kirby()->translation($code) ??
|
||||
$this->kirby()->translation('en');
|
||||
},
|
||||
'kirbytext' => fn () => $this->kirby()->option('panel.kirbytext') ?? true,
|
||||
'user' => fn () => $this->user(),
|
||||
'version' => function () {
|
||||
if ($this->user()?->role()->permissions()->for('access', 'system') === true) {
|
||||
return $this->kirby()->version();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
],
|
||||
'type' => System::class,
|
||||
'views' => [
|
||||
'login' => [
|
||||
'authStatus',
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'loginMethods',
|
||||
'title',
|
||||
'translation'
|
||||
],
|
||||
'troubleshooting' => [
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'title',
|
||||
'translation',
|
||||
'requirements'
|
||||
],
|
||||
'panel' => [
|
||||
'ascii',
|
||||
'defaultLanguage',
|
||||
'isOk',
|
||||
'isInstalled',
|
||||
'isLocal',
|
||||
'kirbytext',
|
||||
'languages',
|
||||
'license',
|
||||
'locales',
|
||||
'multilang',
|
||||
'requirements',
|
||||
'site',
|
||||
'slugs',
|
||||
'title',
|
||||
'translation',
|
||||
'user' => 'auth',
|
||||
'version'
|
||||
]
|
||||
],
|
||||
];
|
||||
24
public/kirby/config/api/models/Translation.php
Normal file
24
public/kirby/config/api/models/Translation.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Translation;
|
||||
|
||||
/**
|
||||
* Translation
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'author' => fn (Translation $translation) => $translation->author(),
|
||||
'data' => fn (Translation $translation) => $translation->dataWithFallback(),
|
||||
'direction' => fn (Translation $translation) => $translation->direction(),
|
||||
'id' => fn (Translation $translation) => $translation->id(),
|
||||
'name' => fn (Translation $translation) => $translation->name(),
|
||||
],
|
||||
'type' => Translation::class,
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'direction',
|
||||
'id',
|
||||
'name'
|
||||
]
|
||||
]
|
||||
];
|
||||
81
public/kirby/config/api/models/User.php
Normal file
81
public/kirby/config/api/models/User.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\User;
|
||||
use Kirby\Form\Form;
|
||||
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
return [
|
||||
'default' => fn () => $this->user(),
|
||||
'fields' => [
|
||||
'avatar' => fn (User $user) => $user->avatar()?->crop(512),
|
||||
'blueprint' => fn (User $user) => $user->blueprint(),
|
||||
'content' => fn (User $user) => Form::for($user)->values(),
|
||||
'email' => fn (User $user) => $user->email(),
|
||||
'files' => fn (User $user) => $user->files()->sorted(),
|
||||
'id' => fn (User $user) => $user->id(),
|
||||
'language' => fn (User $user) => $user->language(),
|
||||
'name' => fn (User $user) => $user->name()->value(),
|
||||
'next' => fn (User $user) => $user->next(),
|
||||
'options' => fn (User $user) => $user->panel()->options(),
|
||||
'panelImage' => fn (User $user) => $user->panel()->image(),
|
||||
'permissions' => fn (User $user) => $user->role()->permissions()->toArray(),
|
||||
'prev' => fn (User $user) => $user->prev(),
|
||||
'role' => fn (User $user) => $user->role(),
|
||||
'roles' => fn (User $user) => $user->roles(),
|
||||
'username' => fn (User $user) => $user->username(),
|
||||
'uuid' => fn (User $user) => $user->uuid()?->toString()
|
||||
],
|
||||
'type' => User::class,
|
||||
'views' => [
|
||||
'default' => [
|
||||
'avatar',
|
||||
'content',
|
||||
'email',
|
||||
'id',
|
||||
'language',
|
||||
'name',
|
||||
'next' => 'compact',
|
||||
'options',
|
||||
'prev' => 'compact',
|
||||
'role',
|
||||
'username',
|
||||
'uuid'
|
||||
],
|
||||
'compact' => [
|
||||
'avatar' => 'compact',
|
||||
'id',
|
||||
'email',
|
||||
'language',
|
||||
'name',
|
||||
'role' => 'compact',
|
||||
'username',
|
||||
'uuid'
|
||||
],
|
||||
'auth' => [
|
||||
'avatar' => 'compact',
|
||||
'permissions',
|
||||
'email',
|
||||
'id',
|
||||
'name',
|
||||
'role',
|
||||
'language'
|
||||
],
|
||||
'panel' => [
|
||||
'avatar' => 'compact',
|
||||
'blueprint',
|
||||
'content',
|
||||
'email',
|
||||
'id',
|
||||
'language',
|
||||
'name',
|
||||
'next' => ['id', 'name'],
|
||||
'options',
|
||||
'prev' => ['id', 'name'],
|
||||
'role',
|
||||
'username',
|
||||
'uuid'
|
||||
],
|
||||
]
|
||||
];
|
||||
17
public/kirby/config/api/models/UserBlueprint.php
Normal file
17
public/kirby/config/api/models/UserBlueprint.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\UserBlueprint;
|
||||
|
||||
/**
|
||||
* UserBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (UserBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (UserBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (UserBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (UserBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => UserBlueprint::class,
|
||||
'views' => [],
|
||||
];
|
||||
29
public/kirby/config/api/routes.php
Normal file
29
public/kirby/config/api/routes.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Api Routes Definitions
|
||||
*/
|
||||
return function ($kirby) {
|
||||
$routes = [
|
||||
...include __DIR__ . '/routes/auth.php',
|
||||
...include __DIR__ . '/routes/changes.php',
|
||||
...include __DIR__ . '/routes/pages.php',
|
||||
...include __DIR__ . '/routes/roles.php',
|
||||
...include __DIR__ . '/routes/site.php',
|
||||
...include __DIR__ . '/routes/users.php',
|
||||
...include __DIR__ . '/routes/files.php',
|
||||
...include __DIR__ . '/routes/system.php',
|
||||
...include __DIR__ . '/routes/translations.php'
|
||||
];
|
||||
|
||||
// only add the language routes if the
|
||||
// multi language setup is activated
|
||||
if ($kirby->option('languages', false) !== false) {
|
||||
$routes = [
|
||||
...$routes,
|
||||
...include __DIR__ . '/routes/languages.php'
|
||||
];
|
||||
}
|
||||
|
||||
return $routes;
|
||||
};
|
||||
126
public/kirby/config/api/routes/auth.php
Normal file
126
public/kirby/config/api/routes/auth.php
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Exception\NotFoundException;
|
||||
|
||||
/**
|
||||
* Authentication
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'auth',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
if ($user = $this->kirby()->auth()->user()) {
|
||||
return $this->resolve($user)->view('auth');
|
||||
}
|
||||
|
||||
throw new NotFoundException(
|
||||
message: 'The user cannot be found'
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/code',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException(
|
||||
message: 'Invalid CSRF token'
|
||||
);
|
||||
}
|
||||
|
||||
$user = $auth->verifyChallenge($this->requestBody('code'));
|
||||
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/login',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
$methods = $this->kirby()->system()->loginMethods();
|
||||
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException(
|
||||
message: 'Invalid CSRF token'
|
||||
);
|
||||
}
|
||||
|
||||
$email = $this->requestBody('email');
|
||||
$long = $this->requestBody('long');
|
||||
$password = $this->requestBody('password');
|
||||
|
||||
if ($password) {
|
||||
if (isset($methods['password']) !== true) {
|
||||
throw new InvalidArgumentException(
|
||||
message: 'Login with password is not enabled'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
isset($methods['password']['2fa']) === true &&
|
||||
$methods['password']['2fa'] === true
|
||||
) {
|
||||
$status = $auth->login2fa($email, $password, $long);
|
||||
} else {
|
||||
$user = $auth->login($email, $password, $long);
|
||||
}
|
||||
} else {
|
||||
$mode = match (true) {
|
||||
isset($methods['code']) => 'login',
|
||||
isset($methods['password-reset']) => 'password-reset',
|
||||
default => throw new InvalidArgumentException(
|
||||
message: 'Login without password is not enabled'
|
||||
)
|
||||
};
|
||||
|
||||
$status = $auth->createChallenge($email, $long, $mode);
|
||||
}
|
||||
|
||||
if (isset($user)) {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'challenge' => $status->challenge()
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/logout',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$this->kirby()->auth()->logout();
|
||||
return true;
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/ping',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
// refresh the session timeout
|
||||
$this->kirby()->session();
|
||||
return true;
|
||||
}
|
||||
],
|
||||
];
|
||||
37
public/kirby/config/api/routes/changes.php
Normal file
37
public/kirby/config/api/routes/changes.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Api\Controller\Changes;
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
|
||||
return [
|
||||
[
|
||||
'pattern' => '(:all)/changes/discard',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path) {
|
||||
return Changes::discard(
|
||||
model: Find::parent($path),
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/changes/publish',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path) {
|
||||
return Changes::publish(
|
||||
model: Find::parent($path),
|
||||
input: App::instance()->request()->get()
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/changes/save',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path) {
|
||||
return Changes::save(
|
||||
model: Find::parent($path),
|
||||
input: App::instance()->request()->get()
|
||||
);
|
||||
}
|
||||
],
|
||||
];
|
||||
146
public/kirby/config/api/routes/files.php
Normal file
146
public/kirby/config/api/routes/files.php
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
|
||||
// routing pattern to match all models with files
|
||||
$filePattern = '(account/|pages/[^/]+/|site/|users/[^/]+/|)files/(:any)';
|
||||
$parentPattern = '(account|pages/[^/]+|site|users/[^/]+)/files';
|
||||
|
||||
/**
|
||||
* Files Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => $filePattern . '/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $parent, string $filename, string $fieldName, string|null $path = null) {
|
||||
if ($file = $this->file($parent, $filename)) {
|
||||
return $this->fieldApi($file, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern . '/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path, string $filename, string $sectionName) {
|
||||
return $this->file($path, $filename)->blueprint()->section($sectionName)?->toResponse();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern . '/sections/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $parent, string $filename, string $sectionName, string|null $path = null) {
|
||||
if ($file = $this->file($parent, $filename)) {
|
||||
return $this->sectionApi($file, $sectionName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $parentPattern,
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path) {
|
||||
return $this->files($path)->sorted();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $parentPattern,
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path) {
|
||||
// move_uploaded_file() not working with unit test
|
||||
// @codeCoverageIgnoreStart
|
||||
return $this->upload(function ($source, $filename) use ($path) {
|
||||
// move the source file to the content folder
|
||||
return $this->parent($path)->createFile([
|
||||
'content' => [
|
||||
'sort' => $this->requestBody('sort')
|
||||
],
|
||||
'source' => $source,
|
||||
'template' => $this->requestBody('template'),
|
||||
'filename' => $filename
|
||||
], true);
|
||||
});
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $parentPattern . '/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function (string $path) {
|
||||
$files = $this->files($path);
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $files->search($this->requestQuery('q'));
|
||||
}
|
||||
|
||||
return $files->query($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $parentPattern . '/sort',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path) {
|
||||
return $this->files($path)->changeSort(
|
||||
$this->requestBody('files'),
|
||||
$this->requestBody('index')
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern,
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern,
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->update(
|
||||
$this->requestBody(),
|
||||
$this->language(),
|
||||
true
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern,
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path, string $filename) {
|
||||
// move the source file from the temp dir
|
||||
return $this->upload(
|
||||
fn ($source) => $this->file($path, $filename)->replace($source, true)
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern,
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern . '/name',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->changeName($this->requestBody('name'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $parentPattern . '/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
$files = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filter('isListable', true)
|
||||
->files()
|
||||
->filter('isListable', true);
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $files->search($this->requestQuery('q'));
|
||||
}
|
||||
|
||||
return $files->query($this->requestBody());
|
||||
}
|
||||
],
|
||||
];
|
||||
35
public/kirby/config/api/routes/kql.php
Normal file
35
public/kirby/config/api/routes/kql.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
return [
|
||||
'routes' => function ($kirby) {
|
||||
return [
|
||||
[
|
||||
'pattern' => 'query',
|
||||
'method' => 'POST|GET',
|
||||
'auth' => $kirby->option('kql.auth') !== false,
|
||||
'action' => function () use ($kirby) {
|
||||
$kql = '\Kirby\Kql\Kql';
|
||||
|
||||
if (class_exists($kql) === false) {
|
||||
return [
|
||||
'code' => 500,
|
||||
'status' => 'error',
|
||||
'message' => 'KQL plugin is not installed',
|
||||
];
|
||||
}
|
||||
|
||||
$input = $kirby->request()->get();
|
||||
$result = $kql::run($input);
|
||||
|
||||
return [
|
||||
'code' => 200,
|
||||
'result' => $result,
|
||||
'status' => 'ok',
|
||||
];
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
||||
42
public/kirby/config/api/routes/languages.php
Normal file
42
public/kirby/config/api/routes/languages.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Roles Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'languages',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->kirby()->languages();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->kirby()->languages()->create($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->languages()->find($code);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->languages()->find($code)?->update($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->languages()->find($code)?->delete();
|
||||
}
|
||||
]
|
||||
];
|
||||
129
public/kirby/config/api/routes/pages.php
Normal file
129
public/kirby/config/api/routes/pages.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Page Routes
|
||||
*/
|
||||
return [
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->delete($this->requestBody('force', false));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/blueprint',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/blueprints',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->pages($id, $this->requestQuery('status'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->createChild($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->searchPages($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/duplicate',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->duplicate($this->requestBody('slug'), [
|
||||
'children' => $this->requestBody('children'),
|
||||
'files' => $this->requestBody('files'),
|
||||
]);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/slug',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeSlug($this->requestBody('slug'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/status',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeStatus($this->requestBody('status'), $this->requestBody('position'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/template',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeTemplate($this->requestBody('template'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/title',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeTitle($this->requestBody('title'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string|null $path = null) {
|
||||
if ($page = $this->page($id)) {
|
||||
return $this->fieldApi($page, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id, string $sectionName) {
|
||||
return $this->page($id)->blueprint()->section($sectionName)?->toResponse();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/sections/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $sectionName, string|null $path = null) {
|
||||
if ($page = $this->page($id)) {
|
||||
return $this->sectionApi($page, $sectionName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
];
|
||||
27
public/kirby/config/api/routes/roles.php
Normal file
27
public/kirby/config/api/routes/roles.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Roles Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'roles',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
$kirby = $this->kirby();
|
||||
|
||||
return match ($kirby->request()->get('canBe')) {
|
||||
'changed' => $kirby->roles()->canBeChanged(),
|
||||
'created' => $kirby->roles()->canBeCreated(),
|
||||
default => $kirby->roles()
|
||||
};
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'roles/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $name) {
|
||||
return $this->kirby()->roles()->find($name);
|
||||
}
|
||||
]
|
||||
];
|
||||
109
public/kirby/config/api/routes/site.php
Normal file
109
public/kirby/config/api/routes/site.php
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Site Routes
|
||||
*/
|
||||
return [
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => 'site',
|
||||
'action' => function () {
|
||||
return $this->site();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site',
|
||||
'method' => 'PATCH',
|
||||
'action' => function () {
|
||||
return $this->site()->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->pages(null, $this->requestQuery('status'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->site()->createChild($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
return $this->searchPages();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/blueprint',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->site()->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/blueprints',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->site()->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/find',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->site()->find(false, ...$this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/title',
|
||||
'method' => 'PATCH',
|
||||
'action' => function () {
|
||||
return $this->site()->changeTitle($this->requestBody('title'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
$pages = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filter('isListable', true);
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $pages->search($this->requestQuery('q'));
|
||||
}
|
||||
|
||||
return $pages->query($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $fieldName, string|null $path = null) {
|
||||
return $this->fieldApi($this->site(), $fieldName, $path);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $sectionName) {
|
||||
return $this->site()->blueprint()->section($sectionName)?->toResponse();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/sections/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $sectionName, string|null $path = null) {
|
||||
return $this->sectionApi($this->site(), $sectionName, $path);
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
];
|
||||
86
public/kirby/config/api/routes/system.php
Normal file
86
public/kirby/config/api/routes/system.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* System Routes
|
||||
*/
|
||||
return [
|
||||
|
||||
[
|
||||
'pattern' => 'system',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$system = $this->kirby()->system();
|
||||
|
||||
if ($this->kirby()->user()) {
|
||||
return $system;
|
||||
}
|
||||
|
||||
$info = match ($system->isOk()) {
|
||||
true => $this->resolve($system)->view('login')->toArray(),
|
||||
false => $this->resolve($system)->view('troubleshooting')->toArray()
|
||||
};
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'data' => $info,
|
||||
'type' => 'model'
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'system/register',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->kirby()->system()->register($this->requestBody('license'), $this->requestBody('email'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'system/install',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$system = $this->kirby()->system();
|
||||
$auth = $this->kirby()->auth();
|
||||
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException(
|
||||
message: 'Invalid CSRF token'
|
||||
);
|
||||
}
|
||||
|
||||
if ($system->isOk() === false) {
|
||||
throw new Exception(
|
||||
message: 'The server is not setup correctly'
|
||||
);
|
||||
}
|
||||
|
||||
if ($system->isInstallable() === false) {
|
||||
throw new Exception(
|
||||
message: 'The Panel cannot be installed'
|
||||
);
|
||||
}
|
||||
|
||||
if ($system->isInstalled() === true) {
|
||||
throw new Exception(
|
||||
message: 'The Panel is already installed'
|
||||
);
|
||||
}
|
||||
|
||||
// create the first user
|
||||
$user = $this->users()->create($this->requestBody());
|
||||
$token = $user->login($this->requestBody('password'));
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'token' => $token,
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
}
|
||||
]
|
||||
|
||||
];
|
||||
24
public/kirby/config/api/routes/translations.php
Normal file
24
public/kirby/config/api/routes/translations.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Translations Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'translations',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
return $this->kirby()->translations();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'translations/(:any)',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->translations()->find($code);
|
||||
}
|
||||
]
|
||||
|
||||
];
|
||||
260
public/kirby/config/api/routes/users.php
Normal file
260
public/kirby/config/api/routes/users.php
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Filesystem\F;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* User Routes
|
||||
*/
|
||||
return [
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => 'users',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->users()->sort('username', 'asc', 'email', 'asc');
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'users',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->users()->create($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'users/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $this->users()->search($this->requestQuery('q'));
|
||||
}
|
||||
|
||||
return $this->users()->query($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->avatar();
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->upload(
|
||||
function ($source, $filename) use ($id) {
|
||||
$type = F::type($filename);
|
||||
if ($type !== 'image') {
|
||||
throw new Exception(
|
||||
key: 'file.type.invalid',
|
||||
data: compact('type')
|
||||
);
|
||||
}
|
||||
|
||||
$mime = F::mime($source);
|
||||
if (Str::startsWith($mime, 'image/') !== true) {
|
||||
throw new Exception(
|
||||
key: 'file.mime.invalid',
|
||||
data: compact('mime')
|
||||
);
|
||||
}
|
||||
|
||||
// delete the old avatar
|
||||
$this->user($id)->avatar()?->delete();
|
||||
|
||||
$props = [
|
||||
'filename' => 'profile.' . F::extension($filename),
|
||||
'template' => 'avatar',
|
||||
'source' => $source
|
||||
];
|
||||
|
||||
// move the source file from the temp dir
|
||||
return $this->user($id)->createFile($props, true);
|
||||
},
|
||||
single: true
|
||||
);
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->avatar()->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/blueprint',
|
||||
'users/(:any)/blueprint',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/blueprints',
|
||||
'users/(:any)/blueprints',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/email',
|
||||
'users/(:any)/email',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeEmail($this->requestBody('email'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/language',
|
||||
'users/(:any)/language',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeLanguage($this->requestBody('language'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/name',
|
||||
'users/(:any)/name',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeName($this->requestBody('name'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/password',
|
||||
'users/(:any)/password',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
$user = $this->user($id);
|
||||
|
||||
// validate password of acting user unless they have logged in to reset it;
|
||||
// always validate password of acting user when changing password of other users
|
||||
if ($this->session()->get('kirby.resetPassword') !== true || $this->user()->is($user) !== true) {
|
||||
$this->user()->validatePassword($this->requestBody('currentPassword'));
|
||||
}
|
||||
|
||||
$result = $user->changePassword($this->requestBody('password'));
|
||||
|
||||
// if we changed the password of the current user…
|
||||
if ($user->isLoggedIn() === true) {
|
||||
// …don't allow additional resets (now the password is known again)
|
||||
$this->session()->remove('kirby.resetPassword');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/role',
|
||||
'users/(:any)/role',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeRole($this->requestBody('role'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/roles',
|
||||
'users/(:any)/roles',
|
||||
],
|
||||
'action' => function (string $id) {
|
||||
$kirby = $this->kirby();
|
||||
$purpose = $kirby->request()->get('purpose');
|
||||
return $this->user($id)->roles($purpose);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/fields/(:any)/(:all?)',
|
||||
'users/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string|null $path = null) {
|
||||
return $this->fieldApi($this->user($id), $fieldName, $path);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/sections/(:any)',
|
||||
'users/(:any)/sections/(:any)',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id, string $sectionName) {
|
||||
if ($section = $this->user($id)->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/sections/(:any)/(:all?)',
|
||||
'users/(:any)/sections/(:any)/(:all?)',
|
||||
],
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $sectionName, string|null $path = null) {
|
||||
return $this->sectionApi($this->user($id), $sectionName, $path);
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
];
|
||||
16
public/kirby/config/areas/account.php
Normal file
16
public/kirby/config/areas/account.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function () {
|
||||
return [
|
||||
'icon' => 'account',
|
||||
'label' => I18n::translate('view.account'),
|
||||
'search' => 'users',
|
||||
'buttons' => require __DIR__ . '/account/buttons.php',
|
||||
'dialogs' => require __DIR__ . '/account/dialogs.php',
|
||||
'drawers' => require __DIR__ . '/account/drawers.php',
|
||||
'dropdowns' => require __DIR__ . '/account/dropdowns.php',
|
||||
'views' => require __DIR__ . '/account/views.php'
|
||||
];
|
||||
};
|
||||
13
public/kirby/config/areas/account/buttons.php
Normal file
13
public/kirby/config/areas/account/buttons.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\User;
|
||||
use Kirby\Panel\Ui\Buttons\ViewButton;
|
||||
|
||||
return [
|
||||
'user.theme' => function (App $kirby, User $user) {
|
||||
if ($kirby->user()->is($user) === true) {
|
||||
return new ViewButton(component: 'k-theme-view-button');
|
||||
}
|
||||
}
|
||||
];
|
||||
65
public/kirby/config/areas/account/dialogs.php
Normal file
65
public/kirby/config/areas/account/dialogs.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Panel\UserTotpEnableDialog;
|
||||
|
||||
$dialogs = require __DIR__ . '/../users/dialogs.php';
|
||||
|
||||
return [
|
||||
'account.changeEmail' => [
|
||||
...$dialogs['user.changeEmail'],
|
||||
'pattern' => '(account)/changeEmail',
|
||||
],
|
||||
'account.changeLanguage' => [
|
||||
...$dialogs['user.changeLanguage'],
|
||||
'pattern' => '(account)/changeLanguage',
|
||||
],
|
||||
'account.changeName' => [
|
||||
...$dialogs['user.changeName'],
|
||||
'pattern' => '(account)/changeName',
|
||||
],
|
||||
'account.changePassword' => [
|
||||
...$dialogs['user.changePassword'],
|
||||
'pattern' => '(account)/changePassword',
|
||||
],
|
||||
'account.changeRole' => [
|
||||
...$dialogs['user.changeRole'],
|
||||
'pattern' => '(account)/changeRole',
|
||||
],
|
||||
'account.delete' => [
|
||||
...$dialogs['user.delete'],
|
||||
'pattern' => '(account)/delete',
|
||||
],
|
||||
'account.fields' => [
|
||||
...$dialogs['user.fields'],
|
||||
'pattern' => '(account)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'account.file.changeName' => [
|
||||
...$dialogs['user.file.changeName'],
|
||||
'pattern' => '(account)/files/(:any)/changeName',
|
||||
],
|
||||
'account.file.changeSort' => [
|
||||
...$dialogs['user.file.changeSort'],
|
||||
'pattern' => '(account)/files/(:any)/changeSort',
|
||||
],
|
||||
'account.file.changeTemplate' => [
|
||||
...$dialogs['user.file.changeTemplate'],
|
||||
'pattern' => '(account)/files/(:any)/changeTemplate',
|
||||
],
|
||||
'account.file.delete' => [
|
||||
...$dialogs['user.file.delete'],
|
||||
'pattern' => '(account)/files/(:any)/delete',
|
||||
],
|
||||
'account.file.fields' => [
|
||||
...$dialogs['user.file.fields'],
|
||||
'pattern' => '(account)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'account.totp.enable' => [
|
||||
'pattern' => '(account)/totp/enable',
|
||||
'load' => fn () => (new UserTotpEnableDialog())->load(),
|
||||
'submit' => fn () => (new UserTotpEnableDialog())->submit()
|
||||
],
|
||||
'account.totp.disable' => [
|
||||
'pattern' => '(account)/totp/disable',
|
||||
...$dialogs['user.totp.disable'],
|
||||
],
|
||||
];
|
||||
14
public/kirby/config/areas/account/drawers.php
Normal file
14
public/kirby/config/areas/account/drawers.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
$drawers = require __DIR__ . '/../users/drawers.php';
|
||||
|
||||
return [
|
||||
'account.fields' => [
|
||||
...$drawers['user.fields'],
|
||||
'pattern' => '(account)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'account.file.fields' => [
|
||||
...$drawers['user.file.fields'],
|
||||
'pattern' => '(account)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
];
|
||||
22
public/kirby/config/areas/account/dropdowns.php
Normal file
22
public/kirby/config/areas/account/dropdowns.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
$dropdowns = require __DIR__ . '/../users/dropdowns.php';
|
||||
|
||||
return [
|
||||
'account' => [
|
||||
...$dropdowns['user'],
|
||||
'pattern' => '(account)',
|
||||
],
|
||||
'account.languages' => [
|
||||
...$dropdowns['user.languages'],
|
||||
'pattern' => '(account)/languages',
|
||||
],
|
||||
'account.file' => [
|
||||
...$dropdowns['user.file'],
|
||||
'pattern' => '(account)/files/(:any)',
|
||||
],
|
||||
'account.file.languages' => [
|
||||
...$dropdowns['user.file.languages'],
|
||||
'pattern' => '(account)/files/(:any)/languages',
|
||||
]
|
||||
];
|
||||
35
public/kirby/config/areas/account/views.php
Normal file
35
public/kirby/config/areas/account/views.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'account' => [
|
||||
'pattern' => 'account',
|
||||
'action' => fn () => [
|
||||
'component' => 'k-account-view',
|
||||
'props' => App::instance()->user()->panel()->props(),
|
||||
],
|
||||
],
|
||||
'account.file' => [
|
||||
'pattern' => 'account/files/(:any)',
|
||||
'action' => function (string $filename) {
|
||||
return Find::file('account', $filename)->panel()->view();
|
||||
}
|
||||
],
|
||||
'account.password' => [
|
||||
'pattern' => 'reset-password',
|
||||
'action' => fn () => [
|
||||
'component' => 'k-reset-password-view',
|
||||
'breadcrumb' => [
|
||||
[
|
||||
'label' => I18n::translate('view.resetPassword')
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'requirePassword' => App::instance()->session()->get('kirby.resetPassword') !== true
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
61
public/kirby/config/areas/fields/dialogs.php
Normal file
61
public/kirby/config/areas/fields/dialogs.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Field;
|
||||
|
||||
return [
|
||||
'model' => [
|
||||
'load' => function (
|
||||
string $modelPath,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::dialog(
|
||||
model: Find::parent($modelPath),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'GET'
|
||||
);
|
||||
},
|
||||
'submit' => function (
|
||||
string $modelPath,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::dialog(
|
||||
model: Find::parent($modelPath),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'POST'
|
||||
);
|
||||
}
|
||||
],
|
||||
'file' => [
|
||||
'load' => function (
|
||||
string $modelPath,
|
||||
string $filename,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::dialog(
|
||||
model: Find::file($modelPath, $filename),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'GET'
|
||||
);
|
||||
},
|
||||
'submit' => function (
|
||||
string $modelPath,
|
||||
string $filename,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::dialog(
|
||||
model: Find::file($modelPath, $filename),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'POST'
|
||||
);
|
||||
}
|
||||
],
|
||||
];
|
||||
61
public/kirby/config/areas/fields/drawers.php
Normal file
61
public/kirby/config/areas/fields/drawers.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Field;
|
||||
|
||||
return [
|
||||
'model' => [
|
||||
'load' => function (
|
||||
string $modelPath,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::drawer(
|
||||
model: Find::parent($modelPath),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'GET'
|
||||
);
|
||||
},
|
||||
'submit' => function (
|
||||
string $modelPath,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::drawer(
|
||||
model: Find::parent($modelPath),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'POST'
|
||||
);
|
||||
}
|
||||
],
|
||||
'file' => [
|
||||
'load' => function (
|
||||
string $modelPath,
|
||||
string $filename,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::drawer(
|
||||
model: Find::file($modelPath, $filename),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'GET'
|
||||
);
|
||||
},
|
||||
'submit' => function (
|
||||
string $modelPath,
|
||||
string $filename,
|
||||
string $fieldName,
|
||||
string|null $path = null
|
||||
) {
|
||||
return Field::drawer(
|
||||
model: Find::file($modelPath, $filename),
|
||||
fieldName: $fieldName,
|
||||
path: $path,
|
||||
method: 'POST'
|
||||
);
|
||||
}
|
||||
],
|
||||
];
|
||||
14
public/kirby/config/areas/files/buttons.php
Normal file
14
public/kirby/config/areas/files/buttons.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\File;
|
||||
use Kirby\Panel\Ui\Buttons\OpenButton;
|
||||
use Kirby\Panel\Ui\Buttons\SettingsButton;
|
||||
|
||||
return [
|
||||
'file.open' => function (File $file) {
|
||||
return new OpenButton(link: $file->previewUrl());
|
||||
},
|
||||
'file.settings' => function (File $file) {
|
||||
return new SettingsButton(model: $file);
|
||||
}
|
||||
];
|
||||
165
public/kirby/config/areas/files/dialogs.php
Normal file
165
public/kirby/config/areas/files/dialogs.php
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Field;
|
||||
use Kirby\Panel\Panel;
|
||||
use Kirby\Toolkit\Escape;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
/**
|
||||
* Shared file dialogs
|
||||
* They are included in the site and
|
||||
* users area to create dialogs there.
|
||||
* The array keys are replaced by
|
||||
* the appropriate routes in the areas.
|
||||
*/
|
||||
return [
|
||||
'changeName' => [
|
||||
'load' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'name' => [
|
||||
'label' => I18n::translate('name'),
|
||||
'type' => 'slug',
|
||||
'required' => true,
|
||||
'icon' => 'title',
|
||||
'allow' => 'a-z0-9@._-',
|
||||
'after' => '.' . $file->extension(),
|
||||
'preselect' => true
|
||||
]
|
||||
],
|
||||
'submitButton' => I18n::translate('rename'),
|
||||
'value' => [
|
||||
'name' => $file->name(),
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
$name = $file->kirby()->request()->get('name');
|
||||
$renamed = $file->changeName($name);
|
||||
$oldUrl = $file->panel()->url(true);
|
||||
$newUrl = $renamed->panel()->url(true);
|
||||
$response = [
|
||||
'event' => 'file.changeName'
|
||||
];
|
||||
|
||||
// check for a necessary redirect after the filename has changed
|
||||
if (Panel::referrer() === $oldUrl && $oldUrl !== $newUrl) {
|
||||
$response['redirect'] = $newUrl;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
],
|
||||
|
||||
'changeSort' => [
|
||||
'load' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'position' => Field::filePosition($file)
|
||||
],
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'position' => $file->sort()->isEmpty() ? $file->siblings(false)->count() + 1 : $file->sort()->toInt(),
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
$files = $file->siblings()->sorted();
|
||||
$ids = $files->keys();
|
||||
$newIndex = (int)($file->kirby()->request()->get('position')) - 1;
|
||||
$oldIndex = $files->indexOf($file);
|
||||
|
||||
array_splice($ids, $oldIndex, 1);
|
||||
array_splice($ids, $newIndex, 0, $file->id());
|
||||
|
||||
$files->changeSort($ids);
|
||||
|
||||
return [
|
||||
'event' => 'file.sort',
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'changeTemplate' => [
|
||||
'load' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
$blueprints = $file->blueprints();
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'warning' => [
|
||||
'type' => 'info',
|
||||
'theme' => 'notice',
|
||||
'text' => I18n::translate('file.changeTemplate.notice')
|
||||
],
|
||||
'template' => Field::template($blueprints, [
|
||||
'required' => true
|
||||
])
|
||||
],
|
||||
'theme' => 'notice',
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'template' => $file->template()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
$template = $file->kirby()->request()->get('template');
|
||||
|
||||
$file->changeTemplate($template);
|
||||
|
||||
return [
|
||||
'event' => 'file.changeTemplate',
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'delete' => [
|
||||
'load' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
return [
|
||||
'component' => 'k-remove-dialog',
|
||||
'props' => [
|
||||
'text' => I18n::template('file.delete.confirm', [
|
||||
'filename' => Escape::html($file->filename())
|
||||
]),
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $path, string $filename) {
|
||||
$file = Find::file($path, $filename);
|
||||
$redirect = false;
|
||||
$referrer = Panel::referrer();
|
||||
$url = $file->panel()->url(true);
|
||||
|
||||
$file->delete();
|
||||
|
||||
// redirect to the parent model URL
|
||||
// if the dialog has been opened in the file view
|
||||
if ($referrer === $url) {
|
||||
$redirect = $file->parent()->panel()->url(true);
|
||||
}
|
||||
|
||||
return [
|
||||
'event' => 'file.delete',
|
||||
'redirect' => $redirect
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
];
|
||||
14
public/kirby/config/areas/files/dropdowns.php
Normal file
14
public/kirby/config/areas/files/dropdowns.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Ui\Buttons\LanguagesDropdown;
|
||||
|
||||
return [
|
||||
'file' => function (string $parent, string $filename) {
|
||||
return Find::file($parent, $filename)->panel()->dropdown();
|
||||
},
|
||||
'language' => function (string $parent, string $filename) {
|
||||
$file = Find::file($parent, $filename);
|
||||
return (new LanguagesDropdown($file))->options();
|
||||
}
|
||||
];
|
||||
40
public/kirby/config/areas/installation.php
Normal file
40
public/kirby/config/areas/installation.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Panel\Panel;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
return [
|
||||
'icon' => 'settings',
|
||||
'label' => I18n::translate('view.installation'),
|
||||
'views' => [
|
||||
'installation' => [
|
||||
'pattern' => 'installation',
|
||||
'auth' => false,
|
||||
'action' => function () use ($kirby) {
|
||||
$system = $kirby->system();
|
||||
return [
|
||||
'component' => 'k-installation-view',
|
||||
'props' => [
|
||||
'isInstallable' => $system->isInstallable(),
|
||||
'isInstalled' => $system->isInstalled(),
|
||||
'isOk' => $system->isOk(),
|
||||
'requirements' => $system->status(),
|
||||
'translations' => $kirby->translations()->values(function ($translation) {
|
||||
return [
|
||||
'text' => $translation->name(),
|
||||
'value' => $translation->code(),
|
||||
];
|
||||
}),
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
'installation.fallback' => [
|
||||
'pattern' => '(:all)',
|
||||
'auth' => false,
|
||||
'action' => fn () => Panel::go('installation')
|
||||
]
|
||||
]
|
||||
];
|
||||
};
|
||||
11
public/kirby/config/areas/lab.php
Normal file
11
public/kirby/config/areas/lab.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
return function () {
|
||||
return [
|
||||
'icon' => 'lab',
|
||||
'label' => 'Lab',
|
||||
'menu' => false,
|
||||
'drawers' => require __DIR__ . '/lab/drawers.php',
|
||||
'views' => require __DIR__ . '/lab/views.php'
|
||||
];
|
||||
};
|
||||
31
public/kirby/config/areas/lab/drawers.php
Normal file
31
public/kirby/config/areas/lab/drawers.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Panel\Lab\Doc;
|
||||
use Kirby\Panel\Lab\Docs;
|
||||
|
||||
return [
|
||||
'lab.docs' => [
|
||||
'pattern' => 'lab/docs/(:any)',
|
||||
'load' => function (string $component) {
|
||||
if (Docs::isInstalled() === false) {
|
||||
return [
|
||||
'component' => 'k-text-drawer',
|
||||
'props' => [
|
||||
'text' => 'The UI docs are not installed.'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$doc = Doc::factory($component);
|
||||
|
||||
return [
|
||||
'component' => 'k-lab-docs-drawer',
|
||||
'props' => [
|
||||
'icon' => 'book',
|
||||
'title' => $component,
|
||||
'docs' => $doc->toArray()
|
||||
]
|
||||
];
|
||||
},
|
||||
],
|
||||
];
|
||||
219
public/kirby/config/areas/lab/views.php
Normal file
219
public/kirby/config/areas/lab/views.php
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Panel\Lab\Category;
|
||||
use Kirby\Panel\Lab\Doc;
|
||||
use Kirby\Panel\Lab\Docs;
|
||||
|
||||
return [
|
||||
'lab' => [
|
||||
'pattern' => 'lab',
|
||||
'action' => function () {
|
||||
return [
|
||||
'component' => 'k-lab-index-view',
|
||||
'props' => [
|
||||
'categories' => Category::all(),
|
||||
'info' => Category::isInstalled() ? null : 'The default Lab examples are not installed.',
|
||||
'tab' => 'examples',
|
||||
],
|
||||
];
|
||||
}
|
||||
],
|
||||
'lab.docs' => [
|
||||
'pattern' => 'lab/docs',
|
||||
'action' => function () {
|
||||
$view = [
|
||||
'component' => 'k-lab-index-view',
|
||||
'title' => 'Docs',
|
||||
'breadcrumb' => [
|
||||
[
|
||||
'label' => 'Docs',
|
||||
'link' => 'lab/docs'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// if docs are not installed, show info message
|
||||
if (Docs::isInstalled() === false) {
|
||||
return [
|
||||
...$view,
|
||||
'props' => [
|
||||
'info' => 'The UI docs are not installed.',
|
||||
'tab' => 'docs',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
...$view,
|
||||
'props' => [
|
||||
'categories' => [
|
||||
['examples' => Docs::all()]
|
||||
],
|
||||
'tab' => 'docs',
|
||||
],
|
||||
];
|
||||
}
|
||||
],
|
||||
'lab.doc' => [
|
||||
'pattern' => 'lab/docs/(:any)',
|
||||
'action' => function (string $component) {
|
||||
$crumbs = [
|
||||
[
|
||||
'label' => 'Docs',
|
||||
'link' => 'lab/docs'
|
||||
],
|
||||
[
|
||||
'label' => $component,
|
||||
'link' => 'lab/docs/' . $component
|
||||
]
|
||||
];
|
||||
|
||||
if (Docs::isInstalled() === false) {
|
||||
return [
|
||||
'component' => 'k-lab-index-view',
|
||||
'title' => $component,
|
||||
'breadcrumb' => $crumbs,
|
||||
'props' => [
|
||||
'info' => 'The UI docs are not installed.',
|
||||
'tab' => 'docs',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$doc = Doc::factory($component);
|
||||
|
||||
if ($doc === null) {
|
||||
return [
|
||||
'component' => 'k-lab-index-view',
|
||||
'title' => $component,
|
||||
'breadcrumb' => $crumbs,
|
||||
'props' => [
|
||||
'info' => 'No UI docs found for ' . $component . '.',
|
||||
'tab' => 'docs',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// header buttons
|
||||
$buttons = [];
|
||||
|
||||
if ($lab = $doc->lab()) {
|
||||
$buttons[] = [
|
||||
'props' => [
|
||||
'text' => 'Lab examples',
|
||||
'icon' => 'lab',
|
||||
'link' => '/lab/' . $lab
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$buttons[] = [
|
||||
'props' => [
|
||||
'icon' => 'github',
|
||||
'link' => $doc->source(),
|
||||
'target' => '_blank'
|
||||
]
|
||||
];
|
||||
|
||||
return [
|
||||
'component' => 'k-lab-docs-view',
|
||||
'title' => $component,
|
||||
'breadcrumb' => $crumbs,
|
||||
'props' => [
|
||||
'buttons' => $buttons,
|
||||
'component' => $component,
|
||||
'docs' => $doc->toArray(),
|
||||
'lab' => $lab
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
'lab.vue' => [
|
||||
'pattern' => [
|
||||
'lab/(:any)/(:any)/index.vue',
|
||||
'lab/(:any)/(:any)/(:any)/index.vue'
|
||||
],
|
||||
'action' => function (
|
||||
string $category,
|
||||
string $id,
|
||||
string|null $tab = null
|
||||
) {
|
||||
return Category::factory($category)->example($id, $tab)->serve();
|
||||
}
|
||||
],
|
||||
'lab.example' => [
|
||||
'pattern' => 'lab/(:any)/(:any)/(:any?)',
|
||||
'action' => function (
|
||||
string $category,
|
||||
string $id,
|
||||
string|null $tab = null
|
||||
) {
|
||||
$category = Category::factory($category);
|
||||
$example = $category->example($id, $tab);
|
||||
$props = $example->props();
|
||||
$vue = $example->vue();
|
||||
$compiler = App::instance()->option('panel.vue.compiler', true);
|
||||
|
||||
if ($doc = $props['docs'] ?? null) {
|
||||
$doc = Doc::factory($doc);
|
||||
}
|
||||
|
||||
$github = $doc?->source();
|
||||
|
||||
if ($source = $props['source'] ?? null) {
|
||||
$github ??= 'https://github.com/getkirby/kirby/tree/main/' . $source;
|
||||
}
|
||||
|
||||
// header buttons
|
||||
$buttons = [];
|
||||
|
||||
if ($doc) {
|
||||
$buttons[] = [
|
||||
'props' => [
|
||||
'text' => $doc->name,
|
||||
'icon' => 'book',
|
||||
'drawer' => 'lab/docs/' . $doc->name
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
if ($github) {
|
||||
$buttons[] = [
|
||||
'props' => [
|
||||
'icon' => 'github',
|
||||
'link' => $github,
|
||||
'target' => '_blank'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-lab-playground-view',
|
||||
'breadcrumb' => [
|
||||
[
|
||||
'label' => $category->name(),
|
||||
],
|
||||
[
|
||||
'label' => $example->title(),
|
||||
'link' => $example->url()
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'buttons' => $buttons,
|
||||
'compiler' => $compiler,
|
||||
'docs' => $doc?->name,
|
||||
'examples' => $vue['examples'],
|
||||
'file' => $example->module(),
|
||||
'github' => $github,
|
||||
'props' => $props,
|
||||
'styles' => $vue['style'],
|
||||
'tab' => $example->tab(),
|
||||
'tabs' => array_values($example->tabs()),
|
||||
'template' => $vue['template'],
|
||||
'title' => $example->title(),
|
||||
],
|
||||
];
|
||||
}
|
||||
]
|
||||
];
|
||||
14
public/kirby/config/areas/languages.php
Normal file
14
public/kirby/config/areas/languages.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
return [
|
||||
'icon' => 'translate',
|
||||
'label' => I18n::translate('view.languages'),
|
||||
'menu' => true,
|
||||
'buttons' => require __DIR__ . '/languages/buttons.php',
|
||||
'dialogs' => require __DIR__ . '/languages/dialogs.php',
|
||||
'views' => require __DIR__ . '/languages/views.php'
|
||||
];
|
||||
};
|
||||
21
public/kirby/config/areas/languages/buttons.php
Normal file
21
public/kirby/config/areas/languages/buttons.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Language;
|
||||
use Kirby\Panel\Ui\Buttons\LanguageCreateButton;
|
||||
use Kirby\Panel\Ui\Buttons\LanguageDeleteButton;
|
||||
use Kirby\Panel\Ui\Buttons\LanguageSettingsButton;
|
||||
use Kirby\Panel\Ui\Buttons\OpenButton;
|
||||
|
||||
return [
|
||||
'languages.create' => fn () =>
|
||||
new LanguageCreateButton(),
|
||||
'language.open' => fn (Language $language) =>
|
||||
new OpenButton(link: $language->url()),
|
||||
'language.settings' => fn (Language $language) =>
|
||||
new LanguageSettingsButton($language),
|
||||
'language.delete' => function (Language $language) {
|
||||
if ($language->isDeletable() === true) {
|
||||
return new LanguageDeleteButton($language);
|
||||
}
|
||||
}
|
||||
];
|
||||
324
public/kirby/config/areas/languages/dialogs.php
Normal file
324
public/kirby/config/areas/languages/dialogs.php
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Cms\Language;
|
||||
use Kirby\Cms\LanguageVariable;
|
||||
use Kirby\Exception\NotFoundException;
|
||||
use Kirby\Toolkit\A;
|
||||
use Kirby\Toolkit\Escape;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
$languageDialogFields = [
|
||||
'name' => [
|
||||
'counter' => false,
|
||||
'label' => I18n::translate('language.name'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'icon' => 'title'
|
||||
],
|
||||
'code' => [
|
||||
'label' => I18n::translate('language.code'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'counter' => false,
|
||||
'icon' => 'translate',
|
||||
'width' => '1/2'
|
||||
],
|
||||
'direction' => [
|
||||
'label' => I18n::translate('language.direction'),
|
||||
'type' => 'select',
|
||||
'required' => true,
|
||||
'empty' => false,
|
||||
'options' => [
|
||||
['value' => 'ltr', 'text' => I18n::translate('language.direction.ltr')],
|
||||
['value' => 'rtl', 'text' => I18n::translate('language.direction.rtl')]
|
||||
],
|
||||
'width' => '1/2'
|
||||
],
|
||||
'locale' => [
|
||||
'counter' => false,
|
||||
'label' => I18n::translate('language.locale'),
|
||||
'type' => 'text',
|
||||
],
|
||||
];
|
||||
|
||||
$translationDialogFields = [
|
||||
'key' => [
|
||||
'counter' => false,
|
||||
'icon' => null,
|
||||
'label' => I18n::translate('language.variable.key'),
|
||||
'type' => 'text'
|
||||
],
|
||||
'multiple' => [
|
||||
'label' => I18n::translate('language.variable.multiple'),
|
||||
'text' => I18n::translate('language.variable.multiple.text'),
|
||||
'help' => I18n::translate('language.variable.multiple.help'),
|
||||
'type' => 'toggle'
|
||||
],
|
||||
'value' => [
|
||||
'buttons' => false,
|
||||
'counter' => false,
|
||||
'label' => I18n::translate('language.variable.value'),
|
||||
'type' => 'textarea',
|
||||
'when' => [
|
||||
'multiple' => false
|
||||
]
|
||||
],
|
||||
'entries' => [
|
||||
'field' => ['type' => 'text'],
|
||||
'label' => I18n::translate('language.variable.entries'),
|
||||
'help' => I18n::translate('language.variable.entries.help'),
|
||||
'type' => 'entries',
|
||||
'min' => 1,
|
||||
'when' => [
|
||||
'multiple' => true
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
return [
|
||||
// create language
|
||||
'language.create' => [
|
||||
'pattern' => 'languages/create',
|
||||
'load' => function () use ($languageDialogFields) {
|
||||
return [
|
||||
'component' => 'k-language-dialog',
|
||||
'props' => [
|
||||
'fields' => $languageDialogFields,
|
||||
'submitButton' => I18n::translate('language.create'),
|
||||
'value' => [
|
||||
'code' => '',
|
||||
'direction' => 'ltr',
|
||||
'locale' => '',
|
||||
'name' => '',
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function () {
|
||||
$kirby = App::instance();
|
||||
|
||||
$data = $kirby->request()->get([
|
||||
'code',
|
||||
'direction',
|
||||
'locale',
|
||||
'name'
|
||||
]);
|
||||
$kirby->languages()->create($data);
|
||||
|
||||
return [
|
||||
'event' => 'language.create'
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
// delete language
|
||||
'language.delete' => [
|
||||
'pattern' => 'languages/(:any)/delete',
|
||||
'load' => function (string $id) {
|
||||
$language = Find::language($id);
|
||||
return [
|
||||
'component' => 'k-remove-dialog',
|
||||
'props' => [
|
||||
'text' => I18n::template('language.delete.confirm', [
|
||||
'name' => Escape::html($language->name())
|
||||
])
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
Find::language($id)->delete();
|
||||
|
||||
return [
|
||||
'event' => 'language.delete',
|
||||
'redirect' => 'languages'
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
// update language
|
||||
'language.update' => [
|
||||
'pattern' => 'languages/(:any)/update',
|
||||
'load' => function (string $id) use ($languageDialogFields) {
|
||||
$language = Find::language($id);
|
||||
$fields = $languageDialogFields;
|
||||
$locale = $language->locale();
|
||||
|
||||
// use the first locale key if there's only one
|
||||
if (count($locale) === 1) {
|
||||
$locale = A::first($locale);
|
||||
}
|
||||
|
||||
// the code of an existing language cannot be changed
|
||||
$fields['code']['disabled'] = true;
|
||||
|
||||
// if the locale settings is more complex than just a
|
||||
// single string, the text field won't do it anymore.
|
||||
// Changes can only be made in the language file and
|
||||
// we display a warning box instead.
|
||||
if (is_array($locale) === true) {
|
||||
$fields['locale'] = [
|
||||
'label' => $fields['locale']['label'],
|
||||
'type' => 'info',
|
||||
'text' => I18n::translate('language.locale.warning')
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-language-dialog',
|
||||
'props' => [
|
||||
'fields' => $fields,
|
||||
'submitButton' => I18n::translate('save'),
|
||||
'value' => [
|
||||
'code' => $language->code(),
|
||||
'direction' => $language->direction(),
|
||||
'locale' => $locale,
|
||||
'name' => $language->name(),
|
||||
'rules' => $language->rules(),
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$kirby = App::instance();
|
||||
|
||||
$data = $kirby->request()->get(['direction', 'locale', 'name']);
|
||||
$language = Find::language($id)->update($data);
|
||||
|
||||
return [
|
||||
'event' => 'language.update'
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'language.translation.create' => [
|
||||
'pattern' => 'languages/(:any)/translations/create',
|
||||
'load' => function (string $languageCode) use ($translationDialogFields) {
|
||||
// find the language to make sure it exists
|
||||
Find::language($languageCode);
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => $translationDialogFields,
|
||||
'size' => 'large',
|
||||
'value' => [
|
||||
'multiple' => false,
|
||||
]
|
||||
],
|
||||
];
|
||||
},
|
||||
'submit' => function (string $languageCode) {
|
||||
$request = App::instance()->request();
|
||||
$language = Find::language($languageCode);
|
||||
|
||||
$key = $request->get('key', '');
|
||||
$multiple = $request->get('multiple', false);
|
||||
|
||||
$value = match ($multiple) {
|
||||
true => $request->get('entries', []),
|
||||
default => $request->get('value', '')
|
||||
};
|
||||
|
||||
LanguageVariable::create($key, $value);
|
||||
|
||||
if ($language->isDefault() === false) {
|
||||
$language->variable($key)->update($value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
],
|
||||
'language.translation.delete' => [
|
||||
'pattern' => 'languages/(:any)/translations/(:any)/delete',
|
||||
'load' => function (string $languageCode, string $translationKey) {
|
||||
$variable = Find::language($languageCode)->variable($translationKey, true);
|
||||
|
||||
if ($variable->exists() === false) {
|
||||
throw new NotFoundException(
|
||||
key: 'language.variable.notFound'
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-remove-dialog',
|
||||
'props' => [
|
||||
'text' => I18n::template('language.variable.delete.confirm', [
|
||||
'key' => Escape::html($variable->key())
|
||||
])
|
||||
],
|
||||
];
|
||||
},
|
||||
'submit' => function (string $languageCode, string $translationKey) {
|
||||
return Find::language($languageCode)->variable($translationKey, true)->delete();
|
||||
}
|
||||
],
|
||||
'language.translation.update' => [
|
||||
'pattern' => 'languages/(:any)/translations/(:any)/update',
|
||||
'load' => function (string $languageCode, string $translationKey) use ($translationDialogFields) {
|
||||
$language = Find::language($languageCode);
|
||||
$variable = $language->variable($translationKey, true);
|
||||
|
||||
if ($variable->exists() === false) {
|
||||
throw new NotFoundException(
|
||||
key: 'language.variable.notFound'
|
||||
);
|
||||
}
|
||||
|
||||
$fields = $translationDialogFields;
|
||||
|
||||
// the key field cannot be changed
|
||||
// the multiple field is hidden
|
||||
$fields['key']['disabled'] = true;
|
||||
$fields['multiple']['type'] = 'hidden';
|
||||
|
||||
// check if the variable has multiple values;
|
||||
// ensure to use the default language for this check because
|
||||
// the variable might not exist in the current language but
|
||||
// already be defined in the default language with multiple values
|
||||
$isVariableArray = Language::ensure('default')->variable($translationKey, true)->hasMultipleValues();
|
||||
|
||||
// set the correct value field
|
||||
// when value is string, set value for value field
|
||||
// when value is array, set value for entries field
|
||||
if ($isVariableArray === true) {
|
||||
$fields['entries']['autofocus'] = true;
|
||||
$value = [
|
||||
'entries' => $variable->value(),
|
||||
'key' => $variable->key(),
|
||||
'multiple' => true
|
||||
];
|
||||
} else {
|
||||
$fields['value']['autofocus'] = true;
|
||||
$value = [
|
||||
'key' => $variable->key(),
|
||||
'multiple' => false,
|
||||
'value' => $variable->value()
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => $fields,
|
||||
'size' => 'large',
|
||||
'value' => $value
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $languageCode, string $translationKey) {
|
||||
$request = App::instance()->request();
|
||||
$multiple = $request->get('multiple', false);
|
||||
$value = match ($multiple) {
|
||||
true => $request->get('entries', []),
|
||||
default => $request->get('value', '')
|
||||
};
|
||||
|
||||
Find::language($languageCode)->variable($translationKey, true)->update($value);
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
|
||||
];
|
||||
137
public/kirby/config/areas/languages/views.php
Normal file
137
public/kirby/config/areas/languages/views.php
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Ui\Buttons\ViewButtons;
|
||||
use Kirby\Toolkit\Escape;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'language' => [
|
||||
'pattern' => 'languages/(:any)',
|
||||
'when' => function (): bool {
|
||||
return App::instance()->option('languages.variables', true) !== false;
|
||||
},
|
||||
'action' => function (string $code) {
|
||||
$kirby = App::instance();
|
||||
$language = Find::language($code);
|
||||
$link = '/languages/' . $language->code();
|
||||
$strings = [];
|
||||
$foundation = $kirby->defaultLanguage()->translations();
|
||||
$translations = $language->translations();
|
||||
|
||||
// TODO: update following line and adapt for update and
|
||||
// delete options when `languageVariables.*` permissions available
|
||||
$canUpdate = $kirby->role()?->permissions()->for('languages', 'update') === true;
|
||||
|
||||
ksort($foundation);
|
||||
|
||||
foreach ($foundation as $key => $value) {
|
||||
$strings[] = [
|
||||
'key' => $key,
|
||||
'value' => $translations[$key] ?? null,
|
||||
'options' => [
|
||||
[
|
||||
'click' => 'update',
|
||||
'disabled' => $canUpdate === false,
|
||||
'icon' => 'edit',
|
||||
'text' => I18n::translate('edit'),
|
||||
],
|
||||
[
|
||||
'click' => 'delete',
|
||||
'disabled' => $canUpdate === false || $language->isDefault() === false,
|
||||
'icon' => 'trash',
|
||||
'text' => I18n::translate('delete'),
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$next = function () use ($language) {
|
||||
if ($next = $language->next()) {
|
||||
return [
|
||||
'link' => '/languages/' . $next->code(),
|
||||
'title' => $next->name(),
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
$prev = function () use ($language) {
|
||||
if ($prev = $language->prev()) {
|
||||
return [
|
||||
'link' => '/languages/' . $prev->code(),
|
||||
'title' => $prev->name(),
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
return [
|
||||
'component' => 'k-language-view',
|
||||
'breadcrumb' => [
|
||||
[
|
||||
'label' => $name = $language->name(),
|
||||
'link' => $link,
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'buttons' => fn () =>
|
||||
ViewButtons::view('language', model: $language)
|
||||
->defaults('open', 'settings', 'delete')
|
||||
->render(),
|
||||
'deletable' => $language->isDeletable(),
|
||||
'code' => Escape::html($language->code()),
|
||||
'default' => $language->isDefault(),
|
||||
'direction' => $language->direction(),
|
||||
'id' => $language->code(),
|
||||
'info' => [
|
||||
[
|
||||
'label' => 'Status',
|
||||
'value' => I18n::translate('language.' . ($language->isDefault() ? 'default' : 'secondary')),
|
||||
],
|
||||
[
|
||||
'label' => I18n::translate('language.code'),
|
||||
'value' => $language->code(),
|
||||
],
|
||||
[
|
||||
'label' => I18n::translate('language.locale'),
|
||||
'value' => $language->locale(LC_ALL)
|
||||
],
|
||||
[
|
||||
'label' => I18n::translate('language.direction'),
|
||||
'value' => I18n::translate('language.direction.' . $language->direction()),
|
||||
],
|
||||
],
|
||||
'name' => $name,
|
||||
'next' => $next,
|
||||
'prev' => $prev,
|
||||
'translations' => $strings,
|
||||
'url' => $language->url(),
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
'languages' => [
|
||||
'pattern' => 'languages',
|
||||
'action' => function () {
|
||||
$kirby = App::instance();
|
||||
|
||||
return [
|
||||
'component' => 'k-languages-view',
|
||||
'props' => [
|
||||
'buttons' => fn () =>
|
||||
ViewButtons::view('languages')
|
||||
->defaults('create')
|
||||
->render(),
|
||||
'languages' => $kirby->languages()->values(fn ($language) => [
|
||||
'deletable' => $language->isDeletable(),
|
||||
'default' => $language->isDefault(),
|
||||
'id' => $language->code(),
|
||||
'info' => Escape::html($language->code()),
|
||||
'text' => Escape::html($language->name()),
|
||||
]),
|
||||
'variables' => $kirby->option('languages.variables', true)
|
||||
]
|
||||
];
|
||||
}
|
||||
]
|
||||
];
|
||||
44
public/kirby/config/areas/login.php
Normal file
44
public/kirby/config/areas/login.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Panel\Panel;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
return [
|
||||
'icon' => 'user',
|
||||
'label' => I18n::translate('login'),
|
||||
'views' => [
|
||||
'login' => [
|
||||
'pattern' => 'login',
|
||||
'auth' => false,
|
||||
'action' => function () use ($kirby) {
|
||||
$system = $kirby->system();
|
||||
$status = $kirby->auth()->status();
|
||||
return [
|
||||
'component' => 'k-login-view',
|
||||
'props' => [
|
||||
'methods' => array_keys($system->loginMethods()),
|
||||
'pending' => [
|
||||
'email' => $status->email(),
|
||||
'challenge' => $status->challenge()
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
],
|
||||
'login.fallback' => [
|
||||
'pattern' => '(:all)',
|
||||
'auth' => false,
|
||||
'action' => function ($path) use ($kirby) {
|
||||
/**
|
||||
* Store the current path in the session
|
||||
* Once the user is logged in, the path will
|
||||
* be used to redirect to that view again
|
||||
*/
|
||||
$kirby->session()->set('panel.path', $path);
|
||||
Panel::go(url: 'login', refresh: 0);
|
||||
}
|
||||
]
|
||||
]
|
||||
];
|
||||
};
|
||||
21
public/kirby/config/areas/logout.php
Normal file
21
public/kirby/config/areas/logout.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Panel\Panel;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
return [
|
||||
'icon' => 'user',
|
||||
'label' => I18n::translate('logout'),
|
||||
'views' => [
|
||||
'logout' => [
|
||||
'pattern' => 'logout',
|
||||
'auth' => false,
|
||||
'action' => function () use ($kirby) {
|
||||
$kirby->auth()->logout();
|
||||
Panel::go('login');
|
||||
},
|
||||
]
|
||||
]
|
||||
];
|
||||
};
|
||||
11
public/kirby/config/areas/search.php
Normal file
11
public/kirby/config/areas/search.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function () {
|
||||
return [
|
||||
'icon' => 'search',
|
||||
'label' => I18n::translate('search'),
|
||||
'views' => require __DIR__ . '/search/views.php'
|
||||
];
|
||||
};
|
||||
17
public/kirby/config/areas/search/views.php
Normal file
17
public/kirby/config/areas/search/views.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
|
||||
return [
|
||||
'search' => [
|
||||
'pattern' => 'search',
|
||||
'action' => function () {
|
||||
return [
|
||||
'component' => 'k-search-view',
|
||||
'props' => [
|
||||
'type' => App::instance()->request()->get('type'),
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
];
|
||||
23
public/kirby/config/areas/site.php
Normal file
23
public/kirby/config/areas/site.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
$blueprint = $kirby->site()->blueprint();
|
||||
|
||||
return [
|
||||
'breadcrumbLabel' => function () use ($kirby) {
|
||||
return $kirby->site()->title()->or(I18n::translate('view.site'))->toString();
|
||||
},
|
||||
'icon' => $blueprint->icon() ?? 'home',
|
||||
'label' => $blueprint->title() ?? I18n::translate('view.site'),
|
||||
'menu' => true,
|
||||
'buttons' => require __DIR__ . '/site/buttons.php',
|
||||
'dialogs' => require __DIR__ . '/site/dialogs.php',
|
||||
'drawers' => require __DIR__ . '/site/drawers.php',
|
||||
'dropdowns' => require __DIR__ . '/site/dropdowns.php',
|
||||
'requests' => require __DIR__ . '/site/requests.php',
|
||||
'searches' => require __DIR__ . '/site/searches.php',
|
||||
'views' => require __DIR__ . '/site/views.php',
|
||||
];
|
||||
};
|
||||
72
public/kirby/config/areas/site/buttons.php
Normal file
72
public/kirby/config/areas/site/buttons.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\ModelWithContent;
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Cms\Site;
|
||||
use Kirby\Panel\Ui\Buttons\LanguagesDropdown;
|
||||
use Kirby\Panel\Ui\Buttons\OpenButton;
|
||||
use Kirby\Panel\Ui\Buttons\PageStatusButton;
|
||||
use Kirby\Panel\Ui\Buttons\PreviewButton;
|
||||
use Kirby\Panel\Ui\Buttons\SettingsButton;
|
||||
use Kirby\Panel\Ui\Buttons\VersionsButton;
|
||||
|
||||
return [
|
||||
'site.open' => function (Site $site, string $versionId = 'latest') {
|
||||
$versionId = $versionId === 'compare' ? 'changes' : $versionId;
|
||||
$link = $site->previewUrl($versionId);
|
||||
|
||||
if ($link !== null) {
|
||||
return new OpenButton(
|
||||
link: $link,
|
||||
);
|
||||
}
|
||||
},
|
||||
'site.preview' => function (Site $site) {
|
||||
if ($site->previewUrl() !== null) {
|
||||
return new PreviewButton(
|
||||
link: $site->panel()->url(true) . '/preview/changes',
|
||||
);
|
||||
}
|
||||
},
|
||||
'site.versions' => function (Site $site, string $versionId = 'latest') {
|
||||
return new VersionsButton(
|
||||
model: $site,
|
||||
versionId: $versionId
|
||||
);
|
||||
},
|
||||
'page.open' => function (Page $page, string $versionId = 'latest') {
|
||||
$versionId = $versionId === 'compare' ? 'changes' : $versionId;
|
||||
$link = $page->previewUrl($versionId);
|
||||
|
||||
if ($link !== null) {
|
||||
return new OpenButton(
|
||||
link: $link,
|
||||
);
|
||||
}
|
||||
},
|
||||
'page.preview' => function (Page $page) {
|
||||
if ($page->previewUrl() !== null) {
|
||||
return new PreviewButton(
|
||||
link: $page->panel()->url(true) . '/preview/changes',
|
||||
);
|
||||
}
|
||||
},
|
||||
'page.versions' => function (Page $page, string $versionId = 'latest') {
|
||||
return new VersionsButton(
|
||||
model: $page,
|
||||
versionId: $versionId
|
||||
);
|
||||
},
|
||||
'page.settings' => fn (Page $page) => new SettingsButton(model: $page),
|
||||
'page.status' => fn (Page $page) => new PageStatusButton($page),
|
||||
|
||||
// `languages` button needs to be in site area,
|
||||
// as the languages might be not loaded even in
|
||||
// multilang mode when the `languages` option is deactivated
|
||||
// (but content languages to switch between still can exist)
|
||||
'languages' => fn (ModelWithContent $model) =>
|
||||
new LanguagesDropdown($model),
|
||||
|
||||
// file buttons
|
||||
...require __DIR__ . '/../files/buttons.php'
|
||||
];
|
||||
592
public/kirby/config/areas/site/dialogs.php
Normal file
592
public/kirby/config/areas/site/dialogs.php
Normal file
|
|
@ -0,0 +1,592 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Cms\PageRules;
|
||||
use Kirby\Cms\Url;
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Exception\PermissionException;
|
||||
use Kirby\Panel\ChangesDialog;
|
||||
use Kirby\Panel\Field;
|
||||
use Kirby\Panel\PageCreateDialog;
|
||||
use Kirby\Panel\Panel;
|
||||
use Kirby\Toolkit\Escape;
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Kirby\Toolkit\Str;
|
||||
use Kirby\Uuid\Uuids;
|
||||
|
||||
$fields = require __DIR__ . '/../fields/dialogs.php';
|
||||
$files = require __DIR__ . '/../files/dialogs.php';
|
||||
|
||||
return [
|
||||
'page.changeSort' => [
|
||||
'pattern' => 'pages/(:any)/changeSort',
|
||||
'load' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
|
||||
if ($page->blueprint()->num() !== 'default') {
|
||||
throw new PermissionException(
|
||||
key: 'page.sort.permission',
|
||||
data: ['slug' => $page->slug()]
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'position' => Field::pagePosition($page),
|
||||
],
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'position' => $page->panel()->position()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
Find::page($id)->changeStatus(
|
||||
'listed',
|
||||
$request->get('position')
|
||||
);
|
||||
|
||||
return [
|
||||
'event' => 'page.sort',
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'page.changeStatus' => [
|
||||
'pattern' => 'pages/(:any)/changeStatus',
|
||||
'load' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
$blueprint = $page->blueprint();
|
||||
$status = $page->status();
|
||||
$states = [];
|
||||
$position = null;
|
||||
|
||||
foreach ($blueprint->status() as $key => $state) {
|
||||
$states[] = [
|
||||
'value' => $key,
|
||||
'text' => $state['label'],
|
||||
'info' => $state['text'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($status === 'draft') {
|
||||
$errors = $page->errors();
|
||||
|
||||
// switch to the error dialog if there are
|
||||
// errors and the draft cannot be published
|
||||
if (count($errors) > 0) {
|
||||
return [
|
||||
'component' => 'k-error-dialog',
|
||||
'props' => [
|
||||
'message' => I18n::translate('error.page.changeStatus.incomplete'),
|
||||
'details' => $errors,
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$fields = [
|
||||
'status' => [
|
||||
'label' => I18n::translate('page.changeStatus.select'),
|
||||
'type' => 'radio',
|
||||
'required' => true,
|
||||
'options' => $states
|
||||
]
|
||||
];
|
||||
|
||||
if ($blueprint->num() === 'default') {
|
||||
$fields['position'] = Field::pagePosition($page, [
|
||||
'when' => [
|
||||
'status' => 'listed'
|
||||
]
|
||||
]);
|
||||
|
||||
$position = $page->panel()->position();
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => $fields,
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'status' => $status,
|
||||
'position' => $position
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
Find::page($id)->changeStatus(
|
||||
$request->get('status'),
|
||||
$request->get('position')
|
||||
);
|
||||
|
||||
return [
|
||||
'event' => 'page.changeStatus',
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'page.changeTemplate' => [
|
||||
'pattern' => 'pages/(:any)/changeTemplate',
|
||||
'load' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
$blueprints = $page->blueprints();
|
||||
|
||||
if (count($blueprints) <= 1) {
|
||||
throw new Exception(
|
||||
key: 'page.changeTemplate.invalid',
|
||||
data: ['slug' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'notice' => [
|
||||
'type' => 'info',
|
||||
'theme' => 'notice',
|
||||
'text' => I18n::translate('page.changeTemplate.notice')
|
||||
],
|
||||
'template' => Field::template($blueprints, [
|
||||
'required' => true
|
||||
])
|
||||
],
|
||||
'theme' => 'notice',
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'template' => $page->intendedTemplate()->name()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
$template = App::instance()->request()->get('template');
|
||||
|
||||
$page->changeTemplate($template);
|
||||
|
||||
return [
|
||||
'event' => 'page.changeTemplate',
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'page.changeTitle' => [
|
||||
'pattern' => 'pages/(:any)/changeTitle',
|
||||
'load' => function (string $id) {
|
||||
$kirby = App::instance();
|
||||
$request = $kirby->request();
|
||||
|
||||
$page = Find::page($id);
|
||||
$permissions = $page->permissions();
|
||||
$select = $request->get('select', 'title');
|
||||
|
||||
// build the path prefix
|
||||
$path = match ($kirby->multilang()) {
|
||||
true => Str::after($kirby->site()->url(), $kirby->url()) . '/',
|
||||
false => '/'
|
||||
};
|
||||
|
||||
if ($parent = $page->parent()) {
|
||||
$path .= $parent->uri() . '/';
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'title' => Field::title([
|
||||
'required' => true,
|
||||
'preselect' => $select === 'title',
|
||||
'disabled' => $permissions->can('changeTitle') === false
|
||||
]),
|
||||
'slug' => Field::slug([
|
||||
'required' => true,
|
||||
'preselect' => $select === 'slug',
|
||||
'path' => $path,
|
||||
'disabled' => $permissions->can('changeSlug') === false,
|
||||
'wizard' => [
|
||||
'text' => I18n::translate('page.changeSlug.fromTitle'),
|
||||
'field' => 'title'
|
||||
]
|
||||
])
|
||||
],
|
||||
'autofocus' => false,
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'title' => $page->title()->value(),
|
||||
'slug' => $page->slug(),
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
$page = Find::page($id);
|
||||
$title = trim($request->get('title', ''));
|
||||
$slug = trim($request->get('slug', ''));
|
||||
|
||||
// basic input validation before we move on
|
||||
PageRules::validateTitleLength($title);
|
||||
PageRules::validateSlugLength($slug);
|
||||
|
||||
// nothing changed
|
||||
if ($page->title()->value() === $title && $page->slug() === $slug) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// prepare the response
|
||||
$response = [
|
||||
'event' => []
|
||||
];
|
||||
|
||||
// the page title changed
|
||||
if ($page->title()->value() !== $title) {
|
||||
$page = $page->changeTitle($title);
|
||||
$response['event'][] = 'page.changeTitle';
|
||||
}
|
||||
|
||||
// the slug changed
|
||||
if ($page->slug() !== $slug) {
|
||||
$response['event'][] = 'page.changeSlug';
|
||||
|
||||
$newPage = $page->changeSlug($slug);
|
||||
$oldUrl = $page->panel()->url(true);
|
||||
$newUrl = $newPage->panel()->url(true);
|
||||
|
||||
// check for a necessary redirect after the slug has changed
|
||||
if (Panel::referrer() === $oldUrl && $oldUrl !== $newUrl) {
|
||||
$response['redirect'] = $newUrl;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
],
|
||||
|
||||
'page.create' => [
|
||||
'pattern' => 'pages/create',
|
||||
'load' => function () {
|
||||
$request = App::instance()->request();
|
||||
$dialog = new PageCreateDialog(
|
||||
parentId: $request->get('parent'),
|
||||
sectionId: $request->get('section'),
|
||||
slug: $request->get('slug'),
|
||||
template: $request->get('template'),
|
||||
title: $request->get('title'),
|
||||
uuid: $request->get('uuid'),
|
||||
viewId: $request->get('view'),
|
||||
);
|
||||
|
||||
return $dialog->load();
|
||||
},
|
||||
'submit' => function () {
|
||||
$request = App::instance()->request();
|
||||
$dialog = new PageCreateDialog(
|
||||
parentId: $request->get('parent'),
|
||||
sectionId: $request->get('section'),
|
||||
slug: $request->get('slug'),
|
||||
template: $request->get('template'),
|
||||
title: $request->get('title'),
|
||||
uuid: $request->get('uuid'),
|
||||
viewId: $request->get('view'),
|
||||
);
|
||||
|
||||
return $dialog->submit($request->get());
|
||||
}
|
||||
],
|
||||
|
||||
'page.delete' => [
|
||||
'pattern' => 'pages/(:any)/delete',
|
||||
'load' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
$text = I18n::template('page.delete.confirm', [
|
||||
'title' => Escape::html($page->title()->value())
|
||||
]);
|
||||
|
||||
if ($page->childrenAndDrafts()->count() > 0) {
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'info' => [
|
||||
'type' => 'info',
|
||||
'theme' => 'negative',
|
||||
'text' => I18n::translate('page.delete.confirm.subpages')
|
||||
],
|
||||
'check' => [
|
||||
'label' => I18n::translate('page.delete.confirm.title'),
|
||||
'type' => 'text',
|
||||
'counter' => false
|
||||
]
|
||||
],
|
||||
'size' => 'medium',
|
||||
'submitButton' => I18n::translate('delete'),
|
||||
'text' => $text,
|
||||
'theme' => 'negative',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-remove-dialog',
|
||||
'props' => [
|
||||
'text' => $text
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
$page = Find::page($id);
|
||||
$redirect = false;
|
||||
$referrer = Panel::referrer();
|
||||
$url = $page->panel()->url(true);
|
||||
|
||||
if (
|
||||
$page->childrenAndDrafts()->count() > 0 &&
|
||||
$request->get('check') !== $page->title()->value()
|
||||
) {
|
||||
throw new InvalidArgumentException(
|
||||
key: 'page.delete.confirm'
|
||||
);
|
||||
}
|
||||
|
||||
$page->delete(true);
|
||||
|
||||
// redirect to the parent model URL
|
||||
// if the dialog has been opened in the page view
|
||||
if ($referrer === $url) {
|
||||
$redirect = $page->parentModel()->panel()->url(true);
|
||||
}
|
||||
|
||||
return [
|
||||
'event' => 'page.delete',
|
||||
'redirect' => $redirect
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'page.duplicate' => [
|
||||
'pattern' => 'pages/(:any)/duplicate',
|
||||
'load' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
$hasChildren = $page->hasChildren();
|
||||
$hasFiles = $page->hasFiles();
|
||||
$toggleWidth = '1/' . count(array_filter([$hasChildren, $hasFiles]));
|
||||
|
||||
$fields = [
|
||||
'title' => Field::title([
|
||||
'required' => true
|
||||
]),
|
||||
'slug' => Field::slug([
|
||||
'required' => true,
|
||||
'path' => $page->parent() ? '/' . $page->parent()->id() . '/' : '/',
|
||||
'wizard' => [
|
||||
'text' => I18n::translate('page.changeSlug.fromTitle'),
|
||||
'field' => 'title'
|
||||
]
|
||||
])
|
||||
];
|
||||
|
||||
if ($hasFiles === true) {
|
||||
$fields['files'] = [
|
||||
'label' => I18n::translate('page.duplicate.files'),
|
||||
'type' => 'toggle',
|
||||
'width' => $toggleWidth
|
||||
];
|
||||
}
|
||||
|
||||
if ($hasChildren === true) {
|
||||
$fields['children'] = [
|
||||
'label' => I18n::translate('page.duplicate.pages'),
|
||||
'type' => 'toggle',
|
||||
'width' => $toggleWidth
|
||||
];
|
||||
}
|
||||
|
||||
$slugAppendix = Url::slug(I18n::translate('page.duplicate.appendix'));
|
||||
$titleAppendix = I18n::translate('page.duplicate.appendix');
|
||||
|
||||
// if the item to be duplicated already exists
|
||||
// add a suffix at the end of slug and title
|
||||
$duplicateSlug = $page->slug() . '-' . $slugAppendix;
|
||||
$siblingKeys = $page->parentModel()->childrenAndDrafts()->pluck('uid');
|
||||
|
||||
if (in_array($duplicateSlug, $siblingKeys, true) === true) {
|
||||
$suffixCounter = 2;
|
||||
$newSlug = $duplicateSlug . $suffixCounter;
|
||||
|
||||
while (in_array($newSlug, $siblingKeys, true) === true) {
|
||||
$newSlug = $duplicateSlug . ++$suffixCounter;
|
||||
}
|
||||
|
||||
$slugAppendix .= $suffixCounter;
|
||||
$titleAppendix .= ' ' . $suffixCounter;
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => $fields,
|
||||
'submitButton' => I18n::translate('duplicate'),
|
||||
'value' => [
|
||||
'children' => false,
|
||||
'files' => false,
|
||||
'slug' => $page->slug() . '-' . $slugAppendix,
|
||||
'title' => $page->title() . ' ' . $titleAppendix
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
$newPage = Find::page($id)->duplicate($request->get('slug'), [
|
||||
'children' => (bool)$request->get('children'),
|
||||
'files' => (bool)$request->get('files'),
|
||||
'title' => (string)$request->get('title'),
|
||||
]);
|
||||
|
||||
return [
|
||||
'event' => 'page.duplicate',
|
||||
'redirect' => $newPage->panel()->url(true)
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'page.fields' => [
|
||||
...$fields['model'],
|
||||
'pattern' => '(pages/[^/]+)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'page.file.changeName' => [
|
||||
...$files['changeName'],
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)/changeName',
|
||||
],
|
||||
'page.file.changeSort' => [
|
||||
...$files['changeSort'],
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)/changeSort',
|
||||
],
|
||||
'page.file.changeTemplate' => [
|
||||
...$files['changeTemplate'],
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)/changeTemplate',
|
||||
],
|
||||
'page.file.delete' => [
|
||||
...$files['delete'],
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)/delete',
|
||||
],
|
||||
'page.file.fields' => [
|
||||
...$fields['file'],
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
|
||||
'page.move' => [
|
||||
'pattern' => 'pages/(:any)/move',
|
||||
'load' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
$parent = $page->parentModel();
|
||||
|
||||
if (Uuids::enabled() === false) {
|
||||
$parentId = $parent?->id() ?? '/';
|
||||
} else {
|
||||
$parentId = $parent?->uuid()->toString() ?? 'site://';
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-page-move-dialog',
|
||||
'props' => [
|
||||
'value' => [
|
||||
'move' => $page->panel()->url(true),
|
||||
'parent' => $parentId
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$kirby = App::instance();
|
||||
$parentId = $kirby->request()->get('parent');
|
||||
$parent = (empty($parentId) === true || $parentId === '/' || $parentId === 'site://') ? $kirby->site() : Find::page($parentId);
|
||||
$oldPage = Find::page($id);
|
||||
$newPage = $oldPage->move($parent);
|
||||
|
||||
return [
|
||||
'event' => 'page.move',
|
||||
'redirect' => $newPage->panel()->url(true)
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'site.changeTitle' => [
|
||||
'pattern' => 'site/changeTitle',
|
||||
'load' => function () {
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'title' => Field::title([
|
||||
'required' => true,
|
||||
'preselect' => true
|
||||
])
|
||||
],
|
||||
'submitButton' => I18n::translate('rename'),
|
||||
'value' => [
|
||||
'title' => App::instance()->site()->title()->value()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function () {
|
||||
$kirby = App::instance();
|
||||
$kirby->site()->changeTitle($kirby->request()->get('title'));
|
||||
|
||||
return [
|
||||
'event' => 'site.changeTitle',
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'site.fields' => [
|
||||
...$fields['model'],
|
||||
'pattern' => '(site)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'site.file.changeName' => [
|
||||
...$files['changeName'],
|
||||
'pattern' => '(site)/files/(:any)/changeName',
|
||||
],
|
||||
'site.file.changeSort' => [
|
||||
...$files['changeSort'],
|
||||
'pattern' => '(site)/files/(:any)/changeSort',
|
||||
],
|
||||
'site.file.changeTemplate' => [
|
||||
...$files['changeTemplate'],
|
||||
'pattern' => '(site)/files/(:any)/changeTemplate',
|
||||
],
|
||||
'site.file.delete' => [
|
||||
...$files['delete'],
|
||||
'pattern' => '(site)/files/(:any)/delete',
|
||||
],
|
||||
'site.file.fields' => [
|
||||
...$fields['file'],
|
||||
'pattern' => '(site)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
|
||||
'changes' => [
|
||||
'pattern' => 'changes',
|
||||
'load' => function () {
|
||||
return (new ChangesDialog())->load();
|
||||
},
|
||||
],
|
||||
];
|
||||
22
public/kirby/config/areas/site/drawers.php
Normal file
22
public/kirby/config/areas/site/drawers.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
$fields = require __DIR__ . '/../fields/drawers.php';
|
||||
|
||||
return [
|
||||
'page.fields' => [
|
||||
...$fields['model'],
|
||||
'pattern' => '(pages/[^/]+)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'page.file.fields' => [
|
||||
...$fields['file'],
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'site.fields' => [
|
||||
...$fields['model'],
|
||||
'pattern' => '(site)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'site.file.fields' => [
|
||||
...$fields['file'],
|
||||
'pattern' => '(site)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
];
|
||||
46
public/kirby/config/areas/site/dropdowns.php
Normal file
46
public/kirby/config/areas/site/dropdowns.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Ui\Buttons\LanguagesDropdown;
|
||||
|
||||
$files = require __DIR__ . '/../files/dropdowns.php';
|
||||
|
||||
return [
|
||||
'page' => [
|
||||
'pattern' => 'pages/(:any)',
|
||||
'options' => function (string $path) {
|
||||
return Find::page($path)->panel()->dropdown();
|
||||
}
|
||||
],
|
||||
'page.languages' => [
|
||||
'pattern' => 'pages/(:any)/languages',
|
||||
'options' => function (string $path) {
|
||||
$page = Find::page($path);
|
||||
return (new LanguagesDropdown($page))->options();
|
||||
}
|
||||
],
|
||||
'page.file' => [
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)',
|
||||
'options' => $files['file']
|
||||
],
|
||||
'page.file.languages' => [
|
||||
'pattern' => '(pages/[^/]+)/files/(:any)/languages',
|
||||
'options' => $files['language']
|
||||
],
|
||||
'site.languages' => [
|
||||
'pattern' => 'site/languages',
|
||||
'options' => function () {
|
||||
$site = App::instance()->site();
|
||||
return (new LanguagesDropdown($site))->options();
|
||||
}
|
||||
],
|
||||
'site.file' => [
|
||||
'pattern' => '(site)/files/(:any)',
|
||||
'options' => $files['file']
|
||||
],
|
||||
'site.file.languages' => [
|
||||
'pattern' => '(site)/files/(:any)/languages',
|
||||
'options' => $files['language']
|
||||
]
|
||||
];
|
||||
25
public/kirby/config/areas/site/requests.php
Normal file
25
public/kirby/config/areas/site/requests.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Panel\Controller\PageTree;
|
||||
|
||||
return [
|
||||
'tree' => [
|
||||
'pattern' => 'site/tree',
|
||||
'action' => function () {
|
||||
return (new PageTree())->children(
|
||||
parent: App::instance()->request()->get('parent'),
|
||||
moving: App::instance()->request()->get('move')
|
||||
);
|
||||
}
|
||||
],
|
||||
'tree.parents' => [
|
||||
'pattern' => 'site/tree/parents',
|
||||
'action' => function () {
|
||||
return (new PageTree())->parents(
|
||||
page: App::instance()->request()->get('page'),
|
||||
includeSite: App::instance()->request()->get('root') === 'true',
|
||||
);
|
||||
}
|
||||
]
|
||||
];
|
||||
17
public/kirby/config/areas/site/searches.php
Normal file
17
public/kirby/config/areas/site/searches.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Panel\Controller\Search;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'pages' => [
|
||||
'label' => I18n::translate('pages'),
|
||||
'icon' => 'page',
|
||||
'query' => fn (string|null $query, int $limit, int $page) => Search::pages($query, $limit, $page)
|
||||
],
|
||||
'files' => [
|
||||
'label' => I18n::translate('files'),
|
||||
'icon' => 'image',
|
||||
'query' => fn (string|null $query, int $limit, int $page) => Search::files($query, $limit, $page)
|
||||
]
|
||||
];
|
||||
98
public/kirby/config/areas/site/views.php
Normal file
98
public/kirby/config/areas/site/views.php
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Exception\PermissionException;
|
||||
use Kirby\Panel\Ui\Buttons\ViewButtons;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'page' => [
|
||||
'pattern' => 'pages/(:any)',
|
||||
'action' => fn (string $path) => Find::page($path)->panel()->view()
|
||||
],
|
||||
'page.file' => [
|
||||
'pattern' => 'pages/(:any)/files/(:any)',
|
||||
'action' => function (string $id, string $filename) {
|
||||
return Find::file('pages/' . $id, $filename)->panel()->view();
|
||||
}
|
||||
],
|
||||
'page.preview' => [
|
||||
'pattern' => 'pages/(:any)/preview/(changes|latest|compare)',
|
||||
'action' => function (string $path, string $versionId) {
|
||||
$page = Find::page($path);
|
||||
$view = $page->panel()->view();
|
||||
$src = [
|
||||
'latest' => $page->previewUrl('latest'),
|
||||
'changes' => $page->previewUrl('changes'),
|
||||
];
|
||||
|
||||
if ($src['latest'] === null) {
|
||||
throw new PermissionException('The preview is not available');
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-preview-view',
|
||||
'props' => [
|
||||
...$view['props'],
|
||||
'back' => $view['props']['link'],
|
||||
'buttons' => fn () =>
|
||||
ViewButtons::view('page.preview', model: $page)
|
||||
->defaults(
|
||||
'page.versions',
|
||||
'languages',
|
||||
)
|
||||
->bind(['versionId' => $versionId])
|
||||
->render(),
|
||||
'src' => $src,
|
||||
'versionId' => $versionId,
|
||||
],
|
||||
'title' => $view['props']['title'] . ' | ' . I18n::translate('preview'),
|
||||
];
|
||||
}
|
||||
],
|
||||
'site' => [
|
||||
'pattern' => 'site',
|
||||
'action' => fn () => App::instance()->site()->panel()->view()
|
||||
],
|
||||
'site.file' => [
|
||||
'pattern' => 'site/files/(:any)',
|
||||
'action' => function (string $filename) {
|
||||
return Find::file('site', $filename)->panel()->view();
|
||||
}
|
||||
],
|
||||
'site.preview' => [
|
||||
'pattern' => 'site/preview/(changes|latest|compare)',
|
||||
'action' => function (string $versionId) {
|
||||
$site = App::instance()->site();
|
||||
$view = $site->panel()->view();
|
||||
$src = [
|
||||
'latest' => $site->previewUrl('latest'),
|
||||
'changes' => $site->previewUrl('changes'),
|
||||
];
|
||||
|
||||
if ($src['latest'] === null) {
|
||||
throw new PermissionException('The preview is not available');
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-preview-view',
|
||||
'props' => [
|
||||
...$view['props'],
|
||||
'back' => $view['props']['link'],
|
||||
'buttons' => fn () =>
|
||||
ViewButtons::view('site.preview', model: $site)
|
||||
->defaults(
|
||||
'site.versions',
|
||||
'languages'
|
||||
)
|
||||
->bind(['versionId' => $versionId])
|
||||
->render(),
|
||||
'src' => $src,
|
||||
'versionId' => $versionId
|
||||
],
|
||||
'title' => I18n::translate('view.site') . ' | ' . I18n::translate('preview'),
|
||||
];
|
||||
}
|
||||
],
|
||||
];
|
||||
13
public/kirby/config/areas/system.php
Normal file
13
public/kirby/config/areas/system.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
return [
|
||||
'icon' => 'settings',
|
||||
'label' => I18n::translate('view.system'),
|
||||
'menu' => true,
|
||||
'dialogs' => require __DIR__ . '/system/dialogs.php',
|
||||
'views' => require __DIR__ . '/system/views.php'
|
||||
];
|
||||
};
|
||||
135
public/kirby/config/areas/system/dialogs.php
Normal file
135
public/kirby/config/areas/system/dialogs.php
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Exception\LogicException;
|
||||
use Kirby\Panel\Field;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
// license key
|
||||
'license' => [
|
||||
'load' => function () {
|
||||
$kirby = App::instance();
|
||||
$license = $kirby->system()->license();
|
||||
$obfuscated = $kirby->user()->isAdmin() === false;
|
||||
$status = $license->status();
|
||||
$renewable = $status->renewable();
|
||||
|
||||
return [
|
||||
'component' => 'k-license-dialog',
|
||||
'props' => [
|
||||
'license' => [
|
||||
'code' => $license->code($obfuscated),
|
||||
'icon' => $status->icon(),
|
||||
'info' => $status->info($license->renewal('Y-m-d', 'date')),
|
||||
'theme' => $status->theme(),
|
||||
'type' => $license->label(),
|
||||
],
|
||||
'cancelButton' => $renewable,
|
||||
'submitButton' => $renewable ? [
|
||||
'icon' => 'refresh',
|
||||
'text' => I18n::translate('renew'),
|
||||
'theme' => 'love',
|
||||
] : false,
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function () {
|
||||
// @codeCoverageIgnoreStart
|
||||
$response = App::instance()->system()->license()->upgrade();
|
||||
|
||||
// the upgrade is still needed
|
||||
if ($response['status'] === 'upgrade') {
|
||||
return [
|
||||
'redirect' => $response['url']
|
||||
];
|
||||
}
|
||||
|
||||
// the upgrade has already been completed
|
||||
if ($response['status'] === 'complete') {
|
||||
return [
|
||||
'event' => 'system.renew',
|
||||
'message' => I18n::translate('license.success')
|
||||
];
|
||||
}
|
||||
|
||||
throw new LogicException(message: 'The upgrade failed');
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
],
|
||||
'license/remove' => [
|
||||
'load' => function () {
|
||||
return [
|
||||
'component' => 'k-remove-dialog',
|
||||
'props' => [
|
||||
'text' => I18n::translate('license.remove.text'),
|
||||
'size' => 'medium',
|
||||
'submitButton' => [
|
||||
'icon' => 'trash',
|
||||
'text' => I18n::translate('remove'),
|
||||
'theme' => 'negative',
|
||||
],
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function () {
|
||||
// @codeCoverageIgnoreStart
|
||||
App::instance()->system()->license()->delete();
|
||||
return true;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
],
|
||||
// license registration
|
||||
'registration' => [
|
||||
'load' => function () {
|
||||
$system = App::instance()->system();
|
||||
$local = $system->isLocal();
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'domain' => [
|
||||
'label' => I18n::translate('license.activate.label'),
|
||||
'type' => 'info',
|
||||
'theme' => $local ? 'warning' : 'info',
|
||||
'text' => I18n::template('license.activate.' . ($local ? 'local' : 'domain'), ['host' => $system->indexUrl()])
|
||||
],
|
||||
'license' => [
|
||||
'label' => I18n::translate('license.code.label'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'counter' => false,
|
||||
'placeholder' => 'K-',
|
||||
'help' => I18n::translate('license.code.help') . ' ' . '<a href="https://getkirby.com/buy" target="_blank">' . I18n::translate('license.buy') . ' →</a>'
|
||||
],
|
||||
'email' => Field::email(['required' => true])
|
||||
],
|
||||
'submitButton' => [
|
||||
'icon' => 'key',
|
||||
'text' => I18n::translate('activate'),
|
||||
'theme' => 'love',
|
||||
],
|
||||
'value' => [
|
||||
'license' => null,
|
||||
'email' => null
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function () {
|
||||
// @codeCoverageIgnoreStart
|
||||
$kirby = App::instance();
|
||||
$kirby->system()->register(
|
||||
$kirby->request()->get('license'),
|
||||
$kirby->request()->get('email')
|
||||
);
|
||||
|
||||
return [
|
||||
'event' => 'system.register',
|
||||
'message' => I18n::translate('license.success')
|
||||
];
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
],
|
||||
];
|
||||
139
public/kirby/config/areas/system/views.php
Normal file
139
public/kirby/config/areas/system/views.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Panel\Ui\Buttons\ViewButtons;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'system' => [
|
||||
'pattern' => 'system',
|
||||
'action' => function () {
|
||||
$kirby = App::instance();
|
||||
$system = $kirby->system();
|
||||
$updateStatus = $system->updateStatus();
|
||||
$license = $system->license();
|
||||
$debugMode = $kirby->option('debug', false) === true;
|
||||
$isLocal = $system->isLocal();
|
||||
|
||||
$environment = [
|
||||
[
|
||||
'label' => $license->status()->label(),
|
||||
'value' => $license->label(),
|
||||
'theme' => $license->status()->theme(),
|
||||
'icon' => $license->status()->icon(),
|
||||
'dialog' => $license->status()->dialog()
|
||||
],
|
||||
[
|
||||
'label' => $updateStatus?->label() ?? I18n::translate('version'),
|
||||
'value' => $kirby->version(),
|
||||
'link' => $updateStatus?->url() ??
|
||||
'https://github.com/getkirby/kirby/releases/tag/' . $kirby->version(),
|
||||
'theme' => $updateStatus?->theme(),
|
||||
'icon' => $updateStatus?->icon() ?? 'info'
|
||||
],
|
||||
[
|
||||
'label' => 'PHP',
|
||||
'value' => phpversion(),
|
||||
'icon' => 'code'
|
||||
],
|
||||
[
|
||||
'label' => I18n::translate('server'),
|
||||
'value' => $system->serverSoftwareShort() ?? '?',
|
||||
'icon' => 'server'
|
||||
]
|
||||
];
|
||||
|
||||
$exceptions = $updateStatus?->exceptionMessages() ?? [];
|
||||
|
||||
$plugins = $system->plugins()->values(function ($plugin) use (&$exceptions) {
|
||||
$authors = $plugin->authorsNames();
|
||||
$updateStatus = $plugin->updateStatus();
|
||||
$version = $updateStatus?->toArray();
|
||||
$version ??= $plugin->version() ?? '–';
|
||||
|
||||
if ($updateStatus !== null) {
|
||||
$exceptions = [
|
||||
...$exceptions,
|
||||
...$updateStatus->exceptionMessages()
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'author' => empty($authors) ? '–' : $authors,
|
||||
'license' => $plugin->license()->toArray(),
|
||||
'name' => [
|
||||
'text' => $plugin->name() ?? '–',
|
||||
'href' => $plugin->link(),
|
||||
],
|
||||
'status' => $plugin->license()->status()->toArray(),
|
||||
'version' => $version,
|
||||
];
|
||||
});
|
||||
|
||||
$security = $updateStatus?->messages() ?? [];
|
||||
|
||||
if ($isLocal === true) {
|
||||
$security[] = [
|
||||
'id' => 'local',
|
||||
'icon' => 'info',
|
||||
'theme' => 'info',
|
||||
'text' => I18n::translate('system.issues.local')
|
||||
];
|
||||
}
|
||||
|
||||
if ($debugMode === true) {
|
||||
$security[] = [
|
||||
'id' => 'debug',
|
||||
'icon' => $isLocal ? 'info' : 'alert',
|
||||
'theme' => $isLocal ? 'info' : 'negative',
|
||||
'text' => I18n::translate('system.issues.debug'),
|
||||
'link' => 'https://getkirby.com/security/debug'
|
||||
];
|
||||
}
|
||||
|
||||
if (
|
||||
$isLocal === false &&
|
||||
$kirby->environment()->https() !== true
|
||||
) {
|
||||
$security[] = [
|
||||
'id' => 'https',
|
||||
'text' => I18n::translate('system.issues.https'),
|
||||
'link' => 'https://getkirby.com/security/https'
|
||||
];
|
||||
}
|
||||
|
||||
if ($kirby->option('panel.vue.compiler', null) === null) {
|
||||
$security[] = [
|
||||
'id' => 'vue-compiler',
|
||||
'link' => 'https://getkirby.com/security/vue-compiler',
|
||||
'text' => I18n::translate('system.issues.vue.compiler'),
|
||||
'theme' => 'notice'
|
||||
];
|
||||
}
|
||||
|
||||
// sensitive URLs
|
||||
if ($isLocal === false) {
|
||||
$sensitive = [
|
||||
'content' => $system->exposedFileUrl('content'),
|
||||
'git' => $system->exposedFileUrl('git'),
|
||||
'kirby' => $system->exposedFileUrl('kirby'),
|
||||
'site' => $system->exposedFileUrl('site')
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-system-view',
|
||||
'props' => [
|
||||
'buttons' => fn () =>
|
||||
ViewButtons::view('system')->render(),
|
||||
'environment' => $environment,
|
||||
'exceptions' => $debugMode ? $exceptions : [],
|
||||
'info' => $system->info(),
|
||||
'plugins' => $plugins,
|
||||
'security' => $security,
|
||||
'urls' => $sensitive ?? []
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
];
|
||||
18
public/kirby/config/areas/users.php
Normal file
18
public/kirby/config/areas/users.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
return [
|
||||
'icon' => 'users',
|
||||
'label' => I18n::translate('view.users'),
|
||||
'search' => 'users',
|
||||
'menu' => true,
|
||||
'buttons' => require __DIR__ . '/users/buttons.php',
|
||||
'dialogs' => require __DIR__ . '/users/dialogs.php',
|
||||
'drawers' => require __DIR__ . '/users/drawers.php',
|
||||
'dropdowns' => require __DIR__ . '/users/dropdowns.php',
|
||||
'searches' => require __DIR__ . '/users/searches.php',
|
||||
'views' => require __DIR__ . '/users/views.php'
|
||||
];
|
||||
};
|
||||
20
public/kirby/config/areas/users/buttons.php
Normal file
20
public/kirby/config/areas/users/buttons.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\User;
|
||||
use Kirby\Panel\Ui\Buttons\SettingsButton;
|
||||
use Kirby\Panel\Ui\Buttons\ViewButton;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'users.create' => function (User $user, string|null $role = null) {
|
||||
return new ViewButton(
|
||||
dialog: 'users/create?role=' . $role,
|
||||
disabled: $user->kirby()->roles()->canBeCreated()->count() < 1,
|
||||
icon: 'add',
|
||||
text: I18n::translate('user.create'),
|
||||
);
|
||||
},
|
||||
'user.settings' => function (User $user) {
|
||||
return new SettingsButton(model: $user);
|
||||
}
|
||||
];
|
||||
360
public/kirby/config/areas/users/dialogs.php
Normal file
360
public/kirby/config/areas/users/dialogs.php
Normal file
|
|
@ -0,0 +1,360 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Cms\UserRules;
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Panel\Field;
|
||||
use Kirby\Panel\Panel;
|
||||
use Kirby\Panel\UserTotpDisableDialog;
|
||||
use Kirby\Toolkit\Escape;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
$fields = require __DIR__ . '/../fields/dialogs.php';
|
||||
$files = require __DIR__ . '/../files/dialogs.php';
|
||||
|
||||
return [
|
||||
'user.create' => [
|
||||
'pattern' => 'users/create',
|
||||
'load' => function () {
|
||||
$kirby = App::instance();
|
||||
$roles = $kirby->roles()->canBeCreated();
|
||||
|
||||
// get default value for role
|
||||
if ($role = $kirby->request()->get('role')) {
|
||||
$role = $roles->find($role)?->id();
|
||||
}
|
||||
|
||||
// get role field definition, incl. available role options
|
||||
$roles = Field::role(
|
||||
roles: $roles,
|
||||
props: ['required' => true]
|
||||
);
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'name' => Field::username(),
|
||||
'email' => Field::email([
|
||||
'link' => false,
|
||||
'required' => true
|
||||
]),
|
||||
'password' => Field::password([
|
||||
'autocomplete' => 'new-password'
|
||||
]),
|
||||
'translation' => Field::translation([
|
||||
'required' => true
|
||||
]),
|
||||
'role' => $roles
|
||||
],
|
||||
'submitButton' => I18n::translate('create'),
|
||||
'value' => [
|
||||
'name' => '',
|
||||
'email' => '',
|
||||
'password' => '',
|
||||
'translation' => $kirby->panelLanguage(),
|
||||
'role' => $role ?: $roles['options'][0]['value'] ?? null
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function () {
|
||||
$kirby = App::instance();
|
||||
|
||||
$kirby->users()->create([
|
||||
'name' => $kirby->request()->get('name'),
|
||||
'email' => $kirby->request()->get('email'),
|
||||
'password' => $kirby->request()->get('password'),
|
||||
'language' => $kirby->request()->get('translation'),
|
||||
'role' => $kirby->request()->get('role')
|
||||
]);
|
||||
|
||||
return [
|
||||
'event' => 'user.create'
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'user.changeEmail' => [
|
||||
'pattern' => 'users/(:any)/changeEmail',
|
||||
'load' => function (string $id) {
|
||||
$user = Find::user($id);
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'email' => [
|
||||
'label' => I18n::translate('email'),
|
||||
'required' => true,
|
||||
'type' => 'email',
|
||||
'preselect' => true
|
||||
]
|
||||
],
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'email' => $user->email()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
Find::user($id)->changeEmail($request->get('email'));
|
||||
|
||||
return [
|
||||
'event' => 'user.changeEmail'
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'user.changeLanguage' => [
|
||||
'pattern' => 'users/(:any)/changeLanguage',
|
||||
'load' => function (string $id) {
|
||||
$user = Find::user($id);
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'translation' => Field::translation(['required' => true])
|
||||
],
|
||||
'submitButton' => I18n::translate('change'),
|
||||
'value' => [
|
||||
'translation' => $user->language()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
Find::user($id)->changeLanguage($request->get('translation'));
|
||||
|
||||
return [
|
||||
'event' => 'user.changeLanguage',
|
||||
'reload' => [
|
||||
'globals' => '$translation'
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'user.changeName' => [
|
||||
'pattern' => 'users/(:any)/changeName',
|
||||
'load' => function (string $id) {
|
||||
$user = Find::user($id);
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'name' => Field::username([
|
||||
'preselect' => true
|
||||
])
|
||||
],
|
||||
'submitButton' => I18n::translate('rename'),
|
||||
'value' => [
|
||||
'name' => $user->name()->value()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
Find::user($id)->changeName($request->get('name'));
|
||||
|
||||
return [
|
||||
'event' => 'user.changeName'
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'user.changePassword' => [
|
||||
'pattern' => 'users/(:any)/changePassword',
|
||||
'load' => function (string $id) {
|
||||
$kirby = App::instance();
|
||||
$user = Find::user($id);
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'currentPassword' => Field::password([
|
||||
'label' => I18n::translate('user.changePassword.' . ($kirby->user()->is($user) ? 'current' : 'own')),
|
||||
'autocomplete' => 'current-password',
|
||||
'help' => I18n::translate('account') . ': ' . App::instance()->user()->email(),
|
||||
]),
|
||||
'line' => [
|
||||
'type' => 'line',
|
||||
],
|
||||
'password' => Field::password([
|
||||
'label' => I18n::translate('user.changePassword.new'),
|
||||
'autocomplete' => 'new-password',
|
||||
'help' => I18n::translate('account') . ': ' . $user->email(),
|
||||
]),
|
||||
'passwordConfirmation' => Field::password([
|
||||
'label' => I18n::translate('user.changePassword.new.confirm'),
|
||||
'autocomplete' => 'new-password'
|
||||
])
|
||||
],
|
||||
'submitButton' => I18n::translate('change'),
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$kirby = App::instance();
|
||||
$request = $kirby->request();
|
||||
|
||||
$user = Find::user($id);
|
||||
$currentPassword = $request->get('currentPassword');
|
||||
$password = $request->get('password');
|
||||
$passwordConfirmation = $request->get('passwordConfirmation');
|
||||
|
||||
// validate the current password of the acting user
|
||||
try {
|
||||
$kirby->user()->validatePassword($currentPassword);
|
||||
} catch (Exception) {
|
||||
// catching and re-throwing exception to avoid automatic
|
||||
// sign-out of current user from the Panel
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'user.password.wrong'
|
||||
]);
|
||||
}
|
||||
|
||||
// validate the new password
|
||||
UserRules::validPassword($user, $password ?? '');
|
||||
|
||||
// compare passwords
|
||||
if ($password !== $passwordConfirmation) {
|
||||
throw new InvalidArgumentException(
|
||||
key: 'user.password.notSame'
|
||||
);
|
||||
}
|
||||
|
||||
// change password if everything's fine
|
||||
$user->changePassword($password);
|
||||
|
||||
return [
|
||||
'event' => 'user.changePassword'
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'user.changeRole' => [
|
||||
'pattern' => 'users/(:any)/changeRole',
|
||||
'load' => function (string $id) {
|
||||
$user = Find::user($id);
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
'fields' => [
|
||||
'role' => Field::role(
|
||||
roles: $user->roles(),
|
||||
props: [
|
||||
'label' => I18n::translate('user.changeRole.select'),
|
||||
'required' => true,
|
||||
]
|
||||
)
|
||||
],
|
||||
'submitButton' => I18n::translate('user.changeRole'),
|
||||
'value' => [
|
||||
'role' => $user->role()->name()
|
||||
]
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
|
||||
$user = Find::user($id)->changeRole($request->get('role'));
|
||||
|
||||
return [
|
||||
'event' => 'user.changeRole',
|
||||
'user' => $user->toArray()
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'user.delete' => [
|
||||
'pattern' => 'users/(:any)/delete',
|
||||
'load' => function (string $id) {
|
||||
$user = Find::user($id);
|
||||
$i18nPrefix = $user->isLoggedIn() ? 'account' : 'user';
|
||||
|
||||
return [
|
||||
'component' => 'k-remove-dialog',
|
||||
'props' => [
|
||||
'text' => I18n::template($i18nPrefix . '.delete.confirm', [
|
||||
'email' => Escape::html($user->email())
|
||||
])
|
||||
]
|
||||
];
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$user = Find::user($id);
|
||||
$redirect = false;
|
||||
$referrer = Panel::referrer();
|
||||
$url = $user->panel()->url(true);
|
||||
|
||||
$user->delete();
|
||||
|
||||
// redirect to the users view
|
||||
// if the dialog has been opened in the user view
|
||||
if ($referrer === $url) {
|
||||
$redirect = '/users';
|
||||
}
|
||||
|
||||
// logout the user if they deleted themselves
|
||||
if ($user->isLoggedIn()) {
|
||||
$redirect = '/logout';
|
||||
}
|
||||
|
||||
return [
|
||||
'event' => 'user.delete',
|
||||
'redirect' => $redirect
|
||||
];
|
||||
}
|
||||
],
|
||||
|
||||
'user.fields' => [
|
||||
...$fields['model'],
|
||||
'pattern' => '(users/[^/]+)/fields/(:any)/(:all?)',
|
||||
],
|
||||
|
||||
'user.file.changeName' => [
|
||||
...$files['changeName'],
|
||||
'pattern' => '(users/[^/]+)/files/(:any)/changeName',
|
||||
],
|
||||
|
||||
'user.file.changeSort' => [
|
||||
...$files['changeSort'],
|
||||
'pattern' => '(users/[^/]+)/files/(:any)/changeSort',
|
||||
],
|
||||
|
||||
'user.file.changeTemplate' => [
|
||||
...$files['changeTemplate'],
|
||||
'pattern' => '(users/[^/]+)/files/(:any)/changeTemplate',
|
||||
],
|
||||
|
||||
'user.file.delete' => [
|
||||
...$files['delete'],
|
||||
'pattern' => '(users/[^/]+)/files/(:any)/delete',
|
||||
],
|
||||
|
||||
'user.file.fields' => [
|
||||
...$fields['file'],
|
||||
'pattern' => '(users/[^/]+)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
|
||||
'user.totp.disable' => [
|
||||
'pattern' => 'users/(:any)/totp/disable',
|
||||
'load' => fn (string $id) => (new UserTotpDisableDialog($id))->load(),
|
||||
'submit' => fn (string $id) => (new UserTotpDisableDialog($id))->submit()
|
||||
],
|
||||
];
|
||||
14
public/kirby/config/areas/users/drawers.php
Normal file
14
public/kirby/config/areas/users/drawers.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
$fields = require __DIR__ . '/../fields/drawers.php';
|
||||
|
||||
return [
|
||||
'user.fields' => [
|
||||
...$fields['model'],
|
||||
'pattern' => '(users/[^/]+)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'user.file.fields' => [
|
||||
...$fields['file'],
|
||||
'pattern' => '(users/[^/]+)/files/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
];
|
||||
29
public/kirby/config/areas/users/dropdowns.php
Normal file
29
public/kirby/config/areas/users/dropdowns.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Ui\Buttons\LanguagesDropdown;
|
||||
|
||||
$files = require __DIR__ . '/../files/dropdowns.php';
|
||||
|
||||
return [
|
||||
'user' => [
|
||||
'pattern' => 'users/(:any)',
|
||||
'options' => fn (string $id) =>
|
||||
Find::user($id)->panel()->dropdown()
|
||||
],
|
||||
'user.languages' => [
|
||||
'pattern' => 'users/(:any)/languages',
|
||||
'options' => function (string $id) {
|
||||
$user = Find::user($id);
|
||||
return (new LanguagesDropdown($user))->options();
|
||||
}
|
||||
],
|
||||
'user.file' => [
|
||||
'pattern' => '(users/[^/]+)/files/(:any)',
|
||||
'options' => $files['file']
|
||||
],
|
||||
'user.file.languages' => [
|
||||
'pattern' => '(users/[^/]+)/files/(:any)/languages',
|
||||
'options' => $files['language']
|
||||
]
|
||||
];
|
||||
12
public/kirby/config/areas/users/searches.php
Normal file
12
public/kirby/config/areas/users/searches.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Panel\Controller\Search;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'users' => [
|
||||
'label' => I18n::translate('users'),
|
||||
'icon' => 'users',
|
||||
'query' => fn (string|null $query, int $limit, int $page) => Search::users($query, $limit, $page)
|
||||
]
|
||||
];
|
||||
65
public/kirby/config/areas/users/views.php
Normal file
65
public/kirby/config/areas/users/views.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Panel\Collector\UsersCollector;
|
||||
use Kirby\Panel\Ui\Buttons\ViewButtons;
|
||||
use Kirby\Panel\Ui\Item\UserItem;
|
||||
|
||||
return [
|
||||
'users' => [
|
||||
'pattern' => 'users',
|
||||
'action' => function () {
|
||||
$kirby = App::instance();
|
||||
$role = $kirby->request()->get('role');
|
||||
$roles = $kirby->roles()->toArray(fn ($role) => [
|
||||
'id' => $role->id(),
|
||||
'title' => $role->title(),
|
||||
]);
|
||||
|
||||
return [
|
||||
'component' => 'k-users-view',
|
||||
'props' => [
|
||||
'buttons' => fn () =>
|
||||
ViewButtons::view('users')
|
||||
->defaults('create')
|
||||
->bind(['role' => $role])
|
||||
->render(),
|
||||
'role' => function () use ($roles, $role) {
|
||||
if ($role) {
|
||||
return $roles[$role] ?? null;
|
||||
}
|
||||
},
|
||||
'roles' => array_values($roles),
|
||||
'users' => function () use ($kirby, $role) {
|
||||
$collector = new UsersCollector(
|
||||
limit: 20,
|
||||
page: $kirby->request()->get('page', 1),
|
||||
role: $role,
|
||||
sortBy: 'username asc',
|
||||
);
|
||||
|
||||
$users = $collector->models(paginated: true);
|
||||
|
||||
return [
|
||||
'data' => $users->values(fn ($user) => (new UserItem(user: $user))->props()),
|
||||
'pagination' => $users->pagination()->toArray()
|
||||
];
|
||||
},
|
||||
]
|
||||
];
|
||||
}
|
||||
],
|
||||
'user' => [
|
||||
'pattern' => 'users/(:any)',
|
||||
'action' => function (string $id) {
|
||||
return Find::user($id)->panel()->view();
|
||||
}
|
||||
],
|
||||
'user.file' => [
|
||||
'pattern' => 'users/(:any)/files/(:any)',
|
||||
'action' => function (string $id, string $filename) {
|
||||
return Find::file('users/' . $id, $filename)->panel()->view();
|
||||
}
|
||||
],
|
||||
];
|
||||
2
public/kirby/config/blocks/code/code.php
Normal file
2
public/kirby/config/blocks/code/code.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<pre><code class="language-<?= $block->language()->or('text') ?>"><?= $block->code()->html(false) ?></code></pre>
|
||||
59
public/kirby/config/blocks/code/code.yml
Normal file
59
public/kirby/config/blocks/code/code.yml
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
name: field.blocks.code.name
|
||||
icon: code
|
||||
wysiwyg: true
|
||||
preview: code
|
||||
fields:
|
||||
code:
|
||||
label: field.blocks.code.name
|
||||
type: textarea
|
||||
placeholder: field.blocks.code.placeholder
|
||||
buttons: false
|
||||
font: monospace
|
||||
language:
|
||||
label: field.blocks.code.language
|
||||
type: select
|
||||
default: text
|
||||
options:
|
||||
bash: Bash
|
||||
basic: BASIC
|
||||
c: C
|
||||
clojure: Clojure
|
||||
cpp: C++
|
||||
csharp: C#
|
||||
css: CSS
|
||||
diff: Diff
|
||||
elixir: Elixir
|
||||
elm: Elm
|
||||
erlang: Erlang
|
||||
go: Go
|
||||
graphql: GraphQL
|
||||
haskell: Haskell
|
||||
html: HTML
|
||||
java: Java
|
||||
js: JavaScript
|
||||
json: JSON
|
||||
latext: LaTeX
|
||||
less: Less
|
||||
lisp: Lisp
|
||||
lua: Lua
|
||||
makefile: Makefile
|
||||
markdown: Markdown
|
||||
markup: Markup
|
||||
objectivec: Objective-C
|
||||
pascal: Pascal
|
||||
perl: Perl
|
||||
php: PHP
|
||||
text: Plain Text
|
||||
python: Python
|
||||
r: R
|
||||
ruby: Ruby
|
||||
rust: Rust
|
||||
sass: Sass
|
||||
scss: SCSS
|
||||
shell: Shell
|
||||
sql: SQL
|
||||
swift: Swift
|
||||
typescript: TypeScript
|
||||
vbnet: VB.net
|
||||
xml: XML
|
||||
yaml: YAML
|
||||
20
public/kirby/config/blocks/gallery/gallery.php
Normal file
20
public/kirby/config/blocks/gallery/gallery.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/** @var \Kirby\Cms\Block $block */
|
||||
$caption = $block->caption();
|
||||
$crop = $block->crop()->isTrue();
|
||||
$ratio = $block->ratio()->or('auto');
|
||||
?>
|
||||
<figure<?= Html::attr(['data-ratio' => $ratio, 'data-crop' => $crop], null, ' ') ?>>
|
||||
<ul>
|
||||
<?php foreach ($block->images()->toFiles() as $image): ?>
|
||||
<li>
|
||||
<?= $image ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<?php if ($caption->isNotEmpty()): ?>
|
||||
<figcaption>
|
||||
<?= $caption ?>
|
||||
</figcaption>
|
||||
<?php endif ?>
|
||||
</figure>
|
||||
40
public/kirby/config/blocks/gallery/gallery.yml
Normal file
40
public/kirby/config/blocks/gallery/gallery.yml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
name: field.blocks.gallery.name
|
||||
icon: dashboard
|
||||
preview: gallery
|
||||
fields:
|
||||
images:
|
||||
label: field.blocks.gallery.images.label
|
||||
type: files
|
||||
query: model.images
|
||||
multiple: true
|
||||
layout: cards
|
||||
size: small
|
||||
empty: field.blocks.gallery.images.empty
|
||||
uploads:
|
||||
template: blocks/image
|
||||
image:
|
||||
ratio: 1/1
|
||||
caption:
|
||||
label: field.blocks.image.caption
|
||||
type: writer
|
||||
icon: text
|
||||
inline: true
|
||||
ratio:
|
||||
label: field.blocks.image.ratio
|
||||
type: select
|
||||
placeholder: Auto
|
||||
width: 1/2
|
||||
options:
|
||||
1/1: "1:1"
|
||||
16/9: "16:9"
|
||||
10/8: "10:8"
|
||||
21/9: "21:9"
|
||||
7/5: "7:5"
|
||||
4/3: "4:3"
|
||||
5/3: "5:3"
|
||||
3/2: "3:2"
|
||||
3/1: "3:1"
|
||||
crop:
|
||||
label: field.blocks.image.crop
|
||||
type: toggle
|
||||
width: 1/2
|
||||
2
public/kirby/config/blocks/heading/heading.php
Normal file
2
public/kirby/config/blocks/heading/heading.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<<?= $level = $block->level()->or('h2') ?>><?= $block->text() ?></<?= $level ?>>
|
||||
35
public/kirby/config/blocks/heading/heading.yml
Normal file
35
public/kirby/config/blocks/heading/heading.yml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
name: field.blocks.heading.name
|
||||
icon: title
|
||||
wysiwyg: true
|
||||
preview: heading
|
||||
fields:
|
||||
level:
|
||||
label: field.blocks.heading.level
|
||||
type: toggles
|
||||
empty: false
|
||||
default: "h2"
|
||||
labels: false
|
||||
options:
|
||||
- value: h1
|
||||
icon: h1
|
||||
text: H1
|
||||
- value: h2
|
||||
icon: h2
|
||||
text: H2
|
||||
- value: h3
|
||||
icon: h3
|
||||
text: H3
|
||||
- value: h4
|
||||
icon: h4
|
||||
text: H4
|
||||
- value: h5
|
||||
icon: h5
|
||||
text: H5
|
||||
- value: h6
|
||||
icon: h6
|
||||
text: H6
|
||||
text:
|
||||
label: field.blocks.heading.text
|
||||
type: writer
|
||||
inline: true
|
||||
placeholder: field.blocks.heading.placeholder
|
||||
35
public/kirby/config/blocks/image/image.php
Normal file
35
public/kirby/config/blocks/image/image.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/** @var \Kirby\Cms\Block $block */
|
||||
$alt = $block->alt();
|
||||
$caption = $block->caption();
|
||||
$crop = $block->crop()->isTrue();
|
||||
$link = $block->link();
|
||||
$ratio = $block->ratio()->or('auto');
|
||||
$src = null;
|
||||
|
||||
if ($block->location() == 'web') {
|
||||
$src = $block->src()->esc();
|
||||
} elseif ($image = $block->image()->toFile()) {
|
||||
$alt = $alt->or($image->alt());
|
||||
$src = $image->url();
|
||||
}
|
||||
|
||||
?>
|
||||
<?php if ($src): ?>
|
||||
<figure<?= Html::attr(['data-ratio' => $ratio, 'data-crop' => $crop], null, ' ') ?>>
|
||||
<?php if ($link->isNotEmpty()): ?>
|
||||
<a href="<?= Str::esc($link->toUrl()) ?>">
|
||||
<img src="<?= $src ?>" alt="<?= $alt->esc() ?>">
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<img src="<?= $src ?>" alt="<?= $alt->esc() ?>">
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($caption->isNotEmpty()): ?>
|
||||
<figcaption>
|
||||
<?= $caption ?>
|
||||
</figcaption>
|
||||
<?php endif ?>
|
||||
</figure>
|
||||
<?php endif ?>
|
||||
61
public/kirby/config/blocks/image/image.yml
Normal file
61
public/kirby/config/blocks/image/image.yml
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
name: field.blocks.image.name
|
||||
icon: image
|
||||
preview: image
|
||||
fields:
|
||||
location:
|
||||
label: field.blocks.image.location
|
||||
type: radio
|
||||
columns: 2
|
||||
default: "kirby"
|
||||
required: true
|
||||
options:
|
||||
kirby: "{{ t('field.blocks.image.location.internal') }}"
|
||||
web: "{{ t('field.blocks.image.location.external') }}"
|
||||
image:
|
||||
label: field.blocks.image.name
|
||||
type: files
|
||||
query: model.images
|
||||
multiple: false
|
||||
image:
|
||||
back: black
|
||||
uploads:
|
||||
template: blocks/image
|
||||
when:
|
||||
location: kirby
|
||||
src:
|
||||
label: field.blocks.image.url
|
||||
type: url
|
||||
when:
|
||||
location: web
|
||||
alt:
|
||||
label: field.blocks.image.alt
|
||||
type: text
|
||||
icon: title
|
||||
caption:
|
||||
label: field.blocks.image.caption
|
||||
type: writer
|
||||
icon: text
|
||||
inline: true
|
||||
link:
|
||||
label: field.blocks.image.link
|
||||
type: text
|
||||
icon: url
|
||||
ratio:
|
||||
label: field.blocks.image.ratio
|
||||
type: select
|
||||
placeholder: Auto
|
||||
width: 1/2
|
||||
options:
|
||||
1/1: "1:1"
|
||||
16/9: "16:9"
|
||||
10/8: "10:8"
|
||||
21/9: "21:9"
|
||||
7/5: "7:5"
|
||||
4/3: "4:3"
|
||||
5/3: "5:3"
|
||||
3/2: "3:2"
|
||||
3/1: "3:1"
|
||||
crop:
|
||||
label: field.blocks.image.crop
|
||||
type: toggle
|
||||
width: 1/2
|
||||
1
public/kirby/config/blocks/line/line.php
Normal file
1
public/kirby/config/blocks/line/line.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<hr />
|
||||
4
public/kirby/config/blocks/line/line.yml
Normal file
4
public/kirby/config/blocks/line/line.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
name: field.blocks.line.name
|
||||
icon: divider
|
||||
preview: line
|
||||
wysiwyg: true
|
||||
2
public/kirby/config/blocks/list/list.php
Normal file
2
public/kirby/config/blocks/list/list.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<?= $block->text();
|
||||
8
public/kirby/config/blocks/list/list.yml
Normal file
8
public/kirby/config/blocks/list/list.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
name: field.blocks.list.name
|
||||
icon: list-bullet
|
||||
wysiwyg: true
|
||||
preview: list
|
||||
fields:
|
||||
text:
|
||||
label: field.blocks.list.name
|
||||
type: list
|
||||
2
public/kirby/config/blocks/markdown/markdown.php
Normal file
2
public/kirby/config/blocks/markdown/markdown.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<?= $block->text()->kt();
|
||||
11
public/kirby/config/blocks/markdown/markdown.yml
Normal file
11
public/kirby/config/blocks/markdown/markdown.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
name: field.blocks.markdown.name
|
||||
icon: markdown
|
||||
preview: markdown
|
||||
wysiwyg: true
|
||||
fields:
|
||||
text:
|
||||
label: field.blocks.markdown.label
|
||||
placeholder: field.blocks.markdown.placeholder
|
||||
type: textarea
|
||||
buttons: false
|
||||
font: monospace
|
||||
9
public/kirby/config/blocks/quote/quote.php
Normal file
9
public/kirby/config/blocks/quote/quote.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<blockquote>
|
||||
<?= $block->text() ?>
|
||||
<?php if ($block->citation()->isNotEmpty()): ?>
|
||||
<footer>
|
||||
<?= $block->citation() ?>
|
||||
</footer>
|
||||
<?php endif ?>
|
||||
</blockquote>
|
||||
17
public/kirby/config/blocks/quote/quote.yml
Normal file
17
public/kirby/config/blocks/quote/quote.yml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
name: field.blocks.quote.name
|
||||
icon: quote
|
||||
wysiwyg: true
|
||||
preview: quote
|
||||
fields:
|
||||
text:
|
||||
label: field.blocks.quote.text.label
|
||||
placeholder: field.blocks.quote.text.placeholder
|
||||
type: writer
|
||||
inline: true
|
||||
icon: quote
|
||||
citation:
|
||||
label: field.blocks.quote.citation.label
|
||||
placeholder: field.blocks.quote.citation.placeholder
|
||||
type: writer
|
||||
inline: true
|
||||
icon: user
|
||||
3
public/kirby/config/blocks/table/table.yml
Normal file
3
public/kirby/config/blocks/table/table.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
name: Table
|
||||
icon: menu
|
||||
preview: table
|
||||
2
public/kirby/config/blocks/text/text.php
Normal file
2
public/kirby/config/blocks/text/text.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<?= $block->text();
|
||||
9
public/kirby/config/blocks/text/text.yml
Normal file
9
public/kirby/config/blocks/text/text.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
name: field.blocks.text.name
|
||||
icon: text
|
||||
wysiwyg: true
|
||||
preview: text
|
||||
fields:
|
||||
text:
|
||||
type: writer
|
||||
nodes: false
|
||||
placeholder: field.blocks.text.placeholder
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue