Public Member Functions | |
ilContObjParser (&$a_content_object, $a_xml_file, $a_subdir) | |
Constructor. | |
setHandlers ($a_xml_parser) | |
set event handler should be overwritten by inherited class private | |
startParsing () | |
stores xml data in array | |
storeTree () | |
insert StructureObjects and PageObjects into tree | |
processPagesToParse () | |
parse pages that contain files, mobs and/or internal links | |
copyMobFiles () | |
copy multimedia object files from import zip file to mob directory | |
copyFileItems () | |
copy files of file items | |
setQuestionMapping ($a_map) | |
set question import ident to pool/test question id mapping | |
beginElement ($a_name) | |
endElement ($a_name) | |
getCurrentElement () | |
getOpenCount ($a_name) | |
buildTag ($type, $name, $attr="") | |
generate a tag with given name and attributes | |
handlerBeginTag ($a_xml_parser, $a_name, $a_attribs) | |
handler for begin of element | |
handlerEndTag ($a_xml_parser, $a_name) | |
handler for end of element | |
handlerCharacterData ($a_xml_parser, $a_data) | |
handler for character data | |
Data Fields | |
$lng | |
$tree | |
$cnt | |
$current_element | |
$learning_module | |
$page_object | |
$lm_page_object | |
$structure_objects | |
$media_object | |
$current_object | |
$meta_data | |
$paragraph | |
$table | |
$lm_tree | |
$pg_into_tree | |
$st_into_tree | |
$container | |
$in_page_object | |
$in_meta_data | |
$in_media_object | |
$in_file_item | |
$in_glossary | |
$in_map_area | |
$content_object | |
$glossary_object | |
$file_item | |
$keyword_language | |
$pages_to_parse | |
$mob_mapping | |
$file_item_mapping | |
$subdir | |
$media_item | |
$loc_type | |
$bib_item | |
$map_area | |
$in_bib_item | |
$link_targets | |
$qst_mapping |
Definition at line 50 of file class.ilContObjParser.php.
ilContObjParser::beginElement | ( | $ | a_name | ) |
Definition at line 386 of file class.ilContObjParser.php.
Referenced by handlerBeginTag().
{ if(!isset($this->status["$a_name"])) { $this->cnt[$a_name] == 1; } else { $this->cnt[$a_name]++; } $this->current_element[count($this->current_element)] = $a_name; }
ilContObjParser::buildTag | ( | $ | type, | |
$ | name, | |||
$ | attr = "" | |||
) |
generate a tag with given name and attributes
string | "start" | "end" for starting or ending tag | |
string | element/tag name | |
array | array of attributes |
Definition at line 439 of file class.ilContObjParser.php.
References $type.
Referenced by handlerBeginTag(), and handlerEndTag().
{ $tag = "<"; if ($type == "end") $tag.= "/"; $tag.= $name; if (is_array($attr)) { while (list($k,$v) = each($attr)) $tag.= " ".$k."=\"$v\""; } $tag.= ">"; return $tag; }
ilContObjParser::copyFileItems | ( | ) |
copy files of file items
Definition at line 345 of file class.ilContObjParser.php.
References ilUtil::getDataDir(), ilUtil::makeDir(), and ilUtil::rCopy().
Referenced by startParsing().
{ $imp_dir = $this->content_object->getImportDirectory(); foreach ($this->file_item_mapping as $origin_id => $file_id) { if(empty($origin_id)) { continue; } $obj_dir = $origin_id; $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir; $target_dir = ilUtil::getDataDir()."/files/file_".$file_id; //echo "copy from $source_dir to $target_dir <br>"; if (@is_dir($source_dir)) { // make target directory ilUtil::makeDir($target_dir); //@mkdir($target_dir); //@chmod($target_dir, 0755); if (@is_dir($target_dir)) { ilUtil::rCopy($source_dir, $target_dir); } } } }
ilContObjParser::copyMobFiles | ( | ) |
copy multimedia object files from import zip file to mob directory
Definition at line 301 of file class.ilContObjParser.php.
References ilUtil::getWebspaceDir(), ilUtil::makeDir(), and ilUtil::rCopy().
Referenced by startParsing().
{ $imp_dir = $this->content_object->getImportDirectory(); foreach ($this->mob_mapping as $origin_id => $mob_id) { if(empty($origin_id)) { continue; } /* $origin_arr = explode("_", $origin_id); if ($origin_arr[2] == "el") // imagemap { $obj_dir = "imagemap".$origin_arr[3]; } else // normal media object { $obj_dir = "mm".$origin_arr[3]; }*/ $obj_dir = $origin_id; $source_dir = $imp_dir."/".$this->subdir."/objects/".$obj_dir; $target_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$mob_id; //echo "copy from $source_dir to $target_dir <br>"; if (@is_dir($source_dir)) { // make target directory ilUtil::makeDir($target_dir); //@mkdir($target_dir); //@chmod($target_dir, 0755); if (@is_dir($target_dir)) { ilUtil::rCopy($source_dir, $target_dir); } } } }
ilContObjParser::endElement | ( | $ | a_name | ) |
Definition at line 402 of file class.ilContObjParser.php.
Referenced by handlerEndTag().
{ $this->cnt[$a_name]--; unset ($this->current_element[count($this->current_element) - 1]); }
ilContObjParser::getCurrentElement | ( | ) |
Definition at line 411 of file class.ilContObjParser.php.
Referenced by handlerCharacterData().
{
return ($this->current_element[count($this->current_element) - 1]);
}
ilContObjParser::getOpenCount | ( | $ | a_name | ) |
Definition at line 419 of file class.ilContObjParser.php.
{ if (isset($this->cnt[$a_name])) { return $this->cnt[$a_name]; } else { return 0; } }
ilContObjParser::handlerBeginTag | ( | $ | a_xml_parser, | |
$ | a_name, | |||
$ | a_attribs | |||
) |
handler for begin of element
Meta Data Section ////////////////////////////////////////////////
Definition at line 462 of file class.ilContObjParser.php.
References $_GET, beginElement(), and buildTag().
{ //echo "<b>BEGIN TAG: $a_name <br></b>"; flush(); switch($a_name) { case "ContentObject": $this->current_object =& $this->content_object; //echo "<br>Parser:CObjType:".$a_attribs["Type"]; if ($a_attribs["Type"] == "Glossary") { $this->glossary_object =& $this->content_object; } break; case "StructureObject": //echo "<br><br>StructureOB-SET-".count($this->structure_objects)."<br>"; $this->structure_objects[count($this->structure_objects)] =& new ilStructureObject($this->content_object); $this->current_object =& $this->structure_objects[count($this->structure_objects) - 1]; $this->current_object->setLMId($this->content_object->getId()); break; case "PageObject": $this->in_page_object = true; $this->cur_qid = ""; if (($this->coType != "tst") and ($this->coType != "qpl")) { $this->lm_page_object =& new ilLMPageObject($this->content_object); $this->page_object =& new ilPageObject($this->content_object->getType()); $this->lm_page_object->setLMId($this->content_object->getId()); $this->lm_page_object->assignPageObject($this->page_object); $this->current_object =& $this->lm_page_object; } else { $this->page_object =& new ilPageObject("qpl"); } break; case "PageAlias": if (($this->coType != "tst") and ($this->coType != "qpl")) { $this->lm_page_object->setAlias(true); $this->lm_page_object->setOriginID($a_attribs["OriginId"]); } break; case "MediaObject": $this->in_media_object = true; $this->media_object =& new ilObjMediaObject(); break; case "MediaAlias": //echo "<br>---NEW MEDIAALIAS---<br>"; $this->media_object->setAlias(true); $this->media_object->setOriginID($a_attribs["OriginId"]); if (is_object($this->page_object)) { $this->page_object->needsImportParsing(true); } break; case "MediaItem": case "MediaAliasItem": $this->in_media_item = true; $this->media_item =& new ilMediaItem(); $this->media_item->setPurpose($a_attribs["Purpose"]); break; case "Layout": if (is_object($this->media_object) && $this->in_media_object) { $this->media_item->setWidth($a_attribs["Width"]); $this->media_item->setHeight($a_attribs["Height"]); $this->media_item->setHAlign($a_attribs["HorizontalAlign"]); } break; case "Parameter": if (is_object($this->media_object) && $this->in_media_object) { $this->media_item->setParameter($a_attribs["Name"], $a_attribs["Value"]); } break; case "MapArea": $this->in_map_area = true; $this->map_area =& new ilMapArea(); $this->map_area->setShape($a_attribs["Shape"]); $this->map_area->setCoords($a_attribs["Coords"]); break; case "Glossary": $this->in_glossary = true; if ($this->content_object->getType() != "glo") { $this->glossary_object =& new ilObjGlossary(); $this->glossary_object->setTitle(""); $this->glossary_object->setDescription(""); $this->glossary_object->create(); $this->glossary_object->createReference(); $parent =& $this->tree->getParentNodeData($this->content_object->getRefId()); $this->glossary_object->putInTree($parent["child"]); $this->glossary_object->setPermissions($parent["child"]); $this->glossary_object->notify("new", $_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$this->glossary_object->getRefId()); } $this->current_object =& $this->glossary_object; break; case "GlossaryItem": $this->glossary_term =& new ilGlossaryTerm(); $this->glossary_term->setGlossaryId($this->glossary_object->getId()); $this->glossary_term->setLanguage($a_attribs["Language"]); $this->glossary_term->setImportId($a_attribs["Id"]); $this->link_targets[$a_attribs["Id"]] = $a_attribs["Id"]; break; case "Definition": $this->in_glossary_definition = true; $this->glossary_definition =& new ilGlossaryDefinition(); $this->page_object =& new ilPageObject("gdf"); $this->glossary_definition->setTermId($this->glossary_term->getId()); $this->glossary_definition->assignPageObject($this->page_object); $this->current_object =& $this->glossary_definition; break; case "FileItem": $this->in_file_item = true; $this->file_item =& new ilObjFile(); $this->file_item->setTitle("dummy"); if (is_object($this->page_object)) { $this->page_object->needsImportParsing(true); } break; case "Paragraph": if ($a_attribs["Characteristic"] == "Code") { $this->inside_code = true; } break; case "MetaData": $this->in_meta_data = true; //echo "<br>---NEW METADATA---<br>"; $this->meta_data =& new ilMetaData(); if(!$this->in_media_object) { //echo "<br><b>assign to current object</b>"; if (($this->coType != "tst") and ($this->coType != "qpl")) { $this->current_object->assignMetaData($this->meta_data); if (strtolower(get_class($this->current_object)) == "ilobjlearningmodule") { $this->meta_data->setId($this->content_object->getId()); $this->meta_data->setType("lm"); } } } else { $this->media_object->assignMetaData($this->meta_data); } break; // GENERAL: Identifier case "Identifier": if ($this->in_meta_data) { $this->meta_data->setImportIdentifierEntryID($a_attribs["Entry"]); $this->link_targets[$a_attribs["Entry"]] = $a_attribs["Entry"]; } if ($this->in_file_item) { if ($this->file_item_mapping[$a_attribs["Entry"]] == "") { $this->file_item->create(); $this->file_item->setImportId($a_attribs["Entry"]); $this->file_item_mapping[$a_attribs["Entry"]] = $this->file_item->getId(); } } break; // GENERAL: Keyword case "Keyword": //echo "<b>>>".count($this->meta_data->technicals)."</b><br>"; $this->keyword_language = $a_attribs["Language"]; break; // Internal Link case "IntLink": if (is_object($this->page_object)) { $this->page_object->setContainsIntLink(true); } if ($this->in_map_area) { //echo "intlink:maparea:<br>"; $this->map_area->setLinkType(IL_INT_LINK); $this->map_area->setTarget($a_attribs["Target"]); $this->map_area->setType($a_attribs["Type"]); $this->map_area->setTargetFrame($a_attribs["TargetFrame"]); if (is_object($this->media_object)) { //echo ":setContainsLink:<br>"; $this->media_object->setContainsIntLink(true); } } break; // External Link case "ExtLink": if ($this->in_map_area) { $this->map_area->setLinkType(IL_EXT_LINK); $this->map_area->setHref($a_attribs["Href"]); $this->map_area->setExtTitle($a_attribs["Title"]); } break; // Question case "Question": $this->cur_qid = $a_attribs["QRef"]; break; // TECHNICAL case "Technical": $this->meta_technical =& new ilMetaTechnical($this->meta_data); $this->meta_data->addTechnicalSection($this->meta_technical); //echo "<b>>>".count($this->meta_data->technicals)."</b><br>"; break; // TECHNICAL: Size case "Size": $this->meta_technical->setSize($a_attribs["Size"]); break; case "Location": $this->loc_type = $a_attribs["Type"]; break; // TECHNICAL: Requirement case "Requirement": if (!is_object($this->requirement_set)) { $this->requirement_set =& new ilMetaTechnicalRequirementSet(); } $this->requirement =& new ilMetaTechnicalRequirement(); break; // TECHNICAL: OperatingSystem case "OperatingSystem": $this->requirement->setType("OperatingSystem"); $this->requirement->setName($a_attribs["Name"]); $this->requirement->setMinVersion($a_attribs["MinimumVersion"]); $this->requirement->setMaxVersion($a_attribs["MaximumVersion"]); break; // TECHNICAL: Browser case "Browser": $this->requirement->setType("Browser"); $this->requirement->setName($a_attribs["Name"]); $this->requirement->setMinVersion($a_attribs["MinimumVersion"]); $this->requirement->setMaxVersion($a_attribs["MaximumVersion"]); break; // TECHNICAL: OrComposite case "OrComposite": $this->meta_technical->addRequirementSet($this->requirement_set); unset($this->requirement_set); break; // TECHNICAL: InstallationRemarks case "InstallationRemarks": $this->meta_technical->setInstallationRemarksLanguage($a_attribs["Language"]); break; // TECHNICAL: InstallationRemarks case "OtherPlatformRequirements": $this->meta_technical->setOtherRequirementsLanguage($a_attribs["Language"]); break; case "Bibliography": $this->in_bib_item = true; #echo "<br>---NEW BIBLIOGRAPHY---<br>"; $this->bib_item =& new ilBibItem(); break; } $this->beginElement($a_name); //echo "Begin Tag: $a_name<br>"; // append content to page xml content if(($this->in_page_object || $this->in_glossary_definition) && !$this->in_meta_data && !$this->in_media_object) { if ($a_name == "Definition") { $app_name = "PageObject"; $app_attribs = array(); } else { $app_name = $a_name; $app_attribs = $a_attribs; } // change identifier entry of file items to new local file id if ($this->in_file_item && $app_name == "Identifier") { $app_attribs["Entry"] = "il__file_".$this->file_item_mapping[$a_attribs["Entry"]]; //$app_attribs["Entry"] = "il__file_".$this->file_item->getId(); } $this->page_object->appendXMLContent($this->buildTag("start", $app_name, $app_attribs)); //echo " after append, xml:".$this->page_object->getXMLContent().":<br>"; } // append content to meta data xml content if ($this->in_meta_data ) // && !$this->in_page_object && !$this->in_media_object { $this->meta_data->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs)); } // append content to bibitem xml content if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object { $this->bib_item->appendXMLContent("\n".$this->buildTag("start", $a_name, $a_attribs)); } }
ilContObjParser::handlerCharacterData | ( | $ | a_xml_parser, | |
$ | a_data | |||
) |
handler for character data
Definition at line 1330 of file class.ilContObjParser.php.
References getCurrentElement().
{ // i don't know why this is necessary, but // the parser seems to convert ">" to ">" and "<" to "<" // in character data, but we don't want that, because it's the // way we mask user html in our content, so we convert back... if ($this->in_meta_data) { $a_data = preg_replace("/&(?!amp;)/","&",$a_data); } $a_data = str_replace("<","<",$a_data); $a_data = str_replace(">",">",$a_data); // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA $a_data = preg_replace("/\n/","",$a_data); if (!$this->inside_code) { $a_data = preg_replace("/\t+/","",$a_data); } $this->chr_data .= $a_data; if(!empty($a_data)) { // append all data to page, if we are within PageObject, // but not within MetaData or MediaObject if (($this->in_page_object || $this->in_glossary_definition) && !$this->in_meta_data && !$this->in_media_object) { $this->page_object->appendXMLContent($a_data); } if ($this->in_meta_data ) { $this->meta_data->appendXMLContent($a_data); //echo "<br>".$a_data; } if ($this->in_bib_item ) { $this->bib_item->appendXMLContent($a_data); } switch($this->getCurrentElement()) { case "IntLink": case "ExtLink": if($this->in_map_area) { $this->map_area->appendTitle($a_data); } break; } } }
ilContObjParser::handlerEndTag | ( | $ | a_xml_parser, | |
$ | a_name | |||
) |
handler for end of element
?!
MetaData Section //////////////////////////////////
Definition at line 800 of file class.ilContObjParser.php.
References $cnt, $file, $xml, buildTag(), domxml_open_mem(), and endElement().
{ //echo "<b>END TAG: $a_name <br></b>"; flush(); // append content to page xml content if (($this->in_page_object || $this->in_glossary_definition) && !$this->in_meta_data && !$this->in_media_object) { $app_name = ($a_name == "Definition") ? "PageObject" : $a_name; $this->page_object->appendXMLContent($this->buildTag("end", $app_name)); } if ($this->in_meta_data) // && !$this->in_page_object && !$this->in_media_object // append content to metadataxml content if($a_name == "MetaData") { $this->meta_data->appendXMLContent("\n".$this->buildTag("end", $a_name)); } else { $this->meta_data->appendXMLContent($this->buildTag("end", $a_name)); } // append content to bibitemxml content if ($this->in_bib_item) // && !$this->in_page_object && !$this->in_media_object { if($a_name == "BibItem") { $this->bib_item->appendXMLContent("\n".$this->buildTag("end", $a_name)); } else { $this->bib_item->appendXMLContent($this->buildTag("end", $a_name)); } } switch($a_name) { case "StructureObject": unset($this->meta_data); unset($this->structure_objects[count($this->structure_objects) - 1]); break; case "PageObject": $this->in_page_object = false; if (($this->coType != "tst") and ($this->coType != "qpl")) { if (!$this->lm_page_object->isAlias()) { //$this->page_object->createFromXML(); $this->page_object->updateFromXML(); $this->pg_mapping[$this->lm_page_object->getImportId()] = $this->lm_page_object->getId(); // collect pages with internal links if ($this->page_object->containsIntLink()) { //echo "<br>Page contains Int Link:".$this->page_object->getId(); $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId(); } if ($this->page_object->needsImportParsing()) { //echo "<br>Page needs import parsing:".$this->page_object->getId(); $this->pages_to_parse["lm:".$this->page_object->getId()] = "lm:".$this->page_object->getId(); } } } else { $xml = $this->page_object->getXMLContent(); if ($this->cur_qid != "") { $ids = $this->qst_mapping[$this->cur_qid]; if ($ids["pool"] > 0) { // question pool question $page = new ilPageObject("qpl", $ids["pool"]); $xmlcontent = str_replace($this->cur_qid, "il__qst_".$ids["pool"], $xml); $page->setXMLContent($xmlcontent); $page->saveMobUsage($xmlcontent); $page->updateFromXML(); unset($page); } if ($ids["test"] > 0) { // test question $page = new ilPageObject("qpl", $ids["test"]); $xmlcontent = str_replace($this->cur_qid, "il__qst_".$ids["test"], $xml); $page->setXMLContent($xmlcontent); $page->saveMobUsage($xmlcontent); $page->updateFromXML(); unset($page); } } } // if we are within a structure object: put page in tree $cnt = count($this->structure_objects); if ($cnt > 0) { $parent_id = $this->structure_objects[$cnt - 1]->getId(); if ($this->lm_page_object->isAlias()) { $this->pg_into_tree[$parent_id][] = array("type" => "pg_alias", "id" => $this->lm_page_object->getOriginId()); } else { $this->pg_into_tree[$parent_id][] = array("type" => "pg", "id" => $this->lm_page_object->getId()); } } // if we are within a structure object: put page in tree unset($this->meta_data); unset($this->page_object); unset($this->lm_page_object); unset ($this->container[count($this->container) - 1]); break; case "MediaObject": $this->in_media_object = false; //echo "ENDMediaObject:ImportId:".$this->media_object->getImportId()."<br>"; // create media object on first occurence of an Id if(empty($this->mob_mapping[$this->media_object->getImportId()])) { if ($this->media_object->isAlias()) { // this data will be overwritten by the "real" mob // see else section below $dummy_meta =& new ilMetaData(); $this->media_object->assignMetaData($dummy_meta); $this->media_object->setTitle("dummy"); //echo "<br>mob create (alias):"; } else { //echo "<br>mob create (real):"; $this->media_object->setTitle($this->meta_data->getTitle()); } // create media object //echo "creating media object:title:".$this->media_object->getTitle().":". // $this->meta_data->getTitle().":<br>"; $this->media_object->create(); //echo $this->media_object->getId().":".$this->media_object->getTitle().":". // $this->media_object->meta_data->getTitle().":"; // collect mobs with internal links if ($this->media_object->containsIntLink()) { //echo "got int link :".$this->media_object->getId().":<br>"; $this->mobs_with_int_links[] = $this->media_object->getId(); } $this->mob_mapping[$this->media_object->getImportId()] = $this->media_object->getId(); //echo "create:import_id:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>"; } else { // get the id from mapping $this->media_object->setId($this->mob_mapping[$this->media_object->getImportId()]); // update "real" (no alias) media object // (note: we overwrite any data from the dummy mob // created by an MediaAlias, only the data of the real // object is stored in db separately; data of the // MediaAliases are within the page XML if (!$this->media_object->isAlias()) { //echo "<b>REAL UPDATING STARTS HERE</b><br>"; //echo "<b>>>".count($this->meta_data->technicals)."</b><br>"; //echo "origin:".$this->media_object->getImportId().":ID:".$this->mob_mapping[$this->media_object->getImportId()]."<br>"; // update media object $this->meta_data->setId($this->media_object->getId()); $this->meta_data->setType("mob"); $this->media_object->assignMetaData($this->meta_data); $this->media_object->setTitle($this->meta_data->getTitle()); $this->media_object->setDescription($this->meta_data->getDescription()); $this->media_object->update(); //echo "<br>update media object :".$this->media_object->getId().":". // $this->media_object->getTitle().":". // $this->meta_data->getTitle(); // collect mobs with internal links if ($this->media_object->containsIntLink()) { //echo "got int link :".$this->media_object->getId().":<br>"; $this->mobs_with_int_links[] = $this->media_object->getId(); } } } // append media alias to page, if we are in a page if ($this->in_page_object || $this->in_glossary_definition) { $this->page_object->appendXMLContent($this->media_object->getXML(IL_MODE_ALIAS)); //echo "Appending:".htmlentities($this->media_object->getXML(IL_MODE_ALIAS))."<br>"; } break; case "MediaItem": case "MediaAliasItem": $this->in_media_item = false; $this->media_object->addMediaItem($this->media_item); //echo "adding media item"; break; case "MapArea": $this->in_map_area = false; $this->media_item->addMapArea($this->map_area); break; case "MetaData": $this->in_meta_data = false; if(strtolower(get_class($this->current_object)) == "illmpageobject" && !$this->in_media_object) { // Metadaten eines PageObjects sichern in NestedSet if (is_object($this->lm_page_object)) { $this->lm_page_object->create(true); //$this->page_object->createFromXML(); include_once("./classes/class.ilNestedSetXML.php"); $nested = new ilNestedSetXML(); $xml = $this->meta_data->getXMLContent(); //echo "<br><br>".htmlentities($xml); $nested->dom = domxml_open_mem($xml); $nodes = $nested->getDomContent("//MetaData/General", "Identifier"); if (is_array($nodes)) { $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId(); $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]); } $xml = $nested->dom->dump_mem(0); //$xml = str_replace(""", "\"", $xml); //echo "<br><br>".htmlentities($xml); $nested->import($xml,$this->lm_page_object->getId(),"pg"); } } else if((strtolower(get_class($this->current_object)) == "ilobjquestionpool" || strtolower(get_class($this->current_object)) == "ilobjtest") && !$this->in_media_object && !$this->in_page_object) { // Metadaten eines Questionpool-Objekts sichern in NestedSet include_once("./classes/class.ilNestedSetXML.php"); $nested = new ilNestedSetXML(); $xml = $this->meta_data->getXMLContent(); //echo "<br><br>".htmlentities($xml); $nested->dom = domxml_open_mem($xml); $nodes = $nested->getDomContent("//MetaData/General", "Identifier"); if (is_array($nodes)) { $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId(); $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]); } $xml = $nested->dom->dump_mem(0); //$xml = str_replace(""", "\"", $xml); //echo "<br><br>".htmlentities($xml); $nested->import($xml, $this->current_object->getId(), $this->current_object->getType()); } else if(strtolower(get_class($this->current_object)) == "ilstructureobject") { // save structure object at the end of its meta block // determine parent $cnt = count($this->structure_objects); if ($cnt > 1) { $parent_id = $this->structure_objects[$cnt - 2]->getId(); } else { $parent_id = $this->lm_tree->getRootId(); } // create structure object and put it in tree $this->current_object->create(true); $this->st_into_tree[] = array ("id" => $this->current_object->getId(), "parent" => $parent_id); // Metadaten eines StructureObjects sichern in NestedSet include_once("./classes/class.ilNestedSetXML.php"); $nested = new ilNestedSetXML(); $xml = $this->meta_data->getXMLContent(); $nested->dom = domxml_open_mem($xml); $nodes = $nested->getDomContent("//MetaData/General", "Identifier"); if (is_array($nodes)) { $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId(); $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]); } $xml = $nested->dom->dump_mem(0); $nested->import($xml,$this->current_object->getId(),"st"); } else if(strtolower(get_class($this->current_object)) == "ilobjdlbook" || strtolower(get_class($this->current_object)) == "ilobjlearningmodule" || strtolower(get_class($this->current_object)) == "ilobjcontentobject" || (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->in_glossary)) { // Metadaten eines ContentObjects sichern in NestedSet include_once("./classes/class.ilNestedSetXML.php"); $nested = new ilNestedSetXML(); $xml = $this->meta_data->getXMLContent(); $nested->dom = domxml_open_mem($xml); $nodes = $nested->getDomContent("//MetaData/General", "Identifier"); if (is_array($nodes)) { $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId(); $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]); } $xml = $nested->dom->dump_mem(0); //echo "<br><br>class:".get_class($this->current_object).":".htmlentities($xml).":<br>"; //echo "<br>ID:".$this->current_object->getId().":Type:".$this->current_object->getType(); //echo $this->in_glossary; $nested->import($xml,$this->current_object->getId(),$this->current_object->getType()); } else if(strtolower(get_class($this->current_object)) == "ilglossarydefinition" && !$this->in_media_object) { //echo "<br><br>class:".get_class($this->current_object).":".htmlentities($this->meta_data->getXMLContent()).":<br>"; $this->glossary_definition->create(); //echo "<br>ID:".$this->current_object->getId().":Type:".$this->current_object->getType(); $this->page_object->setId($this->glossary_definition->getId()); $this->page_object->updateFromXML(); //echo "saving page_object, xml:".$this->page_object->getXMLContent().":<br>"; // save glossary term definition to nested set include_once("./classes/class.ilNestedSetXML.php"); $nested = new ilNestedSetXML(); $xml = $this->meta_data->getXMLContent(); $nested->dom = domxml_open_mem($xml); $nodes = $nested->getDomContent("//MetaData/General", "Identifier"); if (is_array($nodes)) { $nodes[0]["Entry"] = "il__" . $this->current_object->getType() . "_" . $this->current_object->getId(); $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]); } $xml = $nested->dom->dump_mem(0); //echo "<br><br>class:".get_class($this->current_object).":".htmlentities($xml).":<br>"; //echo "<br>ID:".$this->glossary_definition->getId().":Type:gdf"; $nested->import($xml,$this->glossary_definition->getId(),"gdf"); } if(strtolower(get_class($this->current_object)) == "ilobjlearningmodule" || strtolower(get_class($this->current_object)) == "ilobjdlbook" || strtolower(get_class($this->current_object)) == "ilobjglossary") { if (strtolower(get_class($this->current_object)) == "ilobjglossary" && $this->content_object->getType() != "glo") { //echo "<br><b>getting2: ".$this->content_object->getTitle()."</b>"; $this->current_object->setTitle($this->content_object->getTitle()." - ". $this->lng->txt("glossary")); } $this->current_object->update(); } # echo "Type: " . $this->current_object->getType() . "<br>\n"; # echo "Obj.-ID: " . $this->current_object->getId() . "<br>\n"; break; case "FileItem": $this->in_file_item = false; // only update new file items if ($this->file_item->getImportId($a_attribs["Entry"] != "")) { $this->file_item->update(); } break; case "Bibliography": $this->in_bib_item = false; $nested = new ilNestedSetXML(); $nested->import($this->bib_item->getXMLContent(),$this->content_object->getId(),"bib"); break; case "Table": unset ($this->container[count($this->container) - 1]); break; case "Glossary": $this->in_glossary = false; break; case "GlossaryTerm": $this->glossary_term->setTerm(trim($this->chr_data)); $this->glossary_term->create(); break; case "Paragraph": $this->inside_code = false; break; case "Definition": $this->in_glossary_definition = false; $this->page_object->updateFromXML(); $this->page_object->buildDom(); $this->glossary_definition->setShortText($this->page_object->getFirstParagraphText()); $this->glossary_definition->update(); //$this->pg_mapping[$this->lm_page_object->getImportId()] // = $this->lm_page_object->getId(); if ($this->page_object->containsIntLink()) { //echo "<br>Definition contains Int Link:".$this->page_object->getId(); $this->pages_to_parse["gdf:".$this->page_object->getId()] = "gdf:".$this->page_object->getId(); } break; case "Format": if ($this->in_media_item) { $this->media_item->setFormat(trim($this->chr_data)); } if ($this->in_meta_data) { $this->meta_technical->addFormat($this->chr_data); } if ($this->in_file_item) { $this->file_item->setFileType(trim($this->chr_data)); } break; case "Title": if (!$this->in_media_object) { $this->current_object->setTitle(trim($this->chr_data)); $this->meta_data->setTitle(trim($this->chr_data)); } else { $this->media_object->setTitle(trim($this->chr_data)); $this->meta_data->setTitle(trim($this->chr_data)); } break; case "Language": if (is_object($this->meta_data)) { $this->meta_data->setLanguage(trim($this->chr_data)); } else if (is_object($this->bib_item)) { $this->bib_item->setLanguage(trim($this->chr_data)); } break; case "Description": $this->meta_data->setDescription(trim($this->chr_data)); break; case "Caption": if ($this->in_media_object) { $this->media_item->setCaption(trim($this->chr_data)); } break; // Location case "Location": // TODO: adapt for files in "real" subdirectories if ($this->in_media_item) { $this->media_item->setLocationType($this->loc_type); $this->media_item->setLocation(trim($this->chr_data)); } if ($this->in_meta_data) { //$this->meta_technical->addLocation($this->loc_type, $a_data); } if ($this->in_file_item) { // set file name from xml file $this->file_item->setFileName(trim($this->chr_data)); // special handling for file names with special characters // (e.g. ">") if ($this->file_item->getType() == "file" && is_int(strpos($this->chr_data, "&")) && is_int(strpos($this->chr_data, ";"))) { $imp_dir = $this->content_object->getImportDirectory(); $source_dir = $imp_dir."/".$this->subdir."/objects/". $this->file_item->getImportId(); // read "physical" file name from directory if ($dir = opendir($source_dir)) { while (false !== ($file = readdir($dir))) { if ($file != "." && $file != "..") { $this->file_item->setFileName($file); } } closedir($dir); } } // set file item title $this->file_item->setTitle(trim($this->chr_data)); } break; // TECHNICAL: Requirement /* case "Requirement": $this->requirement_set->addRequirement($this->requirement); break;*/ } $this->endElement($a_name); $this->chr_data = ""; }
ilContObjParser::ilContObjParser | ( | &$ | a_content_object, | |
$ | a_xml_file, | |||
$ | a_subdir | |||
) |
Constructor.
object | $a_content_object must be of type ilObjContentObject | |
string | $a_xml_file xml file | |
string | $a_subdir subdirectory in import directory public |
Definition at line 99 of file class.ilContObjParser.php.
References $lng, $tree, and ilSaxParser::ilSaxParser().
{ global $lng, $tree; parent::ilSaxParser($a_xml_file); $this->cnt = array(); $this->current_element = array(); $this->structure_objects = array(); $this->content_object =& $a_content_object; //$this->lm_id = $a_lm_id; $this->st_into_tree = array(); $this->pg_into_tree = array(); $this->pages_to_parse = array(); $this->mobs_with_int_links = array(); $this->mob_mapping = array(); $this->file_item_mapping = array(); $this->pg_mapping = array(); $this->link_targets = array(); $this->subdir = $a_subdir; $this->lng =& $lng; $this->tree =& $tree; $this->inside_code = false; $this->qst_mapping = array(); $this->coType = $this->content_object->getType(); if (($this->coType != "tst") and ($this->coType != "qpl")) { $this->lm_tree = new ilTree($this->content_object->getId()); $this->lm_tree->setTreeTablePK("lm_id"); $this->lm_tree->setTableNames('lm_tree','lm_data'); } //$this->lm_tree->addTree($a_lm_id, 1); happens in ilObjLearningModuleGUI }
ilContObjParser::processPagesToParse | ( | ) |
parse pages that contain files, mobs and/or internal links
Definition at line 207 of file class.ilContObjParser.php.
References $page_object, $target_id, $target_type, ilInternalLink::_getSourcesOfTarget(), ASS_Question::_resolveIntLinks(), and ilMediaItem::_resolveMapAreaLinks().
Referenced by startParsing().
{ /* $pg_mapping = array(); foreach($this->pg_mapping as $key => $value) { $pg_mapping[$key] = "il__pg_".$value; }*/ //echo "<br><b>processIntLinks</b>"; flush(); // outgoin internal links foreach($this->pages_to_parse as $page_id) { $page_arr = explode(":", $page_id); //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush(); switch($page_arr[0]) { case "lm": $page_obj =& new ilPageObject($this->content_object->getType(), $page_arr[1]); break; case "gdf": $page_obj =& new ilPageObject("gdf", $page_arr[1]); break; } $page_obj->buildDom(); $page_obj->resolveIntLinks(); $page_obj->update(false); if ($page_arr[0] == "gdf") { $def =& new ilGlossaryDefinition($page_arr[1]); $def->updateShortText(); } unset($page_obj); } //echo "<br><b>map area internal links</b>"; flush(); // outgoins map area (mob) internal links foreach($this->mobs_with_int_links as $mob_id) { ilMediaItem::_resolveMapAreaLinks($mob_id); } //echo "<br><b>incoming interna links</b>"; flush(); // incoming internal links $done = array(); foreach ($this->link_targets as $link_target) { //echo "doin link target:".$link_target.":<br>"; $link_arr = explode("_", $link_target); $target_inst = $link_arr[1]; $target_type = $link_arr[2]; $target_id = $link_arr[3]; $sources = ilInternalLink::_getSourcesOfTarget($target_type, $target_id, $target_inst); foreach($sources as $key => $source) { //echo "got source:".$key.":<br>"; if(in_array($key, $done)) { continue; } $type_arr = explode(":", $source["type"]); // content object pages if ($type_arr[1] == "pg") { $page_object = new ilPageObject($type_arr[0], $source["id"]); $page_object->buildDom(); $page_object->resolveIntLinks(); $page_object->update(); unset($page_object); } // eventually correct links in questions to learning modules if ($type_arr[0] == "qst") { require_once "./assessment/classes/class.assQuestion.php"; ASS_Question::_resolveIntLinks($source["id"]); } // eventually correct links in survey questions to learning modules if ($type_arr[0] == "sqst") { require_once "./survey/classes/class.SurveyQuestion.php"; ASS_Question::_resolveIntLinks($source["id"]); } $done[$key] = $key; } } }
ilContObjParser::setHandlers | ( | $ | a_xml_parser | ) |
set event handler should be overwritten by inherited class private
Reimplemented from ilSaxParser.
Definition at line 139 of file class.ilContObjParser.php.
{ xml_set_object($a_xml_parser,$this); xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag'); xml_set_character_data_handler($a_xml_parser,'handlerCharacterData'); }
ilContObjParser::setQuestionMapping | ( | $ | a_map | ) |
set question import ident to pool/test question id mapping
Definition at line 377 of file class.ilContObjParser.php.
{ $this->qst_mapping = $a_map; }
ilContObjParser::startParsing | ( | ) |
stores xml data in array
private
Reimplemented from ilSaxParser.
Definition at line 146 of file class.ilContObjParser.php.
References copyFileItems(), copyMobFiles(), processPagesToParse(), and storeTree().
{ //echo "<b>start parsing</b><br>"; parent::startParsing(); //echo "<b>storeTree</b><br>"; $this->storeTree(); //echo "<b>processIntLinks</b><br>"; $this->processPagesToParse(); //echo "<b>copyMobFiles</b><br>"; $this->copyMobFiles(); //echo "<b>copyFileItems</b><br>"; $this->copyFileItems(); }
ilContObjParser::storeTree | ( | ) |
insert StructureObjects and PageObjects into tree
Definition at line 163 of file class.ilContObjParser.php.
References $ilLog.
Referenced by startParsing().
{ global $ilLog; //echo "<b>Storing the tree</b><br>"; foreach($this->st_into_tree as $st) { //echo "insert st id: ".$st["id"].", parent:".$st["parent"]."<br>"; $this->lm_tree->insertNode($st["id"], $st["parent"]); //echo "done<br>"; if (is_array($this->pg_into_tree[$st["id"]])) { foreach($this->pg_into_tree[$st["id"]] as $pg) { switch ($pg["type"]) { case "pg_alias": if ($this->pg_mapping[$pg["id"]] == "") { $ilLog->write("LM Import: No PageObject for PageAlias ".$pg["id"]." found! (Please update export installation to ILIAS 3.3.0)"); continue; } $pg_id = $this->pg_mapping[$pg["id"]]; break; case "pg": $pg_id = $pg["id"]; break; } if (!$this->lm_tree->isInTree($pg_id)) { $this->lm_tree->insertNode($pg_id, $st["id"]); } } } } //echo "6"; //echo "<b>END: storing the tree</b>"; }
ilContObjParser::$bib_item |
Definition at line 85 of file class.ilContObjParser.php.
ilContObjParser::$cnt |
Definition at line 54 of file class.ilContObjParser.php.
Referenced by handlerEndTag().
ilContObjParser::$container |
Definition at line 68 of file class.ilContObjParser.php.
ilContObjParser::$content_object |
Definition at line 75 of file class.ilContObjParser.php.
ilContObjParser::$current_element |
Definition at line 55 of file class.ilContObjParser.php.
ilContObjParser::$current_object |
Definition at line 61 of file class.ilContObjParser.php.
ilContObjParser::$file_item |
Definition at line 77 of file class.ilContObjParser.php.
ilContObjParser::$file_item_mapping |
Definition at line 81 of file class.ilContObjParser.php.
ilContObjParser::$glossary_object |
Definition at line 76 of file class.ilContObjParser.php.
ilContObjParser::$in_bib_item |
Definition at line 87 of file class.ilContObjParser.php.
ilContObjParser::$in_file_item |
Definition at line 72 of file class.ilContObjParser.php.
ilContObjParser::$in_glossary |
Definition at line 73 of file class.ilContObjParser.php.
ilContObjParser::$in_map_area |
Definition at line 74 of file class.ilContObjParser.php.
ilContObjParser::$in_media_object |
Definition at line 71 of file class.ilContObjParser.php.
ilContObjParser::$in_meta_data |
Definition at line 70 of file class.ilContObjParser.php.
ilContObjParser::$in_page_object |
Definition at line 69 of file class.ilContObjParser.php.
ilContObjParser::$keyword_language |
Definition at line 78 of file class.ilContObjParser.php.
ilContObjParser::$learning_module |
Definition at line 56 of file class.ilContObjParser.php.
ilContObjParser::$link_targets |
Definition at line 88 of file class.ilContObjParser.php.
ilContObjParser::$lm_page_object |
Definition at line 58 of file class.ilContObjParser.php.
ilContObjParser::$lm_tree |
Definition at line 65 of file class.ilContObjParser.php.
ilContObjParser::$lng |
Reimplemented from ilSaxParser.
Definition at line 52 of file class.ilContObjParser.php.
Referenced by ilContObjParser().
ilContObjParser::$loc_type |
Definition at line 84 of file class.ilContObjParser.php.
ilContObjParser::$map_area |
Definition at line 86 of file class.ilContObjParser.php.
ilContObjParser::$media_item |
Definition at line 83 of file class.ilContObjParser.php.
ilContObjParser::$media_object |
Definition at line 60 of file class.ilContObjParser.php.
ilContObjParser::$meta_data |
Definition at line 62 of file class.ilContObjParser.php.
ilContObjParser::$mob_mapping |
Definition at line 80 of file class.ilContObjParser.php.
ilContObjParser::$page_object |
Definition at line 57 of file class.ilContObjParser.php.
Referenced by processPagesToParse().
ilContObjParser::$pages_to_parse |
Definition at line 79 of file class.ilContObjParser.php.
ilContObjParser::$paragraph |
Definition at line 63 of file class.ilContObjParser.php.
ilContObjParser::$pg_into_tree |
Definition at line 66 of file class.ilContObjParser.php.
ilContObjParser::$qst_mapping |
Definition at line 89 of file class.ilContObjParser.php.
ilContObjParser::$st_into_tree |
Definition at line 67 of file class.ilContObjParser.php.
ilContObjParser::$structure_objects |
Definition at line 59 of file class.ilContObjParser.php.
ilContObjParser::$subdir |
Definition at line 82 of file class.ilContObjParser.php.
ilContObjParser::$table |
Definition at line 64 of file class.ilContObjParser.php.
ilContObjParser::$tree |
Definition at line 53 of file class.ilContObjParser.php.
Referenced by ilContObjParser().