setColumns($columnWidths); } //// // Sets the column widths for all columns. Does error-checking on passed parameters. // Overwrites any previous values. //// public function setColumns($columnWidths=array(100)){ while(count($columnWidths) < 4){ $columnWidths[] = 0; } $lastColumnFound = false; for( $i = 0; $i < 4; ++$i ){ if( $columnWidths[ $i ] > 0 && !$lastColumnFound ){ $this->columns[ $i ] = new Column( $columnWidths[ $i ], "_wrappermod".nextNum() ); }else if( $columnWidths[ $i ] > 0 && $lastColumnFound ){ throw new Exception( "Columns cannot be specifed after a column with 0 width." ); }else{ $lastColumnFound = true; } } if( count( $this->columns ) == 0 ){ throw new Exception( "No columns specified for this page." ); }else if( count( $this->columns ) == 1 ){ $this->columns[0]->setClass( "highlander" ); }else{ for( $i = 0; $i < count( $this->columns ); ++$i ){ if( $i == 0 ){ $this->columns[ $i ]->setClass( "left" ); }else if( $i == count( $this->columns ) - 1 ){ $this->columns[ $i ]->setClass( "right" ); }else{ $this->columns[ $i ]->setClass( "center" ); } } } } public function getStylesheet(){ return $this->styles; } private function addStyle( $style ){ $this->styles[ $style ] = $style; } public function addModule( $module, $position = 0 ){ if( $this->columns[ $position ] ){ $this->columns[ $position ]->addModule( $module ); $this->addStyle( $module->getStylesheet() ); }else{ throw new Exception( "Adding module to column index ".$position." which does not exist." ); } } protected function clearModules(){ foreach( $this->columns as $column ){ $column->clear(); } } protected function getTop(){ return "
\n"; } public function getContent(){ $retVal = ''; foreach( $this->columns as $column ){ $retVal .= $column->getHTML(); } return $retVal; } protected function getBottom(){ return "
\n"; } } // end class Page ?>