/** * save table properties in db and return to page edit screen */ function saveAliasProperties() { $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard", $this->content_obj->getPcId()); $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen", $this->content_obj->getPcId()); $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard"); $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen"); // standard size if ($_POST["st_derive_size"] == "y") { $std_alias_item->deriveSize(); } else { $std_alias_item->setWidth(ilUtil::stripSlashes($_POST["st_width_height"]["width"])); $std_alias_item->setHeight(ilUtil::stripSlashes($_POST["st_width_height"]["height"])); } // standard caption if ($_POST["st_derive_caption"] == "y") { $std_alias_item->deriveCaption(); } else { $std_alias_item->setCaption(ilUtil::stripSlashes($_POST["st_caption"])); } // text representation if ($_POST["st_derive_text_representation"] == "y") { $std_alias_item->deriveTextRepresentation(); } else { $std_alias_item->setTextRepresentation(ilUtil::stripSlashes($_POST["st_text_representation"])); } // standard parameters if ($_POST["st_derive_parameters"] == "y") { $std_alias_item->deriveParameters(); } else { if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(), $std_item->getFormat())) { if ($_POST["st_autostart"]) { $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"')); } else { $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"')); } } else { $std_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["st_parameters"])))); } } if ($this->content_obj->getMediaObject()->hasFullscreenItem()) { if ($_POST["fullscreen"] == "y") { if (!$full_alias_item->exists()) { $full_alias_item->insert(); } // fullscreen size if ($_POST["full_derive_size"] == "y") { $full_alias_item->deriveSize(); } else { $full_alias_item->setWidth(ilUtil::stripSlashes($_POST["full_width_height"]["width"])); $full_alias_item->setHeight(ilUtil::stripSlashes($_POST["full_width_height"]["height"])); } // fullscreen caption if ($_POST["full_derive_caption"] == "y") { $full_alias_item->deriveCaption(); } else { $full_alias_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"])); } // fullscreen text representation if ($_POST["full_derive_text_representation"] == "y") { $full_alias_item->deriveTextRepresentation(); } else { $full_alias_item->setTextRepresentation(ilUtil::stripSlashes($_POST["full_text_representation"])); } // fullscreen parameters if ($_POST["full_derive_parameters"] == "y") { $full_alias_item->deriveParameters(); } else { if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(), $full_item->getFormat())) { if ($_POST["full_autostart"]) { $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"')); } else { $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"')); } } else { $full_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"])))); } } } else { if ($full_alias_item->exists()) { $full_alias_item->delete(); } } } $this->updated = $this->pg_obj->update(); if ($this->updated === true) { $this->ctrl->returnToParent($this, "jump" . $this->hier_id); } else { $this->pg_obj->addHierIDs(); $this->editAlias(); } }
/** * save properties in db and return to page edit screen */ function savePropertiesObject() { global $lng, $tpl; $this->initForm("edit"); if ($this->form_gui->checkInput()) { $title = trim($_POST["standard_title"]); $this->object->setTitle($title); $std_item = $this->object->getMediaItem("Standard"); $location = $std_item->getLocation(); $format = $std_item->getFormat(); if ($_POST["standard_type"] == "Reference") { $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["standard_reference"])); $std_item->setFormat($format); $std_item->setLocation(ilUtil::secureLink(ilUtil::stripSlashes($_POST["standard_reference"]))); $std_item->setLocationType("Reference"); } $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId()); if ($_POST["standard_type"] == "File") { $resize = false; if ($_FILES['standard_file']['name'] != "") { $file_name = ilObjMediaObject::fixFilename($_FILES['standard_file']['name']); $file = $mob_dir . "/" . $file_name; ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'], $file_name, $file); // get mime type $format = ilObjMediaObject::getMimeType($file); $location = $file_name; $resize = true; } else { if ($_POST["standard_resize"]) { $file = $mob_dir . "/" . $location; $resize = true; } } // resize if ($resize) { if ($_POST["standard_size"] != "original" && is_int(strpos($format, "image"))) { $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["standard_width_height"]["width"], (int) $_POST["standard_width_height"]["height"], (bool) $_POST["standard_width_height"]["contr_prop"]); } $std_item->setFormat($format); $std_item->setLocation($location); } $std_item->setLocationType("LocalFile"); } $this->object->setDescription($format); // determine width and height of known image types $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format, $_POST["standard_type"], $mob_dir . "/" . $location, $std_item->getLocation(), $_POST["standard_width_height"]["constr_prop"], $_POST["standard_size"] == "original", $_POST["standard_width_height"]["width"], $_POST["standard_width_height"]["height"]); if ($wh["info"] != "") { ilUtil::sendInfo($wh["info"], true); } $std_item->setWidth($wh["width"]); $std_item->setHeight($wh["height"]); // set caption $std_item->setCaption(ilUtil::stripSlashes($_POST["standard_caption"])); // text representation $std_item->setTextRepresentation(ilUtil::stripSlashes($_POST["text_representation"])); // set parameters if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes())) { if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(), $std_item->getFormat())) { if ($_POST["standard_autostart"]) { $std_item->setParameters('autostart="true"'); } else { $std_item->setParameters(""); } } else { $std_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["standard_parameters"]))); } } // "None" selected if ($_POST["full_type"] == "None") { if ($this->object->hasFullscreenItem()) { $this->object->removeMediaItem("Fullscreen"); } } else { if ($this->object->hasFullscreenItem()) { $full_item = $this->object->getMediaItem("Fullscreen"); } else { $full_item = new ilMediaItem(); $this->object->addMediaItem($full_item); $full_item->setPurpose("Fullscreen"); } $location = $full_item->getLocation(); $format = $full_item->getFormat(); if ($_POST["full_type"] == "Reference") { $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["full_reference"])); $full_item->setFormat($format); $full_item->setLocationType("Reference"); $location = ilUtil::stripSlashes($_POST["full_reference"]); $type = "Reference"; } $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId()); if ($_POST["full_type"] == "File") { $resize = false; if ($_FILES['full_file']['name'] != "") { $full_file_name = ilObjMediaObject::fixFilename($_FILES['full_file']['name']); $file = $mob_dir . "/" . $full_file_name; ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'], $full_file_name, $file); $format = ilObjMediaObject::getMimeType($file); $location = $full_file_name; $resize = true; } else { if ($_POST["full_resize"]) { $file = $mob_dir . "/" . $location; $resize = true; } } // resize if ($resize) { if ($_POST["full_size"] != "original" && is_int(strpos($format, "image"))) { $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["full_width_height"]["width"], (int) $_POST["full_width_height"]["height"], (bool) $_POST["full_width_height"]["contr_prop"]); } $full_item->setFormat($format); $full_item->setLocation($location); } $full_item->setLocationType("LocalFile"); $type = "File"; } if ($_POST["full_type"] == "Standard") { $format = $std_item->getFormat(); $location = $std_item->getLocation(); $full_item->setLocationType($std_item->getLocationType()); $full_item->setFormat($format); $full_item->setLocation($location); $type = $std_item->getLocationType(); if ($type == "LocalFile") { $type = "File"; } // resize image //echo "-".$_POST["full_size"]."-".is_int(strpos($format, "image"))."-".$full_item->getLocationType()."-"; if ($_POST["full_size"] != "original" && is_int(strpos($format, "image")) && $full_item->getLocationType() == "LocalFile") { $file = $mob_dir . "/" . $location; $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["full_width_height"]["width"], (int) $_POST["full_width_height"]["height"], (bool) $_POST["full_width_height"]["contr_prop"]); } } // determine width and height of known image types $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format, $type, $mob_dir . "/" . $location, $full_item->getLocation(), $_POST["full_width_height"]["constr_prop"], $_POST["full_size"] == "original", $_POST["full_width_height"]["width"], $_POST["full_width_height"]["height"]); if ($wh["info"] != "") { ilUtil::sendInfo($wh["info"], true); } $full_item->setWidth($wh["width"]); $full_item->setHeight($wh["height"]); $full_item->setLocation($location); $full_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"])); // text representation $full_item->setTextRepresentation(ilUtil::stripSlashes($_POST["full_text_representation"])); // set parameters if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes())) { if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(), $std_item->getFormat())) { if ($_POST["full_autostart"]) { $full_item->setParameters('autostart="true"'); } else { $full_item->setParameters(""); } } else { $full_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"]))); } } } ilUtil::renameExecutables(ilObjMediaObject::_getDirectory($this->object->getId())); $this->object->update(); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $this->ctrl->redirect($this, "edit"); } else { $this->form_gui->setValuesByPost(); $tpl->setContent($this->form_gui->getHTML()); } }