00001 <?php
00002
00011 class TKClosePopup extends TKPopup {
00012 const CLOSE_LEFT = 0;
00013 const CLOSE_RIGHT = 1;
00014
00025 public function __construct($shadow = false, $opacity = 1.0, $autohide = false) {
00026 parent::__construct($shadow, $opacity, $autohide);
00027
00028 $this->setSlotOption('main', 'access', self::SLOT_ACCESS_PRIVATE);
00029 $this->addSlot('client', array('size' => self::SLOT_SIZE_SINGLE));
00030 $this->setDefaultSlot('client');
00031 $this->addProperty('close_position', self::PROP_NUMERIC);
00032 $this->addProperty('closebutton_class', self::PROP_CLASS);
00033
00034 $this->set('close_position', self::CLOSE_LEFT);
00035
00036 }
00037
00049 protected function renderContainer($class, $style, $events, $id) {
00050 $children = $this->getChildrenBySlot('client');
00051 if(count($children) > 0) {
00052 $childKeys = array_keys($children);
00053 $client = $children[$childKeys[0]];
00054 $clientId = $childKeys[0];
00055 }
00056 else
00057 $client = new TKLabel("");
00058
00059 $hbox = new TKHBox();
00060 $this->addPriv($hbox, 'main');
00061
00062 switch($this->get('close_position')) {
00063 case self::CLOSE_LEFT:
00064 $closeButton = $hbox->addLabel('X');
00065 $hbox->add($client);
00066 break;
00067 case self::CLOSE_RIGHT:
00068 $hbox->add($client);
00069 $closeButton = $hbox->addLabel('X');
00070 break;
00071 }
00072
00073 $closeButton->class = $this->get('closebutton_class');
00074 $closeButton->onclick = new TKPopupAction($this, TKPopupAction::HIDE);
00075
00076 return parent::renderContainer($class, $style, $events, $id);
00077 }
00078 }
00079
00080 ?>