/** * Object specific configuration * * @param int $a_obj_id object id */ function configureByObjectId($a_obj_id) { if ($a_obj_id > 0) { include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; $this->setEnablePageToc(ilObjWiki::_lookupPageToc($a_obj_id)); } }
/** * execute command */ function &executeCommand() { global $lng, $ilAccess, $tpl, $ilNavigationHistory; $cmd = $this->ctrl->getCmd(); $next_class = $this->ctrl->getNextClass($this); if ($next_class == "") { $this->ctrl->setCmdClass("ilobjwikigui"); $next_class = $this->ctrl->getNextClass($this); } // add entry to navigation history if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) { $obj_id = ilObject::_lookupObjId($_GET["ref_id"]); $title = ilObject::_lookupTitle($obj_id); if ($_GET["page"] != "") { $page = $_GET["page"]; } else { include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; $page = ilObjWiki::_lookupStartPage($obj_id); } include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; if (ilWikiPage::exists($obj_id, $page)) { include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $add = "_" . rawurlencode($page); $page_id = ilWikiPage::getPageIdForTitle($obj_id, $page); $ptitle = ilWikiPage::lookupTitle($page_id); $title .= ": " . $ptitle; $append = $_GET["page"] != "" ? "_" . ilWikiUtil::makeUrlTitle($page) : ""; include_once './Services/Link/classes/class.ilLink.php'; $goto = ilLink::_getStaticLink($_GET["ref_id"], "wiki", true, $append); //var_dump($goto); $ilNavigationHistory->addItem($_GET["ref_id"], "./goto.php?target=wiki_" . $_GET["ref_id"] . $add, "wiki", $title, $page_id, $goto); } } switch ($next_class) { case 'ilobjwikigui': require_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php"; $mc_gui =& new ilObjWikiGUI("", (int) $_GET["ref_id"], true, false); $this->ctrl->forwardCommand($mc_gui); break; } $tpl->show(); }
/** * 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")); }
static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null) { global $ilUser, $ilObjDataCache, $ilAccess; include_once "./Services/Notification/classes/class.ilNotification.php"; include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id); $wiki = new ilObjWiki($a_wiki_ref_id, true); $page = new ilWikiPage($a_page_id); // #11138 $ignore_threshold = $a_action == "comment"; // 1st update will be converted to new - see below if ($a_action == "new") { return; } if ($a_type == ilNotification::TYPE_WIKI_PAGE) { $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold); $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); $users = array_merge($users, $wiki_users); if (!sizeof($users)) { return; } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users); } else { $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); if (!sizeof($users)) { return; } } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id); // #15192 - should always be present if ($a_page_id) { include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php"; $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle()); } else { include_once "./Services/Link/classes/class.ilLink.php"; $link = ilLink::_getLink($a_wiki_ref_id); } include_once "./Services/Mail/classes/class.ilMail.php"; include_once "./Services/User/classes/class.ilObjUser.php"; include_once "./Services/Language/classes/class.ilLanguageFactory.php"; include_once "./Services/User/classes/class.ilUserUtil.php"; // see ilBlogPostingGUI::getSnippet() // see ilBlogPosting::getNotificationAbstract() include_once "Modules/Wiki/classes/class.ilWikiPageGUI.php"; $pgui = new ilWikiPageGUI($page->getId()); $pgui->setRawPageContent(true); $pgui->setAbstractOnly(true); $pgui->setFileDownloadLink("."); $pgui->setFullscreenLink("."); $pgui->setSourcecodeDownloadScript("."); $snippet = $pgui->showPage(); $snippet = ilPageObject::truncateHTML($snippet, 500, "..."); // making things more readable $snippet = str_replace('<br/>', "\n", $snippet); $snippet = str_replace('<br />', "\n", $snippet); $snippet = str_replace('</p>', "\n", $snippet); $snippet = str_replace('</div>', "\n", $snippet); $snippet = trim(strip_tags($snippet)); // "fake" new (to enable snippet - if any) $current_version = array_shift($page->getHistoryEntries()); $current_version = $current_version["nr"]; if (!$current_version) { $a_type = ilNotification::TYPE_WIKI; $a_action = "new"; } foreach (array_unique($users) as $idx => $user_id) { if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) { // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('wiki'); $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle()); $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n"; if ($a_type == ilNotification::TYPE_WIKI_PAGE) { // update/delete $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n"; if ($snippet) { $message .= "\n" . $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n"; } // include comment/note text if ($a_comment) { $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n"; } $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link; } else { // new $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n"; if ($snippet) { $message .= $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n\n"; } $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link; } $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system")); } else { unset($users[$idx]); } } }
/** * View wiki page. */ function preview() { global $ilCtrl, $ilAccess, $lng, $tpl, $ilUser, $ilSetting, $ilToolbar; // block/unblock if ($this->getPageObject()->getBlocked()) { ilUtil::sendInfo($lng->txt("wiki_page_status_blocked")); } $this->increaseViewCount(); $this->addHeaderAction(); // content $this->setSideBlock(); $wtpl = new ilTemplate("tpl.wiki_page_view_main_column.html", true, true, "Modules/Wiki"); $callback = array($this, "observeNoteAction"); // notes if (!$ilSetting->get("disable_comments") && ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId())) { $wtpl->setVariable("NOTES", $this->getNotesHTML($this->getPageObject(), true, ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()), $ilAccess->checkAccess("write", "", $_GET["ref_id"]), $callback)); } // permanent link $append = $_GET["page"] != "" ? "_" . ilWikiUtil::makeUrlTitle($_GET["page"]) : ""; include_once "./Services/PermanentLink/classes/class.ilPermanentLinkGUI.php"; $perma_link = new ilPermanentLinkGUI("wiki", $_GET["ref_id"], $append); $wtpl->setVariable("PERMA_LINK", $perma_link->getHTML()); // page content $this->setOutputMode(IL_PAGE_PRESENTATION); $this->setRenderPageContainer(true); $wtpl->setVariable("PAGE", $this->showPage()); $tpl->setLoginTargetPar("wiki_" . $_GET["ref_id"] . $append); // last edited info include_once "./Services/User/classes/class.ilUserUtil.php"; $wtpl->setVariable("LAST_EDITED_INFO", $lng->txt("wiki_last_edited") . ": " . ilDatePresentation::formatDate(new ilDateTime($this->getPageObject()->getLastChange(), IL_CAL_DATETIME)) . ", " . ilUserUtil::getNamePresentation($this->getPageObject()->getLastChangeUser(), false, true, $ilCtrl->getLinkTarget($this, "preview"))); $tpl->setLoginTargetPar("wiki_" . $_GET["ref_id"] . $append); //highlighting if ($_GET["srcstring"] != "") { include_once './Services/Search/classes/class.ilUserSearchCache.php'; $cache = ilUserSearchCache::_getInstance($ilUser->getId()); $cache->switchSearchType(ilUserSearchCache::LAST_QUERY); $search_string = $cache->getQuery(); include_once "./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php"; include_once "./Services/Search/classes/class.ilQueryParser.php"; $p = new ilQueryParser($search_string); $p->parse(); $words = $p->getQuotedWords(); if (is_array($words)) { foreach ($words as $w) { ilTextHighlighterGUI::highlight("ilCOPageContent", $w, $tpl); } } $this->fill_on_load_code = true; } return $wtpl->get(); }
/** * Rename page */ function rename($a_new_name) { global $ilDB; // replace unallowed characters $a_new_name = str_replace(array("<", ">"), '', $a_new_name); // replace multiple whitespace characters by one single space $a_new_name = trim(preg_replace('!\\s+!', ' ', $a_new_name)); $page_title = ilWikiUtil::makeDbTitle($a_new_name); $pg_id = ilWikiPage::_getPageIdForWikiTitle($this->getWikiId(), $page_title); $xml_new_name = str_replace("&", "&", $a_new_name); if ($pg_id == 0 || $pg_id == $this->getId()) { include_once "./Services/COPage/classes/class.ilInternalLink.php"; $sources = ilInternalLink::_getSourcesOfTarget("wpg", $this->getId(), 0); foreach ($sources as $s) { if ($s["type"] == "wpg:pg") { $wpage = new ilWikiPage($s["id"]); $col = ilWikiUtil::processInternalLinks($wpage->getXmlContent(), 0, IL_WIKI_MODE_EXT_COLLECT); $new_content = $wpage->getXmlContent(); foreach ($col as $c) { // this complicated procedure is needed due to the fact // that depending on the collation e = é is true // in the (mysql) database // see bug http://www.ilias.de/mantis/view.php?id=11227 $t1 = ilWikiUtil::makeDbTitle($c["nt"]->mTextform); $t2 = ilWikiUtil::makeDbTitle($this->getTitle()); // this one replaces C2A0 ( ) by a usual space // otherwise the comparision will fail, since you // get these characters from tiny if more than one // space is repeated in a string. This may not be // 100% but we do not store $t1 anywhere and only // modify it for the comparison $t1 = preg_replace('/\\xC2\\xA0/', ' ', $t1); $t2 = preg_replace('/\\xC2\\xA0/', ' ', $t2); $set = $ilDB->query($q = "SELECT " . $ilDB->quote($t1, "text") . " = " . $ilDB->quote($t2, "text") . " isequal"); $rec = $ilDB->fetchAssoc($set); if ($rec["isequal"]) { $new_content = str_replace("[[" . $c["nt"]->mTextform . "]]", "[[" . $xml_new_name . "]]", $new_content); if ($c["text"] != "") { $new_content = str_replace("[[" . $c["text"] . "]]", "[[" . $xml_new_name . "]]", $new_content); } $add = $c["text"] != "" ? "|" . $c["text"] : ""; $new_content = str_replace("[[" . $c["nt"]->mTextform . $add . "]]", "[[" . $xml_new_name . $add . "]]", $new_content); } } $wpage->setXmlContent($new_content); //echo htmlentities($new_content); $wpage->update(); } } include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; if (ilObjWiki::_lookupStartPage($this->getWikiId()) == $this->getTitle()) { ilObjWiki::writeStartPage($this->getWikiId(), $a_new_name); } $this->setTitle($a_new_name); $this->update(); } return $a_new_name; }
/** * Fill data section */ function fillDataSection() { global $ilCtrl, $lng, $ilAccess; $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki"); $wp = $this->getPageObject(); // info $actions[] = array("txt" => $lng->txt("info_short"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")); // recent changes $actions[] = array("txt" => $lng->txt("wiki_recent_changes"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")); foreach ($actions as $a) { $tpl->setCurrentBlock("action"); $tpl->setVariable("HREF", $a["href"]); $tpl->setVariable("TXT", $a["txt"]); $tpl->parseCurrentBlock(); $tpl->touchBlock("item"); } $actions = array(); // all pages $actions[] = array("txt" => $lng->txt("wiki_all_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")); // new pages $actions[] = array("txt" => $lng->txt("wiki_new_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")); // popular pages $actions[] = array("txt" => $lng->txt("wiki_popular_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")); // orphaned pages $actions[] = array("txt" => $lng->txt("wiki_orphaned_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")); // page lists include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; $list = new ilAdvancedSelectionListGUI(); $list->setListTitle($lng->txt("wiki_page_lists")); $list->setStyle(ilAdvancedSelectionListGUI::STYLE_LINK); $list->setId("wiki_pglists"); foreach ($actions as $a) { $list->addItem($a["txt"], "", $a["href"]); } $tpl->setCurrentBlock("plain"); $tpl->setVariable("PLAIN", $list->getHTML()); $tpl->parseCurrentBlock(); $tpl->touchBlock("item"); // page actions $list = new ilAdvancedSelectionListGUI(); $list->setStyle(ilAdvancedSelectionListGUI::STYLE_LINK); $list->setListTitle($lng->txt("wiki_page_actions")); $list->setId("wiki_pgactions"); if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) { // rating if (ilObjWiki::_lookupRating($this->getPageObject()->getWikiId())) { if (!$this->getPageObject()->getRating()) { $list->addItem($lng->txt("wiki_activate_page_rating"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating")); } else { $list->addItem($lng->txt("wiki_deactivate_page_rating"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating")); } } // unhide advmd? include_once "./Modules/Wiki/classes/class.ilWikiAdvMetaDataBlockGUI.php"; if (ilWikiAdvMetaDataBlockGUI::isActive($this->getPageObject()->getWikiId()) && ilWikiPage::lookupAdvancedMetadataHidden($this->getPageObject()->getId())) { $list->addItem($lng->txt("wiki_unhide_meta_adv_records"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData")); } } if ($ilAccess->checkAccess("edit_content", "", $_GET["ref_id"]) && !$this->getPageObject()->getBlocked() || $ilAccess->checkAccess("write", "", $_GET["ref_id"])) { // rename $list->addItem($lng->txt("wiki_rename_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage")); } if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) { // block/unblock if ($this->getPageObject()->getBlocked()) { $list->addItem($lng->txt("wiki_unblock_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage")); } else { $list->addItem($lng->txt("wiki_block_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage")); } // delete page $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId()); if ($st_page != $this->getPageObject()->getTitle()) { $list->addItem($lng->txt("wiki_delete_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen")); } include_once "Modules/Wiki/classes/class.ilWikiPageTemplate.php"; $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId()); if (!$wpt->isPageTemplate($this->getPageObject()->getId())) { $list->addItem($lng->txt("wiki_add_template"), "", $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction")); } else { $list->addItem($lng->txt("wiki_remove_template_status"), "", $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction")); } } if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) || $ilAccess->checkAccess("read", "", $_GET["ref_id"])) { $tpl->setCurrentBlock("plain"); $tpl->setVariable("PLAIN", $list->getHTML()); $tpl->parseCurrentBlock(); $tpl->touchBlock("item"); } // permissions // if ($ilAccess->checkAccess('edit_permission', "", $_GET["ref_id"])) // { // $actions[] = array( // "txt" => $lng->txt("perm_settings"), // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm") // ); // } $actions = array(); // settings if ($ilAccess->checkAccess('write', "", $_GET["ref_id"])) { // $actions[] = array( // "txt" => $lng->txt("settings"), // "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings") // ); $actions[] = array("txt" => $lng->txt("wiki_contributors"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")); } // manage if ($ilAccess->checkAccess('write', "", $_GET["ref_id"])) { $actions[] = array("txt" => $lng->txt("settings"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")); } else { if ($ilAccess->checkAccess('statistics_read', "", $_GET["ref_id"])) { $actions[] = array("txt" => $lng->txt("statistics"), "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial")); } } foreach ($actions as $a) { $tpl->setCurrentBlock("action"); $tpl->setVariable("HREF", $a["href"]); $tpl->setVariable("TXT", $a["txt"]); $tpl->parseCurrentBlock(); $tpl->touchBlock("item"); } $this->setDataSection($tpl->get()); }
/** * 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()); }
static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null) { global $ilUser, $ilObjDataCache, $ilAccess; include_once "./Services/Notification/classes/class.ilNotification.php"; include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id); $wiki = new ilObjWiki($a_wiki_ref_id, true); $page = new ilWikiPage($a_page_id); // #11138 $ignore_threshold = $a_action == "comment"; if ($a_type == ilNotification::TYPE_WIKI_PAGE) { $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold); $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); $users = array_merge($users, $wiki_users); if (!sizeof($users)) { return; } include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php"; $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle()); ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users); } else { $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); if (!sizeof($users)) { return; } include_once "./Services/Link/classes/class.ilLink.php"; $link = ilLink::_getLink($a_wiki_ref_id); } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id); include_once "./Services/Mail/classes/class.ilMail.php"; include_once "./Services/User/classes/class.ilObjUser.php"; include_once "./Services/Language/classes/class.ilLanguageFactory.php"; include_once "./Services/User/classes/class.ilUserUtil.php"; foreach (array_unique($users) as $idx => $user_id) { if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) { // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('wiki'); $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle()); $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n"; if ($a_type == ilNotification::TYPE_WIKI_PAGE) { // update/delete $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n"; // include comment/note text if ($a_comment) { $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n"; } $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link; } else { // new $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n"; $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link; } $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system")); } else { unset($users[$idx]); } } }
/** * 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; } }
/** * 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; }
/** * Search wiki link list */ function searchWikiLinkAC() { global $lng; $lng->loadLanguageModule("wiki"); $tpl = new ilTemplate("tpl.wiki_ac_search_result.html", true, true, "Modules/Wiki"); $term = trim($_GET["term"]); $pages = ilObjWiki::_performSearch($this->getPageObject()->getParentId(), $term); $found = array(); foreach ($pages as $page) { $found[] = array("page_id" => $page["page_id"], "title" => ilWikiPage::lookupTitle($page["page_id"])); } // sort if all pages are listed if ($term == "") { $found = ilUtil::sortArray($found, "title", "asc"); } foreach ($found as $f) { $tpl->setCurrentBlock("item"); $tpl->setVariable("WIKI_TITLE", $f["title"]); $tpl->parseCurrentBlock(); } if (count($pages) == 0) { $tpl->setVariable("INFOTEXT", str_replace("\$1", $term, $lng->txt("wiki_no_page_found"))); } else { if ($term == '') { $tpl->setVariable("INFOTEXT", $lng->txt("wiki_no_search_term"), $term); } else { $tpl->setVariable("INFOTEXT", str_replace("\$1", $term, $lng->txt("wiki_pages_found"))); } } $tpl->setVariable("TXT_BACK", $lng->txt("back")); echo $tpl->get(); exit; }
/** * 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()); }