/**
  * copy chapter
  */
 function copy($a_target_lm)
 {
     $chap = new ilStructureObject($a_target_lm);
     $chap->setTitle($this->getTitle());
     if ($this->getLMId() != $a_target_lm->getId()) {
         $chap->setImportId("il__st_" . $this->getId());
     }
     $chap->setLMId($a_target_lm->getId());
     $chap->setType($this->getType());
     $chap->setDescription($this->getDescription());
     $chap->create(true);
     $a_copied_nodes[$this->getId()] = $chap->getId();
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
     $new_md =& $md->cloneMD($a_target_lm->getId(), $chap->getId(), $this->getType());
     return $chap;
 }
Exemplo n.º 2
0
 /**
  * Copy sco
  */
 function copy($a_target_slm)
 {
     $ass = new ilSCORM2004Asset($a_target_slm);
     $ass->setTitle($this->getTitle());
     if ($this->getSLMId() != $a_target_slm->getId()) {
         $ass->setImportId("il__ass_" . $this->getId());
     }
     $ass->setSLMId($a_target_slm->getId());
     $ass->setType($this->getType());
     $ass->setDescription($this->getDescription());
     $ass->create(true);
     $a_copied_nodes[$this->getId()] = $ass->getId();
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
     $new_md = $md->cloneMD($a_target_slm->getId(), $ass->getId(), $this->getType());
     return $ass;
 }
Exemplo n.º 3
0
 /**
  * Paste item (tree) from clipboard to current lm
  */
 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy = false, $a_source_lm = null)
 {
     global $ilUser, $ilias, $ilLog;
     include_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     $item_lm_id = ilLMObject::_lookupContObjID($a_item_id);
     $item_type = ilLMObject::_lookupType($a_item_id);
     $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
     if ($item_type == "st") {
         $item = new ilStructureObject($lm_obj, $a_item_id);
     } else {
         if ($item_type == "pg") {
             $item = new ilLMPageObject($lm_obj, $a_item_id);
         }
     }
     $ilLog->write("Getting from clipboard type " . $item_type . ", " . "Item ID: " . $a_item_id . ", of original LM: " . $item_lm_id);
     if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy) {
         // @todo: check whether st is NOT in tree
         // "move" metadata to new lm
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($item_lm_id, $item->getId(), $item->getType());
         $new_md = $md->cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
         // update lm object
         $item->setLMId($a_target_lm->getId());
         $item->setContentObject($a_target_lm);
         $item->update();
         // delete old meta data set
         $md->deleteAll();
         if ($item_type == "pg") {
             $page = $item->getPageObject();
             $page->buildDom();
             $page->setParentId($a_target_lm->getId());
             $page->update();
         }
     }
     if ($a_as_copy) {
         $target_item = $item->copy($a_target_lm);
         $a_copied_nodes[$item->getId()] = $target_item->getId();
     } else {
         $target_item = $item;
     }
     $ilLog->write("Putting into tree type " . $target_item->getType() . "Item ID: " . $target_item->getId() . ", Parent: " . $a_parent_id . ", " . "Target: " . $a_target . ", Item LM:" . $target_item->getContentObject()->getId());
     ilLMObject::putInTree($target_item, $a_parent_id, $a_target);
     if ($a_source_lm == null) {
         $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
     } else {
         $childs = $a_source_lm->lm_tree->getChilds($item->getId());
         foreach ($childs as $k => $child) {
             $childs[$k]["id"] = $childs[$k]["child"];
         }
     }
     foreach ($childs as $child) {
         ilLMObject::pasteTree($a_target_lm, $child["id"], $target_item->getId(), IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_source_lm);
     }
     return $target_item->getId();
     // @todo: write history (see pastePage)
 }
 /**
  * Paste item (tree) from clipboard or other learning module to target scorm learning module
  *
  * @param object $a_target_slm target scorm 2004 learning module object
  * @param int $a_item_id id of item that should be pasted
  * @param int $a_parent_id parent id in target tree,
  * @param int $a_target predecessor target node, no ID means: last child
  * @param string $a_insert_time cliboard insert time (not needed, if $a_from_cliboard is false)
  * @param array $a_copied_nodes array of IDs od copied nodes, key is ID of source node, value is ID of copied node
  * @param bool $a_as_copy if true, items are copied otherwise they are moved
  * @param bool $a_from_clipboard if true, child node information is read from clipboard, otherwise from source tree
  */
 static function pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy = false, $a_from_clipboard = true)
 {
     global $ilUser, $ilias, $ilLog;
     // source lm id, item type and lm object
     $item_slm_id = ilSCORM2004Node::_lookupSLMID($a_item_id);
     $item_type = ilSCORM2004Node::_lookupType($a_item_id);
     //$slm_obj = $ilias->obj_factory->getInstanceByObjId($item_slm_id);
     include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
     $slm_obj = new ilObjSCORM2004LearningModule($item_slm_id, false);
     if ($item_type == "chap") {
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php";
         $item = new ilSCORM2004Chapter($slm_obj, $a_item_id);
     } else {
         if ($item_type == "page") {
             include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php";
             $item = new ilSCORM2004PageNode($slm_obj, $a_item_id);
         } else {
             if ($item_type == "sco") {
                 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php";
                 $item = new ilSCORM2004Sco($slm_obj, $a_item_id);
             } else {
                 if ($item_type == "ass") {
                     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php";
                     $item = new ilSCORM2004Asset($slm_obj, $a_item_id);
                 }
             }
         }
     }
     $ilLog->write("Getting from clipboard type " . $item_type . ", " . "Item ID: " . $a_item_id . ", of original SLM: " . $item_slm_id);
     if ($item_slm_id != $a_target_slm->getId() && !$a_as_copy) {
         // @todo: check whether st is NOT in tree
         // "move" metadata to new lm
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($item_slm_id, $item->getId(), $item->getType());
         $new_md = $md->cloneMD($a_target_slm->getId(), $item->getId(), $item->getType());
         // update lm object
         $item->setSLMId($a_target_slm->getId());
         $item->setSLMObject($a_target_slm);
         $item->update();
         // delete old meta data set
         $md->deleteAll();
         if ($item_type == "page") {
             $page = $item->getPageObject();
             $page->buildDom($a_from_clipboard);
             $page->setParentId($a_target_slm->getId());
             $page->update();
         }
     }
     if ($a_as_copy) {
         $target_item = $item->copy($a_target_slm);
         $a_copied_nodes[$item->getId()] = $target_item->getId();
     } else {
         $target_item = $item;
     }
     $ilLog->write("Putting into tree type " . $target_item->getType() . "Item ID: " . $target_item->getId() . ", Parent: " . $a_parent_id . ", " . "Target: " . $a_target . ", Item LM:" . $target_item->getContentObject()->getId());
     ilSCORM2004Node::putInTree($target_item, $a_parent_id, $a_target);
     if ($a_from_clipboard) {
         $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
     } else {
         // get childs of source tree
         $source_tree = $slm_obj->getTree();
         $childs = $source_tree->getChilds($a_item_id);
     }
     foreach ($childs as $child) {
         $child_id = $a_from_clipboard ? $child["id"] : $child["child"];
         ilSCORM2004Node::pasteTree($a_target_slm, $child_id, $target_item->getId(), IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy);
     }
     return $target_item->getId();
 }
 /**
  * Creates a 1:1 copy of the object and places the copy in a given repository
  *
  * @access public
  */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $newObj->setOnline($this->getOnline());
     }
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQuestions();
     foreach ($questions as $question_id) {
         $newObj->copyQuestion($question_id, $newObj->getId());
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     return $newObj;
 }
 /**
  * copy page node
  */
 function copy($a_target_slm)
 {
     // copy page
     $slm_page = new ilSCORM2004PageNode($a_target_slm);
     $slm_page->setTitle($this->getTitle());
     $slm_page->setSLMId($a_target_slm->getId());
     $slm_page->setType($this->getType());
     $slm_page->setDescription($this->getDescription());
     $slm_page->setImportId("il__page_" . $this->getId());
     $slm_page->create(true);
     // setting "upload" flag to true prevents creating of meta data
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
     $new_md = $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), $this->getType());
     // copy page content
     $page = $slm_page->getPageObject();
     // clone media objects, if source and target lm are not the same
     $clone_mobs = $this->getSLMId() == $a_target_slm->getId() ? false : true;
     $this->page_object->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
     //$page->setXMLContent($this->page_object->copyXMLContent($clone_mobs));
     //$page->buildDom();
     //$page->update();
     return $slm_page;
 }
 /**
 * Creates a 1:1 copy of the object and places the copy in a given repository
 *
 * @access public
 */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     $newObj->setOnline($this->getOnline());
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQplQuestions();
     foreach ($questions as $question_id) {
         $newObj->copyQuestion($question_id, $newObj->getId());
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     return $newObj;
 }
 /**
  * Duplicate media object, return new media object
  */
 function duplicate()
 {
     $new_obj = new ilObjMediaObject();
     $new_obj->setTitle($this->getTitle());
     $new_obj->setDescription($this->getDescription());
     // media items
     foreach ($this->getMediaItems() as $key => $val) {
         $new_obj->addMediaItem($val);
     }
     $new_obj->create(false, true);
     // files
     $new_obj->createDirectory();
     self::_createThumbnailDirectory($new_obj->getId());
     ilUtil::rCopy(ilObjMediaObject::_getDirectory($this->getId()), ilObjMediaObject::_getDirectory($new_obj->getId()));
     ilUtil::rCopy(ilObjMediaObject::_getThumbnailDirectory($this->getId()), ilObjMediaObject::_getThumbnailDirectory($new_obj->getId()));
     // meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD(0, $this->getId(), "mob");
     $new_md = $md->cloneMD(0, $new_obj->getId(), "mob");
     return $new_obj;
 }
Exemplo n.º 9
0
 /**
  * split page at hierarchical id
  *
  * the main reason for this method being static is that a lm page
  * object is not available within ilPageContentGUI where this method
  * is called
  */
 function _splitPage($a_page_id, $a_pg_parent_type, $a_hier_id)
 {
     // get content object (learning module / digilib book)
     $lm_id = ilLMObject::_lookupContObjID($a_page_id);
     $type = ilObject::_lookupType($lm_id, false);
     switch ($type) {
         case "lm":
             include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
             $cont_obj = new ilObjLearningModule($lm_id, false);
             break;
         case "dbk":
             include_once "./Modules/LearningModule/classes/class.ilObjDlBook.php";
             $cont_obj = new ilObjDlBook($lm_id, false);
             break;
     }
     $source_lm_page = new ilLMPageObject($cont_obj, $a_page_id);
     // create new page
     $lm_page = new ilLMPageObject($cont_obj);
     $lm_page->setTitle($source_lm_page->getTitle());
     $lm_page->setLMId($source_lm_page->getLMId());
     $lm_page->setType($source_lm_page->getType());
     $lm_page->setDescription($source_lm_page->getDescription());
     $lm_page->create(true);
     // copy complete content of source page to new page
     $source_page = $source_lm_page->getPageObject();
     $page = $lm_page->getPageObject();
     $page->setXMLContent($source_page->copyXMLContent());
     //echo htmlentities($source_page->copyXMLContent());
     $page->buildDom(true);
     $page->update();
     //		echo "-".$page->getId()."-".$page->getParentType()."-";
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($source_lm_page->getLMId(), $a_page_id, $source_lm_page->getType());
     $md->cloneMD($source_lm_page->getLMId(), $lm_page->getId(), $source_lm_page->getType());
     // insert new page in tree (after original page)
     $tree = new ilTree($cont_obj->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($tree->isInTree($source_lm_page->getId())) {
         $parent_node = $tree->getParentNodeData($source_lm_page->getId());
         $tree->insertNode($lm_page->getId(), $parent_node["child"], $source_lm_page->getId());
     }
     // remove all nodes < hierarchical id from new page (incl. update)
     $page->addHierIds();
     $page->deleteContentBeforeHierId($a_hier_id);
     //		$page->update();
     // remove all nodes >= hierarchical id from source page
     $source_page->buildDom();
     $source_page->addHierIds();
     $source_page->deleteContentFromHierId($a_hier_id);
     return $lm_page;
 }
Exemplo n.º 10
0
 /**
 * Creates a 1:1 copy of the object and places the copy in a given repository
 *
 * @access public
 */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $newObj->setOnline($this->getOnline());
     }
     $newObj->setShowTaxonomies($this->getShowTaxonomies());
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQplQuestions();
     $questionIdsMap = array();
     foreach ($questions as $question_id) {
         $newQuestionId = $newObj->copyQuestion($question_id, $newObj->getId());
         $questionIdsMap[$question_id] = $newQuestionId;
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolTaxonomiesDuplicator.php';
     $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
     $duplicator->setSourceObjId($this->getId());
     $duplicator->setSourceObjType($this->getType());
     $duplicator->setTargetObjId($newObj->getId());
     $duplicator->setTargetObjType($newObj->getType());
     $duplicator->setQuestionIdMapping($questionIdsMap);
     $duplicator->duplicate();
     $duplicatedTaxKeyMap = $duplicator->getDuplicatedTaxonomiesKeysMap();
     $newObj->setNavTaxonomyId($duplicatedTaxKeyMap->getMappedTaxonomyId($this->getNavTaxonomyId()));
     $newObj->saveToDb();
     return $newObj;
 }
Exemplo n.º 11
0
 /**
  * Copy meta data
  *
  * @access public
  * @param object target object
  * 
  */
 public function cloneMetaData($target_obj)
 {
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $md->cloneMD($target_obj->getId(), 0, $target_obj->getType());
     return true;
 }
Exemplo n.º 12
0
 /**
  * Copy a term to a glossary
  *
  * @param
  * @return
  */
 function _copyTerm($a_term_id, $a_glossary_id)
 {
     $old_term = new ilGlossaryTerm($a_term_id);
     // copy the term
     $new_term = new ilGlossaryTerm();
     $new_term->setTerm($old_term->getTerm());
     $new_term->setLanguage($old_term->getLanguage());
     $new_term->setGlossaryId($a_glossary_id);
     $new_term->create();
     // copy the definitions
     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     $def_list = ilGlossaryDefinition::getDefinitionList($a_term_id);
     foreach ($def_list as $def) {
         $old_def = new ilGlossaryDefinition($def["id"]);
         $new_def = new ilGlossaryDefinition();
         $new_def->setShortText($old_def->getShortText());
         $new_def->setNr($old_def->getNr());
         $new_def->setTermId($new_term->getId());
         $new_def->create();
         // copy meta data
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($old_term->getGlossaryId(), $old_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         $new_md = $md->cloneMD($a_glossary_id, $new_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         // page content
         $new_def->getPageObject()->setXMLContent($old_def->getPageObject()->copyXmlContent(true));
         $new_def->getPageObject()->buildDom();
         $new_def->getPageObject()->update();
     }
     return $new_term->getId();
 }