Initial dev export (exclude uploads/runtime)
This commit is contained in:
80
modules/newsletter/module.php
Normal file
80
modules/newsletter/module.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Core\Http\Router;
|
||||
use Core\Services\Shortcodes;
|
||||
use Modules\Newsletter\NewsletterController;
|
||||
|
||||
require_once __DIR__ . '/NewsletterController.php';
|
||||
|
||||
Shortcodes::register('newsletter-signup', static function (array $attrs = []): string {
|
||||
$title = trim((string)($attrs['title'] ?? 'Join the newsletter'));
|
||||
$button = trim((string)($attrs['button'] ?? 'Subscribe'));
|
||||
$placeholder = trim((string)($attrs['placeholder'] ?? 'you@example.com'));
|
||||
if ($title === '') {
|
||||
$title = 'Join the newsletter';
|
||||
}
|
||||
if ($button === '') {
|
||||
$button = 'Subscribe';
|
||||
}
|
||||
if ($placeholder === '') {
|
||||
$placeholder = 'you@example.com';
|
||||
}
|
||||
|
||||
return '<form method="post" action="/newsletter/subscribe" class="ac-shortcode-newsletter-form">'
|
||||
. '<div class="ac-shortcode-newsletter-title">' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '</div>'
|
||||
. '<div class="ac-shortcode-newsletter-row">'
|
||||
. '<input type="email" name="email" required class="ac-shortcode-newsletter-input" placeholder="' . htmlspecialchars($placeholder, ENT_QUOTES, 'UTF-8') . '">'
|
||||
. '<button type="submit" class="ac-shortcode-newsletter-btn">' . htmlspecialchars($button, ENT_QUOTES, 'UTF-8') . '</button>'
|
||||
. '</div>'
|
||||
. '</form>';
|
||||
});
|
||||
|
||||
Shortcodes::register('newsletter-unsubscribe', static function (array $attrs = []): string {
|
||||
$label = trim((string)($attrs['label'] ?? 'Unsubscribe'));
|
||||
if ($label === '') {
|
||||
$label = 'Unsubscribe';
|
||||
}
|
||||
$token = trim((string)($attrs['token'] ?? ''));
|
||||
$href = '/newsletter/unsubscribe';
|
||||
if ($token !== '') {
|
||||
$href .= '?token=' . rawurlencode($token);
|
||||
}
|
||||
return '<a class="ac-shortcode-link ac-shortcode-newsletter-unsubscribe" href="' . htmlspecialchars($href, ENT_QUOTES, 'UTF-8') . '">' . htmlspecialchars($label, ENT_QUOTES, 'UTF-8') . '</a>';
|
||||
});
|
||||
|
||||
Shortcodes::register('newsletter-unsubscribe-form', static function (array $attrs = []): string {
|
||||
$title = trim((string)($attrs['title'] ?? 'Unsubscribe from newsletter'));
|
||||
$button = trim((string)($attrs['button'] ?? 'Unsubscribe'));
|
||||
if ($title === '') {
|
||||
$title = 'Unsubscribe from newsletter';
|
||||
}
|
||||
if ($button === '') {
|
||||
$button = 'Unsubscribe';
|
||||
}
|
||||
return '<form method="post" action="/newsletter/unsubscribe" class="ac-shortcode-newsletter-form">'
|
||||
. '<div class="ac-shortcode-newsletter-title">' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '</div>'
|
||||
. '<div class="ac-shortcode-newsletter-row">'
|
||||
. '<input type="email" name="email" required class="ac-shortcode-newsletter-input" placeholder="you@example.com">'
|
||||
. '<button type="submit" class="ac-shortcode-newsletter-btn">' . htmlspecialchars($button, ENT_QUOTES, 'UTF-8') . '</button>'
|
||||
. '</div>'
|
||||
. '</form>';
|
||||
});
|
||||
|
||||
return function (Router $router): void {
|
||||
$controller = new NewsletterController();
|
||||
|
||||
$router->post('/newsletter/subscribe', [$controller, 'subscribe']);
|
||||
$router->get('/newsletter/unsubscribe', [$controller, 'unsubscribeForm']);
|
||||
$router->post('/newsletter/unsubscribe', [$controller, 'unsubscribe']);
|
||||
|
||||
$router->get('/admin/newsletter', [$controller, 'adminIndex']);
|
||||
$router->get('/admin/newsletter/campaigns/new', [$controller, 'adminEdit']);
|
||||
$router->get('/admin/newsletter/campaigns/edit', [$controller, 'adminEdit']);
|
||||
$router->post('/admin/newsletter/campaigns/save', [$controller, 'adminSave']);
|
||||
$router->post('/admin/newsletter/campaigns/send', [$controller, 'adminSend']);
|
||||
$router->post('/admin/newsletter/campaigns/test', [$controller, 'adminTestSend']);
|
||||
$router->post('/admin/newsletter/campaigns/process', [$controller, 'adminProcessQueue']);
|
||||
$router->get('/admin/newsletter/subscribers', [$controller, 'adminSubscribers']);
|
||||
$router->post('/admin/newsletter/subscribers/delete', [$controller, 'adminDeleteSubscriber']);
|
||||
};
|
||||
Reference in New Issue
Block a user