예제 #1
0
 /**
  * save internal links of page
  *
  * @param	string		xml page code
  */
 function saveInternalLinks($a_domdoc)
 {
     global $ilDB;
     // *** STEP 1: Standard Processing ***
     parent::saveInternalLinks($a_domdoc);
     // *** STEP 2: Other Pages -> This Page ***
     // Check, whether ANOTHER page links to this page as a "missing" page
     // (this is the case, when this page is created newly)
     $set = $ilDB->queryF("SELECT * FROM il_wiki_missing_page WHERE " . " wiki_id = %s AND target_name = %s", array("integer", "text"), array($this->getWikiId(), ilWikiUtil::makeDbTitle($this->getTitle())));
     while ($anmiss = $ilDB->fetchAssoc($set)) {
         //echo "adding link";
         ilInternalLink::_saveLink("wpg:pg", $anmiss["source_id"], "wpg", $this->getId(), 0);
     }
     //exit;
     // now remove the missing page entries
     $ilDB->manipulateF("DELETE FROM il_wiki_missing_page WHERE " . " wiki_id = %s AND target_name = %s", array("integer", "text"), array($this->getWikiId(), $this->getTitle()));
     // *** STEP 3: This Page -> Other Pages ***
     // remove the exising "missing page" links for THIS page (they will be re-inserted below)
     $ilDB->manipulateF("DELETE FROM il_wiki_missing_page WHERE " . " wiki_id = %s AND source_id = %s", array("integer", "integer"), array($this->getWikiId(), $this->getId()));
     // collect the wiki links of the page
     include_once "./Modules/Wiki/classes/class.ilWikiUtil.php";
     $xml = $a_domdoc->saveXML();
     $int_wiki_links = ilWikiUtil::collectInternalLinks($xml, $this->getWikiId(), true);
     foreach ($int_wiki_links as $wlink) {
         $page_id = ilWikiPage::_getPageIdForWikiTitle($this->getWikiId(), $wlink);
         if ($page_id > 0) {
             ilInternalLink::_saveLink("wpg:pg", $this->getId(), "wpg", $page_id, 0);
         } else {
             $ilDB->manipulateF("DELETE FROM il_wiki_missing_page WHERE" . " wiki_id = %s AND source_id = %s AND target_name = %s", array("integer", "integer", "text"), array($this->getWikiId(), $this->getId(), $wlink));
             $ilDB->manipulateF("INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)" . " VALUES (%s,%s,%s)", array("integer", "integer", "text"), array($this->getWikiId(), $this->getId(), $wlink));
         }
     }
 }