/**
  * Constructor
  */
 function __construct($a_parent_obj, $a_parent_cmd)
 {
     global $ilCtrl, $lng, $ilAccess, $lng;
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $data = array("page_id" => 0) + ilObjWiki::_lookupImportantPagesList($a_parent_obj->object->getId());
     $this->setData($data);
     $this->setTitle($lng->txt(""));
     $this->setLimit(9999);
     $this->addColumn("", "", "1", true);
     $this->addColumn($this->lng->txt("wiki_ordering"), "order");
     $this->addColumn($this->lng->txt("wiki_indentation"));
     $this->addColumn($this->lng->txt("wiki_page"));
     $this->setEnableHeader(true);
     $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
     $this->setRowTemplate("tpl.imp_pages_row.html", "Modules/Wiki");
     //$this->disable("footer");
     $this->setEnableTitle(true);
     $this->addMultiCommand("confirmRemoveImportantPages", $lng->txt("remove"));
     $this->addCommandButton("saveOrderingAndIndent", $lng->txt("wiki_save_ordering_and_indent"));
 }
Ejemplo n.º 2
0
 /**
  * List important pages
  */
 function editImportantPagesObject()
 {
     global $tpl, $ilToolbar, $ilTabs, $lng, $ilCtrl;
     $this->checkPermission("write");
     ilUtil::sendInfo($lng->txt("wiki_navigation_info"));
     $ipages = ilObjWiki::_lookupImportantPagesList($this->object->getId());
     $ipages_ids = array();
     foreach ($ipages as $i) {
         $ipages_ids[] = $i["page_id"];
     }
     // list pages
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $pages = ilWikiPage::getAllPages($this->object->getId());
     $options = array("" => $lng->txt("please_select"));
     foreach ($pages as $p) {
         if (!in_array($p["id"], $ipages_ids)) {
             $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
         }
     }
     if (count($options) > 0) {
         include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
         $si = new ilSelectInputGUI($lng->txt("wiki_pages"), "imp_page_id");
         $si->setOptions($options);
         $si->setInfo($lng->txt(""));
         $ilToolbar->addInputItem($si);
         $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
         $ilToolbar->addFormButton($lng->txt("add"), "addImportantPage");
     }
     $ilTabs->activateTab("settings");
     $this->setSettingsSubTabs("imp_pages");
     include_once "./Modules/Wiki/classes/class.ilImportantPagesTableGUI.php";
     $imp_table = new ilImportantPagesTableGUI($this, "editImportantPages");
     $tpl->setContent($imp_table->getHTML());
 }
Ejemplo n.º 3
0
 /**
  * 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->setRatingOverall($this->getRatingOverall());
     $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->hideAdvancedMetadata($page->isAdvancedMetadataHidden());
         $new_page->create();
         $page->copy($new_page->getId(), "", 0, true);
         //$new_page->setXMLContent($page->copyXMLContent(true));
         //$new_page->buildDom(true);
         //$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;
 }
 /**
  * Fill data section
  */
 function fillDataSection()
 {
     global $ilCtrl, $lng, $ilAccess;
     $tpl = new ilTemplate("tpl.wiki_imp_pages_block.html", true, true, "Modules/Wiki");
     $cpar[0] = $cpar[1] = 0;
     include_once "./Services/UIComponent/NestedList/classes/class.ilNestedList.php";
     $list = new ilNestedList();
     $list->setItemClass("ilWikiBlockItem");
     $list->setListClass("ilWikiBlockList");
     $list->setListClass("ilWikiBlockListNoIndent", 1);
     $cnt = 1;
     if (!$this->export) {
         $list->addListNode("<p class='small'><a href='" . $ilCtrl->getLinkTargetByClass("ilobjwikigui", "gotoStartPage") . "'>" . $lng->txt("wiki_start_page") . "</a></p>", 1, 0);
     } else {
         $list->addListNode("<p class='small'><a href='" . "index.html" . "'>" . $lng->txt("wiki_start_page") . "</a></p>", 1, 0);
     }
     $cpar[0] = 1;
     $ipages = ilObjWiki::_lookupImportantPagesList(ilObject::_lookupObjId($_GET["ref_id"]));
     foreach ($ipages as $p) {
         $cnt++;
         $title = ilWikiPage::lookupTitle($p["page_id"]);
         if (!$this->export) {
             $list->addListNode("<p class='small'><a href='" . ilObjWikiGUI::getGotoLink($_GET["ref_id"], $title) . "'>" . $title . "</a></p>", $cnt, (int) $cpar[$p["indent"] - 1]);
         } else {
             $list->addListNode("<p class='small'><a href='" . "wpg_" . $p["page_id"] . ".html" . "'>" . $title . "</a></p>", $cnt, (int) $cpar[$p["indent"] - 1]);
         }
         $cpar[$p["indent"]] = $cnt;
     }
     $this->setDataSection($list->getHTML());
     return;
     // old style
     // the start page
     $tpl->setCurrentBlock("item");
     $title = ilWikiPage::lookupTitle($p["page_id"]);
     $tpl->setVariable("ITEM_TITLE", $lng->txt("wiki_start_page"));
     $tpl->setVariable("PAD", (int) 5 + 0 * 20);
     $tpl->setVariable("ITEM_HREF", $ilCtrl->getLinkTargetByClass("ilobjwikigui", "gotoStartPage"));
     $tpl->parseCurrentBlock();
     $ipages = ilObjWiki::_lookupImportantPagesList(ilObject::_lookupObjId($_GET["ref_id"]));
     foreach ($ipages as $p) {
         $tpl->setCurrentBlock("item");
         $title = ilWikiPage::lookupTitle($p["page_id"]);
         $tpl->setVariable("ITEM_TITLE", $title);
         $tpl->setVariable("PAD", (int) 5 + $p["indent"] * 20);
         $tpl->setVariable("ITEM_HREF", ilObjWikiGUI::getGotoLink($_GET["ref_id"], $title));
         $tpl->parseCurrentBlock();
     }
     $this->setDataSection($tpl->get());
 }