/**
  * Get items of current folder
  */
 function getItems()
 {
     $st_item =& $this->media_object->getMediaItem("Standard");
     $max = ilMapArea::_getMaxNr($st_item->getId());
     $areas = array();
     include_once "./Services/MediaObjects/classes/class.ilMapArea.php";
     for ($i = 1; $i <= $max; $i++) {
         $area = new ilMapArea($st_item->getId(), $i);
         $areas[] = array("nr" => $i, "area" => $area, "title" => $area->getTitle());
     }
     $this->setData($areas);
 }
示例#2
0
 /**
  * Update internal links, after multiple pages have been copied
  */
 static function updateInternalLinks($a_copied_nodes, $a_parent_type = "lm")
 {
     $all_fixes = array();
     foreach ($a_copied_nodes as $original_id => $copied_id) {
         $copied_type = ilLMObject::_lookupType($copied_id);
         $copy_lm = ilLMObject::_lookupContObjID($copied_id);
         if ($copied_type == "pg") {
             //
             // 1. Outgoing links from the copied page.
             //
             //$targets = ilInternalLink::_getTargetsOfSource($a_parent_type.":pg", $copied_id);
             include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
             $tpg = new ilLMPage($copied_id);
             $tpg->buildDom();
             $il = $tpg->getInternalLinks();
             $targets = array();
             foreach ($il as $l) {
                 $targets[] = array("type" => ilInternalLink::_extractTypeOfTarget($l["Target"]), "id" => (int) ilInternalLink::_extractObjIdOfTarget($l["Target"]), "inst" => (int) ilInternalLink::_extractInstOfTarget($l["Target"]));
             }
             $fix = array();
             foreach ($targets as $target) {
                 if (($target["inst"] == 0 || ($target["inst"] = IL_INST_ID)) && ($target["type"] == "pg" || $target["type"] == "st")) {
                     // first check, whether target is also within the copied set
                     if ($a_copied_nodes[$target["id"]] > 0) {
                         $fix[$target["id"]] = $a_copied_nodes[$target["id"]];
                     } else {
                         // now check, if a copy if the target is already in the same lm
                         // only if target is not already in the same lm!
                         $trg_lm = ilLMObject::_lookupContObjID($target["id"]);
                         if ($trg_lm != $copy_lm) {
                             $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $target["type"] . "_" . $target["id"]);
                             $found = false;
                             foreach ($lm_data as $item) {
                                 if (!$found && $item["lm_id"] == $copy_lm) {
                                     $fix[$target["id"]] = $item["obj_id"];
                                     $found = true;
                                 }
                             }
                         }
                     }
                 }
             }
             // outgoing links to be fixed
             if (count($fix) > 0) {
                 //echo "<br>--".$copied_id;
                 //var_dump($fix);
                 $t = ilObject::_lookupType($copy_lm);
                 if (is_array($all_fixes[$t . ":" . $copied_id])) {
                     $all_fixes[$t . ":" . $copied_id] += $fix;
                 } else {
                     $all_fixes[$t . ":" . $copied_id] = $fix;
                 }
             }
         }
         if ($copied_type == "pg" || $copied_type == "st") {
             //
             // 2. Incoming links to the original pages
             //
             // A->B			A2			(A+B currently copied)
             // A->C			B2
             // B->A
             // C->A			C2->A		(C already copied)
             $original_lm = ilLMObject::_lookupContObjID($original_id);
             $original_type = ilObject::_lookupType($original_lm);
             if ($original_lm != $copy_lm) {
                 // This gets sources that link to A+B (so we have C here)
                 // (this also does already the trick when instance map areas are given in C)
                 // int_link, where target_type, target_id, target_inst -> ok
                 $sources = ilInternalLink::_getSourcesOfTarget($copied_type, $original_id, 0);
                 // mobs linking to $original_id
                 // map_area, where link_type, target -> ok
                 $mobs = ilMapArea::_getMobsForTarget("int", "il__" . $copied_type . "_" . $original_id);
                 // pages using these mobs
                 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                 foreach ($mobs as $mob) {
                     // mob_usage, where id -> ok
                     // mep_item, where foreign_id, type -> ok
                     // mep_tree, where child -> already existed
                     // il_news_item, where mob_id -> ok
                     // map_area, where link_type, target -> aready existed
                     // media_item, where id -> already existed
                     // personal_clipboard, where item_id, type -> ok
                     $usages = ilObjMediaObject::lookupUsages($mob);
                     foreach ($usages as $usage) {
                         if ($usage["type"] == "lm:pg" | $usage["type"] == "lm:st") {
                             $sources[] = $usage;
                         }
                     }
                 }
                 $fix = array();
                 foreach ($sources as $source) {
                     $stype = explode(":", $source["type"]);
                     $source_type = $stype[1];
                     if ($source_type == "pg" || $source_type == "st") {
                         // first of all: source must be in original lm
                         $src_lm = ilLMObject::_lookupContObjID($source["id"]);
                         if ($src_lm == $original_lm) {
                             // check, if a copy if the source is already in the same lm
                             // now we look for the latest copy of C in LM2
                             $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $source_type . "_" . $source["id"], $copy_lm);
                             $found = false;
                             foreach ($lm_data as $item) {
                                 if (!$found) {
                                     $fix[$item["obj_id"]][$original_id] = $copied_id;
                                     $found = true;
                                 }
                             }
                         }
                     }
                 }
                 // outgoing links to be fixed
                 if (count($fix) > 0) {
                     foreach ($fix as $page_id => $fix_array) {
                         $t = ilObject::_lookupType($copy_lm);
                         if (is_array($all_fixes[$t . ":" . $page_id])) {
                             $all_fixes[$t . ":" . $page_id] += $fix_array;
                         } else {
                             $all_fixes[$t . ":" . $page_id] = $fix_array;
                         }
                     }
                 }
             }
         }
     }
     foreach ($all_fixes as $pg => $fixes) {
         $pg = explode(":", $pg);
         include_once "./Services/COPage/classes/class.ilPageObjectFactory.php";
         $page = ilPageObjectFactory::getInstance($pg[0], $pg[1]);
         if ($page->moveIntLinks($fixes)) {
             $page->update(true, true);
         }
     }
 }
 /**
  * Get all media objects linked in map areas of this media object
  */
 function getLinkedMediaObjects($a_ignore = "")
 {
     $linked = array();
     if (!is_array($a_ignore)) {
         $a_ignore = array();
     }
     // get linked media objects (map areas)
     $med_items = $this->getMediaItems();
     foreach ($med_items as $med_item) {
         $int_links = ilMapArea::_getIntLinks($med_item->getId());
         foreach ($int_links as $k => $int_link) {
             if ($int_link["Type"] == "MediaObject") {
                 include_once "./Services/COPage/classes/class.ilInternalLink.php";
                 $l_id = ilInternalLink::_extractObjIdOfTarget($int_link["Target"]);
                 if (ilObject::_exists($l_id)) {
                     if (!in_array($l_id, $linked) && !in_array($l_id, $a_ignore)) {
                         $linked[] = $l_id;
                     }
                 }
             }
         }
     }
     //var_dump($linked);
     return $linked;
 }
 /**
  * make map work copy of image
  *
  * @param	int			$a_area_nr		draw area $a_area_nr only
  * @param	boolean		$a_exclude		true: draw all areas but area $a_area_nr
  */
 function makeMapWorkCopy($a_st_item, $a_area_nr = 0, $a_exclude = false, $a_output_new_area, $a_area_type, $a_coords)
 {
     global $lng;
     if (!$a_st_item->copyOriginal()) {
         return false;
     }
     $a_st_item->buildMapWorkImage();
     // determine ratios (first see whether the instance has w/h defined)
     $width = $this->getWidth();
     $height = $this->getHeight();
     // if instance has no size, use object w/h
     if ($width == 0 && $height == 0) {
         $width = $a_st_item->getWidth();
         $height = $a_st_item->getHeight();
     }
     $size = @getimagesize($a_st_item->getMapWorkCopyName());
     $x_ratio = 1;
     if ($size[0] > 0 && $width > 0) {
         $x_ratio = $width / $size[0];
     }
     $y_ratio = 1;
     if ($size[1] > 0 && $height > 0) {
         $y_ratio = $height / $size[1];
     }
     // draw map areas
     $areas = $this->getMapAreas();
     for ($i = 0; $i < count($areas); $i++) {
         if ($i + 1 == $a_area_nr && !$a_exclude || $i + 1 != $a_area_nr && $a_exclude || $a_area_nr == 0) {
             $area = new ilMapArea();
             $area->setShape($areas[$i]["Shape"]);
             $area->setCoords($areas[$i]["Coords"]);
             $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2, true, $x_ratio, $y_ratio);
         }
     }
     if ($a_output_new_area) {
         $area = new ilMapArea();
         $area->setShape($a_area_type);
         $area->setCoords($a_coords);
         $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2, false, $x_ratio, $y_ratio);
     }
     $a_st_item->saveMapWorkImage();
     return true;
 }
示例#5
0
 /**
  * get all internal links of map areas of a mob
  *
  * @param	int		$a_mob_id		media object id
  */
 function _getMapAreasIntLinks($a_mob_id)
 {
     global $ilDB;
     // read media_items records
     $query = "SELECT * FROM media_item WHERE mob_id = " . $ilDB->quote($a_mob_id, "integer") . " ORDER BY nr";
     $item_set = $ilDB->query($query);
     $links = array();
     while ($item_rec = $ilDB->fetchAssoc($item_set)) {
         $map_links = ilMapArea::_getIntLinks($item_rec["id"]);
         foreach ($map_links as $key => $map_link) {
             $links[$key] = $map_link;
         }
     }
     return $links;
 }
 public function dbImportSco($slm, $sco, $asset = false)
 {
     $qtis = array();
     $d = ilUtil::getDir($this->packageFolder);
     foreach ($d as $f) {
         //continue;
         if ($f[type] == 'file' && substr($f[entry], 0, 4) == 'qti_') {
             include_once "./Services/QTI/classes/class.ilQTIParser.php";
             include_once "./Modules/Test/classes/class.ilObjTest.php";
             $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_VERIFY_QTI, 0, "");
             $result = $qtiParser->startParsing();
             $founditems =& $qtiParser->getFoundItems();
             //					die(print_r($founditems));
             foreach ($founditems as $qp) {
                 $newObj = new ilObjTest(0, true);
                 // This creates a lot of invalid repository objects for each question
                 // question are not repository objects (see e.g. table object_data), alex 29 Sep 2009
                 //					$newObj->setType ( $qp ['type'] );
                 //					$newObj->setTitle ( $qp ['title'] );
                 //					$newObj->create ( true );
                 //					$newObj->createReference ();
                 //					$newObj->putInTree ($_GET ["ref_id"]);
                 //					$newObj->setPermissions ( $sco->getId ());
                 //					$newObj->notify ("new", $_GET["ref_id"], $sco->getId (), $_GET["ref_id"], $newObj->getRefId () );
                 //					$newObj->mark_schema->flush ();
                 $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_PARSE_QTI, 0, "");
                 $qtiParser->setTestObject($newObj);
                 $result = $qtiParser->startParsing();
                 //					$newObj->saveToDb ();
                 $qtis = array_merge($qtis, $qtiParser->getImportMapping());
             }
         }
     }
     //exit;
     include_once 'Modules/Scorm2004/classes/class.ilSCORM2004Page.php';
     $doc = new SimpleXMLElement($this->imsmanifest->saveXml());
     $l = $doc->xpath("/ContentObject/MetaData");
     if ($l[0]) {
         include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
         $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $slm->getId(), $sco->getId(), $sco->getType());
         $mdxml->startParsing();
         $mdxml->getMDObject()->update();
     }
     $l = $doc->xpath("/ContentObject/PageObject");
     foreach ($l as $page_xml) {
         $tnode = $page_xml->xpath('MetaData/General/Title');
         $page = new ilSCORM2004PageNode($slm);
         $page->setTitle($tnode[0]);
         $page->setSLMId($slm->getId());
         $page->create(true);
         ilSCORM2004Node::putInTree($page, $sco->getId(), $target);
         $pmd = $page_xml->xpath("MetaData");
         if ($pmd[0]) {
             include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
             $mdxml =& new ilMDXMLCopier($pmd[0]->asXML(), $slm->getId(), $page->getId(), $page->getType());
             $mdxml->startParsing();
             $mdxml->getMDObject()->update();
         }
         $tnode = $page_xml->xpath("//MediaObject/MediaAlias | //InteractiveImage/MediaAlias");
         foreach ($tnode as $ttnode) {
             include_once './Services/MediaObjects/classes/class.ilObjMediaObject.php';
             $OriginId = $ttnode[OriginId];
             $medianodes = $doc->xpath("//MediaObject[MetaData/General/Identifier/@Entry='" . $OriginId . "']");
             $medianode = $medianodes[0];
             if ($medianode) {
                 $media_object = new ilObjMediaObject();
                 $media_object->setTitle($medianode->MetaData->General->Title);
                 $media_object->setDescription($medianode->MetaData->General->Description);
                 $media_object->create(false);
                 $mmd = $medianode->xpath("MetaData");
                 if ($mmd[0]) {
                     include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
                     $mdxml =& new ilMDXMLCopier($mmd[0]->asXML(), 0, $media_object->getId(), $media_object->getType());
                     $mdxml->startParsing();
                     $mdxml->getMDObject()->update();
                 }
                 // determine and create mob directory, move uploaded file to directory
                 $media_object->createDirectory();
                 $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId());
                 foreach ($medianode->MediaItem as $xMediaItem) {
                     $media_item =& new ilMediaItem();
                     $media_object->addMediaItem($media_item);
                     $media_item->setPurpose($xMediaItem[Purpose]);
                     $media_item->setFormat($xMediaItem->Format);
                     $media_item->setLocation($xMediaItem->Location);
                     $media_item->setLocationType($xMediaItem->Location[Type]);
                     $media_item->setWidth($xMediaItem->Layout[Width]);
                     $media_item->setHeight($xMediaItem->Layout[Height]);
                     $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]);
                     $media_item->setCaption($xMediaItem->Caption);
                     $media_item->setTextRepresentation($xMediaItem->TextRepresentation);
                     $nr = 0;
                     // add map areas (external links only)
                     foreach ($xMediaItem->MapArea as $n => $v) {
                         if ($v->ExtLink[Href] != "") {
                             include_once "./Services/MediaObjects/classes/class.ilMapArea.php";
                             $ma = new ilMapArea();
                             $map_area = new ilMapArea();
                             $map_area->setShape($v[Shape]);
                             $map_area->setCoords($v[Coords]);
                             $map_area->setLinkType(IL_EXT_LINK);
                             $map_area->setTitle($v->ExtLink);
                             $map_area->setHref($v->ExtLink[Href]);
                             $media_item->addMapArea($map_area);
                         }
                     }
                     if ($media_item->getLocationType() == "LocalFile") {
                         //							$tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location;
                         //							copy($tmp_name,  $mob_dir."/".$xMediaItem->Location);
                     }
                 }
                 // copy whole directory
                 ilUtil::rCopy($this->packageFolder . "/objects/" . $OriginId, $mob_dir);
                 // alex: fixed media import: these lines have been
                 // behind the next curly bracket which makes it fail
                 // when no medianode is given. (id=0 -> fatal error)
                 ilUtil::renameExecutables($mob_dir);
                 $media_object->update(true);
                 $ttnode[OriginId] = "il__mob_" . $media_object->getId();
             }
         }
         include_once "./Modules/File/classes/class.ilObjFile.php";
         include_once "./Services/Utilities/classes/class.ilFileUtils.php";
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         $intlinks = $page_xml->xpath("//IntLink");
         foreach ($intlinks as $intlink) {
             if ($intlink[Type] != "File") {
                 continue;
             }
             $path = $this->packageFolder . "/objects/" . str_replace('dfile', 'file', $intlink[Target]);
             if (!is_dir($path)) {
                 continue;
             }
             $ffiles = array();
             ilFileUtils::recursive_dirscan($path, $ffiles);
             $filename = $ffiles[file][0];
             $fileObj = new ilObjFile();
             $fileObj->setType("file");
             $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             // better use this, mime_content_type is deprecated
             $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename));
             $fileObj->setFileSize(filesize($path . "/" . $filename));
             $fileObj->create();
             $fileObj->createReference();
             //$fileObj->putInTree($_GET["ref_id"]);
             //$fileObj->setPermissions($slm->getId ());
             $fileObj->createDirectory();
             $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $intlink[Target] = "il__dfile_" . $fileObj->getId();
         }
         $fileitems = $page_xml->xpath("//FileItem/Identifier");
         foreach ($fileitems as $fileitem) {
             $path = $this->packageFolder . "/objects/" . $fileitem[Entry];
             if (!is_dir($path)) {
                 continue;
             }
             $ffiles = array();
             ilFileUtils::recursive_dirscan($path, $ffiles);
             $filename = $ffiles[file][0];
             $fileObj = new ilObjFile();
             $fileObj->setType("file");
             $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             // better use this, mime_content_type is deprecated
             $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename));
             $fileObj->setFileSize(filesize($path . "/" . $filename));
             $fileObj->create();
             $fileObj->createReference();
             //$fileObj->putInTree($_GET["ref_id"]);
             //$fileObj->setPermissions($slm->getId ());
             $fileObj->createDirectory();
             $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
             $fileitem[Entry] = "il__file_" . $fileObj->getId();
         }
         $pagex = new ilSCORM2004Page($page->getId());
         $ddoc = new DOMDocument();
         $ddoc->async = false;
         $ddoc->preserveWhiteSpace = false;
         $ddoc->formatOutput = false;
         $ddoc->loadXML($page_xml->asXML());
         $xpath = new DOMXPath($ddoc);
         $tnode = $xpath->query('PageContent');
         $t = "<PageObject>";
         foreach ($tnode as $ttnode) {
             $t .= $ddoc->saveXML($ttnode);
         }
         $t .= "</PageObject>";
         foreach ($qtis as $old => $q) {
             $t = str_replace($old, 'il__qst_' . $q['pool'], $t);
         }
         $pagex->setXMLContent($t);
         $pagex->updateFromXML();
     }
 }
示例#7
0
 /**
  * draws an outlined two color polygon
  *
  * @param	int			$im			image identifier as returned by ImageCreateFromGIF() etc.
  * @param	string		$coords     coordinate string, format : "x1,y1,x2,y2,..." with every (x,y) pair is
  *									an ending point of a line of the polygon
  * @param	int			$c1			color identifier 1
  * @param	int			$c3			color identifier 2
  * @param	boolean		$closed		true: the first and the last point will be connected with a line
  */
 function drawPoly(&$im, $coords, $c1, $c2, $closed, $a_x_ratio = 1, $a_y_ratio = 1)
 {
     if ($closed) {
         $p = 0;
     } else {
         $p = 1;
     }
     $anz = ilMapArea::countCoords($coords);
     if ($anz < 3 - $p) {
         return;
     }
     $c = explode(",", $coords);
     for ($i = 0; $i < $anz - $p; $i++) {
         $this->drawLine($im, $c[$i * 2] / $a_x_ratio, $c[$i * 2 + 1] / $a_y_ratio, $c[($i * 2 + 2) % (2 * $anz)] / $a_x_ratio, $c[($i * 2 + 3) % (2 * $anz)] / $a_y_ratio, $c1, $c2);
     }
 }
 /**
  * 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;
     }
 }
 /**
  * edit shape of existing map area
  */
 function setShape($a_handle = true)
 {
     global $lng, $ilCtrl;
     if ($a_handle) {
         $this->handleMapParameters();
     }
     if ($_POST["areatype2"] != "") {
         $_SESSION["il_map_edit_area_type"] = $_POST["areatype2"];
     }
     if ($_SESSION["il_map_area_nr"] != "") {
         $_POST["area"][0] = $_SESSION["il_map_area_nr"];
     }
     if (!isset($_POST["area"])) {
         ilUtil::sendFailure($lng->txt("no_checkbox"), true);
         $ilCtrl->redirect($this, "editMapAreas");
     }
     if (count($_POST["area"]) > 1) {
         ilUtil::sendFailure($lng->txt("cont_select_max_one_item"), true);
         $ilCtrl->redirect($this, "editMapAreas");
     }
     if ($_SESSION["il_map_edit_mode"] != "edit_shape") {
         $_SESSION["il_map_area_nr"] = $_POST["area"][0];
         $_SESSION["il_map_edit_mode"] = "edit_shape";
         $_SESSION["il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this, "setShape", "", false, false);
     }
     $area_type = $_SESSION["il_map_edit_area_type"];
     $coords = $_SESSION["il_map_edit_coords"];
     $cnt_coords = ilMapArea::countCoords($coords);
     // decide what to do next
     switch ($area_type) {
         // Rectangle
         case "Rect":
             if ($cnt_coords < 2) {
                 return $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
             } else {
                 if ($cnt_coords == 2) {
                     return $this->saveArea();
                 }
             }
             break;
             // Circle
         // Circle
         case "Circle":
             if ($cnt_coords <= 1) {
                 return $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
             } else {
                 if ($cnt_coords == 2) {
                     $c = explode(",", $coords);
                     $coords = $c[0] . "," . $c[1] . ",";
                     // determine radius
                     $coords .= round(sqrt(pow(abs($c[3] - $c[1]), 2) + pow(abs($c[2] - $c[0]), 2)));
                 }
                 $_SESSION["il_map_edit_coords"] = $coords;
                 return $this->saveArea();
             }
             break;
             // Polygon
         // Polygon
         case "Poly":
             if ($cnt_coords < 1) {
                 return $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
             } else {
                 if ($cnt_coords < 3) {
                     return $this->editMapArea(true, true, false, "shape", $_POST["area"][0]);
                 } else {
                     return $this->editMapArea(true, true, true, "shape", $_POST["area"][0]);
                 }
             }
             break;
             // Whole Picture
         // Whole Picture
         case "WholePicture":
             return $this->saveArea();
     }
 }