Ejemplo n.º 1
0
 function resolveIntLinks()
 {
     // resolve normal internal links
     $xpc = xpath_new_context($this->dom);
     $path = "//IntLink";
     $res =& xpath_eval($xpc, $path);
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $target = $res->nodeset[$i]->get_attribute("Target");
         $type = $res->nodeset[$i]->get_attribute("Type");
         $new_target = ilInternalLink::_getIdForImportId($type, $target);
         if ($new_target !== false) {
             $res->nodeset[$i]->set_attribute("Target", $new_target);
         } else {
             if (ilInternalLink::_extractInstOfTarget($target) == IL_INST_ID && IL_INST_ID > 0 && $type != "RepositoryItem") {
                 $new_target = ilInternalLink::_removeInstFromTarget($target);
                 if (ilInternalLink::_exists($type, $new_target)) {
                     $res->nodeset[$i]->set_attribute("Target", $new_target);
                 }
             }
         }
     }
     unset($xpc);
     // resolve internal links in map areas
     $xpc = xpath_new_context($this->dom);
     $path = "//MediaAlias";
     $res =& xpath_eval($xpc, $path);
     //echo "<br><b>page::resolve</b><br>";
     //echo "Content:".htmlentities($this->getXMLFromDOM()).":<br>";
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $orig_id = $res->nodeset[$i]->get_attribute("OriginId");
         $id_arr = explode("_", $orig_id);
         $mob_id = $id_arr[count($id_arr) - 1];
         ilMediaItem::_resolveMapAreaLinks($mob_id);
     }
 }
 /**
  * parse pages that contain files, mobs and/or internal links
  */
 function processPagesToParse()
 {
     /*
     		$pg_mapping = array();
     		foreach($this->pg_mapping as $key => $value)
     		{
     			$pg_mapping[$key] = "il__pg_".$value;
     		}*/
     //echo "<br><b>processIntLinks</b>"; flush();
     // outgoin internal links
     foreach ($this->pages_to_parse as $page_id) {
         $page_arr = explode(":", $page_id);
         //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
         switch ($page_arr[0]) {
             case "lm":
                 $page_obj =& new ilPageObject($this->content_object->getType(), $page_arr[1]);
                 break;
             case "gdf":
                 $page_obj =& new ilPageObject("gdf", $page_arr[1]);
                 break;
         }
         $page_obj->buildDom();
         $page_obj->resolveIntLinks();
         $page_obj->resolveIIMMediaAliases($this->mob_mapping);
         if (in_array($this->coType, array("lm", "dbk"))) {
             $page_obj->resolveQuestionReferences($this->qst_mapping);
         }
         $page_obj->update(false);
         if ($page_arr[0] == "gdf") {
             $def =& new ilGlossaryDefinition($page_arr[1]);
             $def->updateShortText();
         }
         unset($page_obj);
     }
     //echo "<br><b>map area internal links</b>"; flush();
     // outgoins map area (mob) internal links
     foreach ($this->mobs_with_int_links as $mob_id) {
         ilMediaItem::_resolveMapAreaLinks($mob_id);
     }
     //echo "<br><b>incoming interna links</b>"; flush();
     // incoming internal links
     $done = array();
     foreach ($this->link_targets as $link_target) {
         //echo "doin link target:".$link_target.":<br>";
         $link_arr = explode("_", $link_target);
         $target_inst = $link_arr[1];
         $target_type = $link_arr[2];
         $target_id = $link_arr[3];
         $sources = ilInternalLink::_getSourcesOfTarget($target_type, $target_id, $target_inst);
         foreach ($sources as $key => $source) {
             //echo "got source:".$key.":<br>";
             if (in_array($key, $done)) {
                 continue;
             }
             $type_arr = explode(":", $source["type"]);
             // content object pages
             if ($type_arr[1] == "pg") {
                 $page_object = new ilPageObject($type_arr[0], $source["id"]);
                 $page_object->buildDom();
                 $page_object->resolveIntLinks();
                 $page_object->update();
                 unset($page_object);
             }
             // eventually correct links in questions to learning modules
             if ($type_arr[0] == "qst") {
                 require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 assQuestion::_resolveIntLinks($source["id"]);
             }
             // eventually correct links in survey questions to learning modules
             if ($type_arr[0] == "sqst") {
                 require_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                 SurveyQuestion::_resolveIntLinks($source["id"]);
             }
             $done[$key] = $key;
         }
     }
 }