/** * create new media object in dom and update page in db */ function &create($a_create_alias = true, $a_change_obj_ref = false) { global $ilCtrl, $lng; if ($_GET["subCmd"] == "insertFromPool") { if (is_array($_POST["id"])) { for ($i = count($_POST["id"]) - 1; $i >= 0; $i--) { include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php"; $fid = ilMediaPoolItem::lookupForeignId($_POST["id"][$i]); include_once "./Services/COPage/classes/class.ilPCMediaObject.php"; $this->content_obj = new ilPCMediaObject($this->getPage()); $this->content_obj->readMediaObject($fid); $this->content_obj->createAlias($this->pg_obj, $_GET["hier_id"], $this->pc_id); } $this->updated = $this->pg_obj->update(); } $ilCtrl->returnToParent($this); } // check form input $mob_gui = new ilObjMediaObjectGUI(""); $mob_gui->initForm("create"); if (!$mob_gui->checkFormInput()) { $this->form = $mob_gui->getForm(); $this->insert("edpost", "create_mob", true); return; } // create dummy object in db (we need an id) include_once "./Services/COPage/classes/class.ilPCMediaObject.php"; if ($a_change_obj_ref != true) { $this->content_obj = new ilPCMediaObject($this->getPage()); } $this->content_obj->createMediaObject(); $media_obj = $this->content_obj->getMediaObject(); include_once "./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php"; ilObjMediaObjectGUI::setObjectPerCreationForm($media_obj); if ($a_create_alias) { // need a pcmediaobject here //$this->node = $this->createPageContentNode(); $this->content_obj->createAlias($this->pg_obj, $this->hier_id, $this->pc_id); $this->updated = $this->pg_obj->update(); if ($this->updated === true) { $this->pg_obj->stripHierIDs(); $this->pg_obj->addHierIDs(); $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId()); $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId()); $this->content_obj->setHierId($this->content_obj->readHierId()); $this->setHierId($this->content_obj->readHierId()); $this->content_obj->setPCId($this->content_obj->readPCId()); ilUtil::sendSuccess($lng->txt("saved_media_object"), true); $this->ctrl->redirectByClass("ilobjmediaobjectgui", "edit"); //$this->ctrl->returnToParent($this, "jump".$this->hier_id); } else { $this->insert(); } } else { if ($a_change_obj_ref == true) { $this->content_obj->updateObjectReference(); $this->updated = $this->pg_obj->update(); $this->ctrl->redirect($this, "editAlias"); } return $this->content_obj; } }
/** * create new media object in dom and update page in db */ function saveObject() { global $tpl, $lng; $this->initForm(); if ($this->form_gui->checkInput()) { $this->object = new ilObjMediaObject(); ilObjMediaObjectGUI::setObjectPerCreationForm($this->object); ilUtil::sendSuccess($lng->txt("saved_media_object"), true); return $this->object; } else { $this->form_gui->setValuesByPost(); $tpl->setContent($this->form_gui->getHTML()); return false; } }