From c7c1c95f498d66ebad937bd4a7cf4479f91920e2 Mon Sep 17 00:00:00 2001 From: pzinovkin Date: Sat, 10 Oct 2009 20:17:13 +0000 Subject: [PATCH] hook on request dispatch, mailer refactored, #11 git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@105 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- classes/Mailer.class.php | 38 ++++++++++++++++++-------------------- classes/PageController.class.php | 7 +++++++ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/classes/Mailer.class.php b/classes/Mailer.class.php index f10204c..be5c4ca 100644 --- a/classes/Mailer.class.php +++ b/classes/Mailer.class.php @@ -1,15 +1,15 @@ -* @link -* @package Nakon -* @subpackage face -* @since -* @version SVN: $Id$ -* @filesource $URL$ -*/ + * Класс для отправки почты + * + * @copyright NetMonsters + * @link http://netmonsters.ru + * @package Core + * @subpackage mail + * @since + * @version SVN: $Id$ + * @filesource $URL$ + */ class Mailer { @@ -17,26 +17,24 @@ class Mailer public $template = null; public $templater; public $headers; - protected $url; + protected $host; - function __construct($template = null) + function __construct($host, $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; } - $settings = Env::getParam('site_settings'); - $this->url = $settings['host_name']; + $this->host = $host; - /* если че забыл, не серчайте */ - $this->headers .= 'From: robot@' . $this->url . "\r\n"; + $this->headers .= 'From: robot@' . $this->host . "\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 .= "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 .= "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 .= "Content-Type: text/plain; charset=utf-8\r\n"; $this->headers .= "Content-Transfer-Encoding: 16bit\r\n"; diff --git a/classes/PageController.class.php b/classes/PageController.class.php index 6dda0bd..dc9208c 100644 --- a/classes/PageController.class.php +++ b/classes/PageController.class.php @@ -20,6 +20,12 @@ class PageController protected function init() {} /** + * Действия после разбора роута. + * + */ + protected function onDispatch() {} + + /** * Вывод в браузер всего сайта. * */ @@ -29,6 +35,7 @@ class PageController $this->init(); try{ $this->route = Load::router()->proccess(MJ_PATH); + $this->onDispatch(); $action = new $this->route->action; $decorator = new $this->route->decorator; return $decorator->display($action);