/**
  * 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 "wiki":
             include_once "./Modules/Wiki/classes/class.ilObjWiki.php";
             if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
                 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
             } else {
                 $newObj = new ilObjWiki();
                 $newObj->setType("wiki");
                 $newObj->create(true);
             }
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->setShortTitle($a_rec["Short"]);
             $newObj->setStartPage($a_rec["StartPage"]);
             $newObj->setRatingOverall($a_rec["RatingOverall"]);
             $newObj->setRating($a_rec["Rating"]);
             $newObj->setIntroduction($a_rec["Introduction"]);
             $newObj->setPublicNotes($a_rec["PublicNotes"]);
             // >= 4.3
             if (isset($a_rec["PageToc"])) {
                 // $newObj->setImportantPages($a_rec["ImpPages"]);
                 $newObj->setPageToc($a_rec["PageToc"]);
                 $newObj->setRatingAsBlock($a_rec["RatingSide"]);
                 $newObj->setRatingForNewPages($a_rec["RatingNew"]);
                 $newObj->setRatingCategories($a_rec["RatingExt"]);
             }
             $newObj->update(true);
             $this->current_obj = $newObj;
             $a_mapping->addMapping("Modules/Wiki", "wiki", $a_rec["Id"], $newObj->getId());
             $a_mapping->addMapping("Services/Rating", "rating_category_parent_id", $a_rec["Id"], $newObj->getId());
             $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_rec["Id"], $newObj->getId());
             break;
         case "wpg":
             $wiki_id = $a_mapping->getMapping("Modules/Wiki", "wiki", $a_rec["WikiId"]);
             include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
             $wpage = new ilWikiPage();
             $wpage->setWikiId($wiki_id);
             $wpage->setTitle($a_rec["Title"]);
             // >= 4.3
             if (isset($a_rec["Blocked"])) {
                 $wpage->setBlocked($a_rec["Blocked"]);
                 $wpage->setRating($a_rec["Rating"]);
             }
             $wpage->create(true);
             $a_mapping->addMapping("Modules/Wiki", "wpg", $a_rec["Id"], $wpage->getId());
             $a_mapping->addMapping("Services/COPage", "pg", "wpg:" . $a_rec["Id"], "wpg:" . $wpage->getId());
             $a_mapping->addMapping("Services/AdvancedMetaData", "advmd_sub_item", "advmd:wpg:" . $a_rec["Id"], $wpage->getId());
             break;
     }
 }
 /**
  * Go to specific page
  *
  * @param	string	$a_page		page title
  */
 function gotoPageObject($a_page = "")
 {
     global $ilCtrl;
     if ($a_page == "") {
         $a_page = $_GET["page"];
     }
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     if (ilWikiPage::_wikiPageExists($this->object->getId(), ilWikiUtil::makeDbTitle($a_page))) {
         // to do: get rid of this redirect
         ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $a_page));
     } else {
         // create the page
         $page = new ilWikiPage();
         $page->setWikiId($this->object->getId());
         $page->setTitle(ilWikiUtil::makeDbTitle($_GET["page"]));
         if ($this->object->getRating() && $this->object->getRatingForNewPages()) {
             $page->setRating(true);
         }
         $page->create();
         // redirect to newly created page
         $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle($a_page));
         $ilCtrl->redirectByClass("ilwikipagegui", "edit");
     }
 }
Exemple #3
0
 /**
  * Create new wiki page
  *
  * @param string $a_page_title page title
  * @param int $a_template_page template page id
  * @return ilWikiPage new wiki page
  */
 function createWikiPage($a_page_title, $a_template_page = 0)
 {
     // check if template has to be used
     if ($a_template_page == 0) {
         if (!$this->getEmptyPageTemplate()) {
             include_once "./Modules/Wiki/classes/class.ilWikiPageTemplate.php";
             $wt = new ilWikiPageTemplate($this->getId());
             $ts = $wt->getAllInfo(ilWikiPageTemplate::TYPE_NEW_PAGES);
             if (count($ts) == 1) {
                 $t = current($ts);
                 $a_template_page = $t["wpage_id"];
             }
         }
     }
     // create the page
     $page = new ilWikiPage();
     $page->setWikiId($this->getId());
     $page->setTitle(ilWikiUtil::makeDbTitle($a_page_title));
     if ($this->getRating() && $this->getRatingForNewPages()) {
         $page->setRating(true);
     }
     // needed for notification
     $page->setWikiRefId($this->getRefId());
     $page->create();
     // copy template into new page
     if ($a_template_page > 0) {
         $orig = new ilWikiPage($a_template_page);
         $orig->copy($page->getId());
     }
     return $page;
 }
 /**
  * Clone wiki
  *
  * @param int target ref_id
  * @param int copy id
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB, $ilUser, $ilias;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     $new_obj->setTitle($this->getTitle());
     $new_obj->setStartPage($this->getStartPage());
     $new_obj->setShortTitle($this->getShortTitle());
     $new_obj->setRating($this->getRating());
     $new_obj->setRatingAsBlock($this->getRatingAsBlock());
     $new_obj->setRatingForNewPages($this->getRatingForNewPages());
     $new_obj->setRatingCategories($this->getRatingCategories());
     $new_obj->setPublicNotes($this->getPublicNotes());
     $new_obj->setIntroduction($this->getIntroduction());
     $new_obj->setImportantPages($this->getImportantPages());
     $new_obj->setPageToc($this->getPageToc());
     $new_obj->update();
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $this->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $new_obj->setStyleSheetId($new_id);
         $new_obj->update();
     }
     // copy content
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $pages = ilWikiPage::getAllPages($this->getId());
     if (count($pages) > 0) {
         // if we have any pages, delete the start page first
         $pg_id = ilWikiPage::getPageIdForTitle($new_obj->getId(), $new_obj->getStartPage());
         $start_page = new ilWikiPage($pg_id);
         $start_page->delete();
     }
     $map = array();
     foreach ($pages as $p) {
         $page = new ilWikiPage($p["id"]);
         $new_page = new ilWikiPage();
         $new_page->setTitle($page->getTitle());
         $new_page->setWikiId($new_obj->getId());
         $new_page->setTitle($page->getTitle());
         $new_page->setBlocked($page->getBlocked());
         $new_page->setRating($page->getRating());
         $new_page->create();
         $new_page->setXMLContent($page->copyXMLContent(true));
         $new_page->buildDom();
         $new_page->update();
         $map[$p["id"]] = $new_page->getId();
     }
     // copy important pages
     foreach (ilObjWiki::_lookupImportantPagesList($this->getId()) as $ip) {
         $new_obj->addImportantPage($map[$ip["page_id"]], $ip["ord"], $ip["indent"]);
     }
     // copy rating categories
     include_once "./Services/Rating/classes/class.ilRatingCategory.php";
     foreach (ilRatingCategory::getAllForObject($this->getId()) as $rc) {
         $new_rc = new ilRatingCategory();
         $new_rc->setParentId($new_obj->getId());
         $new_rc->setTitle($rc["title"]);
         $new_rc->setDescription($rc["description"]);
         $new_rc->save();
     }
     return $new_obj;
 }