Browse Source

hook on request dispatch, mailer refactored, #11

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@105 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
master
pzinovkin 15 years ago
parent
commit
c7c1c95f49
  1. 38
      classes/Mailer.class.php
  2. 7
      classes/PageController.class.php

38
classes/Mailer.class.php

@ -1,15 +1,15 @@
<?php <?php
/** /**
* Класс для отправки мыла
*
* @copyright NetMonsters <team@netmonsters.ru>
* @link
* @package Nakon
* @subpackage face
* @since
* @version SVN: $Id$
* @filesource $URL$
*/
* Класс для отправки почты
*
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Core
* @subpackage mail
* @since
* @version SVN: $Id$
* @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->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 .= '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";

7
classes/PageController.class.php

@ -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);

Loading…
Cancel
Save