/** * Get items of current folder */ function getItems() { $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom, $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId(), $this->parent_node_name); $areas = $std_alias_item->getMapAreas(); foreach ($areas as $k => $a) { $areas[$k]["title"] = $a["Link"]["Title"]; } $areas = ilUtil::sortArray($areas, "title", "asc", false, true); $this->setData($areas); }
function moveIntLinks($a_from_to) { $this->buildDom(); $changed = false; // resolve normal internal links $xpc = xpath_new_context($this->dom); $path = "//IntLink"; $res =& xpath_eval($xpc, $path); for ($i = 0; $i < count($res->nodeset); $i++) { $target = $res->nodeset[$i]->get_attribute("Target"); $type = $res->nodeset[$i]->get_attribute("Type"); $obj_id = ilInternalLink::_extractObjIdOfTarget($target); if ($a_from_to[$obj_id] > 0 && is_int(strpos($target, "__"))) { if ($type == "PageObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "pg") { $res->nodeset[$i]->set_attribute("Target", "il__pg_" . $a_from_to[$obj_id]); $changed = true; } if ($type == "StructureObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "st") { $res->nodeset[$i]->set_attribute("Target", "il__st_" . $a_from_to[$obj_id]); $changed = true; } } } unset($xpc); // map areas $this->addHierIDs(); $xpc = xpath_new_context($this->dom); $path = "//MediaAlias"; $res =& xpath_eval($xpc, $path); require_once "Services/MediaObjects/classes/class.ilMediaItem.php"; require_once "Services/COPage/classes/class.ilMediaAliasItem.php"; for ($i = 0; $i < count($res->nodeset); $i++) { $media_object_node = $res->nodeset[$i]->parent_node(); $page_content_node = $media_object_node->parent_node(); $c_hier_id = $page_content_node->get_attribute("HierId"); // first check, wheter we got instance map areas -> take these $std_alias_item = new ilMediaAliasItem($this->dom, $c_hier_id, "Standard"); $areas = $std_alias_item->getMapAreas(); $correction_needed = false; if (count($areas) > 0) { // check if correction needed foreach ($areas as $area) { if ($area["Type"] == "PageObject" || $area["Type"] == "StructureObject") { $t = $area["Target"]; $tid = _extractObjIdOfTarget($t); if ($a_from_to[$tid] > 0) { $correction_needed = true; } } } } else { $areas = array(); // get object map areas and check whether at least one must // be corrected $oid = $res->nodeset[$i]->get_attribute("OriginId"); if (substr($oid, 0, 4) == "il__") { $id_arr = explode("_", $oid); $id = $id_arr[count($id_arr) - 1]; $mob = new ilObjMediaObject($id); $med_item = $mob->getMediaItem("Standard"); $med_areas = $med_item->getMapAreas(); foreach ($med_areas as $area) { $link_type = $area->getLinkType() == "int" ? "IntLink" : "ExtLink"; $areas[] = array("Nr" => $area->getNr(), "Shape" => $area->getShape(), "Coords" => $area->getCoords(), "Link" => array("LinkType" => $link_type, "Href" => $area->getHref(), "Title" => $area->getTitle(), "Target" => $area->getTarget(), "Type" => $area->getType(), "TargetFrame" => $area->getTargetFrame())); if ($area->getType() == "PageObject" || $area->getType() == "StructureObject") { $t = $area->getTarget(); $tid = ilInternalLink::_extractObjIdOfTarget($t); if ($a_from_to[$tid] > 0) { $correction_needed = true; } //var_dump($a_from_to); } } } } // correct map area links if ($correction_needed) { $changed = true; $std_alias_item->deleteAllMapAreas(); foreach ($areas as $area) { if ($area["Link"]["LinkType"] == "IntLink") { $target = $area["Link"]["Target"]; $type = $area["Link"]["Type"]; $obj_id = ilInternalLink::_extractObjIdOfTarget($target); if ($a_from_to[$obj_id] > 0) { if ($type == "PageObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "pg") { $area["Link"]["Target"] = "il__pg_" . $a_from_to[$obj_id]; } if ($type == "StructureObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "st") { $area["Link"]["Target"] = "il__st_" . $a_from_to[$obj_id]; } } } $std_alias_item->addMapArea($area["Shape"], $area["Coords"], $area["Link"]["Title"], array("Type" => $area["Link"]["Type"], "TargetFrame" => $area["Link"]["TargetFrame"], "Target" => $area["Link"]["Target"], "Href" => $area["Link"]["Href"], "LinkType" => $area["Link"]["LinkType"])); } } } unset($xpc); return $changed; }
/** * Update (base image) */ function update() { global $ilCtrl, $lng; $mob = $this->content_obj->getMediaObject(); $mob_dir = ilObjMediaObject::_getDirectory($mob->getId()); $std_item = $mob->getMediaItem("Standard"); $location = $_FILES['image_file']['name']; if ($location != "" && is_file($_FILES['image_file']['tmp_name'])) { $file = $mob_dir . "/" . $_FILES['image_file']['name']; ilUtil::moveUploadedFile($_FILES['image_file']['tmp_name'], $_FILES['image_file']['name'], $file); // get mime type $format = ilObjMediaObject::getMimeType($file); $location = $_FILES['image_file']['name']; $std_item->setFormat($format); $std_item->setLocation($location); $std_item->setLocationType("LocalFile"); $mob->setDescription($format); $mob->update(); } // set caption $std_alias_item = new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard", $this->content_obj->getPcId(), "InteractiveImage"); $std_alias_item->setCaption(ilUtil::stripSlashes($_POST["caption"])); $_SESSION["il_pg_error"] = $this->pg_obj->update(); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $ilCtrl->redirectByClass("ilpcinteractiveimagegui", "editBaseImage"); }
/** * Make work file for editing */ function makeMapWorkCopy($a_edit_property = "", $a_area_nr = 0, $a_output_new_area = false, $a_area_type = "", $a_coords = "") { // old for pc media object // $media_object = $this->media_object->getMediaItem("Standard"); $media_object = $this->content_obj->getMediaObject(); // create/update imagemap work copy $st_item = $media_object->getMediaItem("Standard"); $st_alias_item = new ilMediaAliasItem($this->content_obj->dom, $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId(), $this->getParentNodeName()); if ($a_edit_property == "shape") { $st_alias_item->makeMapWorkCopy($st_item, $a_area_nr, true, $a_output_new_area, $a_area_type, $a_coords); // exclude area currently being edited } else { $st_alias_item->makeMapWorkCopy($st_item, $a_area_nr, false, $a_output_new_area, $a_area_type, $a_coords); } }