mainWidget = null; $this->properties['javaScripts'] = array(); $this->properties['styles'] = array(); } public static function getInstance() { if( self::$instance == null ) { self::$instance = new ezcWgApplication(); } return self::$instance; } /** * 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 'mainWidget': case 'pageMainUrl': case 'eventCreator': case 'pageSelector': $this->properties[$name] = $value; break; case 'styles': case 'javaScripts': 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 'mainWidget': case 'pageMainUrl': case 'eventCreator': case 'pageSelector': case 'javaScripts': case 'styles': return isset( $this->properties[$name] ) ? $this->properties[$name] : null; break; default: throw new ezcBasePropertyNotFoundException( $name ); break; } } // TODO // pages displaying the tag should display these files // maybe these methods should be moved to a "framework" class that people must inherit // in order for this to work. However, that requires that we know the layout widget up front... hmm public function addJavaScript( $file ) { if( !in_array( $file, $this->javaScripts ) ) { $this->properties['javaScripts'][] = $file; } } public function addStyle( $file ) { if( !in_array( $file, $this->styles ) ) { $this->properties['styles'][] = $file; } } public function setEventCreator( ezcWgEventCreator $creator ) { $this->eventCreator = $creator; } public function setPageSelector( ezcWgPageSelector $selector ) { $this->pageSelector = $selector; } /** */ public function run() { if( $this->eventCreator === null ) { $this->eventCreator = new ezcWgDefaultEventCreator(); } $e = $this->eventCreator->getEvent(); if( $this->pageSelector !== null ) { $this->mainWidget = $this->pageSelector->selectPage( $e ); // if it is null, fetch the defaultpage if( $this->mainWidget === null ) { $this->mainWidget = $this->pageSelector->defaultPage(); } } // check for main widget if( $this->mainWidget === null ) { throw new Exception( "No mainwidget...." ); } if( $e === null ) { // no event } else if( $this->mainWidget->handleEvent( $e ) == false ) { // event was handled } else { // event was not handled } // render echo $this->mainWidget->render(); } } ?>