| 1: | <?php |
| 2: | |
| 3: | namespace Zippy\Html\Link; |
| 4: | |
| 5: | use Zippy\WebApplication; |
| 6: | use Zippy\Interfaces\ClickListener; |
| 7: | use Zippy\Interfaces\EventReceiver; |
| 8: | |
| 9: | use Zippy\Interfaces\Requestable; |
| 10: | use Zippy\Event; |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | class ClickLink extends AbstractLink implements ClickListener, Requestable |
| 17: | { |
| 18: | protected $event; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | public function __construct($id, $receiver = null, $handler = null, $ajax = false) { |
| 27: | parent::__construct($id); |
| 28: | |
| 29: | if (is_object($receiver) && $handler != null) { |
| 30: | $this->onClick($receiver, $handler, $ajax); |
| 31: | } |
| 32: | } |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | public function RenderImpl() { |
| 38: | parent::RenderImpl(); |
| 39: | |
| 40: | |
| 41: | if ($this->disabled == true) { |
| 42: | $this->setAttribute("href", ""); |
| 43: | |
| 44: | return; |
| 45: | } |
| 46: | if ($this->event == null) { |
| 47: | $this->setAttribute("href", ""); |
| 48: | |
| 49: | return; |
| 50: | } |
| 51: | |
| 52: | $this->setAttribute("href", "javascript:void(0);"); |
| 53: | if ($this->event->isajax == false) { |
| 54: | $url = $this->owner->getURLNode() . "::" . $this->id; |
| 55: | $this->setAttribute("onclick", "if(beforeZippy('{$this->id}') ==false) return false;window.location='{$url}';event.returnValue=false; return false;"); |
| 56: | } else { |
| 57: | $url = $this->owner->getURLNode() . "::" . $this->id . "&ajax=true"; |
| 58: | $this->setAttribute("onclick", "if(beforeZippy('{$this->id}') ==false) return false;getUpdate('{$url}');event.returnValue=false; return false;"); |
| 59: | } |
| 60: | } |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | public function RequestHandle() { |
| 66: | $this->OnEvent(); |
| 67: | |
| 68: | } |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | public function onClick(EventReceiver $receiver, $handler, $ajax = false) { |
| 74: | $this->event = new Event($receiver, $handler); |
| 75: | $this->event->isajax = $ajax; |
| 76: | } |
| 77: | |
| 78: | |
| 79: | |
| 80: | |
| 81: | public function OnEvent() { |
| 82: | if ($this->event != null) { |
| 83: | $this->event->onEvent($this); |
| 84: | } |
| 85: | } |
| 86: | |
| 87: | } |
| 88: | |