imlement HtmlmailAgent, TextmailAgent and MailreceiverAgent for generating plaintext- and HTML-mail messages
This commit is contained in:
parent
333c45773f
commit
c995fea203
11 changed files with 301 additions and 0 deletions
35
agents/bottomlevel/MailreceiverAgent.inc
Normal file
35
agents/bottomlevel/MailreceiverAgent.inc
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace hhu\z\agents\bottomlevel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Agent to generate a mail receiver salutation.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class MailreceiverAgent extends \nre\agents\BottomlevelAgent
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
45
agents/toplevel/HtmlmailAgent.inc
Normal file
45
agents/toplevel/HtmlmailAgent.inc
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Agent for generating a HTML-mail message.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class HtmlmailAgent extends \hhu\z\agents\ToplevelAgent
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new HtmlmailAgent.
|
||||||
|
*/
|
||||||
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
|
{
|
||||||
|
parent::__construct($request, $response, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
47
agents/toplevel/TextmailAgent.inc
Normal file
47
agents/toplevel/TextmailAgent.inc
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Agent for generating a simple text-mail message.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class TextmailAgent extends \hhu\z\agents\ToplevelAgent
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new TextmailAgent.
|
||||||
|
*/
|
||||||
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
|
{
|
||||||
|
parent::__construct($request, $response, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
'genericname' => 'The Legend of Z',
|
'genericname' => 'The Legend of Z',
|
||||||
'namespace' => 'hhu\\z\\',
|
'namespace' => 'hhu\\z\\',
|
||||||
'timeZone' => 'Europe/Berlin',
|
'timeZone' => 'Europe/Berlin',
|
||||||
|
'url' => 'http://zyren.inf-d.de',
|
||||||
'mailsender' => 'questlab@hhu.de'
|
'mailsender' => 'questlab@hhu.de'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
54
controllers/HtmlmailController.inc
Normal file
54
controllers/HtmlmailController.inc
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller of the HtmlmailAgent for generating a HTML-mail message.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class HtmlmailController extends \nre\core\Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefilter.
|
||||||
|
*
|
||||||
|
* @param Request $request Current request
|
||||||
|
* @param Response $response Current response
|
||||||
|
*/
|
||||||
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
|
|
||||||
|
// Set application URL
|
||||||
|
$this->set('url', \nre\configs\AppConfig::$app['url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*
|
||||||
|
* Create HTML-structure of mail message.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
37
controllers/MailreceiverController.inc
Normal file
37
controllers/MailreceiverController.inc
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller of the MailreceiverAgent to generate a mail receiver
|
||||||
|
* salutation.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class MailreceiverController extends \nre\core\Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*/
|
||||||
|
public function index($user)
|
||||||
|
{
|
||||||
|
$this->set('user', $user);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
55
controllers/TextmailController.inc
Normal file
55
controllers/TextmailController.inc
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Legend of Z
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller of the TextmailAgent for generating a simple text-mail
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class TextmailController extends \nre\core\Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefilter.
|
||||||
|
*
|
||||||
|
* @param Request $request Current request
|
||||||
|
* @param Response $response Current response
|
||||||
|
*/
|
||||||
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
|
|
||||||
|
// Set application URL
|
||||||
|
$this->set('url', \nre\configs\AppConfig::$app['url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: index.
|
||||||
|
*
|
||||||
|
* Create simple text-mail message.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
17
views/htmlmail/htmlmail.tpl
Normal file
17
views/htmlmail/htmlmail.tpl
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<p><?=$mailreceiver?>,</p>
|
||||||
|
<p>
|
||||||
|
<?=$intermediate?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>– <a href="<?=$url?>"><?=$appname?></a></p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
1
views/htmlmail/mailreceiver/index.tpl
Normal file
1
views/htmlmail/mailreceiver/index.tpl
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<?=sprintf(_('Hello %s'), $user['username'])?>
|
||||||
1
views/textmail/mailreceiver/index.tpl
Normal file
1
views/textmail/mailreceiver/index.tpl
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<?=sprintf(_('Hello %s'), $user['username'])?>
|
||||||
8
views/textmail/textmail.tpl
Normal file
8
views/textmail/textmail.tpl
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?=$mailreceiver?>,
|
||||||
|
|
||||||
|
<?=$intermediate?>
|
||||||
|
|
||||||
|
|
||||||
|
– <?=$appname?>
|
||||||
|
|
||||||
|
<?=$url?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue