Merge pull request 'fix: removed form component and use kirby integrated tools instead' (#17) from develop into main
Reviewed-on: https://git.feigel.it/SFBadSteben/schachfreunde-badsteben/pulls/17
This commit is contained in:
+1
-2
@@ -22,8 +22,7 @@
|
|||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
|
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
|
||||||
"getkirby/cms": "^5.0",
|
"getkirby/cms": "^5.0"
|
||||||
"mzur/kirby-uniform": "^5.6"
|
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
|
|||||||
Generated
+1
-178
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "9c8fcd821a223ac622d59eac3a763ea2",
|
"content-hash": "43770e3691ceb6a19553beb3dbca1057",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "christian-riesen/base32",
|
"name": "christian-riesen/base32",
|
||||||
@@ -597,183 +597,6 @@
|
|||||||
},
|
},
|
||||||
"time": "2016-12-13T01:01:17+00:00"
|
"time": "2016-12-13T01:01:17+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "mzur/kirby-flash",
|
|
||||||
"version": "v2.2.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/mzur/kirby-flash.git",
|
|
||||||
"reference": "298df11e3adc8d872db8cd48ef3736c3cbdb6c6e"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/mzur/kirby-flash/zipball/298df11e3adc8d872db8cd48ef3736c3cbdb6c6e",
|
|
||||||
"reference": "298df11e3adc8d872db8cd48ef3736c3cbdb6c6e",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"getkirby/composer-installer": "^1.2"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"getkirby/cms": "^3.0",
|
|
||||||
"mzur/kirby-defuse-session": "^1.0",
|
|
||||||
"phpunit/phpunit": "^9.0"
|
|
||||||
},
|
|
||||||
"type": "kirby-plugin",
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"src/helpers.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Jevets\\Kirby\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Steve Jamesson",
|
|
||||||
"email": "steve@evendev.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Martin Zurowietz",
|
|
||||||
"email": "martin@the-inspired-ones.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Stores data in the session for the next request. Data is removed after the next page load.",
|
|
||||||
"keywords": [
|
|
||||||
"flash",
|
|
||||||
"kirby",
|
|
||||||
"session"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/mzur/kirby-flash/issues",
|
|
||||||
"source": "https://github.com/mzur/kirby-flash/tree/v2.2.0"
|
|
||||||
},
|
|
||||||
"time": "2023-01-05T18:59:28+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mzur/kirby-form",
|
|
||||||
"version": "v3.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/mzur/kirby-form.git",
|
|
||||||
"reference": "8dc211b321375dbf77c43e1287e9fe0be2762ec0"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/mzur/kirby-form/zipball/8dc211b321375dbf77c43e1287e9fe0be2762ec0",
|
|
||||||
"reference": "8dc211b321375dbf77c43e1287e9fe0be2762ec0",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"getkirby/composer-installer": "^1.2",
|
|
||||||
"mzur/kirby-flash": "^2.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"getkirby/cms": "^3.0",
|
|
||||||
"mzur/kirby-defuse-session": "^1.0",
|
|
||||||
"phpunit/phpunit": "^9.0"
|
|
||||||
},
|
|
||||||
"type": "kirby-plugin",
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"src/helpers.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Jevets\\Kirby\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Steve Jamesson",
|
|
||||||
"email": "steve@evendev.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Martin Zurowietz",
|
|
||||||
"email": "martin@the-inspired-ones.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A form helper for Kirby-based websites, using the Post/Redirect/Get pattern.",
|
|
||||||
"keywords": [
|
|
||||||
"form",
|
|
||||||
"kirby"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/mzur/kirby-form/issues",
|
|
||||||
"source": "https://github.com/mzur/kirby-form/tree/v3.3.0"
|
|
||||||
},
|
|
||||||
"time": "2023-02-19T09:51:38+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mzur/kirby-uniform",
|
|
||||||
"version": "v5.6.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/mzur/kirby-uniform.git",
|
|
||||||
"reference": "b16b507e36b710c21044eba8cc3ae36c512be554"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/mzur/kirby-uniform/zipball/b16b507e36b710c21044eba8cc3ae36c512be554",
|
|
||||||
"reference": "b16b507e36b710c21044eba8cc3ae36c512be554",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"getkirby/composer-installer": "^1.2",
|
|
||||||
"mzur/kirby-form": "^3.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"getkirby/cms": "^3.5 || ^4.0",
|
|
||||||
"phpunit/phpunit": "^9.0"
|
|
||||||
},
|
|
||||||
"type": "kirby-plugin",
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"src/helpers.php"
|
|
||||||
],
|
|
||||||
"psr-4": {
|
|
||||||
"Uniform\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Martin Zurowietz",
|
|
||||||
"email": "martin@the-inspired-ones.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A versatile Kirby plugin to handle web form actions.",
|
|
||||||
"keywords": [
|
|
||||||
"form",
|
|
||||||
"kirby"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"docs": "http://kirby-uniform.readthedocs.io",
|
|
||||||
"issues": "https://github.com/mzur/kirby-uniform/issues",
|
|
||||||
"source": "https://github.com/mzur/kirby-uniform"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://www.paypal.me/drmzur",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/mzur",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2024-03-07T10:29:12+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "phpmailer/phpmailer",
|
"name": "phpmailer/phpmailer",
|
||||||
"version": "v6.10.0",
|
"version": "v6.10.0",
|
||||||
|
|||||||
@@ -1,33 +1,71 @@
|
|||||||
<?php
|
<?php
|
||||||
|
return function($kirby, $pages, $page) {
|
||||||
|
|
||||||
use Uniform\Form;
|
$alert = null;
|
||||||
|
|
||||||
return function ($kirby)
|
if ($kirby->request()->is('POST') && get('submit')) {
|
||||||
{
|
|
||||||
$form = new Form([
|
|
||||||
'email' => [
|
|
||||||
'rules' => ['required', 'email'],
|
|
||||||
'message' => 'Bitte geben Sie eine gültige E-Mail Adresse ein.',
|
|
||||||
],
|
|
||||||
'name' => [
|
|
||||||
'rules' => ['required'],
|
|
||||||
'message' => 'Bitte geben Sie Ihren Namen ein.',
|
|
||||||
],
|
|
||||||
'message' => [
|
|
||||||
'rules' => ['required'],
|
|
||||||
'message' => 'Bitte geben Sie eine Nachricht ein.',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($kirby->request()->is('POST')) {
|
// check the honeypot
|
||||||
$form->emailAction([
|
if (empty(get('website')) === false) {
|
||||||
'to' => [
|
go($page->url());
|
||||||
'info@feigel.it'
|
}
|
||||||
],
|
|
||||||
'from' => 'webmaster@schachfreunde-badsteben.de',
|
$data = [
|
||||||
'subject' => 'Kontaktanfrage über die Homepage der Schachfreunde Bad Steben',
|
'name' => get('name'),
|
||||||
])->done();
|
'email' => get('email'),
|
||||||
|
'text' => get('text')
|
||||||
|
];
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'name' => ['required', 'minLength' => 3],
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
'text' => ['required', 'minLength' => 3, 'maxLength' => 3000],
|
||||||
|
];
|
||||||
|
|
||||||
|
$messages = [
|
||||||
|
'name' => 'Bitte geben Sie einen Namen ein.',
|
||||||
|
'email' => 'Bitte geben Sie eine gültige E-Mail-Adresse ein.',
|
||||||
|
'text' => 'Bitte geben Sie einen Text ein, der zwischen 3 und 3000 Zeichen lang ist.'
|
||||||
|
];
|
||||||
|
|
||||||
|
// some of the data is invalid
|
||||||
|
if ($invalid = invalid($data, $rules, $messages)) {
|
||||||
|
$alert = $invalid;
|
||||||
|
|
||||||
|
// the data is fine, let's send the email
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$kirby->email([
|
||||||
|
'template' => 'email',
|
||||||
|
'from' => 'webmaster@schachfreunde-badsteben.de',
|
||||||
|
'replyTo' => $data['email'],
|
||||||
|
'to' => 'info@feigel.it',
|
||||||
|
'subject' => esc($data['name']) . ' hat eine Nachricht über das Kontaktformular gesendet',
|
||||||
|
'data' => [
|
||||||
|
'text' => esc($data['text']),
|
||||||
|
'sender' => esc($data['name'])
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (Exception $error) {
|
||||||
|
if (option('debug')):
|
||||||
|
$alert['error'] = 'Beim Versenden ist ein Fehler aufgetreten: <strong>' . $error->getMessage() . '</strong>';
|
||||||
|
else:
|
||||||
|
$alert['error'] = 'Beim Versenden ist ein Fehler aufgetreten!';
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no exception occurred, let's send a success message
|
||||||
|
if (empty($alert) === true) {
|
||||||
|
$success = 'Ihre Nachricht wurde gesendet! Wir werden uns bald bei Ihnen melden.';
|
||||||
|
$data = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return compact('form');
|
return [
|
||||||
|
'alert' => $alert,
|
||||||
|
'data' => $data ?? false,
|
||||||
|
'success' => $success ?? false
|
||||||
|
];
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Hallo Schachfreunde Bad Steben,
|
||||||
|
|
||||||
|
<?= $text ?>
|
||||||
|
|
||||||
|
<?= $sender ?>
|
||||||
+40
-32
@@ -58,45 +58,53 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
<form action="<?php echo $page->url() ?>" method="POST" class="px-6 pt-20 pb-24 sm:pb-32 lg:px-8 lg:py-12">
|
<form action="<?= $page->url() ?>" method="POST" class="px-6 pt-20 pb-24 sm:pb-32 lg:px-8 lg:py-12">
|
||||||
<div class="mx-auto max-w-xl lg:mr-0 lg:max-w-lg">
|
<div class="honeypot">
|
||||||
<div class="grid grid-cols-1 gap-x-8 gap-y-6 sm:grid-cols-2">
|
<label for="website">Website <abbr title="required">*</abbr></label>
|
||||||
<div class="sm:col-span-2">
|
<input type="url" id="website" name="website" tabindex="-1">
|
||||||
<label for="name" class="block text-sm/6 font-semibold text-gray-900">Name</label>
|
</div>
|
||||||
<div class="mt-2.5">
|
<div class="mx-auto max-w-xl lg:mr-0 lg:max-w-lg">
|
||||||
<input type="text" id="name" name="name" class="<?php if ($form->error('name')): ?>error <?php endif; ?>block w-full rounded-md bg-white px-3.5 py-2 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600" value="<?php echo $form->old('name') ?>" />
|
<div class="grid grid-cols-1 gap-x-8 gap-y-6 sm:grid-cols-2">
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label for="name" class="block text-sm/6 font-semibold text-gray-900">Name</label>
|
||||||
|
<div class="mt-2.5">
|
||||||
|
<input type="text" id="name" name="name" class="block w-full rounded-md bg-white px-3.5 py-2 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600" value="<?= esc($data['name'] ?? '', 'attr') ?>" required>
|
||||||
|
<?= isset($alert['name']) ? '<span class="alert error">' . esc($alert['name']) . '</span>' : '' ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label for="email" class="block text-sm/6 font-semibold text-gray-900">E-Mail-Adresse</label>
|
||||||
|
<div class="mt-2.5">
|
||||||
|
<input type="email" name="email" id="email" autocomplete="email" class="block w-full rounded-md bg-white px-3.5 py-2 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600" value="<?= esc($data['email'] ?? '', 'attr') ?>" required>
|
||||||
|
<?= isset($alert['email']) ? '<span class="alert error">' . esc($alert['email']) . '</span>' : '' ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sm:col-span-2">
|
||||||
|
<label for="message" class="block text-sm/6 font-semibold text-gray-900">Nachricht</label>
|
||||||
|
<div class="mt-2.5">
|
||||||
|
<textarea name="message" id="message" rows="4" class="block w-full rounded-md bg-white px-3.5 py-2 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600" required><?= esc($data['text'] ?? '') ?></textarea>
|
||||||
|
<?= isset($alert['text']) ? '<span class="alert error">' . esc($alert['text']) . '</span>' : '' ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-8 flex justify-end">
|
||||||
|
<button type="submit" class="rounded-md bg-sf_blau-500 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-xs hover:bg-sf_gelb-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Absenden</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sm:col-span-2">
|
|
||||||
<label for="email" class="block text-sm/6 font-semibold text-gray-900">E-Mail-Adresse</label>
|
|
||||||
<div class="mt-2.5">
|
|
||||||
<input type="email" name="email" id="email" autocomplete="email" class="<?php if ($form->error('email')): ?>error <?php endif; ?>block w-full rounded-md bg-white px-3.5 py-2 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600" value="<?php echo $form->old('email') ?>"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="sm:col-span-2">
|
|
||||||
<label for="message" class="block text-sm/6 font-semibold text-gray-900">Nachricht</label>
|
|
||||||
<div class="mt-2.5">
|
|
||||||
<textarea name="message" id="message" rows="4" class="<?php if ($form->error('message')): ?>error <?php endif; ?>block w-full rounded-md bg-white px-3.5 py-2 text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"><?php echo $form->old('message') ?></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-8 flex justify-end">
|
</form>
|
||||||
<button type="submit" class="rounded-md bg-sf_blau-500 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-xs hover:bg-sf_gelb-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Absenden</button>
|
<?php if ($success): ?>
|
||||||
|
<div class="alert success">
|
||||||
|
<p><?= $success ?></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<?php echo csrf_field() ?>
|
|
||||||
<?php echo honeypot_field() ?>
|
|
||||||
<?php if ($form->success()): ?>
|
|
||||||
Thank you for your message. We will get back to you soon!
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div class="text-red-500 pt-12">
|
<?php if (isset($alert['error'])): ?>
|
||||||
<?php snippet('uniform/errors', ['form' => $form]) ?>
|
<div><?= $alert['error'] ?></div>
|
||||||
</div>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@
|
|||||||
@apply text-sf_blau-500 font-bold hover:text-sf_gelb-600;
|
@apply text-sf_blau-500 font-bold hover:text-sf_gelb-600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uniform__potty {
|
.honeypot {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: -9999px;
|
left: -9999px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user