imlement HtmlmailAgent, TextmailAgent and MailreceiverAgent for generating plaintext- and HTML-mail messages

This commit is contained in:
coderkun 2014-05-25 11:58:50 +02:00
commit c995fea203
11 changed files with 301 additions and 0 deletions

View 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)
{
}
}
?>

View 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));
}
}
?>

View 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));
}
}
?>

View file

@ -34,6 +34,7 @@
'genericname' => 'The Legend of Z',
'namespace' => 'hhu\\z\\',
'timeZone' => 'Europe/Berlin',
'url' => 'http://zyren.inf-d.de',
'mailsender' => 'questlab@hhu.de'
);

View 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']);
}
}
?>

View 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);
}
}
?>

View 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']);
}
}
?>

View 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>

View file

@ -0,0 +1 @@
<?=sprintf(_('Hello %s'), $user['username'])?>

View file

@ -0,0 +1 @@
<?=sprintf(_('Hello %s'), $user['username'])?>

View file

@ -0,0 +1,8 @@
<?=$mailreceiver?>,
<?=$intermediate?>
<?=$appname?>
<?=$url?>