/**
  * output media
  */
 function ilMedia()
 {
     global $ilUser;
     $this->tpl->setCurrentBlock("ContentStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
     } else {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
     }
     $this->tpl->parseCurrentBlock();
     $this->renderPageTitle();
     // set style sheets
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     } else {
         $style_name = $ilUser->getPref("style") . ".css";
         $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
     }
     $this->tpl->setCurrentBlock("ilMedia");
     //$int_links = $page_object->getInternalLinks();
     $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
     $link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
     $link_xml .= $this->getLinkTargetsXML();
     //echo "<br><br>".htmlentities($link_xml);
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $media_obj = new ilObjMediaObject($_GET["mob_id"]);
     if (!empty($_GET["pg_id"])) {
         require_once "./Modules/LearningModule/classes/class.ilLMPage.php";
         $pg_obj = $this->getLMPage($_GET["pg_id"]);
         $pg_obj->buildDom();
         $xml = "<dummy>";
         // todo: we get always the first alias now (problem if mob is used multiple
         // times in page)
         $xml .= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= $link_xml;
         $xml .= "</dummy>";
     } else {
         $xml = "<dummy>";
         // todo: we get always the first alias now (problem if mob is used multiple
         // times in page)
         $xml .= $media_obj->getXML(IL_MODE_ALIAS);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= $link_xml;
         $xml .= "</dummy>";
     }
     //echo htmlentities($xml); exit;
     // todo: utf-header should be set globally
     //header('Content-type: text/html; charset=UTF-8');
     $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
     $args = array('/_xml' => $xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     //echo "<b>XML:</b>".htmlentities($xml);
     // determine target frames for internal links
     //$pg_frame = $_GET["frame"];
     if (!$this->offlineMode()) {
         $wb_path = ilUtil::getWebspaceDir("output") . "/";
     } else {
         $wb_path = "";
     }
     $mode = $_GET["cmd"] == "fullscreen" ? "fullscreen" : "media";
     $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output", $this->offlineMode());
     $fullscreen_link = $this->getLink($this->lm->getRefId(), "fullscreen");
     $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path, 'link_params' => "ref_id=" . $this->lm->getRefId(), 'fullscreen_link' => $fullscreen_link, 'ref_id' => $this->lm->getRefId(), 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     echo xslt_error($xh);
     xslt_free($xh);
     // unmask user html
     $this->tpl->setVariable("MEDIA_CONTENT", $output);
     // add js
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php";
     ilObjMediaObjectGUI::includePresentationJS($this->tpl);
 }
 /**
  * Export media object to html
  */
 function exportHTMLMOB($a_mob_id, &$a_linked_mobs)
 {
     global $tpl;
     $source_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $a_mob_id;
     if (@is_dir($source_dir)) {
         ilUtil::makeDir($this->mobs_dir . "/mm_" . $a_mob_id);
         ilUtil::rCopy($source_dir, $this->mobs_dir . "/mm_" . $a_mob_id);
     }
     // #12930 - fullscreen
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mob_obj = new ilObjMediaObject($a_mob_id);
     if ($mob_obj->hasFullscreenItem()) {
         // render media object html
         $xh = xslt_create();
         $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, array("/_xml" => "<dummy>" . $mob_obj->getXML(IL_MODE_ALIAS) . $mob_obj->getXML(IL_MODE_OUTPUT) . "</dummy>", "/_xsl" => file_get_contents("./Services/COPage/xsl/page.xsl")), array("mode" => "fullscreen"));
         xslt_free($xh);
         unset($xh);
         // render fullscreen html
         $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
         $tpl = $this->getPreparedMainTemplate($tpl);
         // adds js/css
         $tpl->setCurrentBlock("ilMedia");
         $tpl->setVariable("MEDIA_CONTENT", $output);
         $output = $tpl->get();
         unset($tpl);
         // write file
         $file = $this->exp_dir . "/fullscreen_" . $a_mob_id . ".html";
         if (!($fp = @fopen($file, "w+"))) {
             die("<b>Error</b>: Could not open \"" . $file . "\" for writing" . " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
         }
         chmod($file, 0770);
         fwrite($fp, $output);
         fclose($fp);
         unset($fp);
         unset($output);
     }
     $linked_mobs = $mob_obj->getLinkedMediaObjects();
     $a_linked_mobs = array_merge($a_linked_mobs, $linked_mobs);
 }
 /**
  * Display media
  */
 function displayMedia($a_fullscreen = false)
 {
     $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
     $tpl->setCurrentBlock("ilMedia");
     //$int_links = $page_object->getInternalLinks();
     $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
     // @todo
     //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $media_obj = new ilObjMediaObject($_GET["mob_id"]);
     require_once "./Services/COPage/classes/class.ilPageObject.php";
     $pg_obj = $this->getPageObject();
     $pg_obj->buildDom();
     if (!empty($_GET["pg_id"])) {
         $xml = "<dummy>";
         $xml .= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= $link_xml;
         $xml .= "</dummy>";
     } else {
         $xml = "<dummy>";
         $xml .= $media_obj->getXML(IL_MODE_ALIAS);
         $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
         $xml .= $link_xml;
         $xml .= "</dummy>";
     }
     $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
     $args = array('/_xml' => $xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     $mode = "media";
     if ($a_fullscreen) {
         $mode = "fullscreen";
     }
     //echo "<b>XML:</b>".htmlentities($xml);
     // determine target frames for internal links
     $wb_path = ilUtil::getWebspaceDir("output") . "/";
     $enlarge_path = ilUtil::getImagePath("enlarge.svg");
     $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path, 'link_params' => "ref_id=" . $_GET["ref_id"], 'fullscreen_link' => "", 'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path);
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     //echo "<br><br>".htmlentities($output);
     //echo xslt_error($xh);
     xslt_free($xh);
     // unmask user html
     $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
     $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $tpl->setVariable("MEDIA_CONTENT", $output);
     echo $tpl->get();
     exit;
 }
 /**
  * show media object
  */
 protected function showMedia()
 {
     global $ilAccess;
     $this->checkPermission("read");
     $item = new ilMediaPoolItem((int) $_GET["mepitem_id"]);
     $mob_id = $item->getForeignId();
     $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
     include_once "Services/Style/classes/class.ilObjStyleSheet.php";
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php";
     ilObjMediaObjectGUI::includePresentationJS($this->tpl);
     $media_obj = new ilObjMediaObject((int) $mob_id);
     $this->tpl->setVariable("TITLE", " - " . $media_obj->getTitle());
     $xml = "<dummy>";
     // todo: we get always the first alias now (problem if mob is used multiple
     // times in page)
     $xml .= $media_obj->getXML(IL_MODE_ALIAS);
     $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
     $xml .= $link_xml;
     $xml .= "</dummy>";
     $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
     $args = array('/_xml' => $xml, '/_xsl' => $xsl);
     $xh = xslt_create();
     $wb_path = ilUtil::getWebspaceDir("output") . "/";
     $mode = $_GET["cmd"] != "showPreview" ? "fullscreen" : "media";
     $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output");
     $fullscreen_link = $this->ctrl->getLinkTarget($this, "showFullscreen", "", false, false);
     $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path, 'link_params' => "ref_id=" . $_GET["ref_id"], 'fullscreen_link' => $fullscreen_link, 'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
     $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
     echo xslt_error($xh);
     xslt_free($xh);
     // unmask user html
     $this->tpl->setVariable("MEDIA_CONTENT", $output);
 }