00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("./content/classes/class.ilObjLearningModule.php");
00025 require_once("./classes/class.ilMainMenuGUI.php");
00026 require_once("./classes/class.ilObjStyleSheet.php");
00027
00040 class ilLMPresentationGUI
00041 {
00042 var $ilias;
00043 var $lm;
00044 var $tpl;
00045 var $lng;
00046 var $layout_doc;
00047 var $offline;
00048 var $offline_directory;
00049
00050 function ilLMPresentationGUI()
00051 {
00052 global $ilias, $lng, $tpl, $rbacsystem, $ilCtrl, $ilAccess;
00053
00054
00055 $lng->loadLanguageModule("content");
00056
00057 $this->ilias =& $ilias;
00058 $this->lng =& $lng;
00059 $this->tpl =& $tpl;
00060 $this->offline = false;
00061 $this->frames = array();
00062 $this->ctrl =& $ilCtrl;
00063 $this->ctrl->saveParameter($this, array("ref_id"));
00064
00065
00066
00067 if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) &&
00068 (!(($this->ctrl->getCmd() == "infoScreen" || $this->ctrl->getNextClass() == "ilinfoscreengui")
00069 && $ilAccess->checkAccess("visible", "", $_GET["ref_id"]))))
00070 {
00071 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
00072 }
00073 include_once './payment/classes/class.ilPaymentObject.php';
00074 include_once './classes/class.ilSearch.php';
00075
00076 if(!ilPaymentObject::_hasAccess($_GET['ref_id']))
00077 {
00078 ilUtil::redirect('./payment/start_purchase.php?ref_id='.$_GET['ref_id']);
00079 }
00080 if(!ilSearch::_checkParentConditions($_GET['ref_id']))
00081 {
00082 $ilias->error_obj->raiseError($lng->txt('access_denied'),$ilias->error_obj->WARNING);
00083 }
00084
00085 $type = $this->ilias->obj_factory->getTypeByRefId($_GET["ref_id"]);
00086
00087
00088 switch($type)
00089 {
00090 case "dbk":
00091 include_once("./content/classes/class.ilObjDlBookGUI.php");
00092
00093 $this->lm_gui = new ilObjDlBookGUI($data,$_GET["ref_id"],true,false);
00094 break;
00095 case "lm":
00096 include_once("./content/classes/class.ilObjLearningModuleGUI.php");
00097
00098 $this->lm_gui = new ilObjLearningModuleGUI($data,$_GET["ref_id"],true,false);
00099
00100 break;
00101 }
00102 $this->lm =& $this->lm_gui->object;
00103
00104
00105 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
00106 {
00107 if (!$this->lm->getOnline())
00108 {
00109 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
00110 }
00111 }
00112
00113 $this->lm_tree = new ilTree($this->lm->getId());
00114 $this->lm_tree->setTableNames('lm_tree','lm_data');
00115 $this->lm_tree->setTreeTablePK("lm_id");
00116
00117
00118 if ($type == "dbk")
00119 {
00120 $this->abstract = true;
00121 $this->setSessionVars();
00122 if((count($_POST["tr_id"]) > 1) or
00123 (!$_POST["target"] and ($_POST["action"] == "show" or $_POST["action"] == "show_citation")))
00124 {
00125 $this->abstract = true;
00126 }
00127 else if($_GET["obj_id"] or ($_POST["action"] == "show") or ($_POST["action"] == "show_citation"))
00128 {
00129 $this->abstract = false;
00130 }
00131 }
00132
00133 }
00134
00135
00139 function &executeCommand()
00140 {
00141 $next_class = $this->ctrl->getNextClass($this);
00142 $cmd = $this->ctrl->getCmd("layout");
00143
00144 $cmd = (isset($_POST['cmd']['citation']))
00145 ? "ilCitation"
00146 : $cmd;
00147
00148
00149 $this->lmAccess($this->ilias->account->getId(),$_GET["ref_id"],$_GET["obj_id"]);
00150
00151 switch($next_class)
00152 {
00153 case "ilnotegui":
00154 $ret =& $this->layout();
00155 break;
00156
00157 case "ilinfoscreengui":
00158 $ret =& $this->outputInfoScreen();
00159 break;
00160
00161 default:
00162 $ret =& $this->$cmd();
00163 break;
00164 }
00165 }
00166
00167
00171 function setOfflineMode($a_offline = true)
00172 {
00173 $this->offline = $a_offline;
00174 }
00175
00176
00180 function offlineMode()
00181 {
00182 return $this->offline;
00183 }
00184
00190 function setExportFormat($a_format)
00191 {
00192 $this->export_format = $a_format;
00193 }
00194
00200 function getExportFormat()
00201 {
00202 return $this->export_format;
00203 }
00204
00208 function nop()
00209 {
00210 }
00211
00212
00219 function lmAccess($usr_id,$lm_id,$obj_id)
00220 {
00221 global $ilDB;
00222
00223
00224 $q = "DELETE FROM lo_access ".
00225 "WHERE usr_id='".$usr_id."' ".
00226 "AND lm_id='".$lm_id."'";
00227 $this->ilias->db->query($q);
00228 $title = (is_object($this->lm))?$this->lm->getTitle():"- no title -";
00229
00230 $pg_title = "";
00231 $q = "INSERT INTO lo_access ".
00232 "(timestamp,usr_id,lm_id,obj_id,lm_title) ".
00233 "VALUES ".
00234 "(now(),'".$usr_id."','".$lm_id."',".$ilDB->quote($obj_id).",'".ilUtil::prepareDBString($title)."')";
00235 $this->ilias->db->query($q);
00236 }
00237
00246 function export()
00247 {
00248 switch($this->lm->getType())
00249 {
00250 case "dbk":
00251 $this->lm_gui->export();
00252 break;
00253 }
00254 }
00255
00263 function offlineexport() {
00264
00265 if ($_POST["cmd"]["cancel"] != "")
00266 {
00267 $this->ctrl->setParameter($this, "frame", "maincontent");
00268 $this->ctrl->redirect($this, "layout");
00269 }
00270
00271 switch($this->lm->getType())
00272 {
00273 case "dbk":
00274
00275 $_GET["frame"] = "maincontent";
00276
00277 $query = "SELECT * FROM object_reference,object_data WHERE object_reference.ref_id='".
00278 $_GET["ref_id"]."' AND object_reference.obj_id=object_data.obj_id ";
00279 $result = $this->ilias->db->query($query);
00280 $objRow = $result->fetchRow(DB_FETCHMODE_ASSOC);
00281 $_GET["obj_id"] = $objRow["obj_id"];
00282
00283 $query = "SELECT * FROM lm_data WHERE lm_id='".$objRow["obj_id"]."' AND type='pg' ";
00284 $result = $this->ilias->db->query($query);
00285
00286 $page = 0;
00287 $showpage = 0;
00288 while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) )
00289 {
00290
00291 $page++;
00292
00293 if ($_POST["pages"]=="all" || ($_POST["pages"]=="fromto" && $page>=$_POST["pagefrom"] && $page<=$_POST["pageto"] ))
00294 {
00295
00296 if ($showpage>0)
00297 {
00298 if($_POST["type"] == "pdf") $output .= "<hr BREAK >\n";
00299 if($_POST["type"] == "print") $output .= "<p style=\"page-break-after:always\" />";
00300 if($_POST["type"] == "html") $output .= "<br><br><br><br>";
00301 }
00302 $showpage++;
00303
00304 $_GET["obj_id"] = $row["obj_id"];
00305 $o = $this->layout("main.xml",false);
00306
00307 $output .= "<div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" class=\"ilc_PageTitle\">".$this->lm->title."</div><p>";
00308 $output .= $o;
00309
00310 $output .= "\n<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td valign=top align=center>- ".$page." -</td></tr></table>\n";
00311
00312 }
00313 }
00314
00315 $printTpl = new ilTemplate("tpl.print.html", true, true, true);
00316
00317 if($_POST["type"] == "print")
00318 {
00319 $printTpl->touchBlock("printreq");
00320 $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
00321 $css2 = ilUtil::getStyleSheetLocation();
00322 }
00323 else
00324 {
00325 $css1 = "./css/delos.css";
00326 $css2 = "./css/content.css";
00327 }
00328 $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
00329
00330 $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
00331 $printTpl->setVariable("CONTENT",$output);
00332
00333
00334 $printTpl->setCurrentBlock("SyntaxStyle");
00335 $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00336 ilObjStyleSheet::getSyntaxStylePath());
00337 $printTpl->parseCurrentBlock();
00338
00339
00340 $html = $printTpl->get();
00341
00345 $this->lm->createExportDirectory();
00346 $export_dir = $this->lm->getExportDirectory();
00347
00351 $fileName = "offline";
00352 $fileName = str_replace(" ","_",$fileName);
00353
00354 if (!file_exists($export_dir."/".$fileName))
00355 {
00356 @mkdir($export_dir."/".$fileName);
00357 @chmod($export_dir."/".$fileName, 0755);
00358
00359 @mkdir($export_dir."/".$fileName."/css");
00360 @chmod($export_dir."/".$fileName."/css", 0755);
00361
00362 }
00363
00364 if($_POST["type"] == "xml")
00365 {
00366
00367 $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($_GET["ref_id"]);
00368
00369 if ($tmp_obj->getType() == "dbk" )
00370 {
00371 require_once "content/classes/class.ilObjDlBook.php";
00372 $dbk =& new ilObjDlBook($_GET["ref_id"]);
00373 $dbk->export();
00374 }
00375
00376 }
00377 else if($_POST["type"] == "print")
00378 {
00379 echo $html;
00380 }
00381 else if ($_POST["type"]=="html")
00382 {
00383
00389 $css1 = file("./templates/default/delos.css");
00390 $css1 = implode($css1,"");
00391
00392 $fp = fopen($export_dir."/".$fileName."/css/delos.css","wb");
00393 fwrite($fp,$css1);
00394 fclose($fp);
00395
00396 $css2 = file("./content/content.css");
00397 $css2 = implode($css2,"");
00398
00399 $fp = fopen($export_dir."/".$fileName."/css/content.css","wb");
00400 fwrite($fp,$css2);
00401 fclose($fp);
00402
00403
00404 $fp = fopen($export_dir."/".$fileName."/".$fileName.".html","wb");
00405 fwrite($fp,$html);
00406 fclose($fp);
00407
00408 ilUtil::zip($export_dir."/".$fileName, $export_dir."/".$fileName.".zip");
00409
00410 ilUtil::deliverFile($export_dir."/".$fileName.".zip", $fileName.".zip");
00411
00412 }
00413 else if ($_POST["type"]=="pdf")
00414 {
00415
00416 ilUtil::html2pdf($html, $export_dir."/".$fileName.".pdf");
00417
00418 ilUtil::deliverFile($export_dir."/".$fileName.".pdf", $fileName.".pdf");
00419
00420 }
00421
00422 exit;
00423 }
00424
00425 }
00426
00434 function offlineexportform()
00435 {
00436
00437 switch($this->lm->getType())
00438 {
00439 case "dbk":
00440 $this->lm_gui->offlineexportform();
00441 break;
00442 }
00443
00444 }
00445
00446
00454 function exportbibinfo()
00455 {
00456 $query = "SELECT * FROM object_reference,object_data WHERE object_reference.ref_id='".$_GET["ref_id"]."' AND object_reference.obj_id=object_data.obj_id ";
00457 $result = $this->ilias->db->query($query);
00458
00459 $objRow = $result->fetchRow(DB_FETCHMODE_ASSOC);
00460
00461 $filename = preg_replace('/[^a-z0-9_]/i', '_', $objRow["title"]);
00462
00463 $C = $this->lm_gui->showAbstract(array(1));
00464
00465 if ($_GET["print"]==1)
00466 {
00467 $printTpl = new ilTemplate("tpl.print.html", true, true, true);
00468 $printTpl->touchBlock("printreq");
00469 $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
00470 $css2 = ilUtil::getStyleSheetLocation();
00471 $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
00472
00473 $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
00474
00475
00476 $printTpl->setCurrentBlock("SyntaxStyle");
00477 $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00478 ilObjStyleSheet::getSyntaxStylePath());
00479 $printTpl->parseCurrentBlock();
00480
00481 $printTpl->setVariable("CONTENT",$C);
00482
00483 echo $printTpl->get();
00484 exit;
00485 }
00486 else
00487 {
00488 ilUtil::deliverData($C, $filename.".html");
00489 exit;
00490 }
00491
00492 }
00493
00494
00495
00496
00497 function attrib2arr($a_attributes)
00498 {
00499 $attr = array();
00500 if(!is_array($a_attributes))
00501 {
00502 return $attr;
00503 }
00504 foreach ($a_attributes as $attribute)
00505 {
00506 $attr[$attribute->name()] = $attribute->value();
00507 }
00508 return $attr;
00509 }
00510
00514 function getCurrentFrameSet()
00515 {
00516 return $this->frames;
00517 }
00518
00522 function layout($a_xml = "main.xml", $doShow = true)
00523 {
00524 global $tpl, $ilBench;
00525
00526 $ilBench->start("ContentPresentation", "layout");
00527
00528
00529 if ($this->getExportFormat() == "scorm")
00530 {
00531 $layout = "1window";
00532 }
00533 else
00534 {
00535 $layout = $this->lm->getLayout();
00536 }
00537
00538
00539
00540
00541
00542
00543 $xmlfile = file_get_contents("./layouts/lm/".$layout."/".$a_xml);
00544
00545 if (!$doc = domxml_open_mem($xmlfile)) { echo "ilLMPresentation: XML File invalid"; exit; }
00546 $this->layout_doc =& $doc;
00547
00548
00549
00550 $ilBench->start("ContentPresentation", "layout_getFrameNode");
00551 $xpc = xpath_new_context($doc);
00552 $path = (empty($_GET["frame"]) || ($_GET["frame"] == "_new"))
00553 ? "/ilLayout/ilFrame[1]"
00554 : "//ilFrame[@name='".$_GET["frame"]."']";
00555 $result = xpath_eval($xpc, $path);
00556 $found = $result->nodeset;
00557 if (count($found) != 1) { echo "ilLMPresentation: XML File invalid"; exit; }
00558 $node = $found[0];
00559
00560 $ilBench->stop("ContentPresentation", "layout_getFrameNode");
00561
00562
00563
00564 $attributes = $this->attrib2arr($node->attributes());
00565 $this->frames = array();
00566 if((!empty($attributes["rows"])) || (!empty($attributes["cols"])))
00567 {
00568 $ilBench->start("ContentPresentation", "layout_processFrameset");
00569 $content .= $this->buildTag("start", "frameset", $attributes);
00570
00571
00572 $this->processNodes($content, $node);
00573 $content .= $this->buildTag("end", "frameset");
00574 $this->tpl = new ilTemplate("tpl.frameset.html", true, true, true);
00575 $this->tpl->setVariable("PAGETITLE", "- ".$this->lm->getTitle());
00576 $this->tpl->setVariable("FS_CONTENT", $content);
00577 $ilBench->stop("ContentPresentation", "layout_processFrameset");
00578 if (!$doshow)
00579 {
00580 $content = $this->tpl->get();
00581 }
00582 }
00583 else
00584 {
00585
00586 $ilBench->start("ContentPresentation", "layout_processContentTag");
00587
00588 if ((empty($attributes["template"]) || !empty($_GET["obj_type"]))
00589 && ($_GET["frame"] != "_new" || $_GET["obj_type"] != "MediaObject"))
00590 {
00591
00592
00593
00594
00595
00596 if(empty($_GET["obj_type"]))
00597 {
00598 $obj_type = "PageObject";
00599 }
00600 else
00601 {
00602 $obj_type = $_GET["obj_type"];
00603 }
00604
00605
00606 $childs = $node->child_nodes();
00607 $found = false;
00608 foreach($childs as $child)
00609 {
00610 if ($child->node_name() == $obj_type)
00611 {
00612 $found = true;
00613 $attributes = $this->attrib2arr($child->attributes());
00614 $node =& $child;
00615
00616 break;
00617 }
00618 }
00619 if (!$found) { echo "ilLMPresentation: No template specified for frame '".
00620 $_GET["frame"]."' and object type '".$obj_type."'."; exit; }
00621 }
00622
00623
00624 $in_module = ($attributes["template_location"] == "module")
00625 ? true
00626 : false;
00627 if ($in_module)
00628 {
00629 $this->tpl = new ilTemplate($attributes["template"], true, true, $in_module);
00630 }
00631 else
00632 {
00633 $this->tpl =& $tpl;
00634 }
00635
00636
00637 if (!$this->offlineMode())
00638 {
00639 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00640 }
00641 else
00642 {
00643 $style_name = $this->ilias->account->prefs["style"].".css";;
00644 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00645 }
00646
00647 $childs = $node->child_nodes();
00648 foreach($childs as $child)
00649 {
00650
00651 $child_attr = $this->attrib2arr($child->attributes());
00652
00653 switch ($child->node_name())
00654 {
00655 case "ilMainMenu":
00656 $this->ilMainMenu();
00657 break;
00658
00659 case "ilTOC":
00660 $this->ilTOC($child_attr["target_frame"]);
00661 break;
00662
00663 case "ilPage":
00664 switch($this->lm->getType())
00665 {
00666 case "lm":
00667 unset($_SESSION["tr_id"]);
00668 unset($_SESSION["bib_id"]);
00669 unset($_SESSION["citation"]);
00670 $content = $this->ilPage($child);
00671 break;
00672
00673 case "dbk":
00674 $this->setSessionVars();
00675 if($this->abstract)
00676 {
00677 $content = $this->lm_gui->showAbstract($_POST["target"]);
00678 }
00679 else
00680 {
00681
00682 $content = $this->ilPage($child);
00683
00684 if($_SESSION["tr_id"])
00685 {
00686 $translation_content = $this->ilTranslation($child);
00687 }
00688 }
00689 break;
00690 }
00691 break;
00692
00693 case "ilGlossary":
00694 $content = $this->ilGlossary($child);
00695 break;
00696
00697 case "ilLMNavigation":
00698
00699
00700 if($_GET["obj_id"] or
00701 ((count($_POST["tr_id"]) < 2) and $_POST["target"] and
00702 ($_POST["action"] == "show" or $_POST["action"] == "show_citation")) or
00703 $this->lm->getType() == 'lm')
00704 {
00705 $this->ilLMNavigation();
00706 }
00707 break;
00708
00709 case "ilMedia":
00710 $this->ilMedia();
00711 break;
00712
00713 case "ilLocator":
00714 $this->ilLocator();
00715 break;
00716
00717 case "ilLMMenu":
00718 $this->ilLMMenu();
00719 break;
00720
00721 case "ilLMSubMenu":
00722 $this->ilLMSubMenu();
00723 break;
00724
00725 case "ilLMNotes":
00726 $this->ilLMNotes();
00727 break;
00728 }
00729 }
00730 $ilBench->stop("ContentPresentation", "layout_processContentTag");
00731 }
00732 $content = $this->tpl->get();
00733
00734 if ($doShow)
00735 {
00736
00737
00738
00739
00740 $this->tpl->fillTabs();
00741 $content = $this->tpl->get();
00742 $content = str_replace("{", "{", $content);
00743 $content = str_replace("}", "}", $content);
00744
00745 header('Content-type: text/html; charset=UTF-8');
00746 echo $content;
00747 }
00748
00749 $ilBench->stop("ContentPresentation", "layout");
00750
00751 return($content);
00752 }
00753
00754 function fullscreen()
00755 {
00756 return $this->layout("fullscreen.xml", !$this->offlineMode());
00757 }
00758
00759 function media()
00760 {
00761 if ($_GET["frame"] != "_new")
00762 {
00763 return $this->layout("main.xml", !$this->offlineMode());
00764 }
00765 else
00766 {
00767 return $this->layout("fullscreen.xml", !$this->offlineMode());
00768 }
00769 }
00770
00771 function glossary()
00772 {
00773 if ($_GET["frame"] != "_new")
00774 {
00775 $this->layout();
00776 }
00777 else
00778 {
00779 $this->tpl = new ilTemplate("tpl.glossary_term_output.html", true, true, true);
00780 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
00781
00782
00783 if (!$this->offlineMode())
00784 {
00785 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00786 }
00787 else
00788 {
00789 $style_name = $this->ilias->account->prefs["style"].".css";;
00790 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00791 }
00792
00793 $this->ilGlossary($child);
00794 if (!$this->offlineMode())
00795 {
00796 $this->tpl->show();
00797 }
00798 else
00799 {
00800 return $this->tpl->get();
00801 }
00802 }
00803 }
00804
00808 function ilMainMenu()
00809 {
00810 global $ilBench;
00811
00812
00813
00814
00815 $showViewInFrameset = true;
00816
00817
00818 $ilBench->start("ContentPresentation", "ilMainMenu");
00819 if ($showViewInFrameset) {
00820 $menu = new ilMainMenuGUI("bottom", true);
00821 }
00822 else
00823 {
00824 $menu = new ilMainMenuGUI("_top", true);
00825 }
00826 $menu->setTemplate($this->tpl);
00827 $menu->addMenuBlock("CONTENT", "navigation");
00828 $menu->setTemplateVars();
00829 $ilBench->stop("ContentPresentation", "ilMainMenu");
00830 }
00831
00835 function ilTOC($a_target)
00836 {
00837 global $ilBench;
00838
00839 $ilBench->start("ContentPresentation", "ilTOC");
00840 require_once("./content/classes/class.ilLMTOCExplorer.php");
00841 if ($this->lm->cleanFrames())
00842 {
00843 $a_target = "";
00844 }
00845 $exp = new ilLMTOCExplorer($this->getLink($this->lm->getRefId(), "layout", "", $a_target),$this->lm);
00846 $exp->setExpandTarget($this->getLink($this->lm->getRefId(), $_GET["cmd"], $_GET["obj_id"], $_GET["frame"]));
00847 $exp->setTargetGet("obj_id");
00848 if ($this->lm->cleanFrames())
00849 {
00850 if ($this->offlineMode())
00851 {
00852 $exp->setFrameTarget("_top");
00853 }
00854 else
00855 {
00856 $exp->setFrameTarget("bottom");
00857 }
00858 }
00859 else
00860 {
00861 $exp->setFrameTarget($a_target);
00862 }
00863 $exp->addFilter("du");
00864 $exp->addFilter("st");
00865
00866
00867 if ($this->lm->cleanFrames())
00868 {
00869 $page_id = $this->getCurrentPageId();
00870 if ($page_id > 0)
00871 {
00872 $path = $this->lm_tree->getPathId($page_id);
00873 $exp->setForceOpenPath($path);
00874 }
00875 if (!$this->offlineMode())
00876 {
00877 $exp->highlightNode($page_id);
00878 }
00879 }
00880
00881 $exp->setOfflineMode($this->offlineMode());
00882 if ($this->lm->getTOCMode() == "pages")
00883 {
00884 $exp->addFilter("pg");
00885 }
00886 $exp->setFiltered(true);
00887 $exp->setFilterMode(IL_FM_POSITIVE);
00888
00889 if ($_GET["lmexpand"] == "")
00890 {
00891 $expanded = $this->lm_tree->readRootId();
00892 }
00893 else
00894 {
00895 $expanded = $_GET["lmexpand"];
00896 }
00897 $exp->setExpand($expanded);
00898
00899
00900 $exp->setOutput(0);
00901 $output = $exp->getOutput();
00902
00903 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
00904
00905
00906 if (!$this->offlineMode())
00907 {
00908 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00909 }
00910 else
00911 {
00912 $style_name = $this->ilias->account->prefs["style"].".css";;
00913 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00914 }
00915
00916 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_toc"));
00917 $this->tpl->setVariable("EXPLORER",$output);
00918 $this->tpl->setVariable("ACTION",
00919 $this->getLink($this->lm->getRefId(), $_GET["cmd"], "", $_GET["frame"]).
00920 "&lmexpand=".$_GET["lmexpand"]);
00921 $this->tpl->parseCurrentBlock();
00922 $ilBench->stop("ContentPresentation", "ilTOC");
00923 }
00924
00928 function ilLMMenu()
00929 {
00930 $this->tpl->setVariable("MENU", $this->lm_gui->setilLMMenu($this->offlineMode()
00931 ,$this->getExportFormat()));
00932 }
00933
00937 function ilLMSubMenu()
00938 {
00939 global $rbacsystem;
00940
00941
00942 if ($this->lm->getType() == "dbk" && $this->abstract)
00943 {
00944 return;
00945 }
00946
00947
00948 $showViewInFrameset = true;
00949
00950 if ($showViewInFrameset)
00951 {
00952 $buttonTarget = "bottom";
00953 }
00954 else
00955 {
00956 $buttonTarget = "_top";
00957 }
00958
00959
00960 include_once("./classes/class.ilTemplate.php");
00961 $tpl_menu =& new ilTemplate("tpl.lm_menu.html", true, true, true);
00962
00963
00964 if (!$this->offlineMode())
00965 {
00966 if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
00967 {
00968 $tpl_menu->setCurrentBlock("lm_menu_btn");
00969 $page_id = $this->getCurrentPageId();
00970 $tpl_menu->setVariable("BTN_LINK", ILIAS_HTTP_PATH."/ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"].
00971 "&obj_id=".$page_id."&to_page=1");
00972 $tpl_menu->setVariable("BTN_TXT", $this->lng->txt("edit"));
00973 $tpl_menu->setVariable("BTN_TARGET", $buttonTarget);
00974 $tpl_menu->parseCurrentBlock();
00975 }
00976
00977 $tpl_menu->setCurrentBlock("lm_menu_btn");
00978 $page_id = $this->getCurrentPageId();
00979 $tpl_menu->setVariable("BTN_LINK", ILIAS_HTTP_PATH.
00980 "/goto.php?target=pg_".$page_id."&client_id=".CLIENT_ID);
00981 $tpl_menu->setVariable("BTN_TXT", $this->lng->txt("cont_page_link"));
00982 $tpl_menu->setVariable("BTN_TARGET", "_top");
00983 $tpl_menu->parseCurrentBlock();
00984
00985 }
00986
00987 $this->tpl->setVariable("SUBMENU", $tpl_menu->get());
00988 }
00989
00990
00994 function ilLMNotes()
00995 {
00996 global $ilAccess;
00997
00998
00999 if ($this->lm->getType() == "dbk" && $this->abstract)
01000 {
01001 return;
01002 }
01003
01004
01005
01006 if ($this->offlineMode())
01007 {
01008 return;
01009 }
01010
01011
01012 $next_class = $this->ctrl->getNextClass($this);
01013
01014 include_once("Services/Notes/classes/class.ilNoteGUI.php");
01015 $notes_gui = new ilNoteGUI($this->lm->getId(), $this->getCurrentPageId(), "pg");
01016 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
01017 {
01018 $notes_gui->enablePublicNotesDeletion(true);
01019 }
01020
01021 $this->ctrl->setParameter($this, "frame", $_GET["frame"]);
01022 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
01023
01024 $notes_gui->enablePrivateNotes();
01025 if ($this->lm->publicNotes())
01026 {
01027 $notes_gui->enablePublicNotes();
01028 }
01029
01030 if ($next_class == "ilnotegui")
01031 {
01032 $html = $this->ctrl->forwardCommand($notes_gui);
01033 }
01034 else
01035 {
01036 $html = $notes_gui->getNotesHTML();
01037 }
01038 $this->tpl->setVariable("NOTES", $html);
01039 }
01040
01041
01045 function ilLocator()
01046 {
01047 global $ilLocator, $tree;
01048
01049 require_once("content/classes/class.ilStructureObject.php");
01050
01051 if (empty($_GET["obj_id"]))
01052 {
01053 $a_id = $this->lm_tree->getRootId();
01054 }
01055 else
01056 {
01057 $a_id = $_GET["obj_id"];
01058 }
01059
01060 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
01061
01062 if (!$this->lm->cleanFrames())
01063 {
01064 $frame_param = $_GET["frame"];
01065 $frame_target = "";
01066 }
01067 else if (!$this->offlineMode())
01068 {
01069 $frame_param = "";
01070 $frame_target = "bottom";
01071 }
01072 else
01073 {
01074 $frame_param = "";
01075 $frame_target = "_top";
01076 }
01077
01078 if (!$this->offlineMode())
01079 {
01080 $ilLocator->addItem("...", "");
01081
01082 $par_id = $tree->getParentId($_GET["ref_id"]);
01083 $ilLocator->addItem(
01084 ilObject::_lookupTitle(ilObject::_lookupObjId($par_id)),
01085 "repository.php?cmd=frameset&ref_id=".$par_id,
01086 ilFrameTargetInfo::_getFrame("MainContent"));
01087 }
01088
01089 if($this->lm_tree->isInTree($a_id))
01090 {
01091 $path = $this->lm_tree->getPathFull($a_id);
01092
01093 foreach ($path as $key => $row)
01094 {
01095 if ($row["type"] != "pg")
01096 {
01097 if($row["child"] != $this->lm_tree->getRootId())
01098 {
01099 $ilLocator->addItem(
01100 ilUtil::shortenText(
01101 ilStructureObject::_getPresentationTitle($row["child"],
01102 $this->lm->isActiveNumbering()),50,true),
01103 $this->getLink($_GET["ref_id"], "layout", $row["child"], $frame_param, "StructureObject"),
01104 $frame_target);
01105 }
01106 else
01107 {
01108 $ilLocator->addItem(
01109 ilUtil::shortenText($this->lm->getTitle(),50,true),
01110 $this->getLink($_GET["ref_id"], "layout", "", $frame_param),
01111 $frame_target);
01112 }
01113 }
01114 }
01115 }
01116 else
01117 {
01118
01119 $ilLocator->addItem(
01120 $this->lm->getTitle(),
01121 $this->getLink($_GET["ref_id"], "layout", "", $_GET["frame"]));
01122
01123 require_once("content/classes/class.ilLMObjectFactory.php");
01124 $lm_obj =& ilLMObjectFactory::getInstance($this->lm, $a_id);
01125
01126 $ilLocator->addItem(
01127 $lm_obj->getTitle(),
01128 $this->getLink($_GET["ref_id"], "layout", $a_id, $frame_param),
01129 $frame_target);
01130 }
01131
01132 if (DEBUG)
01133 {
01134 $debug = "DEBUG: <font color=\"red\">".$this->type."::".$this->id."::".$_GET["cmd"]."</font><br/>";
01135 }
01136
01137
01138
01139
01140 $this->tpl->setLocator();
01141 }
01142
01143 function getCurrentPageId()
01144 {
01145 global $ilUser;
01146
01147
01148 if(empty($_GET["obj_id"]))
01149 {
01150 $obj_id = $this->lm_tree->getRootId();
01151 }
01152 else
01153 {
01154 $obj_id = $_GET["obj_id"];
01155 }
01156
01157
01158 if (!$this->lm_tree->isInTree($obj_id))
01159 {
01160 return $obj_id;
01161 }
01162
01163 $curr_node = $this->lm_tree->getNodeData($obj_id);
01164
01165 if($curr_node["type"] == "pg")
01166 {
01167 $page_id = $curr_node["obj_id"];
01168 }
01169 else
01170 {
01171 $succ_node = $this->lm_tree->fetchSuccessorNode($obj_id, "pg");
01172 $page_id = $succ_node["obj_id"];
01173
01174 if ($succ_node["type"] != "pg")
01175 {
01176 $this->tpl = new ilTemplate("tpl.main.html", true, true);
01177 $this->ilias->raiseError($this->lng->txt("cont_no_page"),$this->ilias->error_obj->FATAL);
01178 $this->tpl->show();
01179 exit;
01180 }
01181
01182
01183 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
01184 {
01185 $public = ilLMObject::_isPagePublic($page_id);
01186
01187 while ($public === false)
01188 {
01189 $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
01190 $page_id = $succ_node["obj_id"];
01191 $public = ilLMObject::_isPagePublic($page_id);
01192 }
01193 }
01194 }
01195
01196 return $page_id;
01197 }
01198
01199 function mapCurrentPageId($current_page_id)
01200 {
01201 $subtree = $this->lm_tree->getSubTree($this->lm_tree->getNodeData(1));
01202 $node = $this->lm_tree->getNodeData($current_page_id);
01203 $pos = array_search($node,$subtree);
01204
01205 $this->tr_obj =& $this->ilias->obj_factory->getInstanceByRefId($_SESSION["tr_id"]);
01206
01207 $lmtree = new ilTree($this->tr_obj->getId());
01208 $lmtree->setTableNames('lm_tree','lm_data');
01209 $lmtree->setTreeTablePK("lm_id");
01210
01211 $subtree = $lmtree->getSubTree($lmtree->getNodeData(1));
01212
01213 return $subtree[$pos]["child"];
01214 }
01215
01216 function ilTranslation(&$a_page_node)
01217 {
01218 global $ilUser;
01219
01220 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
01221 require_once("content/classes/class.ilLMPageObject.php");
01222
01223 $page_id = $this->mapCurrentPageId($this->getCurrentPageId());
01224
01225 if(!$page_id)
01226 {
01227 $this->tpl->setVariable("TRANSLATION_CONTENT","NO TRNSLATION FOUND");
01228 return false;
01229 }
01230
01231 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
01232 $page_object_gui =& new ilPageObjectGUI($page_object);
01233
01234
01235 $this->ilias->account->setDesktopItemParameters($_SESSION["tr_id"], $this->lm->getType(),$page_id);
01236
01237
01238 include_once './course/classes/class.ilCourseLMHistory.php';
01239
01240 ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
01241
01242
01243 $targets = $this->getLayoutLinkTargets();
01244
01245 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
01246 $lm_pg_obj->setLMId($_SESSION["tr_id"]);
01247
01248 #$page_object_gui->setLayoutLinkTargets($targets);
01249
01250
01251 $page_object_gui->setBibId($_SESSION["bib_id"]);
01252
01253
01254
01255 $page_object_gui->setLinkFrame($_GET["frame"]);
01256 $page_object_gui->setOutputMode("presentation");
01257 $page_object_gui->setOutputSubmode("translation");
01258
01259 $page_object_gui->setPresentationTitle(
01260 ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
01261 $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
01262 # $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
01263 $page_object_gui->setLinkParams("ref_id=".$_SESSION["tr_id"]);
01264 $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
01265 $page_object_gui->setTemplateOutputVar("TRANSLATION_CONTENT");
01266
01267
01268 return $page_object_gui->presentation();
01269
01270 }
01271
01272 function ilCitation()
01273 {
01274 $page_id = $this->getCurrentPageId();
01275 $this->tpl = new ilTemplate("tpl.page.html",true,true,true);
01276 $this->ilLocator();
01277 $this->tpl->setVariable("MENU",$this->lm_gui->setilCitationMenu());
01278
01279 include_once("content/classes/Pages/class.ilPageObject.php");
01280
01281 $this->pg_obj =& new ilPageObject($this->lm->getType(),$page_id);
01282 $xml = $this->pg_obj->getXMLContent();
01283 $this->lm_gui->showCitation($xml);
01284 $this->tpl->show();
01285 }
01286
01287
01288 function getLayoutLinkTargets()
01289 {
01290
01291 if (!is_object($this->layout_doc))
01292 return array ();
01293
01294 $xpc = xpath_new_context($this->layout_doc);
01295
01296 $path = "/ilLayout/ilLinkTargets/LinkTarget";
01297 $res = xpath_eval($xpc, $path);
01298 $targets = array();
01299 for ($i = 0; $i < count($res->nodeset); $i++)
01300 {
01301 $type = $res->nodeset[$i]->get_attribute("Type");
01302 $frame = $res->nodeset[$i]->get_attribute("Frame");
01303 $targets[$type] = array("Type" => $type, "Frame" => $frame);
01304 }
01305 return $targets;
01306 }
01307
01311 function ilPage(&$a_page_node)
01312 {
01313 global $ilBench,$ilUser;
01314
01315 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
01316 {
01317 $public = ilLMObject::_isPagePublic($this->getCurrentPageId());
01318
01319 if (!$public)
01320 return $this->showNoPublicAccess($this->getCurrentPageId());
01321 }
01322
01323 if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $this->getCurrentPageId()))
01324 {
01325 return $this->showPreconditionsOfPage($this->getCurrentPageId());
01326 }
01327
01328 $ilBench->start("ContentPresentation", "ilPage");
01329
01330 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
01331 require_once("content/classes/class.ilLMPageObject.php");
01332 $page_id = $this->getCurrentPageId();
01333 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
01334 $page_object->buildDom();
01335 $page_object->registerOfflineHandler($this);
01336 $int_links = $page_object->getInternalLinks();
01337 $page_object_gui =& new ilPageObjectGUI($page_object);
01338
01339
01340 $this->ilias->account->setDesktopItemParameters($this->lm->getRefId(), $this->lm->getType(), $page_id);
01341
01342
01343 include_once './course/classes/class.ilCourseLMHistory.php';
01344
01345 ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
01346
01347
01348 $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
01349
01350
01351 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
01352 $lm_pg_obj->setLMId($this->lm->getId());
01353
01354 $page_object_gui->setLinkXML($link_xml);
01355
01356
01357 $page_object_gui->setBibId($_SESSION["bib_id"]);
01358 $page_object_gui->enableCitation((bool) $_SESSION["citation"]);
01359
01360
01361
01362 $page_object_gui->setLinkFrame($_GET["frame"]);
01363 if (!$this->offlineMode())
01364 {
01365 $page_object_gui->setOutputMode("presentation");
01366 }
01367 else
01368 {
01369 $page_object_gui->setOutputMode("offline");
01370 }
01371 $page_object_gui->setFileDownloadLink($this->getLink($_GET["ref_id"], "downloadFile"));
01372 $page_object_gui->setFullscreenLink($this->getLink($_GET["ref_id"], "fullscreen"));
01373 $page_object_gui->setPresentationTitle(
01374 ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
01375 $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
01376
01377
01378 $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
01379 $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
01380 $page_object_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadLink());
01381
01382 if($_SESSION["tr_id"])
01383 {
01384 $page_object_gui->setOutputSubmode("translation");
01385 }
01386
01387
01388 $this->tpl->setCurrentBlock("ContentStyle");
01389 if (!$this->offlineMode())
01390 {
01391 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01392 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01393 }
01394 else
01395 {
01396 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01397 }
01398 $this->tpl->parseCurrentBlock();
01399
01400
01401 $this->tpl->setCurrentBlock("SyntaxStyle");
01402 if (!$this->offlineMode())
01403 {
01404 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01405 ilObjStyleSheet::getSyntaxStylePath());
01406 }
01407 else
01408 {
01409 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01410 "syntaxhighlight.css");
01411 }
01412 $this->tpl->parseCurrentBlock();
01413
01414
01415 include_once "Services/Tracking/classes/class.ilTracking.php";
01416 ilTracking::_trackAccess($this->lm->getId(), $this->lm->getType(),
01417 $page_id, "pg", "read");
01418
01419 $ilBench->stop("ContentPresentation", "ilPage");
01420
01421 return $page_object_gui->presentation($page_object_gui->getOutputMode());
01422
01423 }
01424
01428 function showPreconditionsOfPage()
01429 {
01430 global $ilBench;
01431
01432 $ilBench->start("ContentPresentation", "showPagePreconditions");
01433 $conds = ilObjContentObject::_getMissingPreconditionsOfPage($this->lm->getId(), $this->getCurrentPageId());
01434 $topchap = ilObjContentObject::_getMissingPreconditionsTopChapter($this->lm->getId(), $this->getCurrentPageId());
01435
01436 $page_id = $this->getCurrentPageId();
01437
01438
01439 $this->tpl->setCurrentBlock("ContentStyle");
01440 if (!$this->offlineMode())
01441 {
01442 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01443 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01444 }
01445 else
01446 {
01447 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01448 }
01449 $this->tpl->parseCurrentBlock();
01450
01451 $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_preconditions.html", true);
01452
01453
01454 include_once("classes/class.ilRepositoryExplorer.php");
01455 foreach($conds as $cond)
01456 {
01457 $obj_link = ilRepositoryExplorer::buildLinkTarget($cond["trigger_ref_id"],$cond["trigger_type"]);
01458 $obj_frame = ilRepositoryExplorer::buildFrameTarget($cond["trigger_type"],$cond["trigger_ref_id"],$cond["trigger_obj_id"]);
01459 $this->tpl->setCurrentBlock("condition");
01460 $this->tpl->setVariable("ROWCOL", $rc = ($rc != "tblrow2") ? "tblrow2" : "tblrow1");
01461 $this->tpl->setVariable("VAL_ITEM", ilObject::_lookupTitle($cond["trigger_obj_id"]));
01462 $this->tpl->setVariable("LINK_ITEM", $obj_link);
01463 $this->tpl->setVariable("FRAME_ITEM", $obj_frame);
01464 if ($cond["operator"] == "passed")
01465 {
01466 $cond_str = $this->lng->txt("passed");
01467 }
01468 else
01469 {
01470 $cond_str = $cond["operator"];
01471 }
01472 $this->tpl->setVariable("VAL_CONDITION", $cond_str." ".$cond["value"]);
01473 $this->tpl->parseCurrentBlock();
01474 }
01475 $this->tpl->setCurrentBlock("pg_content");
01476
01477
01478 $this->tpl->setVariable("TXT_MISSING_PRECONDITIONS",
01479 sprintf($this->lng->txt("cont_missing_preconditions"),
01480 ilLMObject::_lookupTitle($topchap)));
01481 $this->tpl->setVariable("TXT_ITEM", $this->lng->txt("item"));
01482 $this->tpl->setVariable("TXT_CONDITION", $this->lng->txt("condition"));
01483
01484
01485 $parent = $this->lm_tree->getParentId($topchap);
01486 $childs = $this->lm_tree->getChildsByType($parent, "st");
01487 $next = "";
01488 $j=-2; $i=1;
01489 foreach($childs as $child)
01490 {
01491 if ($child["child"] == $topchap)
01492 {
01493 $j = $i;
01494 }
01495 if ($i++ == ($j+1))
01496 {
01497 $succ_node = $this->lm_tree->fetchSuccessorNode($child["child"], "pg");
01498 }
01499 }
01500 if($succ_node != "")
01501 {
01502 $framestr = (!empty($_GET["frame"]))
01503 ? "frame=".$_GET["frame"]."&"
01504 : "";
01505
01506 $showViewInFrameset = true;
01507 $link = "<br /><a href=\"".
01508 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]).
01509 "\">".$this->lng->txt("cont_skip_chapter")."</a>";
01510 $this->tpl->setVariable("LINK_SKIP_CHAPTER", $link);
01511 }
01512
01513 $this->tpl->parseCurrentBlock();
01514
01515 $ilBench->stop("ContentPresentation", "showPagePreconditions");
01516 }
01517
01521 function getLinkXML($a_int_links, $a_layoutframes)
01522 {
01523
01524
01525
01526 $showViewInFrameset = true;
01527
01528 if ($a_layoutframes == "")
01529 {
01530 $a_layoutframes = array();
01531 }
01532 $link_info = "<IntLinkInfos>";
01533 foreach ($a_int_links as $int_link)
01534 {
01535 $target = $int_link["Target"];
01536 if (substr($target, 0, 4) == "il__")
01537 {
01538 $target_arr = explode("_", $target);
01539 $target_id = $target_arr[count($target_arr) - 1];
01540 $type = $int_link["Type"];
01541 $targetframe = ($int_link["TargetFrame"] != "")
01542 ? $int_link["TargetFrame"]
01543 : "None";
01544
01545 switch($type)
01546 {
01547 case "PageObject":
01548 case "StructureObject":
01549 $lm_id = ilLMObject::_lookupContObjID($target_id);
01550 if ($lm_id == $this->lm->getId() ||
01551 ($targetframe != "None" && $targetframe != "New"))
01552 {
01553 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01554
01555
01556
01557 $nframe = ($ltarget == "")
01558 ? ""
01559 : $ltarget;
01560 if ($ltarget == "")
01561 {
01562 if ($showViewInFrameset) {
01563 $ltarget="_parent";
01564 } else {
01565 $ltarget="_top";
01566 }
01567 }
01568
01569
01570 if ($this->getExportFormat() == "scorm" &&
01571 $this->offlineMode())
01572 {
01573 $ltarget = "";
01574 }
01575 $href =
01576 $this->getLink($_GET["ref_id"], "layout", $target_id, $nframe, $type);
01577 }
01578 else
01579 {
01580 if (!$this->offlineMode())
01581 {
01582 if ($type == "PageObject")
01583 {
01584 $href = "./goto.php?target=pg_".$target_id;
01585 }
01586 else
01587 {
01588 $href = "./goto.php?target=st_".$target_id;
01589 }
01590 }
01591 else
01592 {
01593 if ($type == "PageObject")
01594 {
01595 $href = ILIAS_HTTP_PATH."/goto.php?target=pg_".$target_id."&client_id=".CLIENT_ID;
01596 }
01597 else
01598 {
01599 $href = ILIAS_HTTP_PATH."/goto.php?target=st_".$target_id."&client_id=".CLIENT_ID;
01600 }
01601 }
01602 $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
01603 }
01604 break;
01605
01606 case "GlossaryItem":
01607 if ($targetframe == "None")
01608 {
01609 $targetframe = "Glossary";
01610 }
01611 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01612 $nframe = ($ltarget == "")
01613 ? $_GET["frame"]
01614 : $ltarget;
01615 $href =
01616 $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
01617 break;
01618
01619 case "MediaObject":
01620 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01621 $nframe = ($ltarget == "")
01622 ? $_GET["frame"]
01623 : $ltarget;
01624 $href =
01625 $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
01626 break;
01627
01628 case "RepositoryItem":
01629 $obj_type = ilObject::_lookupType($target_id, true);
01630 $obj_id = ilObject::_lookupObjId($target_id);
01631 if (!$this->offlineMode())
01632 {
01633 $href = "./goto.php?target=".$obj_type."_".$target_id;
01634 }
01635 else
01636 {
01637 $href = ILIAS_HTTP_PATH."/goto.php?target=".$obj_type."_".$target_id."&client_id=".CLIENT_ID;
01638 }
01639 $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
01640 break;
01641
01642 }
01643 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
01644 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
01645
01646
01647
01648
01649
01650
01651
01652
01653 }
01654 }
01655 $link_info.= "</IntLinkInfos>";
01656
01657 return $link_info;
01658 }
01659
01660
01664 function ilGlossary()
01665 {
01666 global $ilBench;
01667
01668 $ilBench->start("ContentPresentation", "ilGlossary");
01669
01670
01671
01672
01673 require_once("content/classes/class.ilGlossaryTermGUI.php");
01674 $term_gui =& new ilGlossaryTermGUI($_GET["obj_id"]);
01675
01676
01677 $this->tpl->setCurrentBlock("ContentStyle");
01678 if (!$this->offlineMode())
01679 {
01680 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01681 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01682 }
01683 else
01684 {
01685 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01686 }
01687 $this->tpl->parseCurrentBlock();
01688
01689
01690 $this->tpl->setCurrentBlock("SyntaxStyle");
01691
01692 if (!$this->offlineMode())
01693 {
01694 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01695 ilObjStyleSheet::getSyntaxStylePath());
01696 }
01697 else
01698 {
01699 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01700 "syntaxhighlight.css");
01701 }
01702 $this->tpl->parseCurrentBlock();
01703
01704 $int_links = $term_gui->getInternalLinks();
01705 $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
01706 $term_gui->setLinkXML($link_xml);
01707
01708 $term_gui->output($this->offlineMode(), "content/");
01709
01710
01711 $ilBench->stop("ContentPresentation", "ilGlossary");
01712 }
01713
01717 function ilMedia()
01718 {
01719 global $ilBench;
01720
01721 $ilBench->start("ContentPresentation", "ilMedia");
01722
01723 $this->tpl->setCurrentBlock("ContentStyle");
01724 if (!$this->offlineMode())
01725 {
01726 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01727 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01728 }
01729 else
01730 {
01731 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01732 }
01733 $this->tpl->parseCurrentBlock();
01734
01735 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
01736
01737
01738 if (!$this->offlineMode())
01739 {
01740 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
01741 }
01742 else
01743 {
01744 $style_name = $this->ilias->account->prefs["style"].".css";;
01745 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
01746 }
01747
01748 $this->tpl->setCurrentBlock("ilMedia");
01749
01750
01751 $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
01752 $link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
01753
01754 require_once("content/classes/Media/class.ilObjMediaObject.php");
01755 $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
01756 if (!empty ($_GET["pg_id"]))
01757 {
01758 require_once("content/classes/Pages/class.ilPageObject.php");
01759 $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
01760 $pg_obj->buildDom();
01761
01762 $xml = "<dummy>";
01763
01764
01765 $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
01766 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
01767 $xml.= $link_xml;
01768 $xml.="</dummy>";
01769 }
01770 else
01771 {
01772 $xml = "<dummy>";
01773
01774
01775 $xml.= $media_obj->getXML(IL_MODE_ALIAS);
01776 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
01777 $xml.= $link_xml;
01778 $xml.="</dummy>";
01779 }
01780
01781
01782
01783
01784
01785
01786 $xsl = file_get_contents("./content/page.xsl");
01787 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
01788 $xh = xslt_create();
01789
01790
01791
01792
01793 if (!$this->offlineMode())
01794 {
01795 $wb_path = ilUtil::getWebspaceDir("output");
01796 }
01797 else
01798 {
01799 $wb_path = ".";
01800 }
01801
01802 $mode = ($_GET["cmd"] == "fullscreen")
01803 ? "fullscreen"
01804 : "media";
01805 $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output", $this->offlineMode());
01806 $fullscreen_link =
01807 $this->getLink($this->lm->getRefId(), "fullscreen");
01808 $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
01809 'link_params' => "ref_id=".$this->lm->getRefId(),'fullscreen_link' => $fullscreen_link,
01810 'ref_id' => $this->lm->getRefId(), 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
01811 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
01812 echo xslt_error($xh);
01813 xslt_free($xh);
01814
01815
01816 $this->tpl->setVariable("MEDIA_CONTENT", $output);
01817
01818 $ilBench->stop("ContentPresentation", "ilMedia");
01819 }
01820
01821
01826 function ilLMNavigation()
01827 {
01828 global $ilBench,$ilUser;
01829
01830 $ilBench->start("ContentPresentation", "ilLMNavigation");
01831
01832 $page_id = $this->getCurrentPageId();
01833
01834 if(empty($page_id))
01835 {
01836 return;
01837 }
01838
01839
01840 if(!$this->lm_tree->isInTree($page_id))
01841 {
01842 if ($this->offlineMode() || $_GET["back_pg"] == "")
01843 {
01844 return;
01845 }
01846 $limpos = strpos($_GET["back_pg"], ":");
01847 if ($limpos > 0)
01848 {
01849 $back_pg = substr($_GET["back_pg"], 0, $limpos);
01850 }
01851 else
01852 {
01853 $back_pg = $_GET["back_pg"];
01854 }
01855 if (!$this->lm->cleanFrames())
01856 {
01857 $back_href =
01858 $this->getLink($this->lm->getRefId(), "layout", $back_pg, $_GET["frame"],
01859 "", "reduce");
01860 $back_target = "";
01861 }
01862 else
01863 {
01864 $back_href =
01865 $this->getLink($this->lm->getRefId(), "layout", $back_pg, "",
01866 "", "reduce");
01867 $back_target = 'target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ';
01868 }
01869 $back_img =
01870 ilUtil::getImagePath("nav_arr2_L.gif", false, "output", $this->offlineMode());
01871 $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
01872 $this->tpl->setVariable("IMG_PREV", $back_img);
01873 $this->tpl->setVariable("HREF_PREV", $back_href);
01874 $this->tpl->setVariable("FRAME_PREV", $back_target);
01875 $this->tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
01876 $this->tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
01877 $this->tpl->parseCurrentBlock();
01878 $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
01879 $this->tpl->setVariable("IMG_PREV2", $back_img);
01880 $this->tpl->setVariable("HREF_PREV2", $back_href);
01881 $this->tpl->setVariable("FRAME_PREV2", $back_target);
01882 $this->tpl->setVariable("TXT_PREV2", $this->lng->txt("back"));
01883 $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("back"));
01884 $this->tpl->parseCurrentBlock();
01885 return;
01886 }
01887
01888
01889 $ilBench->start("ContentPresentation", "ilLMNavigation_fetchSuccessor");
01890 $found = false;
01891 $c_id = $page_id;
01892 while (!$found)
01893 {
01894 $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
01895 $c_id = $succ_node["obj_id"];
01896 if ($succ_node["obj_id"] > 0 &&
01897 $ilUser->getId() == ANONYMOUS_USER_ID &&
01898 ( $this->lm->getPublicAccessMode() == "selected" &&
01899 !ilLMObject::_isPagePublic($succ_node["obj_id"])))
01900 {
01901 $found = false;
01902 }
01903 else
01904 {
01905 $found = true;
01906 }
01907 }
01908 $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchSuccessor");
01909
01910 $succ_str = ($succ_node !== false)
01911 ? " -> ".$succ_node["obj_id"]."_".$succ_node["type"]
01912 : "";
01913
01914
01915 $ilBench->start("ContentPresentation", "ilLMNavigation_fetchPredecessor");
01916 $found = false;
01917 $c_id = $page_id;
01918 while (!$found)
01919 {
01920 $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
01921 $c_id = $pre_node["obj_id"];
01922 if ($pre_node["obj_id"] > 0 &&
01923 $ilUser->getId() == ANONYMOUS_USER_ID &&
01924 ( $this->lm->getPublicAccessMode() == "selected" &&
01925 !ilLMObject::_isPagePublic($pre_node["obj_id"])))
01926 {
01927 $found = false;
01928 }
01929 else
01930 {
01931 $found = true;
01932 }
01933 }
01934 $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchPredecessor");
01935
01936 $pre_str = ($pre_node !== false)
01937 ? $pre_node["obj_id"]."_".$pre_node["type"]." -> "
01938 : "";
01939
01940
01941 $framestr = (!empty($_GET["frame"]))
01942 ? "frame=".$_GET["frame"]."&"
01943 : "";
01944
01945
01946
01947
01948
01949 $showViewInFrameset = true;
01950
01951 if($pre_node != "")
01952 {
01953 $ilBench->start("ContentPresentation", "ilLMNavigation_outputPredecessor");
01954
01955
01956
01957
01958
01959
01960
01961
01962 $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
01963 $prev_title = ilLMPageObject::_getPresentationTitle($pre_node["obj_id"],
01964 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
01965 $prev_title = ilUtil::shortenText($prev_title, 50, true);
01966 $prev_img =
01967 ilUtil::getImagePath("nav_arr_L.gif", false, "output", $this->offlineMode());
01968
01969 if (!$this->lm->cleanFrames())
01970 {
01971 $prev_href =
01972 $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]);
01973 $prev_target = "";
01974 }
01975 else if ($showViewInFrameset && !$this->offlineMode())
01976 {
01977 $prev_href =
01978 $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
01979 $prev_target = 'target="bottom" ';
01980 }
01981 else
01982 {
01983 $prev_href =
01984 $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
01985 $prev_target = 'target="_top" ';
01986 }
01987
01988 if ($ilUser->getId() == ANONYMOUS_USER_ID and ($this->lm->getPublicAccessMode() == "selected" and !ilLMObject::_isPagePublic($pre_node["obj_id"])))
01989 {
01990 $output = $this->lng->txt("msg_page_not_public");
01991 }
01992
01993 $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
01994
01995 $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
01996 $this->tpl->setVariable("IMG_PREV", $prev_img);
01997 $this->tpl->setVariable("HREF_PREV", $prev_href);
01998 $this->tpl->setVariable("FRAME_PREV", $prev_target);
01999 $this->tpl->setVariable("TXT_PREV", $prev_title);
02000 $this->tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
02001 $this->tpl->parseCurrentBlock();
02002 $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
02003 $this->tpl->setVariable("IMG_PREV2", $prev_img);
02004 $this->tpl->setVariable("HREF_PREV2", $prev_href);
02005 $this->tpl->setVariable("FRAME_PREV2", $prev_target);
02006 $this->tpl->setVariable("TXT_PREV2", $prev_title);
02007 $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("previous"));
02008 $this->tpl->parseCurrentBlock();
02009 $ilBench->stop("ContentPresentation", "ilLMNavigation_outputPredecessor");
02010 }
02011 if($succ_node != "")
02012 {
02013 $ilBench->start("ContentPresentation", "ilLMNavigation_outputSuccessor");
02014
02015
02016 $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
02017 $succ_title = ilLMPageObject::_getPresentationTitle($succ_node["obj_id"],
02018 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
02019 $succ_title = ilUtil::shortenText($succ_title,50,true);
02020 $succ_img =
02021 ilUtil::getImagePath("nav_arr_R.gif", false, "output", $this->offlineMode());
02022 if (!$this->lm->cleanFrames())
02023 {
02024 $succ_href =
02025 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]);
02026 $succ_target = "";
02027 }
02028 else if ($showViewInFrameset && !$this->offlineMode())
02029 {
02030 $succ_href =
02031 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
02032 $succ_target = ' target="bottom" ';
02033 }
02034 else
02035 {
02036 $succ_href =
02037 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
02038 $succ_target = ' target="_top" ';
02039 }
02040
02041 if ($ilUser->getId() == ANONYMOUS_USER_ID and ($this->lm->getPublicAccessMode() == "selected" and !ilLMObject::_isPagePublic($succ_node["obj_id"])))
02042 {
02043 $output = $this->lng->txt("msg_page_not_public");
02044 }
02045
02046 $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
02047
02048 $this->tpl->setCurrentBlock("ilLMNavigation_Next");
02049 $this->tpl->setVariable("IMG_SUCC", $succ_img);
02050 $this->tpl->setVariable("HREF_SUCC", $succ_href);
02051 $this->tpl->setVariable("FRAME_SUCC", $succ_target);
02052 $this->tpl->setVariable("TXT_SUCC", $succ_title);
02053 $this->tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
02054 $this->tpl->parseCurrentBlock();
02055 $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
02056 $this->tpl->setVariable("IMG_SUCC2", $succ_img);
02057 $this->tpl->setVariable("HREF_SUCC2", $succ_href);
02058 $this->tpl->setVariable("FRAME_SUCC2", $succ_target);
02059 $this->tpl->setVariable("TXT_SUCC2", $succ_title);
02060 $this->tpl->setVariable("ALT_SUCC2", $this->lng->txt("next"));
02061 $this->tpl->parseCurrentBlock();
02062 $ilBench->stop("ContentPresentation", "ilLMNavigation_outputSuccessor");
02063 }
02064
02065 $ilBench->stop("ContentPresentation", "ilLMNavigation");
02066 }
02067
02068
02069 function processNodes(&$a_content, &$a_node)
02070 {
02071 $child_nodes = $a_node->child_nodes();
02072 foreach ($child_nodes as $child)
02073 {
02074 if($child->node_name() == "ilFrame")
02075 {
02076 $attributes = $this->attrib2arr($child->attributes());
02077
02078 if ((!empty($attributes["rows"])) || (!empty($attrubtes["cols"])))
02079 {
02080
02081
02082 if(!empty($attributes["name"]))
02083 {
02084 unset($attributes["template"]);
02085 unset($attributes["template_location"]);
02086 $attributes["src"] =
02087 $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"],
02088 "", "keep");
02089 $attributes["title"] = $this->lng->txt("cont_frame_".$attributes["name"]);
02090 $a_content .= $this->buildTag("", "frame", $attributes);
02091 $this->frames[$attributes["name"]] = $attributes["name"];
02092
02093 }
02094 else
02095 {
02096 $a_content .= $this->buildTag("start", "frameset", $attributes);
02097 $this->processNodes($a_content, $child);
02098 $a_content .= $this->buildTag("end", "frameset");
02099 }
02100 }
02101 else
02102 {
02103 unset($attributes["template"]);
02104 unset($attributes["template_location"]);
02105 $attributes["src"] =
02106 $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"],
02107 "", "keep");
02108 $attributes["title"] = $this->lng->txt("cont_frame_".$attributes["name"]);
02109 if ($attributes["name"] == "toc")
02110 {
02111 $attributes["src"].= "#".$_GET["obj_id"];
02112 }
02113 $a_content .= $this->buildTag("", "frame", $attributes);
02114 $this->frames[$attributes["name"]] = $attributes["name"];
02115
02116
02117
02118 }
02119 }
02120 }
02121 }
02122
02130 function buildTag ($type, $name, $attr="")
02131 {
02132 $tag = "<";
02133
02134 if ($type == "end")
02135 $tag.= "/";
02136
02137 $tag.= $name;
02138
02139 if (is_array($attr))
02140 {
02141 while (list($k,$v) = each($attr))
02142 $tag.= " ".$k."=\"$v\"";
02143 }
02144
02145 if ($type == "")
02146 $tag.= "/";
02147
02148 $tag.= ">\n";
02149
02150 return $tag;
02151 }
02152
02153
02157 function showTableOfContents()
02158 {
02159 global $ilBench;
02160
02161 $ilBench->start("ContentPresentation", "TableOfContents");
02162
02163
02164 $this->tpl->setCurrentBlock("ContentStyle");
02165 if (!$this->offlineMode())
02166 {
02167 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02168 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02169 }
02170 else
02171 {
02172 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02173 }
02174 $this->tpl->parseCurrentBlock();
02175
02176 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02177
02178
02179 if (!$this->offlineMode())
02180 {
02181 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02182 }
02183 else
02184 {
02185 $style_name = $this->ilias->account->prefs["style"].".css";;
02186 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
02187 }
02188
02189
02190 $this->tpl->getStandardTemplate();
02191 $this->ilLocator();
02192 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_toc.html", true);
02193
02194
02195 $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
02196 $this->tpl->setTitle($this->lm->getTitle());
02197 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
02198
02199 if (!$this->offlineMode())
02200 {
02201 $this->tpl->setCurrentBlock("back_to_lm");
02202 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02203 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
02204 $this->tpl->setVariable("LINK_BACK",
02205 $this->ctrl->getLinkTarget($this, ""));
02206 $this->tpl->parseCurrentBlock();
02207 }
02208
02209 include_once ("content/classes/class.ilLMTableOfContentsExplorer.php");
02210 $exp = new ilTableOfContentsExplorer(
02211 $this->getLink($this->lm->getRefId(), ""),
02212 $this->lm, $this->getExportFormat());
02213 $exp->setExpandTarget($this->getLink($this->lm->getRefId(), $_GET["cmd"], "", $_GET["frame"]));
02214 $exp->setTargetGet("obj_id");
02215 $exp->setOfflineMode($this->offlineMode());
02216 $exp->forceExpandAll(true, false);
02217
02218 $tree =& $this->lm->getTree();
02219 if ($_GET["lmtocexpand"] == "")
02220 {
02221 $expanded = $tree->readRootId();
02222 }
02223 else
02224 {
02225 $expanded = $_GET["lmtocexpand"];
02226 }
02227
02228 $exp->setExpand($expanded);
02229
02230
02231 $exp->setOutput(0);
02232 $output = $exp->getOutput();
02233
02234 $this->tpl->setVariable("EXPLORER", $output);
02235 $this->tpl->parseCurrentBlock();
02236
02237 if ($this->offlineMode())
02238 {
02239 return $this->tpl->get();
02240 }
02241 else
02242 {
02243 $this->tpl->show();
02244 }
02245
02246 $ilBench->stop("ContentPresentation", "TableOfContents");
02247 }
02248
02249
02255 function infoScreen()
02256 {
02257 $this->ctrl->setCmd("showSummary");
02258 $this->ctrl->setCmdClass("ilinfoscreengui");
02259 $this->outputInfoScreen();
02260 }
02261
02265 function showInfoScreen()
02266 {
02267 $this->outputInfoScreen(true);
02268 }
02269
02273 function outputInfoScreen($a_standard_locator = false)
02274 {
02275 global $ilBench, $ilLocator, $ilAccess;
02276
02277 $this->tpl->setHeaderPageTitle("PAGETITLE", " - ".$this->lm->getTitle());
02278
02279
02280 if (!$this->offlineMode())
02281 {
02282 $this->tpl->setStyleSheetLocation(ilUtil::getStyleSheetLocation());
02283 }
02284 else
02285 {
02286 $style_name = $this->ilias->account->prefs["style"].".css";;
02287 $this->tpl->setStyleSheetLocation("./".$style_name);
02288 }
02289
02290 $this->tpl->getStandardTemplate();
02291 $this->tpl->setTitle($this->lm->getTitle());
02292 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
02293
02294
02295 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
02296 {
02297 $this->ilLocator();
02298 }
02299 else
02300 {
02301 $ilLocator->addRepositoryItems();
02302 $this->tpl->setLocator();
02303 }
02304
02305 $this->lng->loadLanguageModule("meta");
02306
02307 include_once("classes/class.ilInfoScreenGUI.php");
02308
02309 $info = new ilInfoScreenGUI($this->lm_gui);
02310 $info->enablePrivateNotes();
02311 $info->enableLearningProgress();
02312
02313
02314 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
02315 {
02316 if ($_GET["obj_id"] > 0)
02317 {
02318 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
02319 $info->addButton($this->lng->txt("back"),
02320 $this->ctrl->getLinkTarget($this, "layout"));
02321 }
02322 else
02323 {
02324 $info->addButton($this->lng->txt("view"),
02325 $this->ctrl->getLinkTarget($this, "layout"));
02326 }
02327 }
02328
02329
02330 $info->addMetaDataSections($this->lm->getId(),0, $this->lm->getType());
02331
02332 if ($this->offlineMode())
02333 {
02334 $this->tpl->setContent($info->getHTML());
02335 return $this->tpl->get();
02336 }
02337 else
02338 {
02339
02340 $this->ctrl->forwardCommand($info);
02341
02342 $this->tpl->show();
02343 }
02344 }
02345
02349 function showPrintViewSelection()
02350 {
02351 global $ilBench,$ilUser;
02352
02353 include_once("content/classes/class.ilStructureObject.php");
02354
02355 $ilBench->start("ContentPresentation", "PrintViewSelection");
02356
02357
02358 $this->tpl->setCurrentBlock("ContentStyle");
02359 if (!$this->offlineMode())
02360 {
02361 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02362 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02363 }
02364 else
02365 {
02366 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02367 }
02368 $this->tpl->parseCurrentBlock();
02369
02370 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02371 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02372 $this->tpl->getStandardTemplate();
02373 $this->ilLocator();
02374 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content",
02375 "tpl.lm_print_selection.html", true);
02376
02377
02378 $this->tpl->setTitle($this->lm->getTitle());
02379 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
02380 $this->tpl->setVariable("TXT_SHOW_PRINT", $this->lng->txt("cont_show_print_view"));
02381 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02382 $this->ctrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
02383 $this->tpl->setVariable("LINK_BACK",
02384 $this->ctrl->getLinkTargetByClass("illmpresentationgui", ""));
02385
02386 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
02387
02388 $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
02389
02390 if (!is_array($_POST["item"]))
02391 {
02392 if ($_GET["obj_id"] != "")
02393 {
02394 $_POST["item"][$_GET["obj_id"]] = "y";
02395 }
02396 else
02397 {
02398 $_POST["item"][1] = "y";
02399 }
02400 }
02401
02402 foreach ($nodes as $node)
02403 {
02404
02405
02406 for ($i=0; $i<$node["depth"]; $i++)
02407 {
02408 $this->tpl->setCurrentBlock("indent");
02409 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
02410 $this->tpl->parseCurrentBlock();
02411 }
02412
02413
02414 $this->tpl->setCurrentBlock("lm_item");
02415
02416 switch ($node["type"])
02417 {
02418
02419 case "pg":
02420 $this->tpl->setVariable("TXT_TITLE",
02421 ilLMPageObject::_getPresentationTitle($node["obj_id"],
02422 $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
02423
02424 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02425 {
02426 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02427 {
02428 $this->tpl->setVariable("DISABLED", "disabled=\"disabled\"");
02429 $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02430 }
02431 }
02432 $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_pg.gif"));
02433 break;
02434
02435
02436 case "du":
02437 $this->tpl->setVariable("TXT_TITLE", "<b>".$this->lm->getTitle()."</b>");
02438 $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_lm.gif"));
02439 break;
02440
02441
02442 case "st":
02443
02444
02445
02446
02447
02448 $this->tpl->setVariable("TXT_TITLE", "<b>".
02449 ilStructureObject::_getPresentationTitle($node["obj_id"],
02450 $this->lm->isActiveNumbering())
02451 ."</b>");
02452 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02453 {
02454 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02455 {
02456 $this->tpl->setVariable("DISABLED", "disabled=\"disabled\"");
02457 $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02458 }
02459 }
02460 $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_st.gif"));
02461
02462 break;
02463 }
02464
02465 if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node["obj_id"]))
02466 {
02467 $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02468 }
02469
02470 $this->tpl->setVariable("ITEM_ID", $node["obj_id"]);
02471
02472 if ($_POST["item"][$node["obj_id"]] == "y")
02473 {
02474 $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
02475 }
02476
02477 $this->tpl->parseCurrentBlock();
02478 }
02479
02480 $this->tpl->show();
02481
02482 $ilBench->stop("ContentPresentation", "PrintViewSelection");
02483 }
02484
02488 function showPrintView()
02489 {
02490 global $ilBench,$ilUser;
02491
02492 $ilBench->start("ContentPresentation", "PrintView");
02493
02494 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02495
02496
02497 if (!$this->offlineMode())
02498 {
02499 $this->tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
02500 }
02501 else
02502 {
02503 $style_name = $this->ilias->account->prefs["style"].".css";;
02504 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
02505 }
02506
02507
02508 $this->tpl->setCurrentBlock("ContentStyle");
02509 if (!$this->offlineMode())
02510 {
02511 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02512 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02513 }
02514 else
02515 {
02516 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02517 }
02518 $this->tpl->parseCurrentBlock();
02519
02520
02521 $this->tpl->setCurrentBlock("SyntaxStyle");
02522 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
02523 ilObjStyleSheet::getSyntaxStylePath());
02524 $this->tpl->parseCurrentBlock();
02525
02526
02527 $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_view.html", true);
02528
02529
02530 $this->tpl->setVariable("HEADER", $this->lm->getTitle());
02531
02532 $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
02533
02534 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
02535 include_once("content/classes/class.ilLMPageObject.php");
02536 include_once("content/classes/class.ilStructureObject.php");
02537
02538 $act_level = 99999;
02539 $activated = false;
02540
02541 $glossary_links = array();
02542 $output_header = false;
02543 $media_links = array();
02544
02545 foreach ($nodes as $node)
02546 {
02547
02548
02549
02550 if ($node["depth"] <= $act_level)
02551 {
02552 if ($_POST["item"][$node["obj_id"]] == "y")
02553 {
02554 $act_level = $node["depth"];
02555 $activated = true;
02556 }
02557 else
02558 {
02559 $act_level = 99999;
02560 $activated = false;
02561 }
02562 }
02563
02564 if ($activated &&
02565 ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node["obj_id"]))
02566 {
02567
02568 if ($node["type"] == "du")
02569 {
02570 $output_header = true;
02571 }
02572
02573
02574 if ($node["type"] == "st")
02575 {
02576 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02577 {
02578 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02579 {
02580 continue;
02581 }
02582 }
02583
02584 $chap =& new ilStructureObject($this->lm, $node["obj_id"]);
02585 $this->tpl->setCurrentBlock("print_chapter");
02586
02587 $chapter_title = $chap->_getPresentationTitle($node["obj_id"],
02588 $this->lm->isActiveNumbering());
02589 $this->tpl->setVariable("CHAP_TITLE",
02590 $chapter_title);
02591
02592 $this->tpl->parseCurrentBlock();
02593 $this->tpl->setCurrentBlock("print_block");
02594 $this->tpl->parseCurrentBlock();
02595 }
02596
02597
02598 if ($node["type"] == "pg")
02599 {
02600 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02601 {
02602 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02603 {
02604 continue;
02605 }
02606 }
02607
02608 $this->tpl->setCurrentBlock("print_item");
02609 $page_id = $node["obj_id"];
02610
02611 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
02612
02613 $page_object_gui =& new ilPageObjectGUI($page_object);
02614
02615 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
02616 $lm_pg_obj->setLMId($this->lm->getId());
02617
02618
02619 $page_object_gui->setLinkFrame($_GET["frame"]);
02620 $page_object_gui->setOutputMode("print");
02621
02622 $page_object_gui->setPresentationTitle("");
02623 if ($this->lm->getPageHeader() == IL_PAGE_TITLE)
02624 {
02625 $page_title = ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
02626 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
02627
02628
02629
02630 if ($this->lm->isActiveNumbering())
02631 {
02632 $chapter_title = trim(substr($chapter_title,
02633 strpos($chapter_title, " ")));
02634 }
02635
02636 if ($page_title != $chapter_title)
02637 {
02638 $page_object_gui->setPresentationTitle($page_title);
02639 }
02640 }
02641
02642 $page_content = $page_object_gui->showPage();
02643 if ($this->lm->getPageHeader() != IL_PAGE_TITLE)
02644 {
02645 $this->tpl->setVariable("CONTENT", $page_content);
02646 }
02647 else
02648 {
02649 $this->tpl->setVariable("CONTENT", $page_content."<br />");
02650 }
02651 $chapter_title = "";
02652 $this->tpl->parseCurrentBlock();
02653 $this->tpl->setCurrentBlock("print_block");
02654 $this->tpl->parseCurrentBlock();
02655
02656
02657 $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType().":pg", $node["obj_id"]);
02658
02659 $got_mobs = false;
02660
02661 foreach ($int_links as $key => $link)
02662 {
02663 if ($link["type"] == "git" &&
02664 ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
02665 {
02666 $glossary_links[$key] = $link;
02667 }
02668 if ($link["type"] == "mob" &&
02669 ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
02670 {
02671 $got_mobs = true;
02672 $mob_links[$key] = $link;
02673 }
02674 }
02675
02676
02677
02678
02679
02680
02681 if ($got_mobs)
02682 {
02683 $page_object->buildDom();
02684 $links = $page_object->getInternalLinks();
02685 foreach($links as $link)
02686 {
02687 if ($link["Type"] == "MediaObject"
02688 && $link["TargetFrame"] != ""
02689 && $link["TargetFrame"] != "None")
02690 {
02691 $media_links[] = $link;
02692 }
02693 }
02694 }
02695 }
02696 }
02697 }
02698
02699 $annex_cnt = 0;
02700 $annexes = array();
02701
02702
02703 if (count($glossary_links) > 0)
02704 {
02705 include_once("content/classes/class.ilGlossaryTerm.php");
02706 include_once("content/classes/class.ilGlossaryDefinition.php");
02707
02708
02709 $terms = array();
02710
02711 foreach($glossary_links as $key => $link)
02712 {
02713 $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]);
02714 $terms[$term.":".$key] = $link;
02715 }
02716 ksort($terms);
02717
02718 foreach($terms as $key => $link)
02719 {
02720 $defs = ilGlossaryDefinition::getDefinitionList($link["id"]);
02721 $def_cnt = 1;
02722
02723
02724 foreach($defs as $def)
02725 {
02726
02727 if (count($defs) > 1)
02728 {
02729 $this->tpl->setCurrentBlock("def_title");
02730 $this->tpl->setVariable("TXT_DEFINITION",
02731 $this->lng->txt("cont_definition")." ".($def_cnt++));
02732 $this->tpl->parseCurrentBlock();
02733 }
02734 $page =& new ilPageObject("gdf", $def["id"]);
02735 $page_gui =& new ilPageObjectGUI($page);
02736 $page_gui->setTemplateOutput(false);
02737 $page_gui->setOutputMode("print");
02738
02739 $this->tpl->setCurrentBlock("definition");
02740 $output = $page_gui->showPage();
02741 $this->tpl->setVariable("VAL_DEFINITION", $output);
02742 $this->tpl->parseCurrentBlock();
02743 }
02744
02745
02746 $this->tpl->setCurrentBlock("term");
02747 $this->tpl->setVariable("VAL_TERM",
02748 $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]));
02749 $this->tpl->parseCurrentBlock();
02750 }
02751
02752
02753 $annex_cnt++;
02754 $this->tpl->setCurrentBlock("glossary");
02755 $annex_title = $this->lng->txt("cont_annex")." ".
02756 chr(64+$annex_cnt).": ".$this->lng->txt("glo");
02757 $this->tpl->setVariable("TXT_GLOSSARY", $annex_title);
02758 $this->tpl->parseCurrentBlock();
02759
02760 $annexes[] = $annex_title;
02761 }
02762
02763
02764 if (count($media_links) > 0)
02765 {
02766 include_once("content/classes/Media/class.ilObjMediaObject.php");
02767 include_once("content/classes/Media/class.ilMediaItem.php");
02768
02769 foreach($media_links as $media)
02770 {
02771 if (substr($media["Target"],0,4) == "il__")
02772 {
02773 $arr = explode("_",$media["Target"]);
02774 $id = $arr[count($arr) - 1];
02775
02776 $med_obj = new ilObjMediaObject($id);
02777 $med_item =& $med_obj->getMediaItem("Standard");
02778 if (is_object($med_item))
02779 {
02780 if (is_int(strpos($med_item->getFormat(), "image")))
02781 {
02782 $this->tpl->setCurrentBlock("ref_image");
02783
02784
02785 if ($med_item->getLocationType() == "LocalFile")
02786 {
02787 $this->tpl->setVariable("IMG_SOURCE",
02788 ilUtil::getWebspaceDir("output")."/mobs/mm_".$id.
02789 "/".$med_item->getLocation());
02790 }
02791 else
02792 {
02793 $this->tpl->setVariable("IMG_SOURCE",
02794 $med_item->getLocation());
02795 }
02796
02797 if ($med_item->getCaption() != "")
02798 {
02799 $this->tpl->setVariable("IMG_TITLE", $med_item->getCaption());
02800 }
02801 else
02802 {
02803 $this->tpl->setVariable("IMG_TITLE", $med_obj->getTitle());
02804 }
02805 $this->tpl->parseCurrentBlock();
02806 }
02807 }
02808 }
02809 }
02810
02811
02812 $annex_cnt++;
02813 $this->tpl->setCurrentBlock("ref_images");
02814 $annex_title = $this->lng->txt("cont_annex")." ".
02815 chr(64+$annex_cnt).": ".$this->lng->txt("cont_ref_images");
02816 $this->tpl->setVariable("TXT_REF_IMAGES", $annex_title);
02817 $this->tpl->parseCurrentBlock();
02818
02819 $annexes[] = $annex_title;
02820 }
02821
02822
02823 if ($output_header)
02824 {
02825 $this->tpl->setCurrentBlock("print_header");
02826 $this->tpl->setVariable("LM_TITLE", $this->lm->getTitle());
02827 if ($this->lm->getDescription() != "none")
02828 {
02829 include_once("Services/MetaData/classes/class.ilMD.php");
02830 $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
02831 $md_gen = $md->getGeneral();
02832 foreach($md_gen->getDescriptionIds() as $id)
02833 {
02834 $md_des = $md_gen->getDescription($id);
02835 $description = $md_des->getDescription();
02836 }
02837
02838 $this->tpl->setVariable("LM_DESCRIPTION",
02839 $description);
02840 }
02841 $this->tpl->parseCurrentBlock();
02842
02843
02844 $nodes2 = $nodes;
02845 foreach ($nodes2 as $node2)
02846 {
02847 if ($node2["type"] == "st"
02848 && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node2["obj_id"]))
02849 {
02850 for ($j=1; $j < $node2["depth"]; $j++)
02851 {
02852 $this->tpl->setCurrentBlock("indent");
02853 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
02854 $this->tpl->parseCurrentBlock();
02855 }
02856 $this->tpl->setCurrentBlock("toc_entry");
02857 $this->tpl->setVariable("TXT_TOC_TITLE",
02858 ilStructureObject::_getPresentationTitle($node2["obj_id"],
02859 $this->lm->isActiveNumbering()));
02860 $this->tpl->parseCurrentBlock();
02861 }
02862 }
02863
02864
02865 foreach ($annexes as $annex)
02866 {
02867 $this->tpl->setCurrentBlock("indent");
02868 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
02869 $this->tpl->parseCurrentBlock();
02870 $this->tpl->setCurrentBlock("toc_entry");
02871 $this->tpl->setVariable("TXT_TOC_TITLE", $annex);
02872 $this->tpl->parseCurrentBlock();
02873 }
02874
02875 $this->tpl->setCurrentBlock("toc");
02876 $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
02877 $this->tpl->parseCurrentBlock();
02878
02879 $this->tpl->setCurrentBlock("print_start_block");
02880 $this->tpl->parseCurrentBlock();
02881 }
02882
02883
02884 include_once 'Services/MetaData/classes/class.ilMD.php';
02885 $md = new ilMD($this->lm->getId(),0, $this->lm->getType());
02886 if (is_object($md_rights = $md->getRights()))
02887 {
02888 $copyright = $md_rights->getDescription();
02889 if ($copyright != "")
02890 {
02891 $this->lng->loadLanguageModule("meta");
02892 $this->tpl->setCurrentBlock("copyright");
02893 $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
02894 $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
02895 $this->tpl->parseCurrentBlock();
02896 }
02897 }
02898
02899 $this->tpl->show(false);
02900
02901 $ilBench->stop("ContentPresentation", "PrintView");
02902 }
02903
02904
02905 function setSessionVars()
02906 {
02907 if($_POST["action"] == "show" or $_POST["action"] == "show_citation")
02908 {
02909 if($_POST["action"] == "show_citation")
02910 {
02911
02912 if(count($_POST["target"]) != 1)
02913 {
02914 sendInfo($this->lng->txt("cont_citation_err_one"));
02915 $_POST["action"] = "";
02916 $_POST["target"] = 0;
02917 return false;
02918 }
02919 $_SESSION["citation"] = 1;
02920 }
02921 else
02922 {
02923 unset($_SESSION["citation"]);
02924 }
02925 if(isset($_POST["tr_id"]))
02926 {
02927 $_SESSION["tr_id"] = $_POST["tr_id"][0];
02928 }
02929 else
02930 {
02931 unset($_SESSION["tr_id"]);
02932 }
02933 if(is_array($_POST["target"]))
02934 {
02935 $_SESSION["bib_id"] = ",".implode(',',$_POST["target"]).",";
02936 }
02937 else
02938 {
02939 $_SESSION["bib_id"] = ",0,";
02940 }
02941 }
02942 return true;
02943 }
02944
02948 function downloadFile()
02949 {
02950 $file = explode("_", $_GET["file_id"]);
02951 require_once("classes/class.ilObjFile.php");
02952 $fileObj =& new ilObjFile($file[count($file) - 1], false);
02953 $fileObj->sendFile();
02954 exit;
02955 }
02956
02960 function download_paragraph ()
02961 {
02962 require_once("content/classes/Pages/class.ilPageObject.php");
02963 $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
02964 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
02965 }
02966
02970 function showDownloadList()
02971 {
02972 global $ilBench;
02973
02974
02975 $this->tpl->setCurrentBlock("ContentStyle");
02976 if (!$this->offlineMode())
02977 {
02978 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02979 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02980 }
02981 else
02982 {
02983 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02984 }
02985 $this->tpl->parseCurrentBlock();
02986
02987 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02988 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02989 $this->tpl->getStandardTemplate();
02990 $this->ilLocator();
02991 $this->tpl->stopTitleFloating();
02992 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_download_list.html", true);
02993
02994
02995 $this->tpl->setTitle($this->lm->getTitle());
02996 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
02997 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02998 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
02999 $this->tpl->setVariable("LINK_BACK",
03000 $this->ctrl->getLinkTarget($this, ""));
03001
03002
03003 include_once 'Services/MetaData/classes/class.ilMD.php';
03004 $md = new ilMD($this->lm->getId(),0, $this->lm->getType());
03005 if (is_object($md_rights = $md->getRights()))
03006 {
03007 $copyright = $md_rights->getDescription();
03008 if ($copyright != "")
03009 {
03010 $this->lng->loadLanguageModule("meta");
03011 $this->tpl->setCurrentBlock("copyright");
03012 $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
03013 $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
03014 $this->tpl->parseCurrentBlock();
03015 }
03016 }
03017
03018
03019 require_once("classes/class.ilTableGUI.php");
03020 $tbl = new ilTableGUI();
03021
03022
03023 $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
03024
03025
03026 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", true);
03027
03028 $export_files = array();
03029 $types = array("xml", "html");
03030 foreach($types as $type)
03031 {
03032 if ($this->lm->getPublicExportFile($type) != "")
03033 {
03034 if (is_file($this->lm->getExportDirectory($type)."/".
03035 $this->lm->getPublicExportFile($type)))
03036 {
03037 $dir = $this->lm->getExportDirectory($type);
03038 $size = filesize($this->lm->getExportDirectory($type)."/".
03039 $this->lm->getPublicExportFile($type));
03040 $export_files[] = array("type" => $type,
03041 "file" => $this->lm->getPublicExportFile($type),
03042 "size" => $size);
03043 }
03044 }
03045 }
03046
03047 $num = 0;
03048
03049 $tbl->setTitle($this->lng->txt("download"));
03050
03051 $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
03052 $this->lng->txt("cont_file"),
03053 $this->lng->txt("size"), $this->lng->txt("date"),
03054 ""));
03055
03056 $cols = array("format", "file", "size", "date", "download");
03057 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
03058 "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
03059 $tbl->setHeaderVars($cols, $header_params);
03060 $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
03061 $tbl->disable("sort");
03062
03063
03064 $tbl->setOrderColumn($_GET["sort_by"]);
03065 $tbl->setOrderDirection($_GET["sort_order"]);
03066 $tbl->setLimit($_GET["limit"]);
03067 $tbl->setOffset($_GET["offset"]);
03068 $tbl->setMaxCount($this->maxcount);
03069
03070
03071
03072
03073
03074 $tbl->disable("footer");
03075
03076 $tbl->setMaxCount(count($export_files));
03077 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
03078
03079 $tbl->render();
03080 if(count($export_files) > 0)
03081 {
03082 $i=0;
03083 foreach($export_files as $exp_file)
03084 {
03085 if (!$exp_file["size"] > 0)
03086 {
03087 continue;
03088 }
03089
03090 $this->tpl->setCurrentBlock("tbl_content");
03091 $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
03092
03093 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
03094 $this->tpl->setVariable("CSS_ROW", $css_row);
03095
03096 $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
03097 $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
03098 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
03099
03100 $file_arr = explode("__", $exp_file["file"]);
03101 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
03102
03103 $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
03104 $this->ctrl->setParameter($this, "type", $exp_file["type"]);
03105 $this->tpl->setVariable("LINK_DOWNLOAD",
03106 $this->ctrl->getLinkTarget($this, "downloadExportFile"));
03107
03108 $this->tpl->parseCurrentBlock();
03109 }
03110 }
03111 else
03112 {
03113 $this->tpl->setCurrentBlock("notfound");
03114 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
03115 $this->tpl->setVariable("NUM_COLS", 5);
03116 $this->tpl->parseCurrentBlock();
03117 }
03118
03119 $this->tpl->show();
03120 }
03121
03122
03126 function downloadExportFile()
03127 {
03128 $file = $this->lm->getPublicExportFile($_GET["type"]);
03129 if ($this->lm->getPublicExportFile($_GET["type"]) != "")
03130 {
03131 $dir = $this->lm->getExportDirectory($_GET["type"]);
03132 if (is_file($dir."/".$file))
03133 {
03134 ilUtil::deliverFile($dir."/".$file, $file);
03135 exit;
03136 }
03137 }
03138 $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
03139 }
03140
03144 function getLink($a_ref_id, $a_cmd = "", $a_obj_id = "", $a_frame = "", $a_type = "",
03145 $a_back_link = "append")
03146 {
03147 global $ilCtrl;
03148
03149 if ($a_cmd == "")
03150 {
03151 $a_cmd = "layout";
03152 }
03153
03154
03155 $cur_page_id = $this->getCurrentPageId();
03156 $back_pg = $_GET["back_pg"];
03157 if ($a_obj_id != "" && !$this->lm_tree->isInTree($a_obj_id) && $cur_page_id != "" &&
03158 $a_back_link == "append")
03159 {
03160 if ($back_pg != "")
03161 {
03162 $back_pg = $cur_page_id.":".$back_pg;
03163 }
03164 else
03165 {
03166 $back_pg = $cur_page_id;
03167 }
03168 }
03169 else
03170 {
03171 if ($a_back_link == "reduce")
03172 {
03173 $limpos = strpos($_GET["back_pg"], ":");
03174
03175 if ($limpos > 0)
03176 {
03177 $back_pg = substr($back_pg, strpos($back_pg, ":") + 1);
03178 }
03179 else
03180 {
03181 $back_pg = "";
03182 }
03183 }
03184 else if ($a_back_link != "keep")
03185 {
03186 $back_pg = "";
03187 }
03188 }
03189
03190
03191 if (!$this->offlineMode())
03192 {
03193 switch ($a_cmd)
03194 {
03195 case "fullscreen":
03196 $link = $this->ctrl->getLinkTarget($this, "fullscreen");
03197 break;
03198
03199 default:
03200
03201 if ($back_pg != "")
03202 {
03203 $this->ctrl->setParameter($this, "back_pg", $back_pg);
03204 }
03205 if ($a_frame != "")
03206 {
03207 $this->ctrl->setParameter($this, "frame", $a_frame);
03208 }
03209 if ($a_obj_id != "")
03210 {
03211 switch ($a_type)
03212 {
03213 case "MediaObject":
03214 $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
03215 break;
03216
03217 default:
03218 $this->ctrl->setParameter($this, "obj_id", $a_obj_id);
03219 $link.= "&obj_id=".$a_obj_id;
03220 break;
03221 }
03222 }
03223 if ($a_type != "")
03224 {
03225 $this->ctrl->setParameter($this, "obj_type", $a_type);
03226 }
03227 $link = $this->ctrl->getLinkTarget($this, $a_cmd);
03228 $link = str_replace("&", "&", $link);
03229
03230 $this->ctrl->setParameter($this, "frame", "");
03231 $this->ctrl->setParameter($this, "obj_id", "");
03232 $this->ctrl->setParameter($this, "mob_id", "");
03233 break;
03234 }
03235 }
03236 else
03237 {
03238 switch ($a_cmd)
03239 {
03240 case "downloadFile":
03241 break;
03242
03243 case "fullscreen":
03244 $link = "fullscreen.html";
03245 break;
03246
03247 case "layout":
03248
03249 if ($a_obj_id == "")
03250 {
03251 $a_obj_id = $this->lm_tree->getRootId();
03252 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
03253 $a_obj_id = $pg_node["obj_id"];
03254 }
03255 if ($a_type == "StructureObject")
03256 {
03257 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
03258 $a_obj_id = $pg_node["obj_id"];
03259 }
03260 if ($a_frame != "")
03261 {
03262 if ($a_frame != "toc")
03263 {
03264 $link = "frame_".$a_obj_id."_".$a_frame.".html";
03265 }
03266 else
03267 {
03268 $link = "frame_".$a_frame.".html";
03269 }
03270 }
03271 else
03272 {
03273 if ($nid = ilLMObject::_lookupNID($this->lm->getId(), $a_obj_id, "pg"))
03274 {
03275 $link = "lm_pg_".$nid.".html";
03276 }
03277 else
03278 {
03279 $link = "lm_pg_".$a_obj_id.".html";
03280 }
03281 }
03282 break;
03283
03284 case "glossary":
03285 $link = "term_".$a_obj_id.".html";
03286 break;
03287
03288 case "media":
03289 $link = "media_".$a_obj_id.".html";
03290 break;
03291
03292 default:
03293 break;
03294 }
03295 }
03296
03297 $this->ctrl->clearParameters($this);
03298
03299 return $link;
03300 }
03301
03302
03303
03304 function showNoPublicAccess()
03305 {
03306 $page_id = $this->getCurrentPageId();
03307
03308
03309 $this->tpl->setCurrentBlock("ContentStyle");
03310
03311 if (!$this->offlineMode())
03312 {
03313 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
03314 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
03315 }
03316 else
03317 {
03318 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
03319 }
03320
03321 $this->tpl->parseCurrentBlock();
03322 $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_nopublicaccess.html", true);
03323 $this->tpl->setCurrentBlock("pg_content");
03324 $this->tpl->setVariable("TXT_PAGE_NO_PUBLIC_ACCESS",$this->lng->txt("msg_page_no_public_access"));
03325 $this->tpl->parseCurrentBlock();
03326 }
03327
03328 function getSourcecodeDownloadLink() {
03329 if (!$this->offlineMode())
03330 {
03331
03332 $target = $this->ctrl->getLinkTarget($this, "");
03333 $target = ilUtil::appendUrlParameterString($target, session_name()."=".session_id());
03334 return $this->ctrl->getLinkTarget($this, "");
03335 }
03336 else
03337 {
03338 return "";
03339 }
03340 }
03341
03349 function setOfflineDirectory ($offdir) {
03350 $this->offline_directory = $offdir;
03351 }
03352
03353
03360 function getOfflineDirectory () {
03361 return $this->offline_directory;
03362 }
03363
03368 function handleCodeParagraph ($page_id, $paragraph_id, $title, $text) {
03369 $directory = $this->getOfflineDirectory()."/codefiles/".$page_id."/".$paragraph_id;
03370 ilUtil::makeDirParents ($directory);
03371 $file = $directory."/".$title;
03372 if (!($fp = @fopen($file,"w+")))
03373 {
03374 die ("<b>Error</b>: Could not open \"".$file."\" for writing".
03375 " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
03376 }
03377 chmod($file, 0770);
03378 fwrite($fp, $text);
03379 fclose($fp);
03380 }
03381 }
03382 ?>