コード例 #1
0
 /**
  * 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 "htlm":
             include_once "./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php";
             if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
                 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
             } else {
                 $newObj = new ilObjFileBasedLM();
                 $newObj->setType("htlm");
                 $newObj->create(true);
             }
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->setStartFile($a_rec["StartFile"], true);
             $newObj->update();
             $this->current_obj = $newObj;
             $dir = str_replace("..", "", $a_rec["Dir"]);
             if ($dir != "" && $this->getImportDirectory() != "") {
                 $source_dir = $this->getImportDirectory() . "/" . $dir;
                 $target_dir = $newObj->getDataDirectory();
                 ilUtil::rCopy($source_dir, $target_dir);
             }
             $a_mapping->addMapping("Modules/HTMLLearningModule", "htlm", $a_rec["Id"], $newObj->getId());
             $a_mapping->addMapping("Services/MetaData", "md", $a_rec["Id"] . ":0:htlm", $newObj->getId() . ":0:htlm");
             break;
     }
 }
コード例 #2
0
 /**
  * Create new object from a html zip file
  *
  * @param
  * @return
  */
 function createFromDirectory($a_dir)
 {
     global $ilErr;
     if (!$this->checkPermissionBool("create", "", "htlm") || $a_dir == "") {
         $ilErr->raiseError($this->lng->txt("no_create_permission"));
     }
     // create instance
     $newObj = new ilObjFileBasedLM();
     $filename = ilUtil::stripSlashes($_FILES["importfile"]["name"]);
     $newObj->setTitle($filename);
     $newObj->setDescription("");
     $newObj->create();
     $newObj->populateByDirectoy($a_dir, $filename);
     $this->putObjectInTree($newObj);
     $this->afterSave($newObj);
 }