Skip to content

Commit

Permalink
EMail namespaced
Browse files Browse the repository at this point in the history
  • Loading branch information
dergel committed Sep 7, 2024
1 parent a7e0f9e commit 1a08f4b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
3 changes: 3 additions & 0 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class_alias('Yakamara\YForm\Rest\Route', 'rex_yform_rest_route');
class_alias('Yakamara\YForm\Rest\AuthToken', 'rex_yform_rest_auth_token');
class_alias('Yakamara\YForm\List\YList', 'rex_yform_list');
class_alias('Yakamara\YForm\List\Tools', 'rex_yform_list_tools');
class_alias('Yakamara\YForm\RexVar\Data', 'rex_var_yform_data');
class_alias('Yakamara\YForm\RexVar\TableData', 'rex_var_yform_data');
class_alias('Yakamara\YForm\Email\Template', 'rex_yform_email_template');

YForm::addTemplatePath(rex_path::addon('yform', 'ytemplates'));

Expand Down
4 changes: 2 additions & 2 deletions fragments/yform/manager/page/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
$popup = $this->getVar('popup');
$hasDataPageFunctions = $this->getVar('hasDataPageFunctions');

/** @var rex_yform_list $list */
$list = rex_yform_list::factory($query, $table->getListAmount());
/** @var \Yakamara\YForm\List\YList $list */
$list = \Yakamara\YForm\List\YList::factory($query, $table->getListAmount());

$list->addTableAttribute('class', 'table-striped table-hover yform-table-' . rex_string::normalize($this->table->getTableName()));

Expand Down
21 changes: 19 additions & 2 deletions lib/email_template.php → lib/Email/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@
* @author <a href="http://www.yakamara.de">www.yakamara.de</a>
*/

class rex_yform_email_template
namespace Yakamara\YForm\Email;

use PHPMailer\PHPMailer\Exception;
use rex;
use rex_article;
use rex_extension;
use rex_extension_point;
use rex_file;
use rex_mailer;
use rex_sql;
use rex_sql_exception;
use rex_stream;
use rex_var;

use function count;
use function is_array;

class Template
{
/**
* @throws rex_sql_exception
Expand Down Expand Up @@ -91,7 +108,7 @@ public static function makeSingleLine(string $str): string
}

/**
* @throws \PHPMailer\PHPMailer\Exception
* @throws Exception
* @return bool
*/
public static function sendMail(array $template, string $template_name = '')
Expand Down
6 changes: 3 additions & 3 deletions lib/yform/action/tpl2email.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class rex_yform_action_tpl2email extends rex_yform_action_abstract
public function executeAction(): void
{
$template_name = $this->getElement(2);
if ($etpl = rex_yform_email_template::getTemplate($template_name)) {
if ($etpl = \Yakamara\YForm\Email\Template::getTemplate($template_name)) {
$email_to = rex::getErrorEmail();

if (filter_var($this->getElement(3), FILTER_VALIDATE_EMAIL)) {
Expand Down Expand Up @@ -41,7 +41,7 @@ public function executeAction(): void
dump($etpl);
}

$etpl = rex_yform_email_template::replaceVars($etpl, $this->params['value_pool']['email']);
$etpl = \Yakamara\YForm\Email\Template::replaceVars($etpl, $this->params['value_pool']['email']);

$etpl['mail_to'] = $email_to;
$etpl['mail_to_name'] = $email_to_name;
Expand All @@ -66,7 +66,7 @@ public function executeAction(): void
dump($etpl);
}

if (!rex_yform_email_template::sendMail($etpl, $template_name)) {
if (!\Yakamara\YForm\Email\Template::sendMail($etpl, $template_name)) {
if ($this->params['debug']) {
dump('email could not be sent');
}
Expand Down
9 changes: 6 additions & 3 deletions pages/email.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use Yakamara\YForm\Email\Template;
use Yakamara\YForm\YForm;

/**
* yform.
*
Expand All @@ -22,9 +25,9 @@
$template = null;

if ($template_key) {
$template = rex_yform_email_template::getTemplate($template_key);
$template = Template::getTemplate($template_key);
} elseif ($template_id) {
$template = rex_yform_email_template::getTemplateById($template_id);
$template = Template::getTemplateById($template_id);
}

$template_id = null;
Expand Down Expand Up @@ -68,7 +71,7 @@

$form_data[] = 'datestamp|updatedate||||0';

$yform = \Yakamara\YForm\YForm::factory();
$yform = YForm::factory();
$yform->setObjectparams('form_action', 'index.php?page=yform/email');
$yform->setObjectparams('form_name', 'yform-email-template');

Expand Down
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
'rex_yform_list_tools' => 'Yakamara\YForm\List\Tools',
'rex_var_yform_data' => 'Yakamara\YForm\RexVar\Data',
'rex_var_yform_table_data' => 'Yakamara\YForm\RexVar\TableData',
'rex_yform_email_template' => 'Yakamara\YForm\Email\Template',
],
);
6 changes: 3 additions & 3 deletions ytemplates/bootstrap/value.be_manager_relation.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<?php
$e = [];
if (4 == $this->getRelationType()) {
echo \rex_var_yform_table_data::getRelationWidget($id, $this->getFieldName(), $this->getValue(), $link, $this->params['main_id']);
echo \Yakamara\YForm\RexVar\TableData::getRelationWidget($id, $this->getFieldName(), $this->getValue(), $link, $this->params['main_id']);
} elseif (2 == $this->getRelationType()) {
$name = $this->getFieldName();
$args = [];
Expand All @@ -74,7 +74,7 @@
$_csrf_key = rex_yform_manager_table::get($this->relation['target_table'])->getCSRFKey();
$args += rex_csrf_token::factory($_csrf_key)->getUrlParams();
$value = implode(',', $this->getValue());
echo \rex_var_yform_table_data::getSingleWidget($id, $name, $value, $args);
echo \Yakamara\YForm\RexVar\TableData::getSingleWidget($id, $name, $value, $args);
} else {
$name = $this->getFieldName();
$args = [];
Expand All @@ -86,7 +86,7 @@
$_csrf_key = rex_yform_manager_table::get($this->relation['target_table'])->getCSRFKey();
$args += rex_csrf_token::factory($_csrf_key)->getUrlParams();
$value = implode(',', $this->getValue());
echo \rex_var_yform_table_data::getMultipleWidget($id, $name, $value, $args);
echo \Yakamara\YForm\RexVar\TableData::getMultipleWidget($id, $name, $value, $args);
}
?>
<?= $notice ?>
Expand Down

0 comments on commit 1a08f4b

Please sign in to comment.