Paste VIEW-luokka, #awo -- näytä pelkkänä tekstinä -- uusi tämän pohjalta
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <?php class VIEW{ private $pohja; private $elements; public function __consruct($title,$floor){ $this->pohja = new Domdocument( "1.0", "UTF-8" ); $this->pohja -> formatOutput = true; //rakennetaan pohja: $this->insertElement(Array("","html","html","html","","")); $this -> insertElement(Array("html","head","head","","")); $this -> insertElement(Array("html","body","body","","")); $this->insertElement(Array("head","title","title","",$title)); foreach( $floor as $arr){ $this-> insertElement($arr); } } //mihin,nimi,tyyppi,atribuutit,sisältö public function insertElement($element){ if($element[4]==""){ $this->elements[$element[1]] = $this->pohja-> createElement($element[2]); } else{ $this->elements[$element[1]] = $this->pohja-> createElement($element[2],$element[4]); } if($element[3] !=""){ foreach($element[3] as $key => $value){ $this->elements[1]->setAttribute($key,$value); } } if($element[0]==""){ $this->pohja->appendChild($elements[$element[1]]); } $this->elements[$element[0]]->appendChild($elements[$element[1]]); } public function naytasivu(){ echo $this->pohja->saveXML(); } } ?> |