properties['parentWidget'] = $parentWidget; $this->properties['children'] = array(); if( $parentWidget !== null ) { $parentWidget->addChild( $this ); } } /** * Sets the property $name to $value. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @param string $name * @param mixed $value * @ignore */ public function __set( $name, $value ) { switch ( $name ) { case 'contentDisposition': $this->properties[$name] = $value; break; case 'children': case 'parentWidget': throw new ezcBasePropertyPermissionException( $name, ezcBasePropertyPermissionException::READ ); break; default: throw new ezcBasePropertyNotFoundException( $name ); break; } } /** * Returns the property $name. * * @throws ezcBasePropertyNotFoundException if the property does not exist. * @param string $name * @return mixed * @ignore */ public function __get( $name ) { switch ( $name ) { case 'parentWidget': case 'children': return isset( $this->properties[$name] ) ? $this->properties[$name] : null; break; default: throw new ezcBasePropertyNotFoundException( $name ); break; } } public function setParent( ezcWgWidget $parent ) { if( $this->parentWidget !== null ) { $this->parentWidget->removeChild( $this ); } $this->properties['parentWidget'] = $parent; $this->parentWidget->addChild( $this ); } public function addChild( ezcWgWidget $child ) { $this->properties['children'][] = $child; } public function removeChild( ezcWgWidget $child ) { $this->properties['children'] = array_diff( $this->children, array( $child ) ); } public function render() { $result = ""; foreach( $this->children as $child ) { $result .= $child->render(); } return $result; } /** * QT does bottom up event handling since the target widget will actually receive the event. * In our case the target widget is unknown. Hence we need to ask all widgets if they accept the * event. * * Once a widget has accepted the event the handler stops. * * Later versions should have something like QEvent with the event info. For now, we just get it from $_POST. */ public function handleEvent( ezcWgEvent $e ) { foreach( $this->children as $child ) { $child->handleEvent( $e ); if( $e->isAccepted ) { break; } } } } ?>