@@ -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'];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user