-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView.php
More file actions
85 lines (74 loc) · 2.12 KB
/
View.php
File metadata and controls
85 lines (74 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* @package framework
* @copyright Copyright (c) 2005-2020 The Regents of the University of California.
* @license http://opensource.org/licenses/MIT MIT
*/
namespace Qubeshub\Mail;
require_once PATH_APP . DS . 'libraries' . DS . 'Qubeshub' . DS . 'Mail' . DS . 'Template.php';
use Qubeshub\Mail\Template;
use Hubzero\View\View as AbstractView;
/**
* Class for a mail View
*/
class View extends AbstractView
{
/**
* Mail template object
*
* @var object Hubzero\Mail\Template
*/
private $_mailTemplate;
/**
* Constructor
*
* [!] Override to create instance of mail template
*
* @param array $config A named configuration array for object construction.
* @return void
*/
public function __construct($config = array())
{
// create new mail template, loading email.php
// in active template falling back to system email.php
$this->_mailTemplate = new Template();
// call parent construct
parent::__construct($config);
}
/**
* Load a template file -- first look in the templates folder for an override
*
* [!] Override to wrap html view in mail template
*
* @param string $tpl The name of the template source file; automatically searches the template paths and compiles as needed.
* @return string The output of the the template script.
*/
public function loadTemplate($tpl = null)
{
// hold reference to template passed in
$template = ($tpl === false) ? null : $tpl;
// call load template and hold on to content
$content = parent::loadTemplate($template);
// if we want to wrap in mail template
if ($tpl !== false)
{
$this->_mailTemplate->setBuffer($content, 'component');
$content = $this->_mailTemplate->render();
//$this->_mailTemplate->setBuffer(null, array('type' => 'head', 'name' => 'email'));
$this->_mailTemplate->setBuffer(null, 'component');
$this->_mailTemplate->setBuffer(null, 'head');
}
// return content
return $content;
}
/**
* Include CSS declaration in document head
*
* @param string $css CSS string
* @return void
*/
public function css($css)
{
$this->_mailTemplate->addStyleDeclaration($css);
}
}