/**
  * Set standard link xml
  */
 function setDefaultLinkXml()
 {
     global $ilCtrl;
     $int_links = $this->getPageObject()->getInternalLinks();
     //var_dump($int_links);
     $link_info = "<IntLinkInfos>";
     $targetframe = "None";
     foreach ($int_links as $int_link) {
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             $ltarget = "_top";
             if ($targetframe != "None") {
                 $ltarget = "_blank";
             }
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             $href = "";
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     break;
                 case "GlossaryItem":
                     if ($targetframe == "None") {
                         $targetframe = "Glossary";
                     }
                     $href = "./goto.php?target=git_" . $target_id;
                     break;
                 case "MediaObject":
                     $ilCtrl->setParameter($this, "mob_id", $target_id);
                     //$ilCtrl->setParameter($this, "pg_id", $this->obj->getId());
                     $href = $ilCtrl->getLinkTarget($this, "displayMedia");
                     $ilCtrl->setParameter($this, "mob_id", "");
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . $anc_par . " " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" />";
         }
     }
     $link_info .= "</IntLinkInfos>";
     $this->setLinkXML($link_info);
 }
 /**
  * get xml for links
  */
 function getLinkXML($a_int_links, $a_layoutframes)
 {
     global $ilCtrl;
     // Determine whether the view of a learning resource should
     // be shown in the frameset of ilias, or in a separate window.
     $showViewInFrameset = true;
     if ($a_layoutframes == "") {
         $a_layoutframes = array();
     }
     $link_info = "<IntLinkInfos>";
     foreach ($a_int_links as $int_link) {
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     if ($lm_id == $this->lm->getId() || $targetframe != "None" && $targetframe != "New") {
                         $ltarget = $a_layoutframes[$targetframe]["Frame"];
                         //$nframe = ($ltarget == "")
                         //	? $_GET["frame"]
                         //	: $ltarget;
                         $nframe = $ltarget == "" ? "" : $ltarget;
                         if ($ltarget == "") {
                             if ($showViewInFrameset) {
                                 $ltarget = "_parent";
                             } else {
                                 $ltarget = "_top";
                             }
                         }
                         // scorm always in 1window view and link target
                         // is always same frame
                         if ($this->getExportFormat() == "scorm" && $this->offlineMode()) {
                             $ltarget = "";
                         }
                         $href = $this->getLink($_GET["ref_id"], "layout", $target_id, $nframe, $type, "append", $anc);
                     } else {
                         if (!$this->offlineMode()) {
                             if ($type == "PageObject") {
                                 $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                             } else {
                                 $href = "./goto.php?target=st_" . $target_id;
                             }
                         } else {
                             if ($type == "PageObject") {
                                 $href = ILIAS_HTTP_PATH . "/goto.php?target=pg_" . $target_id . $anc_add . "&amp;client_id=" . CLIENT_ID;
                             } else {
                                 $href = ILIAS_HTTP_PATH . "/goto.php?target=st_" . $target_id . "&amp;client_id=" . CLIENT_ID;
                             }
                         }
                         if ($targetframe != "New") {
                             $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
                         } else {
                             $ltarget = "_blank";
                         }
                     }
                     break;
                 case "GlossaryItem":
                     if ($targetframe == "None") {
                         $targetframe = "Glossary";
                     }
                     $ltarget = $a_layoutframes[$targetframe]["Frame"];
                     $nframe = $ltarget == "" ? $_GET["frame"] : $ltarget;
                     $href = $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
                     break;
                 case "MediaObject":
                     $ltarget = $a_layoutframes[$targetframe]["Frame"];
                     $nframe = $ltarget == "" ? $_GET["frame"] : $ltarget;
                     $href = $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     if (!$this->offlineMode()) {
                         $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     } else {
                         $href = ILIAS_HTTP_PATH . "/goto.php?target=" . $obj_type . "_" . $target_id . "&amp;client_id=" . CLIENT_ID;
                     }
                     $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
                 case "File":
                     if (!$this->offlineMode()) {
                         $ilCtrl->setParameter($this, "file_id", "il__file_" . $target_id);
                         $href = $ilCtrl->getLinkTarget($this, "downloadFile");
                         $ilCtrl->setParameter($this, "file_id", "");
                     }
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" {$anc_par}/>";
             // set equal link info for glossary links of target "None" and "Glossary"
             /*
             				if ($targetframe=="None" && $type=="GlossaryItem")
             				{
             					$link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
             						"TargetFrame=\"Glossary\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
             				}*/
         }
     }
     $link_info .= "</IntLinkInfos>";
     return $link_info;
 }
 /**
  * get link targets
  */
 function getLinkXML($a_int_links)
 {
     if ($a_layoutframes == "") {
         $a_layoutframes = array();
     }
     $link_info = "<IntLinkInfos>";
     foreach ($a_int_links as $int_link) {
         //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             if ($targetframe == "New") {
                 $ltarget = "_blank";
             } else {
                 $ltarget = "";
             }
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     $cont_obj =& $this->content_object;
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     //$ltarget = "ilContObj".$lm_id;
                     break;
                 case "GlossaryItem":
                     if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId()) {
                         if ($this->offlineMode()) {
                             $href = "term_" . $target_id . ".html";
                         } else {
                             $this->ctrl->setParameter($this, "term_id", $target_id);
                             $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
                             $href = str_replace("&", "&amp;", $href);
                         }
                     } else {
                         $href = "./goto.php?target=git_" . $target_id;
                     }
                     break;
                 case "MediaObject":
                     if ($this->offlineMode()) {
                         $href = "media_" . $target_id . ".html";
                     } else {
                         $this->ctrl->setParameter($this, "obj_type", $type);
                         $this->ctrl->setParameter($this, "mob_id", $target_id);
                         $href = $this->ctrl->getLinkTarget($this, "media");
                         $href = str_replace("&", "&amp;", $href);
                     }
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
                     $ltarget = $t_frame;
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" {$anc_par}/>";
             $this->ctrl->clearParameters($this);
         }
     }
     $link_info .= "</IntLinkInfos>";
     return $link_info;
 }