예제 #1
0
 function saveInternalLinks($a_domdoc)
 {
     global $ilDB;
     $this->deleteInternalLinks();
     // query IntLink elements
     $xpath = new DOMXPath($a_domdoc);
     $nodes = $xpath->query('//IntLink');
     foreach ($nodes as $node) {
         $link_type = $node->getAttribute("Type");
         switch ($link_type) {
             case "StructureObject":
                 $t_type = "st";
                 break;
             case "PageObject":
                 $t_type = "pg";
                 break;
             case "GlossaryItem":
                 $t_type = "git";
                 break;
             case "MediaObject":
                 $t_type = "mob";
                 break;
             case "RepositoryItem":
                 $t_type = "obj";
                 break;
             case "File":
                 $t_type = "file";
                 break;
             case "WikiPage":
                 $t_type = "wpage";
                 break;
         }
         $target = $node->getAttribute("Target");
         $target_arr = explode("_", $target);
         $t_id = $target_arr[count($target_arr) - 1];
         // link to other internal object
         if (is_int(strpos($target, "__"))) {
             $t_inst = 0;
         } else {
             $t_inst = $target_arr[1];
         }
         if ($t_id > 0) {
             ilInternalLink::_saveLink($this->getParentType() . ":pg", $this->getId(), $t_type, $t_id, $t_inst, $this->getLanguage());
         }
     }
 }
예제 #2
0
 function _resolveIntLinks($question_id)
 {
     global $ilDB;
     $resolvedlinks = 0;
     $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s", array('integer'), array($question_id));
     if ($result->numRows()) {
         while ($row = $ilDB->fetchAssoc($result)) {
             $internal_link = $row["internal_link"];
             include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
             $resolved_link = SurveyQuestion::_resolveInternalLink($internal_link);
             if (strcmp($internal_link, $resolved_link) != 0) {
                 // internal link was resolved successfully
                 $affectedRows = $ilDB->manipulateF("UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s", array('text', 'integer', 'integer'), array($resolved_link, time(), $row["material_id"]));
                 $resolvedlinks++;
             }
         }
     }
     if ($resolvedlinks) {
         // there are resolved links -> reenter theses links to the database
         // delete all internal links from the database
         include_once "./Services/Link/classes/class.ilInternalLink.php";
         ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
         $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s", array('integer'), array($question_id));
         if ($result->numRows()) {
             while ($row = $ilDB->fetchAssoc($result)) {
                 if (preg_match("/il_(\\d*?)_(\\w+)_(\\d+)/", $row["internal_link"], $matches)) {
                     ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
                 }
             }
         }
     }
 }
예제 #3
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));
         }
     }
 }
 /**
  * save internal links of page
  *
  * @param	string		xml page code
  */
 function saveInternalLinks($a_xml)
 {
     global $ilDB;
     //echo "<br>PageObject::saveInternalLinks[".$this->getId()."]";
     $doc = domxml_open_mem($a_xml);
     include_once "./Services/COPage/classes/class.ilInternalLink.php";
     ilInternalLink::_deleteAllLinksOfSource($this->getParentType() . ":pg", $this->getId());
     // get all internal links
     $xpc = xpath_new_context($doc);
     $path = "//IntLink";
     $res =& xpath_eval($xpc, $path);
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $link_type = $res->nodeset[$i]->get_attribute("Type");
         switch ($link_type) {
             case "StructureObject":
                 $t_type = "st";
                 break;
             case "PageObject":
                 $t_type = "pg";
                 break;
             case "GlossaryItem":
                 $t_type = "git";
                 break;
             case "MediaObject":
                 $t_type = "mob";
                 break;
             case "RepositoryItem":
                 $t_type = "obj";
                 break;
             case "File":
                 $t_type = "file";
                 break;
         }
         $target = $res->nodeset[$i]->get_attribute("Target");
         $target_arr = explode("_", $target);
         $t_id = $target_arr[count($target_arr) - 1];
         // link to other internal object
         if (is_int(strpos($target, "__"))) {
             $t_inst = 0;
         } else {
             $t_inst = $target_arr[1];
         }
         if ($t_id > 0) {
             ilInternalLink::_saveLink($this->getParentType() . ":pg", $this->getId(), $t_type, $t_id, $t_inst);
         }
     }
     // *** STEP 2: Save question references of page ***
     // delete all reference records
     $ilDB->manipulateF("DELETE FROM page_question WHERE page_parent_type = %s " . " AND page_id = %s", array("text", "integer"), array($this->getParentType(), $this->getId()));
     // save question references of page
     $doc = domxml_open_mem($a_xml);
     $xpc = xpath_new_context($doc);
     $path = "//Question";
     $res = xpath_eval($xpc, $path);
     $q_ids = array();
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $q_ref = $res->nodeset[$i]->get_attribute("QRef");
         $inst_id = ilInternalLink::_extractInstOfTarget($q_ref);
         if (!($inst_id > 0)) {
             $q_id = ilInternalLink::_extractObjIdOfTarget($q_ref);
             if ($q_id > 0) {
                 $q_ids[$q_id] = $q_id;
             }
         }
     }
     foreach ($q_ids as $qid) {
         $ilDB->manipulateF("INSERT INTO page_question (page_parent_type, page_id, question_id)" . " VALUES (%s,%s,%s)", array("text", "integer", "integer"), array($this->getParentType(), $this->getId(), $qid));
     }
 }