@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Reservair\Templating\Elements;
|
||||
|
||||
use Reservair\Templating\RsvTemplateElement;
|
||||
use Reservair\Templating\RsvTemplateSymbols;
|
||||
|
||||
/**
|
||||
* Renders accept / refuse action buttons for a reservation, for the maintainer
|
||||
* approval email. The links come from the template's accept_url and refuse_url
|
||||
* symbols; the button labels can be overridden with the accept-label and
|
||||
* refuse-label attributes.
|
||||
*/
|
||||
class RsvReservationActionsElement implements RsvTemplateElement {
|
||||
|
||||
/** Inline styles, since email clients ignore stylesheets. */
|
||||
private const string ACCEPT_STYLE = 'display:inline-block;padding:10px 18px;margin-right:8px;background:#2e7d32;color:#ffffff;text-decoration:none;border-radius:4px;font-weight:bold;';
|
||||
private const string REFUSE_STYLE = 'display:inline-block;padding:10px 18px;background:#c62828;color:#ffffff;text-decoration:none;border-radius:4px;font-weight:bold;';
|
||||
|
||||
public function render(RsvTemplateSymbols $symbols): string {
|
||||
$accept_url = (string) $symbols->get('accept_url', '');
|
||||
$refuse_url = (string) $symbols->get('refuse_url', '');
|
||||
if ($accept_url === '' && $refuse_url === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$accept_label = (string) $symbols->get('accept-label', 'Přijmout');
|
||||
$refuse_label = (string) $symbols->get('refuse-label', 'Odmítnout');
|
||||
|
||||
return '<a href="' . esc_url($accept_url) . '" style="' . self::ACCEPT_STYLE . '">' . esc_html($accept_label) . '</a>'
|
||||
. '<a href="' . esc_url($refuse_url) . '" style="' . self::REFUSE_STYLE . '">' . esc_html($refuse_label) . '</a>';
|
||||
}
|
||||
|
||||
public function symbols(): array {
|
||||
return ['accept-label', 'refuse-label'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Reservair\Templating\Elements;
|
||||
|
||||
use Reservair\Templating\RsvTemplateElement;
|
||||
use Reservair\Templating\RsvTemplateSymbols;
|
||||
|
||||
/**
|
||||
* Emits the client-side summary placeholder. The browser-side RsvFormSender
|
||||
* locates this div after form submission and fills it with the visitor's
|
||||
* selected time slots.
|
||||
*/
|
||||
class RsvReservationSummaryElement implements RsvTemplateElement {
|
||||
|
||||
public function render(RsvTemplateSymbols $symbols): string {
|
||||
return '<div class="rsv-success-summary"></div>';
|
||||
}
|
||||
|
||||
public function symbols(): array {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Reservair\Templating\Elements;
|
||||
|
||||
use Reservair\Templating\RsvTemplateElement;
|
||||
use Reservair\Templating\RsvTemplateSymbols;
|
||||
|
||||
/**
|
||||
* Renders a button that asks the form to clear itself. It only carries the
|
||||
* data-rsv-reset marker; RsvFormSender finds marked buttons in the success card
|
||||
* and links them to the form's cleanup. The label can be overridden with the
|
||||
* label attribute.
|
||||
*/
|
||||
class RsvResetFormButtonElement implements RsvTemplateElement {
|
||||
|
||||
public function render(RsvTemplateSymbols $symbols): string {
|
||||
$label = (string) $symbols->get('label', 'Odeslat znova');
|
||||
return '<button type="button" class="rsv-form-btn" data-rsv-reset>'
|
||||
. esc_html($label)
|
||||
. '</button>';
|
||||
}
|
||||
|
||||
public function symbols(): array {
|
||||
return ['label'];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user