mirror of
https://github.com/Oreolek/kangana.git
synced 2024-05-24 11:58:11 +03:00
DAR-18: HTML message layouts
This commit is contained in:
parent
ade890c38c
commit
12a7db25e3
|
@ -63,4 +63,16 @@ class Controller_Letter extends Controller_Layout {
|
|||
$this->redirect('/');
|
||||
}
|
||||
}
|
||||
|
||||
public function action_view()
|
||||
{
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Letter', $id);
|
||||
if (!$model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template = new View_Letter_View;
|
||||
$this->template->content = $model->text;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,9 @@ class Model_Letter extends ORM {
|
|||
{
|
||||
Log::instance()->add(Log::NOTICE, __('Sending letter with subject "%subject" to address %address', array('%subject' => $subject, '%address' => $address)));
|
||||
$sender = Kohana::$config->load('email')->get('sender');
|
||||
$email = Email::factory($subject, $text)->from($sender[0], $sender[1]);
|
||||
$template = new View_Letter_View;
|
||||
$renderer = Kostache_Layout::factory($template->_layout);
|
||||
$email = Email::factory($subject, $renderer->render($template, $template->_view))->from($sender[0], $sender[1]);
|
||||
if (is_array($address))
|
||||
{
|
||||
$email->bcc($address);
|
||||
|
|
|
@ -21,7 +21,7 @@ class View_Letter_Index extends View_Index {
|
|||
|
||||
$output = array(
|
||||
'description' => $item->text,
|
||||
'view_link' => $item->subject,//HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view','id' => $item->id)), $item->subject, array('class' => 'link_view')),
|
||||
'view_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view','id' => $item->id)), $item->subject, array('class' => 'link_view')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete')),
|
||||
);
|
||||
|
|
46
application/classes/View/Letter/View.php
Normal file
46
application/classes/View/Letter/View.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* E-mail letter view controller
|
||||
**/
|
||||
class View_Letter_View extends View {
|
||||
public $_view = NULL;
|
||||
public $_layout = 'email';
|
||||
public $token = '';
|
||||
public $scripts = array();
|
||||
|
||||
public function stylesheet()
|
||||
{
|
||||
$url = Less::compile(APPPATH.'assets/stylesheets/main', 'screen', FALSE);
|
||||
return file_get_contents(DOCROOT.$url[0]);
|
||||
}
|
||||
|
||||
public function get_content()
|
||||
{
|
||||
return Kostache::factory()->render($this->content);
|
||||
}
|
||||
|
||||
public function scripts()
|
||||
{
|
||||
$scripts = $this->scripts;
|
||||
$temp = "";
|
||||
foreach($scripts as $script):
|
||||
if (strstr($script, '://') === FALSE) //no protocol given, script is local
|
||||
{
|
||||
if ($script === 'jquery') // CDN shortcut
|
||||
{
|
||||
$temp .= HTML::script('https://yandex.st/jquery/2.0.3/jquery.min.js')."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp .= HTML::script('application/assets/javascript/'.$script)."\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp .= HTML::script($script)."\n";
|
||||
}
|
||||
endforeach;
|
||||
return $temp;
|
||||
}
|
||||
}
|
20
application/templates/email.mustache
Normal file
20
application/templates/email.mustache
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
<meta charset="utf-8">
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport">
|
||||
<style type="text/css">
|
||||
{{{stylesheet}}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class = "main_content">
|
||||
<h3>{{title}}</h3>
|
||||
{{>content}}
|
||||
</div>
|
||||
</div>
|
||||
{{{scripts}}}
|
||||
</body>
|
||||
</html>
|
1
application/templates/letter/view.mustache
Normal file
1
application/templates/letter/view.mustache
Normal file
|
@ -0,0 +1 @@
|
|||
{{content}}
|
|
@ -1 +1 @@
|
|||
Subproject commit aaffc1b4eaf878e975f8ce9933cf4b34e72b42e3
|
||||
Subproject commit 19e61497e200316d66be75ae8ae0b2074761769b
|
Loading…
Reference in a new issue