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\HtmlElements; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class Link |
25
|
|
|
* Represents a link tag (<a>) in html content |
26
|
|
|
*/ |
27
|
|
|
class Link extends \Kristuff\Phtemail\Core\HtmlElement |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @access private |
31
|
|
|
* @var string $linkHref |
32
|
|
|
*/ |
33
|
|
|
private $linkHref = ''; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @access private |
37
|
|
|
* @var string $linkTitle |
38
|
|
|
*/ |
39
|
|
|
private $linkTitle = ''; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @access private |
43
|
|
|
* @var string $content |
44
|
|
|
*/ |
45
|
|
|
protected $content = ''; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Constructor |
49
|
|
|
* |
50
|
|
|
* @access public |
51
|
|
|
* @param string $content The element content |
52
|
|
|
* @param string $href The link href |
53
|
|
|
* @param string $title The link title |
54
|
|
|
* @param array $styles The inline styles |
55
|
|
|
*/ |
56
|
|
|
public function __construct(string $content = '', string $href, string $title = '', array $styles = []) |
57
|
|
|
{ |
58
|
|
|
$this->content = $content; |
59
|
|
|
$this->linkHref = $href; |
60
|
|
|
$this->linkTitle = $title; |
61
|
|
|
$this->setStyles($styles); |
62
|
|
|
$this->mandatoryStyles = array( |
63
|
|
|
'color', |
64
|
|
|
'font-family', |
65
|
|
|
'font-size', |
66
|
|
|
// 'font-weight', todo |
67
|
|
|
// 'line-height', |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get the HTML |
73
|
|
|
* |
74
|
|
|
* @access public |
75
|
|
|
* @param string $indent |
76
|
|
|
* |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public function getHtml(string $indent = '') |
80
|
|
|
{ |
81
|
|
|
return '' // $this->getBuilder()->getHtmlComment('A', $indent) |
82
|
|
|
. $indent |
83
|
|
|
. '<a class="link"' |
84
|
|
|
. ' target="_blank"' |
85
|
|
|
. ' href="'. $this->linkHref . '"' |
86
|
|
|
. ' title="'. $this->linkTitle . '"' |
87
|
|
|
. $this->getInlineStyles() |
88
|
|
|
. '>'. PHP_EOL |
89
|
|
|
. $this->content |
90
|
|
|
. '</a>'. PHP_EOL; |
91
|
|
|
} |
92
|
|
|
} |