| @@ 7-49 (lines=43) @@ | ||
| 4 | ||
| 5 | use KodiComponents\Support\HtmlAttributes; |
|
| 6 | ||
| 7 | class Element |
|
| 8 | { |
|
| 9 | use HtmlAttributes; |
|
| 10 | ||
| 11 | protected $text; |
|
| 12 | protected $tag; |
|
| 13 | ||
| 14 | public function __construct($text, $tag = 'span') |
|
| 15 | { |
|
| 16 | $this->text = $text; |
|
| 17 | $this->tag = $tag; |
|
| 18 | } |
|
| 19 | ||
| 20 | public function getText() |
|
| 21 | { |
|
| 22 | return $this->text; |
|
| 23 | } |
|
| 24 | ||
| 25 | public function setText($text) |
|
| 26 | { |
|
| 27 | $this->text = $text; |
|
| 28 | } |
|
| 29 | ||
| 30 | public function getTag() |
|
| 31 | { |
|
| 32 | return $this->tag; |
|
| 33 | } |
|
| 34 | ||
| 35 | public function setTag($tag) |
|
| 36 | { |
|
| 37 | $this->tag = $tag; |
|
| 38 | } |
|
| 39 | ||
| 40 | public static function create($text) |
|
| 41 | { |
|
| 42 | return new static($text); |
|
| 43 | } |
|
| 44 | ||
| 45 | public function attributes() |
|
| 46 | { |
|
| 47 | return $this->htmlAttributesToString(); |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| @@ 7-56 (lines=50) @@ | ||
| 4 | ||
| 5 | use KodiComponents\Support\HtmlAttributes; |
|
| 6 | ||
| 7 | class Link |
|
| 8 | { |
|
| 9 | use HtmlAttributes; |
|
| 10 | ||
| 11 | protected $url; |
|
| 12 | protected $title; |
|
| 13 | ||
| 14 | public function __construct($url, $title) |
|
| 15 | { |
|
| 16 | $this->url = $url; |
|
| 17 | $this->title = $title; |
|
| 18 | } |
|
| 19 | ||
| 20 | public function getUrl() |
|
| 21 | { |
|
| 22 | return $this->url; |
|
| 23 | } |
|
| 24 | ||
| 25 | public function setUrl($url) |
|
| 26 | { |
|
| 27 | $this->url = $url; |
|
| 28 | } |
|
| 29 | ||
| 30 | public function getTitle() |
|
| 31 | { |
|
| 32 | return $this->title; |
|
| 33 | } |
|
| 34 | ||
| 35 | public function setTitle($title) |
|
| 36 | { |
|
| 37 | $this->title = $title; |
|
| 38 | } |
|
| 39 | ||
| 40 | public function blank() |
|
| 41 | { |
|
| 42 | $this->setHtmlAttribute('target', '_blank'); |
|
| 43 | ||
| 44 | return $this; |
|
| 45 | } |
|
| 46 | ||
| 47 | public static function create($url, $title) |
|
| 48 | { |
|
| 49 | return new static($url, $title); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function attributes() |
|
| 53 | { |
|
| 54 | return $this->htmlAttributesToString(); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||