Exemplo n.º 1
0
 public function fromXML($xmlfile)
 {
     $xml = simplexml_load_file($xmlfile);
     $contentTree = new EfrontContentTree($this->lesson['id']);
     $contentTree->fromXMLNode($xml->lessonId[0]);
     $fields = array();
     $fields['name'] = (string) $xml->lesson->name;
     $fields['info'] = (string) $xml->lesson->info;
     $fields['options'] = (string) $xml->lesson->options;
     $fields['course_only'] = (string) $xml->lesson->course_only;
     //$fields['auto_certificate'] = (string)$xml->lesson->auto_certificate;
     //$fields['auto_complete'] = (string)$xml->lesson->auto_complete;
     //$fields['publish'] = (string)$xml->lesson->publish;
     $lid = ef_inserTableData("lessons", $fields);
     for ($i = 0; $i < sizeof($xml->lesson->conditions->condition); $i++) {
         $condition = array();
         $condition['type'] = $xml->lessonId->conditions->condition[$i]->type;
         $condition['options'] = $xml->lessonId->conditions->condition[$i]->options;
         $condition['relation'] = $xml->lessonId->conditions->condition[$i]->relation;
         $cid = ef_insertTableData("lesson_conditions", $condition);
     }
     for ($i = 0; $i < sizeof($xml->lesson->rules->rule); $i++) {
         $rule = array();
         $rule['content_id'] = $xml->lessonId->rules->rule[$i]->content_id;
         $rule['rule_content_id'] = $xml->lessonId->rules->rule[$i]->rule_content_id;
         $rule['rule_type'] = $xml->lessonId->rules->rule[$i]->rule_type;
         $rule['rule_option'] = $xml->lessonId->rules->rule[$i]->rule_option;
         $rid = ef_insertTableData("rules", $rule);
     }
 }