Diff #4 - trunk/src/Opus/Forms/NotificationMessage.php
2,442 bytes
|
|
January 20, 2025 at 08:20
|
Diff
Index: NotificationMessage.php
--- NotificationMessage.php (nonexistent) +++ NotificationMessage.php (revision 4) @@ -0,0 +1,96 @@ +<?php +declare(strict_types = 1); + +namespace App\Webapp\Opus\Forms; + +use Apex\Svc{Container, View, Db}; +use Apex\App\Base\Web\Utils\FormBuilder; +use App\Webapp\Notifications\NotificationsConfig; +use Apex\App\Interfaces\Opus\FormInterface; + +/** + * Form - NotificationMessage + */ +class NotificationMessage implements FormInterface +{ + + #[Inject(Container::class)] + private Container $cntr; + + #[Inject(View::class)] + private View $view; + + #[Inject(NotificationsConfig::class)] + private NotificationsConfig $config; + + #[Inject(FormFieldsCreator::class)] + private FormFieldsCreator $creator; + + #[Inject(Db::class)] + private Db $db; + + /** + * Whether or not to pre-populate form fields with POSTed data. + */ + public bool $allow_post_values = true; + + /** + * Get necessary form fieldss + */ + public function getFields(array $attr = []):array + { + + // Initialize + $creator = $this->cntr->make(FormBuilder::class); + $obj = $this->cntr->make($attr['controller']); + + // Get merge fields + $merge_fields = $this->config->getMergeFieldOptions($obj); + $this->view->assign('merge_field_options', $merge_fields); + + // Define fields + $fields = [ + 'sep_email' => $creator->seperator('Optional E-Mails'), + 'reply_to' => $creator->textbox(), + 'cc' => $creator->textbox(), + 'bcc' => $creator->textbox(), + 'sep_message' => $creator->seperator('Message Contents'), + 'subject' => $creator->textbox(), + 'attachment' => $creator->textbox('', '', false, '', 'file'), + 'merge_fields' => $creator->select('', '', false, '', '~merge_field_options~'), + 'text_contents' => $creator->textarea()->label('Text Contents'), + 'html_contents' => $creator->textarea()->label('HTML Message'), + 'submit' => $creator->createOrUpdateButton('E-Mail Notification', $attr) + ]; + + // Return + return $fields; + } + + /** + * Get record + */ + public function getRecord(string $record_id):array + { + + // Get row + if (!$row = $this->db->getIdRow('internal_email_notifications', $record_id)) { + $row = []; + } + + // Return + return $row; + } + + /** + * Validate + */ + public function validate(array $attr = []):bool + { + + // Return + return true; + } + +} +
Full Code
<?php declare(strict_types = 1);
namespace App\Webapp\Opus\Forms;
use Apex\Svc{Container, View, Db}; use Apex\App\Base\Web\Utils\FormBuilder; use App\Webapp\Notifications\NotificationsConfig; use Apex\App\Interfaces\Opus\FormInterface;
/** * Form - NotificationMessage */ class NotificationMessage implements FormInterface {
#[Inject(Container::class)]
private Container $cntr;
#[Inject(View::class)]
private View $view;
#[Inject(NotificationsConfig::class)]
private NotificationsConfig $config;
#[Inject(FormFieldsCreator::class)]
private FormFieldsCreator $creator;
#[Inject(Db::class)]
private Db $db;
/**
* Whether or not to pre-populate form fields with POSTed data.
*/
public bool $allow_post_values = true;
/**
* Get necessary form fieldss
*/
public function getFields(array $attr = []):array
{
// Initialize
$creator = $this->cntr->make(FormBuilder::class);
$obj = $this->cntr->make($attr['controller']);
// Get merge fields
$merge_fields = $this->config->getMergeFieldOptions($obj);
$this->view->assign('merge_field_options', $merge_fields);
// Define fields
$fields = [
'sep_email' => $creator->seperator('Optional E-Mails'),
'reply_to' => $creator->textbox(),
'cc' => $creator->textbox(),
'bcc' => $creator->textbox(),
'sep_message' => $creator->seperator('Message Contents'),
'subject' => $creator->textbox(),
'attachment' => $creator->textbox('', '', false, '', 'file'),
'merge_fields' => $creator->select('', '', false, '', '~merge_field_options~'),
'text_contents' => $creator->textarea()->label('Text Contents'),
'html_contents' => $creator->textarea()->label('HTML Message'),
'submit' => $creator->createOrUpdateButton('E-Mail Notification', $attr)
];
// Return
return $fields;
}
/**
* Get record
*/
public function getRecord(string $record_id):array
{
// Get row
if (!$row = $this->db->getIdRow('internal_email_notifications', $record_id)) {
$row = [];
}
// Return
return $row;
}
/**
* Validate
*/
public function validate(array $attr = []):bool
{
// Return
return true;
}
}