1: | <?php |
2: | |
3: | namespace Zippy\Html\Link; |
4: | |
5: | use Zippy\Html\HtmlComponent; |
6: | use Zippy\Interfaces\Binding; |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | abstract class AbstractLink extends \Zippy\Html\HtmlContainer |
13: | { |
14: | protected $value = null; |
15: | protected $disabled = false; |
16: | protected $htmlvalue = false; |
17: | |
18: | public function __construct($id) { |
19: | parent::__construct($id); |
20: | $this->setAttribute("href", "javascript:void(0);"); |
21: | } |
22: | |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | public function setValue($text,$htmlvalue=false) { |
30: | $this->value = $text; |
31: | $this->htmlvalue = $htmlvalue; |
32: | return $this; |
33: | } |
34: | |
35: | public function getValue() { |
36: | if ($this->value instanceof Binding) { |
37: | return $this->value->getValue(); |
38: | } else { |
39: | return $this->value; |
40: | } |
41: | } |
42: | |
43: | |
44: | |
45: | |
46: | public function beforeRender() { |
47: | $HtmlTag = $this->getTag('a'); |
48: | $children = $HtmlTag->children('img'); |
49: | |
50: | if ($this->value != null && $children->count() == 0) { |
51: | if($this->htmlvalue) { |
52: | $HtmlTag->html($this->getValue()); |
53: | }else { |
54: | $HtmlTag->text($this->getValue()); |
55: | } |
56: | |
57: | } |
58: | if ($children->count() == 1 && $this->value != null) { |
59: | $children[0]->attr('src', $this->getValue()); |
60: | } |
61: | } |
62: | |
63: | |
64: | |
65: | |
66: | public function setDisabled($disabled = true) { |
67: | $this->disabled = $disabled; |
68: | } |
69: | |
70: | public function RenderImpl() { |
71: | parent::RenderImpl(); |
72: | } |
73: | |
74: | } |
75: | |