/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "mob": //var_dump($a_rec); include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $newObj = new ilObjMediaObject(); $newObj->setType("mob"); $newObj->setTitle($a_rec["Title"]); $newObj->setDescription($a_rec["Description"]); $newObj->create(); $newObj->createDirectory(); ilObjMediaObject::_createThumbnailDirectory($newObj->getId()); $this->current_mob = $newObj; $dir = str_replace("..", "", $a_rec["Dir"]); if ($dir != "" && $this->getImportDirectory() != "") { $source_dir = $this->getImportDirectory() . "/" . $dir; $target_dir = $dir = ilObjMediaObject::_getDirectory($newObj->getId()); ilUtil::rCopy($source_dir, $target_dir); } $a_mapping->addMapping("Services/MediaObjects", "mob", $a_rec["Id"], $newObj->getId()); //echo "<br>++add++"."0:".$a_rec["Id"].":mob+0:".$newObj->getId().":mob"."+"; $a_mapping->addMapping("Services/MetaData", "md", "0:" . $a_rec["Id"] . ":mob", "0:" . $newObj->getId() . ":mob"); break; case "mob_media_item": // determine parent mob include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]); if (is_object($this->current_mob) && $this->current_mob->getId() == $mob_id) { $mob = $this->current_mob; } else { $mob = new ilObjMediaObject($mob_id); } include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; $newObj = new ilMediaItem(); $newObj->setMobId($mob_id); $newObj->setWidth($a_rec["Width"]); $newObj->setHeight($a_rec["Height"]); $newObj->setCaption($a_rec["Caption"]); $newObj->setNr($a_rec["Nr"]); $newObj->setPurpose($a_rec["Purpose"]); $newObj->setLocation($a_rec["Location"]); $newObj->setLocationType($a_rec["LocationType"]); $newObj->setFormat($a_rec["Format"]); $newObj->setTextRepresentation($a_rec["TextRepresentation"]); $newObj->create(); $this->current_media_item = $newObj; $a_mapping->addMapping("Services/MediaObjects", "mob_media_item", $a_rec["Id"], $newObj->getId()); break; case "mob_mi_parameter": // get media item include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]); if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) { $med = $this->current_media_item; } else { $med = new ilMediaItem($med_id); } $med->writeParameter($a_rec["Name"], $a_rec["Value"]); break; case "mob_mi_map_area": // get media item include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]); if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) { $med = $this->current_media_item; } else { $med = new ilMediaItem($med_id); } include_once "./Services/MediaObjects/classes/class.ilMapArea.php"; $map_area = new ilMapArea(); $map_area->setItemId($med_id); $map_area->setNr($a_rec["Nr"]); $map_area->setShape($a_rec["Shape"]); $map_area->setCoords($a_rec["Coords"]); $map_area->setLinkType($a_rec["LinkType"]); $map_area->setTitle($a_rec["Title"]); $map_area->setHref($a_rec["Href"]); $map_area->setTarget($a_rec["Target"]); $map_area->setType($a_rec["Type"]); $map_area->setTargetFrame($a_rec["TargetFrame"]); $map_area->setHighlightMode($a_rec["HighlightMode"]); $map_area->setHighlightClass($a_rec["HighlightClass"]); $map_area->create(); break; } }
/** * Save new or updated map area */ function saveArea() { global $lng, $ilCtrl; switch ($_SESSION["il_map_edit_mode"]) { // save edited link case "edit_link": $st_item = $this->media_object->getMediaItem("Standard"); $max = ilMapArea::_getMaxNr($st_item->getId()); $area = new ilMapArea($st_item->getId(), $_SESSION["il_map_area_nr"]); if ($_POST["area_link_type"] == IL_INT_LINK) { $area->setLinkType(IL_INT_LINK); $area->setType($_SESSION["il_map_il_type"]); $area->setTarget($_SESSION["il_map_il_target"]); $area->setTargetFrame($_SESSION["il_map_il_targetframe"]); } else { $area->setLinkType(IL_EXT_LINK); if ($_POST["area_link_type"] != IL_NO_LINK) { $area->setHref(ilUtil::stripSlashes($_POST["area_link_ext"])); } else { $area->setHref(""); } } $area->update(); break; // save edited shape // save edited shape case "edit_shape": $st_item = $this->media_object->getMediaItem("Standard"); $max = ilMapArea::_getMaxNr($st_item->getId()); $area =& new ilMapArea($st_item->getId(), $_SESSION["il_map_area_nr"]); $area->setShape($_SESSION["il_map_edit_area_type"]); $area->setCoords($_SESSION["il_map_edit_coords"]); $area->update(); break; // save new area // save new area default: $area_type = $_SESSION["il_map_edit_area_type"]; $coords = $_SESSION["il_map_edit_coords"]; $st_item = $this->media_object->getMediaItem("Standard"); $max = ilMapArea::_getMaxNr($st_item->getId()); // make new area object $area = new ilMapArea(); $area->setItemId($st_item->getId()); $area->setShape($area_type); $area->setCoords($coords); $area->setNr($max + 1); $area->setTitle(ilUtil::stripSlashes($_POST["area_name"])); switch ($_POST["area_link_type"]) { case "ext": $area->setLinkType(IL_EXT_LINK); $area->setHref($_POST["area_link_ext"]); break; case "int": $area->setLinkType(IL_INT_LINK); $area->setType($_SESSION["il_map_il_type"]); $area->setTarget($_SESSION["il_map_il_target"]); $area->setTargetFrame($_SESSION["il_map_il_targetframe"]); break; } // put area into item and update media object $st_item->addMapArea($area); $this->media_object->update(); break; } //$this->initMapParameters(); ilUtil::sendSuccess($lng->txt("cont_saved_map_area"), true); $ilCtrl->redirect($this, "editMapAreas"); }