1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\elements; |
4
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Semantic Emoji component |
10
|
|
|
* Ajax\semantic\html\elements$HtmlIcon |
11
|
|
|
* This class is part of phpMv-ui |
12
|
|
|
* @author jcheron <[email protected]> |
13
|
|
|
* @version 1.0.0 |
14
|
|
|
* |
15
|
|
|
*/ |
16
|
|
|
class HtmlEmoji extends HtmlSemDoubleElement { |
17
|
|
|
protected $_emoji; |
18
|
|
|
|
19
|
|
|
public function __construct($identifier, $emoji) { |
20
|
|
|
parent::__construct($identifier, "em", "", NULL); |
21
|
|
|
$this->setEmoji($emoji); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function getEmoji() { |
25
|
|
|
return $this->_emoji; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* sets the emoji |
30
|
|
|
* @param string $emoji |
31
|
|
|
* @return HtmlEmoji |
32
|
|
|
*/ |
33
|
|
|
public function setEmoji($emoji) { |
34
|
|
|
if (isset($this->_emoji)) { |
35
|
|
|
$this->removePropertyValue("data-emoji", $this->_emoji); |
36
|
|
|
} |
37
|
|
|
$this->_emoji=$emoji; |
38
|
|
|
$this->addToProperty("data-emoji", $emoji); |
39
|
|
|
return $this; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Emoji used as a simple loader |
44
|
|
|
* @return HtmlEmoji |
45
|
|
|
*/ |
46
|
|
|
public function asLoader() { |
47
|
|
|
return $this->addToProperty("class", "loading"); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* icon formatted as a link |
52
|
|
|
* @param string $href |
53
|
|
|
* @param string $target |
54
|
|
|
* @return HtmlEmoji |
55
|
|
|
*/ |
56
|
|
|
public function asLink($href=NULL,$target=NULL) { |
57
|
|
|
if (isset($href)) { |
58
|
|
|
$_target=""; |
59
|
|
|
if(isset($target)) |
60
|
|
|
$_target="target='{$target}'"; |
61
|
|
|
$this->wrap("<a href='" . $href . "' {$_target}>", "</a>"); |
62
|
|
|
} |
63
|
|
|
return $this->addToProperty("class", "link"); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function addLabel($label, $before=false, $emoji='slight_smile') { |
67
|
|
|
if($before) |
68
|
|
|
$this->wrap($label); |
69
|
|
|
else |
70
|
|
|
$this->wrap("", $label); |
71
|
|
|
if(isset($emoji)) |
72
|
|
|
$this->setEmoji($emoji); |
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|