1
|
|
|
<?php |
2
|
|
|
namespace phpbu\App\Log; |
3
|
|
|
|
4
|
|
|
use phpbu\App\Exception; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* MailTemplate |
8
|
|
|
* |
9
|
|
|
* @package phpbu |
10
|
|
|
* @subpackage Log |
11
|
|
|
* @author Sebastian Feldmann <[email protected]> |
12
|
|
|
* @copyright Sebastian Feldmann <[email protected]> |
13
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
14
|
|
|
* @link http://phpbu.de/ |
15
|
|
|
* @since Class available since Release 2.1.8 |
16
|
|
|
*/ |
17
|
|
|
class MailTemplate |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* List of available snippets |
21
|
|
|
* |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
private static $snippets; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Return a template snippet. |
28
|
|
|
* |
29
|
|
|
* @param string $snippet |
30
|
|
|
* @return string |
31
|
|
|
* @throws \phpbu\App\Exception |
32
|
|
|
*/ |
33
|
8 |
|
public static function getSnippet($snippet) : string |
34
|
|
|
{ |
35
|
8 |
|
if (null === self::$snippets) { |
|
|
|
|
36
|
1 |
|
self::setDefaultSnippets(); |
37
|
|
|
} |
38
|
8 |
|
if (!isset(self::$snippets[$snippet])) { |
39
|
1 |
|
throw new Exception('Unknown snippet'); |
40
|
|
|
} |
41
|
7 |
|
return self::$snippets[$snippet]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Set the default template snippets. |
46
|
|
|
*/ |
47
|
2 |
|
public static function setDefaultSnippets() |
48
|
|
|
{ |
49
|
2 |
|
self::setSnippets([ |
50
|
2 |
|
'sBody' => 'style="font-family: Arial, Helvetica, sans-serif; ' . |
51
|
|
|
'background-color:#343b43; ' . |
52
|
|
|
'font-size: 15px; margin:0; ' . |
53
|
|
|
'padding:0;"', |
54
|
|
|
'sTableHeader' => 'style="width:100%; ' . |
55
|
|
|
'font-family: Arial, Helvetica, sans-serif; ' . |
56
|
|
|
'margin:0; color:#e6e6e6;" ' . |
57
|
|
|
'align="center" cellpadding="5" cellspacing="0"', |
58
|
|
|
'sTableError' => 'style="width:100%; ' . |
59
|
|
|
'background-color:#e6e6e6; ' . |
60
|
|
|
'margin:0 auto 15px; ' . |
61
|
|
|
'border:1px solid #011516;" ' . |
62
|
|
|
'align="center" cellpadding="5" cellspacing="0"', |
63
|
|
|
'sTableErrorCol' => 'style="border-top: 1px solid #f6f6f6; ' . |
64
|
|
|
'border-bottom: 1px solid #c9c9c9;"', |
65
|
|
|
'sTableContent' => 'style="width:420px; ' . |
66
|
|
|
'font-family: Arial, Helvetica, sans-serif; ' . |
67
|
|
|
'margin:0 auto;" ' . |
68
|
|
|
'align="center" cellpadding="0" cellspacing="0"', |
69
|
|
|
'sTableContentCol' => 'style="padding:0 10px;"', |
70
|
|
|
'sTableStatus' => 'style="background-color:#%s; ' . |
71
|
|
|
'width:100%%; ' . |
72
|
|
|
'margin:0 auto 15px; ' . |
73
|
|
|
'border:1px solid #011516;" ' . |
74
|
|
|
'align="center" cellpadding="10" cellspacing="0"', |
75
|
|
|
'sTableStatusHead' => 'style="margin:0;"', |
76
|
|
|
'sTableStatusText' => 'style="font-size:16px;"', |
77
|
|
|
'sTableBackup' => 'style="width:100%; font-family: Arial, Helvetica, sans-serif; ' . |
78
|
|
|
'background-color:#e6e6e6; ' . |
79
|
|
|
'margin:0 0 15px; ' . |
80
|
|
|
'border:1px solid #011516;" ' . |
81
|
|
|
'align="center" cellpadding="5" cellspacing="0" width="100%"', |
82
|
|
|
'sTableBackupStatusColumn' => 'style="background-color:#%s; ' . |
83
|
|
|
'border-bottom:1px solid #747474;"', |
84
|
|
|
'sTableBackupStatusText' => 'style="float:right;"', |
85
|
|
|
'sRowHead' => 'style="border-top: 1px solid #f6f6f6; border-bottom: 1px solid #c9c9c9;"', |
86
|
|
|
'sRowCheck' => 'style="border-top: 1px solid #f6f6f6; border-bottom: 1px solid #c9c9c9;"', |
87
|
|
|
'sRowCrypt' => 'style="border-top: 1px solid #f6f6f6; border-bottom: 1px solid #c9c9c9;"', |
88
|
|
|
'sRowSync' => 'style="border-top: 1px solid #f6f6f6; border-bottom: 1px solid #c9c9c9;"', |
89
|
|
|
'sRowCleanup' => 'style="border-top: 1px solid #f6f6f6;"', |
90
|
|
|
'sStats' => 'style="color:#e6e6e6;"', |
91
|
|
|
'cStatusOK' => '91ff94', |
92
|
|
|
'cStatusWARN' => 'ffcc6a', |
93
|
|
|
'cStatusFAIL' => 'ff7b7b', |
94
|
|
|
]); |
95
|
2 |
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Snippet setter. |
99
|
|
|
* |
100
|
|
|
* @param array $list |
101
|
|
|
*/ |
102
|
3 |
|
public static function setSnippets(array $list) |
103
|
|
|
{ |
104
|
3 |
|
self::$snippets = $list; |
105
|
3 |
|
} |
106
|
|
|
} |
107
|
|
|
|