00001 <?php
00010 class STransLessonPlanHelper extends STransStdXML3Helper{
00011
00012 protected $parent;
00013 protected $translator;
00014 protected $mapStr;
00015
00024 public function __construct($parent)
00025 {
00026 $this->mapStr['abstract'] = "Lesson Abstract";
00027 $this->mapStr['standards'] = "Standards Addressed";
00028 $this->mapStr['concepts'] = "Concepts";
00029 $this->mapStr['objectives'] = "Objectives";
00030 $this->mapStr['prereq'] = "Prerequisite Knowledge";
00031 $this->mapStr['teacherPrep'] = "Teacher Preparation";
00032 $this->mapStr['required'] = "Materials";
00033 $this->mapStr['materials'] = "Required Materials";
00034 $this->mapStr['media'] = "Media";
00035 $this->mapStr['equipment'] = "Equipment";
00036 $this->mapStr['safety'] = "Safety";
00037 $this->mapStr['outline'] = "Presentation Outline";
00038 $this->mapStr['assessments'] = "Assessments";
00039 $this->mapStr['preassess'] = "Pre-assessment";
00040 $this->mapStr['formative'] = "Formative Assessment";
00041 $this->mapStr['summative'] = "Summative Assessment";
00042 $this->mapStr['bibliography'] = "Bibliography";
00043 $this->mapStr['keyterms'] = "Key Terms";
00044
00045 parent::__construct($parent);
00046 $this->depth = 0;
00047 $this->curNumber = 0;
00048 }
00049
00058 public function setTranslator($t) {
00059 $this->translator = $t;
00060 }
00061
00069 public function getTranslator() {
00070 return $this->translator;
00071 }
00072
00081 protected function processSectionXML( $xml ){
00082 $this->sectionDepth++;
00083 $mapping = $xml->getAttribute('mapping');
00084 $html = '<div class="StdXML3 section">';
00085
00086 if( $mapping == 'moduleInfo'){
00087 $html .= $this->processModuleInfo( $xml );
00088 }
00089 else if( $mapping == 'concepts' ){
00090 $html .= $this->processConcepts( $xml );
00091 }
00092 else if( $mapping == 'required'){
00093 $html .= $this->processRequiredMaterials( $xml );
00094 }
00095 else if( $mapping == 'outline'){
00096 $html .= $this->processOutline( $xml );
00097 }
00098 else if( $mapping == 'assessments' ){
00099 $html .= $this->processAssessments( $xml );
00100 }
00101 else{
00102 $html .= $this->addHeaderTags( $this->mapStr[ $mapping ] ) . $this->processGeneral($xml);
00103 }
00104 $this->sectionDepth--;
00105 $html .= '</div>';
00106
00107 return $html;
00108 }
00109
00110
00111
00120 private function addHeaderTags( $str ){
00121 return '<h' . ($this->sectionDepth +1) . ' class="StdXML3">' . $str . '</h' . ($this->sectionDepth +1) . '>';
00122 }
00131 private function addSectionTags( $str ){
00132 return '<div class="StdXML3 section">' . $str . '</div>';
00133 }
00134
00135
00136
00145 private function processNestedSection( $xml ){
00146 $name = (string)$xml['mapping' ];
00147 return $this->addHeaderTags( $this->mapStr[ $name ] )
00148 . parent::processSectionXML(dom_import_simplexml($xml));
00149 }
00158 private function processGeneral( $xml ){
00159 $elt = simplexml_import_dom($xml);
00160 if (isset($elt->p)) {
00161 return '<p class="StdXML3">' . parent::processSectionXML($xml) . '</p>';
00162 }
00163 else return "";
00164 }
00173 private function processModuleInfo( $xml ){
00174 $elt = simplexml_import_dom($xml);
00175 $title = "";
00176 $grade = "";
00177 $children = $elt->section;
00178 if (isset($children[0]->p))
00179 $title = $this->processTitle( $children[0]->p );
00180 if (isset($children[1]->p))
00181 $grade = $this->processGrade( $children[1]->p );
00182 $this->sectionDepth++;
00183 return $title . $grade;
00184 }
00193 private function processTitle( $elt ){
00194
00195 return '<div class="StdXML3 left">' . $this->addHeaderTags( $elt) . '</div>';
00196 }
00205 private function processGrade( $elt ){
00206
00207 return '<div class="StdXML3 right">' . $this->addHeaderTags( $elt ) . '</div>';
00208
00209 }
00218 private function processConcepts( $xml ){
00219 $elt = simplexml_import_dom($xml);
00220
00221 $html = $this->addHeaderTags( $this->mapStr[ $xml->getAttribute('mapping') ] );
00222 $this->sectionDepth++;
00223 $html .= $this->addSectionTags( $this->processNestedSection( $elt->section[0] ) )
00224 . $this->addSectionTags( $this->processNestedSection( $elt->section[1] ) )
00225 . $this->addSectionTags( $this->processNestedSection( $elt->section[2] ) )
00226 . $this->addSectionTags( $this->processNestedSection( $elt->section[3] ) );
00227 $this->sectionDepth--;
00228
00229 return $html;
00230 }
00239 private function processRequiredMaterials( $xml ){
00240 $elt = simplexml_import_dom($xml);
00241 for($i=0;$i<=2;$i++){
00242 $mapping[$i] = $this->mapStr[(string)$elt->section[$i]['mapping']];
00243 $content[$i] = parent::processSectionXML(dom_import_simplexml($elt->section[$i]));
00244 }
00245 $html = '<div class="StdXML3 section">'
00246 . $this->addHeaderTags( $this->mapStr[$xml->getAttribute('mapping')] )
00247 . '<table class="StdXML3 required"><tr class="StdXML3"><td class="StdXML3">'
00248 . $mapping[0] . '</td><td class="StdXML3">' . $mapping[1] . '</td><td class="StdXML3">'. $mapping[2]
00249 . '</td></tr><tr class="StdXML3"><td class="StdXML3">'
00250 . $content[0] . '</td><td class="StdXML3">' . $content[1] . '</td><td class="StdXML3">'. $content[2]
00251 . '</td></tr></table></div>';
00252
00253 return $html;
00254 }
00263 private function processOutline( $xml ){
00264 $elt = simplexml_import_dom($xml);
00265
00266 $html = '<div class="StdXML3 section">'
00267 . $this->addHeaderTags( $this->mapStr[$xml->getAttribute('mapping')] )
00268 .'<table class="StdXML3">';
00269 $numElems = 0;
00270 foreach( $elt as $event ){
00271 foreach( $event->section as $eventXML ){
00272 $eventType = $eventXML['mapping'];
00273 switch( $eventType ){
00274 case 'eventName':
00275 $dom = dom_import_simplexml( $eventXML );
00276 $name[ $numElems ] = parent::processSectionXML( $dom );
00277 break;
00278 case 'eventTime':
00279 $dom = dom_import_simplexml( $eventXML );
00280 $time[ $numElems ] = parent::processSectionXML( $dom );
00281 break;
00282 case 'eventContent':
00283 $dom = dom_import_simplexml( $eventXML );
00284 $text[ $numElems ] = parent::processSectionXML( $dom );
00285 break;
00286 default:
00287 break;
00288 }
00289
00290 }
00291 $numElems++;
00292 }
00293 $this->sectionDepth++;
00294 for($i=0;$i<$numElems;$i++){
00295 $html .= '<tr class="StdXML3"><td class="StdXML3">' . $this->addHeaderTags($name[$i]) . $time[$i]
00296 . '</td><td class="StdXML3">' . $text[$i] . '</td></tr>';
00297 }
00298 $html .= '</table></div>';
00299 $this->sectionDepth--;
00300 return $html;
00301 }
00310 private function processAssessments( $xml ){
00311 $elt = simplexml_import_dom($xml);
00312 $html = $this->addHeaderTags( $this->mapStr[ (string)$elt['mapping'] ]);
00313 $this->sectionDepth++;
00314 foreach( $elt->children() as $assessment ){
00315 $html .= $this->addSectionTags( $this->addHeaderTags( $this->mapStr[ (string)$assessment['mapping'] ]) . parent::processSectionXML(dom_import_simplexml($assessment)));
00316 }
00317 $this->sectionDepth--;
00318 return $html;
00319 }
00320 }
00321
00322 ?>