1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: namespace picon;
24:
25: 26: 27: 28: 29: 30:
31: class Link extends AbstractLink
32: {
33: private $callback;
34: private $popupSettings;
35:
36: public function __construct($id, $callback)
37: {
38: parent::__construct($id);
39: Args::callBack($callback, 'callback');
40: $this->callback = $callback;
41: }
42:
43: protected function onLinkClicked()
44: {
45: $callable = $this->callback;
46: $callable();
47: }
48:
49: public function setPopupSettings(PopupSettings $settings)
50: {
51: $this->popupSettings = $settings;
52: }
53:
54: protected function onComponentTag(ComponentTag $tag)
55: {
56: parent::onComponentTag($tag);
57: $url = $this->urlForListener($this);
58: $tag->put('href', $this->popupSettings==null?$url:'javascript:;');
59:
60: if($this->popupSettings!=null)
61: {
62: $properties = $this->popupSettings;
63: $tag->put('onClick', sprintf("javascript:window.open('%s','%s','width=%s,height=%s');", $url, $properties->name, $properties->width, $properties->height));
64: }
65: }
66:
67: protected function generateHref($url)
68: {
69: if($this->popupSettings==null)
70: {
71: return $url;
72: }
73: else
74: {
75: $properties = $this->popupSettings;
76: return sprintf("javascript:window.open('%s','%s','width=%s,height=%s');", $url, $properties->name, $properties->width, $properties->height);
77: }
78: }
79: }
80:
81: ?>
82: