Example #1
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "blog":
             include_once "./Modules/Blog/classes/class.ilObjBlog.php";
             // container copy
             if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
                 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
             } else {
                 $newObj = new ilObjBlog();
                 $newObj->create();
             }
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->setNotesStatus($a_rec["Notes"]);
             $newObj->setBackgroundColor($a_rec["BgColor"]);
             $newObj->setFontColor($a_rec["FontColor"]);
             $newObj->setProfilePicture($a_rec["Ppic"]);
             $newObj->setRSS($a_rec["RssActive"]);
             $newObj->setApproval($a_rec["Approval"]);
             $newObj->setImage($a_rec["Img"]);
             $newObj->setAbstractShorten($a_rec["AbsShorten"]);
             $newObj->setAbstractShortenLength($a_rec["AbsShortenLen"]);
             $newObj->setAbstractImage($a_rec["AbsImage"]);
             $newObj->setAbstractImageWidth($a_rec["AbsImgWidth"]);
             $newObj->setAbstractImageHeight($a_rec["AbsImgHeight"]);
             $newObj->setNavMode($a_rec["NavMode"]);
             $newObj->setNavModeListPostings($a_rec["NavListPost"]);
             $newObj->setNavModeListMonths($a_rec["NavListMon"]);
             $newObj->setKeywords($a_rec["Keywords"]);
             $newObj->setAuthors($a_rec["Authors"]);
             $newObj->setOrder(trim($a_rec["NavOrder"]) ? explode(";", $a_rec["NavOrder"]) : null);
             $newObj->setOverviewPostings($a_rec["OvPost"]);
             $newObj->update();
             // handle image(s)
             if ($a_rec["Img"]) {
                 $dir = str_replace("..", "", $a_rec["Dir"]);
                 if ($dir != "" && $this->getImportDirectory() != "") {
                     $source_dir = $this->getImportDirectory() . "/" . $dir;
                     $target_dir = ilObjBlog::initStorage($newObj->getId());
                     ilUtil::rCopy($source_dir, $target_dir);
                 }
             }
             if ($a_rec["Style"]) {
                 self::$style_map[$a_rec["Style"]][] = $newObj->getId();
             }
             $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId());
             break;
         case "blog_posting":
             $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
             if ($blog_id) {
                 include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
                 $newObj = new ilBlogPosting();
                 $newObj->setBlogId($blog_id);
                 $newObj->setTitle($a_rec["Title"]);
                 $newObj->setCreated(new ilDateTime($a_rec["Created"], IL_CAL_DATETIME));
                 $newObj->setApproved($a_rec["Approved"]);
                 // parse export id into local id (if possible)
                 $author = $this->parseObjectExportId($a_rec["Author"], -1);
                 $newObj->setAuthor($author["id"]);
                 $newObj->create(true);
                 // keywords
                 $keywords = array();
                 for ($loop = 0; $loop < 1000; $loop++) {
                     if (isset($a_rec["Keyword" . $loop])) {
                         $keyword = trim($a_rec["Keyword" . $loop]);
                         if (strlen($keyword)) {
                             $keywords[] = $keyword;
                         }
                     }
                 }
                 if (sizeof($keywords)) {
                     $newObj->updateKeywords($keywords);
                 }
                 $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
             }
             break;
     }
 }