hook on request dispatch, mailer refactored, #11

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@105 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2009-10-10 20:17:13 +00:00
parent df781c8eb2
commit c7c1c95f49
2 changed files with 25 additions and 20 deletions

View File

@ -1,15 +1,15 @@
<?php <?php
/** /**
* Класс для отправки мыла * Класс для отправки почты
* *
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link * @link http://netmonsters.ru
* @package Nakon * @package Core
* @subpackage face * @subpackage mail
* @since * @since
* @version SVN: $Id$ * @version SVN: $Id$
* @filesource $URL$ * @filesource $URL$
*/ */
class Mailer class Mailer
{ {
@ -17,26 +17,24 @@ class Mailer
public $template = null; public $template = null;
public $templater; public $templater;
public $headers; public $headers;
protected $url; protected $host;
function __construct($template = null) function __construct($host, $template = null)
{ {
if ($template !== null) { if ($template !== null) {
$this->templater = Load::templater(ACTION_TPL_PATH.'/'.$this->template_dir); $this->templater = Load::templater(ACTION_TPL_PATH . '/' . $this->template_dir);
$this->template = $template; $this->template = $template;
} }
$settings = Env::getParam('site_settings'); $this->host = $host;
$this->url = $settings['host_name'];
/* если че забыл, не серчайте */ $this->headers .= 'From: robot@' . $this->host . "\r\n";
$this->headers .= 'From: robot@' . $this->url . "\r\n";
$this->headers .= 'Date: '. date('r') ."\r\n"; $this->headers .= 'Date: '. date('r') ."\r\n";
$this->headers .= "Return-Path: robot@". $this->url ."\r\n"; $this->headers .= "Return-Path: robot@". $this->host ."\r\n";
$this->headers .= "X-Mailer: PHPMail Tool\r\n"; $this->headers .= "X-Mailer: PHPMail Tool\r\n";
$this->headers .= "Reply-To: robot@". $this->url ."\r\n"; $this->headers .= "Reply-To: robot@". $this->host ."\r\n";
$this->headers .= "X-Priority: 3 (Normal)\r\n"; $this->headers .= "X-Priority: 3 (Normal)\r\n";
$this->headers .= "Message-ID: <". md5(uniqid(time()))."@". $this->url .">\r\n"; $this->headers .= "Message-ID: <". md5(uniqid(time()))."@". $this->host .">\r\n";
$this->headers .= "MIME-Version: 1.0\r\n"; $this->headers .= "MIME-Version: 1.0\r\n";
$this->headers .= "Content-Type: text/plain; charset=utf-8\r\n"; $this->headers .= "Content-Type: text/plain; charset=utf-8\r\n";
$this->headers .= "Content-Transfer-Encoding: 16bit\r\n"; $this->headers .= "Content-Transfer-Encoding: 16bit\r\n";

View File

@ -20,6 +20,12 @@ class PageController
protected function init() {} protected function init() {}
/** /**
* Действия после разбора роута.
*
*/
protected function onDispatch() {}
/**
* Вывод в браузер всего сайта. * Вывод в браузер всего сайта.
* *
*/ */
@ -29,6 +35,7 @@ class PageController
$this->init(); $this->init();
try{ try{
$this->route = Load::router()->proccess(MJ_PATH); $this->route = Load::router()->proccess(MJ_PATH);
$this->onDispatch();
$action = new $this->route->action; $action = new $this->route->action;
$decorator = new $this->route->decorator; $decorator = new $this->route->decorator;
return $decorator->display($action); return $decorator->display($action);