/** * Rename page */ public function renamePage() { global $tpl, $lng, $ilCtrl, $ilAccess; $this->initRenameForm(); if ($this->form->checkInput()) { if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) { $new_name = $this->form->getInput("new_page_name"); $page_title = ilWikiUtil::makeDbTitle($new_name); $pg_id = ilWikiPage::_getPageIdForWikiTitle($this->getPageObject()->getWikiId(), $page_title); // we might get the same page id back here, if the page // name only differs in diacritics // see bug http://www.ilias.de/mantis/view.php?id=11226 if ($pg_id > 0 && $pg_id != $this->getPageObject()->getId()) { ilUtil::sendFailure($lng->txt("wiki_page_already_exists")); } else { $new_name = $this->getPageObject()->rename($new_name); $ilCtrl->setParameterByClass("ilobjwikigui", "page", ilWikiUtil::makeUrlTitle($new_name)); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $ilCtrl->redirect($this, "preview"); } } } $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); }
/** * Make a wiki link, the following formats are supported: * * [[Page Title]] * [[Page Title|Presentation Text]] * [[Page Title#Anchor]] * [[Page Title#Anchor|Presentation Text]] * [[#Anchor|Presentation Text]] (link to anchor on same wiki page) */ static function makeLink(&$nt, $a_wiki_id, $text = '', $query = '', $trail = '', $prefix = '', $a_offline = false) { global $ilCtrl; //wfProfileIn( __METHOD__ ); if (!is_object($nt)) { # Fail gracefully $retVal = "<!-- ERROR -->{$prefix}{$text}{$trail}"; } else { //var_dump($trail); //var_dump($nt); // remove anchor from text, define anchor $anc = ""; if ($nt->mFragment != "") { if (substr($text, strlen($text) - strlen("#" . $nt->mFragment)) == "#" . $nt->mFragment) { $text = substr($text, 0, strlen($text) - strlen("#" . $nt->mFragment)); $anc = "#" . $nt->mFragment; } else { $anc = "#" . $nt->mFragment; } } # Separate the link trail from the rest of the link // outcommented due to bug #14590 // list( $inside, $trail ) = ilWikiUtil::splitTrail( $trail ); $retVal = '***' . $text . "***" . $trail; $url_title = ilWikiUtil::makeUrlTitle($nt->mTextform); $db_title = ilWikiUtil::makeDbTitle($nt->mTextform); if ($db_title != "") { $pg_exists = ilWikiPage::_wikiPageExists($a_wiki_id, $db_title); } else { // links on same page (only anchor used) $pg_exists = true; } //var_dump($nt); //var_dump($inside); //var_dump($trail); $wiki_link_class = !$pg_exists ? ' class="ilc_link_IntLink ilWikiPageMissing" ' : ' class="ilc_link_IntLink" '; if (!$a_offline) { if ($url_title != "") { $ilCtrl->setParameterByClass("ilobjwikigui", "page", $url_title); $retVal = '<a ' . $wiki_link_class . ' href="' . $ilCtrl->getLinkTargetByClass("ilobjwikigui", "gotoPage") . $anc . '">' . $text . '</a>' . $trail; $ilCtrl->setParameterByClass("ilobjwikigui", "page", $_GET["page"]); } else { $retVal = '<a ' . $wiki_link_class . ' href="' . $anc . '">' . $text . '</a>' . $trail; } } else { if ($pg_exists) { if ($db_title != "") { $pg_id = ilWikiPage::getIdForPageTitle($a_wiki_id, $db_title); $retVal = '<a ' . $wiki_link_class . ' href="' . "wpg_" . $pg_id . ".html" . $anc . '">' . $text . '</a>' . $trail; } else { $retVal = '<a ' . $wiki_link_class . ' href="' . $anc . '">' . $text . '</a>' . $trail; } } else { $retVal = $text . $trail; } } //$ilCtrl->debug("ilWikiUtil::makeLink:-$inside-$trail-"); /* if ( $nt->isExternal() ) { $nr = array_push( $this->mInterwikiLinkHolders['texts'], $prefix.$text.$inside ); $this->mInterwikiLinkHolders['titles'][] = $nt; $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}"; } else { $nr = array_push( $this->mLinkHolders['namespaces'], $nt->getNamespace() ); $this->mLinkHolders['dbkeys'][] = $nt->getDBkey(); $this->mLinkHolders['queries'][] = $query; $this->mLinkHolders['texts'][] = $prefix.$text.$inside; $this->mLinkHolders['titles'][] = $nt; $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}"; } */ } //wfProfileOut( __METHOD__ ); //echo "<br>".$retVal; exit; return $retVal; }
/** * 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; }
/** * 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 { if (!$this->object->getTemplateSelectionOnCreation()) { $this->object->createWikiPage($a_page); // redirect to newly created page $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle($a_page)); $ilCtrl->redirectByClass("ilwikipagegui", "edit"); } else { $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"])); $ilCtrl->setParameter($this, "from_page", ilWikiUtil::makeUrlTitle($_GET["from_page"])); $ilCtrl->redirect($this, "showTemplateSelection"); } } }
/** * 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; }
/** * 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"); } }
/** * Write start page */ static function writeStartPage($a_id, $a_name) { global $ilDB; include_once "./Modules/Wiki/classes/class.ilWikiUtil.php"; $ilDB->manipulate("UPDATE il_wiki_data SET " . " startpage = " . $ilDB->quote(ilWikiUtil::makeDbTitle($a_name), "text") . " WHERE id = " . $ilDB->quote($a_id, "integer")); }