|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ____ _ _ _ _ |
|
5
|
|
|
* | _ \| |__ | |_ ___ _ __ ___ __ _(_) | |
|
6
|
|
|
* | |_) | '_ \| __/ _ \ '_ ` _ \ / _` | | | |
|
7
|
|
|
* | __/| | | | || __/ | | | | | (_| | | | |
|
8
|
|
|
* |_| |_| |_|\__\___|_| |_| |_|\__,_|_|_| |
|
9
|
|
|
* |
|
10
|
|
|
* This file is part of Kristuff\Phtemail. |
|
11
|
|
|
* |
|
12
|
|
|
* (c) Kristuff <[email protected]> |
|
13
|
|
|
* |
|
14
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
15
|
|
|
* file that was distributed with this source code. |
|
16
|
|
|
* |
|
17
|
|
|
* @version 0.2.0 |
|
18
|
|
|
* @copyright 2017-2020 Kristuff |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace Kristuff\Phtemail\Core; |
|
22
|
|
|
|
|
23
|
|
|
use Kristuff\Phtemail\HtmlEmailBuilder; |
|
24
|
|
|
use Kristuff\Phtemail\Core\HtmlContainerElement; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Class HtmlBuilderContainer |
|
28
|
|
|
* Abstract base class for top level builder elements (ie: header, body and footer) |
|
29
|
|
|
* Contrary to the other containers, the parent is the HtmlEmailBuilder, not another HtmlElement |
|
30
|
|
|
*/ |
|
31
|
|
|
abstract class HtmlBuilderContainer extends HtmlContainerElement |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* The htmlEmailBuilder parent class |
|
35
|
|
|
* |
|
36
|
|
|
* @access protected |
|
37
|
|
|
* @var HtmlEmailBuilder $parent |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $parent = null; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Constructor |
|
43
|
|
|
*/ |
|
44
|
|
|
public function __construct(HtmlEmailBuilder $parent) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->parent = $parent; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Gets the HTML |
|
51
|
|
|
* |
|
52
|
|
|
* @access public |
|
53
|
|
|
* @param string $indent The indendation to start with |
|
54
|
|
|
* @param string $partName The part name: EMAIL BODY, FOOTER, or HEADER |
|
55
|
|
|
* @param string $id The section id |
|
56
|
|
|
* @param string $backgroundColor The background color |
|
57
|
|
|
* |
|
58
|
|
|
* @return string The html string content |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function getHtmlStructure(string $indent, string $partName, string $id, string $backgroundColor) |
|
61
|
|
|
{ |
|
62
|
|
|
// html result. start with an empty string or a html comment |
|
63
|
|
|
$html = $this->getBuilder()->getHtmlComment($partName . ' //', $indent); |
|
64
|
|
|
|
|
65
|
|
|
// create a table container |
|
66
|
|
|
$html .= $indent . '<table bgcolor="'. $backgroundColor . '"' |
|
67
|
|
|
. ' width="'. $this->getBuilder()->emailBodyWidth() . '"' |
|
68
|
|
|
. ' border="0" cellpadding="0" cellspacing="0" id="'. $id .'">' .PHP_EOL; |
|
69
|
|
|
|
|
70
|
|
|
$html .= $indent . ' <tr>'.PHP_EOL; |
|
71
|
|
|
$html .= $indent . ' <td align="center" valign="top">'.PHP_EOL; |
|
72
|
|
|
|
|
73
|
|
|
$html .= $this->getBuilder()->getHtmlComment('CENTERING TABLE //', $indent . ' '); |
|
74
|
|
|
|
|
75
|
|
|
$html .= $indent . ' <table border="0" cellpadding="0" cellspacing="0" width="100%">'.PHP_EOL; |
|
76
|
|
|
$html .= $indent . ' <tr>'.PHP_EOL; |
|
77
|
|
|
$html .= $indent . ' <td align="center" valign="top">'.PHP_EOL; |
|
78
|
|
|
|
|
79
|
|
|
$html .= $this->getBuilder()->getHtmlComment('FLEXIBLE CONTAINER //', $indent . ' '); |
|
80
|
|
|
|
|
81
|
|
|
$html .= $indent . ' <table border="0" cellpadding="' . $this->cellPadding . '" cellspacing="0" width="'. $this->getBuilder()->emailBodyWidth() . '" class="flexibleContainer">'.PHP_EOL; |
|
82
|
|
|
$html .= $indent . ' <tr>'.PHP_EOL; |
|
83
|
|
|
$html .= $indent . ' <td align="center" valign="top" width="'. $this->getBuilder()->emailBodyWidth() . '" class="flexibleContainerCell">'.PHP_EOL; |
|
84
|
|
|
|
|
85
|
|
|
$html .= $this->getBuilder()->getHtmlComment('CONTENT TABLE //', $indent . ' '); |
|
86
|
|
|
|
|
87
|
|
|
$html .= $indent . ' <table border="0" cellpadding="0" cellspacing="0" width="100%">'.PHP_EOL; |
|
88
|
|
|
$html .= $indent . ' <tr>'.PHP_EOL; |
|
89
|
|
|
$html .= $indent . ' <td valign="'. $this->verticalAlign .'" align="'. $this->horizontalAlign .'" bgcolor="'. $backgroundColor . '">'.PHP_EOL; |
|
90
|
|
|
|
|
91
|
|
|
// render child elements collection |
|
92
|
|
|
foreach ($this->childElements as $element){ |
|
93
|
|
|
$html .= $element->getHtml($indent . ' '); |
|
94
|
|
|
$html .= PHP_EOL ; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
$html .= $indent . ' </td>'.PHP_EOL; |
|
98
|
|
|
$html .= $indent . ' </tr>'.PHP_EOL; |
|
99
|
|
|
$html .= $indent . ' </table>'.PHP_EOL; |
|
100
|
|
|
|
|
101
|
|
|
$html .= $this->getBuilder()->getHtmlComment('// CONTENT TABLE', $indent . ' '); |
|
102
|
|
|
|
|
103
|
|
|
$html .= $indent . ' </td>'.PHP_EOL; |
|
104
|
|
|
$html .= $indent . ' </tr>'.PHP_EOL; |
|
105
|
|
|
$html .= $indent . ' </table>'.PHP_EOL; |
|
106
|
|
|
|
|
107
|
|
|
$html .= $this->getBuilder()->getHtmlComment('// FLEXIBLE CONTAINER', $indent . ' '); |
|
108
|
|
|
|
|
109
|
|
|
$html .= $indent . ' </td>'.PHP_EOL; |
|
110
|
|
|
$html .= $indent . ' </tr>'.PHP_EOL; |
|
111
|
|
|
$html .= $indent . ' </table>'.PHP_EOL; |
|
112
|
|
|
|
|
113
|
|
|
$html .= $this->getBuilder()->getHtmlComment('// CENTERING TABLE', $indent . ' '); |
|
114
|
|
|
|
|
115
|
|
|
$html .= $indent . ' </td>'.PHP_EOL; |
|
116
|
|
|
$html .= $indent . ' </tr>'.PHP_EOL; |
|
117
|
|
|
$html .= $indent . '</table>'.PHP_EOL; |
|
118
|
|
|
|
|
119
|
|
|
$html .= $this->getBuilder()->getHtmlComment('// ' . $partName, $indent); |
|
120
|
|
|
$html .= PHP_EOL; |
|
121
|
|
|
|
|
122
|
|
|
// done |
|
123
|
|
|
return $html; |
|
124
|
|
|
} |
|
125
|
|
|
} |