Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
 /**
  * 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("&", "&amp;", $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 (&nbsp;) 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());
 }
Ejemplo n.º 4
0
 /**
  * Get goto link
  */
 static function getGotoLink($a_ref_id, $a_page = "")
 {
     if ($a_page == "") {
         $a_page = ilObjWiki::_lookupStartPage(ilObject::_lookupObjId($a_ref_id));
     }
     $goto = "goto.php?target=wiki_" . $a_ref_id . "_" . ilWikiUtil::makeUrlTitle($a_page);
     return $goto;
 }
 /**
  * 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;
     $title = ilObjWiki::_lookupStartPage(ilObject::_lookupObjId($_GET["ref_id"]));
     if (!$this->export) {
         $list->addListNode("<p class='small'><a href='" . $ilCtrl->getLinkTargetByClass("ilobjwikigui", "gotoStartPage") . "'>" . $title . "</a></p>", 1, 0);
     } else {
         $list->addListNode("<p class='small'><a href='" . "index.html" . "'>" . $title . "</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());
 }