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
00038 class ilLMPresentationGUI
00039 {
00040 var $ilias;
00041 var $lm;
00042 var $tpl;
00043 var $lng;
00044 var $layout_doc;
00045 var $offline;
00046
00047 function ilLMPresentationGUI()
00048 {
00049 global $ilias, $lng, $tpl, $rbacsystem;
00050
00051 $this->ilias =& $ilias;
00052 $this->lng =& $lng;
00053 $this->tpl =& $tpl;
00054 $this->offline = false;
00055 $this->frames = array();
00056
00057 $cmd = (!empty($_GET["cmd"]))
00058 ? $_GET["cmd"]
00059 : "layout";
00060
00061 $cmd = ($cmd == "edpost")
00062 ? "ilCitation"
00063 : $cmd;
00064
00065
00066 $type = $this->ilias->obj_factory->getTypeByRefId($_GET["ref_id"]);
00067
00068
00069 switch($type)
00070 {
00071 case "dbk":
00072 include_once("./content/classes/class.ilObjDlBookGUI.php");
00073
00074 $this->lm_gui = new ilObjDlBookGUI($data,$_GET["ref_id"],true,false);
00075 break;
00076 case "lm":
00077 include_once("./content/classes/class.ilObjLearningModuleGUI.php");
00078
00079 $this->lm_gui = new ilObjLearningModuleGUI($data,$_GET["ref_id"],true,false);
00080
00081 break;
00082 }
00083 $this->lm =& $this->lm_gui->object;
00084
00085 $this->lm_tree = new ilTree($this->lm->getId());
00086 $this->lm_tree->setTableNames('lm_tree','lm_data');
00087 $this->lm_tree->setTreeTablePK("lm_id");
00088
00089
00090
00091 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
00092 {
00093 if (!$this->lm->getOnline())
00094 {
00095 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
00096 }
00097 }
00098
00099
00100
00101 $this->lmAccess($this->ilias->account->getId(),$_GET["ref_id"],$_GET["obj_id"]);
00102
00103 if ($cmd == "post")
00104 {
00105 $cmd = key($_POST["cmd"]);
00106 }
00107 $this->$cmd();
00108 }
00109
00110
00114 function setOfflineMode($a_offline = true)
00115 {
00116 $this->offline = $a_offline;
00117 }
00118
00119
00123 function offlineMode()
00124 {
00125 return $this->offline;
00126 }
00127
00133 function setExportFormat($a_format)
00134 {
00135 $this->export_format = $a_format;
00136 }
00137
00143 function getExportFormat()
00144 {
00145 return $this->export_format;
00146 }
00147
00151 function nop()
00152 {
00153 }
00154
00155
00162 function lmAccess($usr_id,$lm_id,$obj_id)
00163 {
00164
00165 $q = "DELETE FROM lo_access ".
00166 "WHERE usr_id='".$usr_id."' ".
00167 "AND lm_id='".$lm_id."'";
00168 $this->ilias->db->query($q);
00169 $title = (is_object($this->lm))?$this->lm->getTitle():"- no title -";
00170
00171 $pg_title = "";
00172 $q = "INSERT INTO lo_access ".
00173 "(timestamp,usr_id,lm_id,obj_id,lm_title) ".
00174 "VALUES ".
00175 "(now(),'".$usr_id."','".$lm_id."','".$obj_id."','".ilUtil::prepareDBString($title)."')";
00176 $this->ilias->db->query($q);
00177 }
00178
00187 function export()
00188 {
00189 switch($this->lm->getType())
00190 {
00191 case "dbk":
00192 $this->lm_gui->export();
00193 break;
00194 }
00195 }
00196
00204 function offlineexport() {
00205
00206 if ($_POST["cmd"]["cancel"] != "")
00207 {
00208 ilUtil::redirect("lm_presentation.php?cmd=layout&frame=maincontent&ref_id=".$_GET["ref_id"]);
00209 }
00210
00211 switch($this->lm->getType())
00212 {
00213 case "dbk":
00214
00215 $_GET["frame"] = "maincontent";
00216
00217 $query = "SELECT * FROM object_reference,object_data WHERE object_reference.ref_id='".
00218 $_GET["ref_id"]."' AND object_reference.obj_id=object_data.obj_id ";
00219 $result = $this->ilias->db->query($query);
00220 $objRow = $result->fetchRow(DB_FETCHMODE_ASSOC);
00221 $_GET["obj_id"] = $objRow["obj_id"];
00222
00223 $query = "SELECT * FROM lm_data WHERE lm_id='".$objRow["obj_id"]."' AND type='pg' ";
00224 $result = $this->ilias->db->query($query);
00225
00226 $page = 0;
00227 $showpage = 0;
00228 while (is_array($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) )
00229 {
00230
00231 $page++;
00232
00233 if ($_POST["pages"]=="all" || ($_POST["pages"]=="fromto" && $page>=$_POST["pagefrom"] && $page<=$_POST["pageto"] ))
00234 {
00235
00236 if ($showpage>0)
00237 {
00238 if($_POST["type"] == "pdf") $output .= "<hr BREAK >\n";
00239 if($_POST["type"] == "print") $output .= "<p style=\"page-break-after:always\" />";
00240 if($_POST["type"] == "html") $output .= "<br><br><br><br>";
00241 }
00242 $showpage++;
00243
00244 $_GET["obj_id"] = $row["obj_id"];
00245 $o = $this->layout("main.xml",false);
00246
00247 $output .= "<div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" class=\"ilc_PageTitle\">".$this->lm->title."</div><p>";
00248 $output .= $o;
00249
00250 $output .= "\n<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td valign=top align=center>- ".$page." -</td></tr></table>\n";
00251
00252 }
00253 }
00254
00255 $printTpl = new ilTemplate("tpl.print.html", true, true, true);
00256
00257 if($_POST["type"] == "print")
00258 {
00259 $printTpl->touchBlock("printreq");
00260 $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
00261 $css2 = ilUtil::getStyleSheetLocation();
00262 }
00263 else
00264 {
00265 $css1 = "./css/blueshadow.css";
00266 $css2 = "./css/content.css";
00267 }
00268 $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
00269
00270 $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
00271 $printTpl->setVariable("CONTENT",$output);
00272
00273
00274 $printTpl->setCurrentBlock("SyntaxStyle");
00275 $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00276 ilObjStyleSheet::getSyntaxStylePath());
00277 $printTpl->parseCurrentBlock();
00278
00279
00280 $html = $printTpl->get();
00281
00285 $this->lm->createExportDirectory();
00286 $export_dir = $this->lm->getExportDirectory();
00287
00291 $fileName = "offline";
00292 $fileName = str_replace(" ","_",$fileName);
00293
00294 if (!file_exists($export_dir."/".$fileName))
00295 {
00296 @mkdir($export_dir."/".$fileName);
00297 @chmod($export_dir."/".$fileName, 0755);
00298
00299 @mkdir($export_dir."/".$fileName."/css");
00300 @chmod($export_dir."/".$fileName."/css", 0755);
00301
00302 }
00303
00304 if($_POST["type"] == "xml")
00305 {
00306
00307 $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($_GET["ref_id"]);
00308
00309 if ($tmp_obj->getType() == "dbk" )
00310 {
00311 require_once "content/classes/class.ilObjDlBook.php";
00312 $dbk =& new ilObjDlBook($_GET["ref_id"]);
00313 $dbk->export();
00314 }
00315
00316 }
00317 else if($_POST["type"] == "print")
00318 {
00319 echo $html;
00320 }
00321 else if ($_POST["type"]=="html")
00322 {
00323
00329 $css1 = file("./templates/default/blueshadow.css");
00330 $css1 = implode($css1,"");
00331
00332 $fp = fopen($export_dir."/".$fileName."/css/blueshadow.css","wb");
00333 fwrite($fp,$css1);
00334 fclose($fp);
00335
00336 $css2 = file("./content/content.css");
00337 $css2 = implode($css2,"");
00338
00339 $fp = fopen($export_dir."/".$fileName."/css/content.css","wb");
00340 fwrite($fp,$css2);
00341 fclose($fp);
00342
00343
00344 $fp = fopen($export_dir."/".$fileName."/".$fileName.".html","wb");
00345 fwrite($fp,$html);
00346 fclose($fp);
00347
00348 ilUtil::zip($export_dir."/".$fileName, $export_dir."/".$fileName.".zip");
00349
00350 ilUtil::deliverFile($export_dir."/".$fileName.".zip", $fileName.".zip");
00351
00352 }
00353 else if ($_POST["type"]=="pdf")
00354 {
00355
00356 ilUtil::html2pdf($html, $export_dir."/".$fileName.".pdf");
00357
00358 ilUtil::deliverFile($export_dir."/".$fileName.".pdf", $fileName.".pdf");
00359
00360 }
00361
00362 exit;
00363 }
00364
00365 }
00366
00374 function offlineexportform()
00375 {
00376
00377 switch($this->lm->getType())
00378 {
00379 case "dbk":
00380 $this->lm_gui->offlineexportform();
00381 break;
00382 }
00383
00384 }
00385
00386
00394 function exportbibinfo()
00395 {
00396 $query = "SELECT * FROM object_reference,object_data WHERE object_reference.ref_id='".$_GET["ref_id"]."' AND object_reference.obj_id=object_data.obj_id ";
00397 $result = $this->ilias->db->query($query);
00398
00399 $objRow = $result->fetchRow(DB_FETCHMODE_ASSOC);
00400
00401 $filename = preg_replace('/[^a-z0-9_]/i', '_', $objRow["title"]);
00402
00403 $C = $this->lm_gui->showAbstract(array(1));
00404
00405 if ($_GET["print"]==1)
00406 {
00407 $printTpl = new ilTemplate("tpl.print.html", true, true, true);
00408 $printTpl->touchBlock("printreq");
00409 $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
00410 $css2 = ilUtil::getStyleSheetLocation();
00411 $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
00412
00413 $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
00414
00415
00416 $printTpl->setCurrentBlock("SyntaxStyle");
00417 $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
00418 ilObjStyleSheet::getSyntaxStylePath());
00419 $printTpl->parseCurrentBlock();
00420
00421 $printTpl->setVariable("CONTENT",$C);
00422
00423 echo $printTpl->get();
00424 exit;
00425 }
00426 else
00427 {
00428 ilUtil::deliverData($C, $filename.".html");
00429 exit;
00430 }
00431
00432 }
00433
00434
00435
00436
00437 function attrib2arr($a_attributes)
00438 {
00439 $attr = array();
00440 if(!is_array($a_attributes))
00441 {
00442 return $attr;
00443 }
00444 foreach ($a_attributes as $attribute)
00445 {
00446 $attr[$attribute->name()] = $attribute->value();
00447 }
00448 return $attr;
00449 }
00450
00454 function getCurrentFrameSet()
00455 {
00456 return $this->frames;
00457 }
00458
00462 function layout($a_xml = "main.xml", $doShow = true)
00463 {
00464 global $tpl, $ilBench;
00465
00466 $ilBench->start("ContentPresentation", "layout");
00467
00468
00469 if ($this->getExportFormat() == "scorm")
00470 {
00471 $layout = "1window";
00472 }
00473 else
00474 {
00475 $layout = $this->lm->getLayout();
00476 }
00477
00478
00479
00480
00481
00482
00483 $xmlfile = file_get_contents("./layouts/lm/".$layout."/".$a_xml);
00484
00485 if (!$doc = domxml_open_mem($xmlfile)) { echo "ilLMPresentation: XML File invalid"; exit; }
00486 $this->layout_doc =& $doc;
00487
00488
00489
00490 $ilBench->start("ContentPresentation", "layout_getFrameNode");
00491 $xpc = xpath_new_context($doc);
00492 $path = (empty($_GET["frame"]) || ($_GET["frame"] == "_new"))
00493 ? "/ilLayout/ilFrame[1]"
00494 : "//ilFrame[@name='".$_GET["frame"]."']";
00495 $result = xpath_eval($xpc, $path);
00496 $found = $result->nodeset;
00497 if (count($found) != 1) { echo "ilLMPresentation: XML File invalid"; exit; }
00498 $node = $found[0];
00499
00500 $ilBench->stop("ContentPresentation", "layout_getFrameNode");
00501
00502
00503
00504 $attributes = $this->attrib2arr($node->attributes());
00505 $this->frames = array();
00506 if((!empty($attributes["rows"])) || (!empty($attributes["cols"])))
00507 {
00508 $ilBench->start("ContentPresentation", "layout_processFrameset");
00509 $content .= $this->buildTag("start", "frameset", $attributes);
00510
00511
00512 $this->processNodes($content, $node);
00513 $content .= $this->buildTag("end", "frameset");
00514 $this->tpl = new ilTemplate("tpl.frameset.html", true, true, true);
00515 $this->tpl->setVariable("PAGETITLE", "- ".$this->lm->getTitle());
00516 $this->tpl->setVariable("FS_CONTENT", $content);
00517 $ilBench->stop("ContentPresentation", "layout_processFrameset");
00518 if (!$doshow)
00519 {
00520 $content = $this->tpl->get();
00521 }
00522 }
00523 else
00524 {
00525
00526 $ilBench->start("ContentPresentation", "layout_processContentTag");
00527
00528 if ((empty($attributes["template"]) || !empty($_GET["obj_type"]))
00529 && ($_GET["frame"] != "_new" || $_GET["obj_type"] != "MediaObject"))
00530 {
00531
00532
00533
00534
00535
00536 if(empty($_GET["obj_type"]))
00537 {
00538 $obj_type = "PageObject";
00539 }
00540 else
00541 {
00542 $obj_type = $_GET["obj_type"];
00543 }
00544
00545
00546 $childs = $node->child_nodes();
00547 $found = false;
00548 foreach($childs as $child)
00549 {
00550 if ($child->node_name() == $obj_type)
00551 {
00552 $found = true;
00553 $attributes = $this->attrib2arr($child->attributes());
00554 $node =& $child;
00555
00556 break;
00557 }
00558 }
00559 if (!$found) { echo "ilLMPresentation: No template specified for frame '".
00560 $_GET["frame"]."' and object type '".$obj_type."'."; exit; }
00561 }
00562
00563
00564 $in_module = ($attributes["template_location"] == "module")
00565 ? true
00566 : false;
00567 if ($in_module)
00568 {
00569 $this->tpl = new ilTemplate($attributes["template"], true, true, $in_module);
00570 }
00571 else
00572 {
00573 $this->tpl =& $tpl;
00574 }
00575
00576
00577 if (!$this->offlineMode())
00578 {
00579 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00580 }
00581 else
00582 {
00583 $style_name = $this->ilias->account->prefs["style"].".css";;
00584 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00585 }
00586
00587 $childs = $node->child_nodes();
00588 foreach($childs as $child)
00589 {
00590
00591 $child_attr = $this->attrib2arr($child->attributes());
00592
00593 switch ($child->node_name())
00594 {
00595 case "ilMainMenu":
00596 $this->ilMainMenu();
00597 break;
00598
00599 case "ilTOC":
00600 $this->ilTOC($child_attr["target_frame"]);
00601 break;
00602
00603 case "ilPage":
00604 switch($this->lm->getType())
00605 {
00606 case "lm":
00607 unset($_SESSION["tr_id"]);
00608 unset($_SESSION["bib_id"]);
00609 unset($_SESSION["citation"]);
00610 $content = $this->ilPage($child);
00611 break;
00612
00613 case "dbk":
00614 $this->setSessionVars();
00615 if((count($_POST["tr_id"]) > 1) or
00616 (!$_POST["target"] and ($_POST["action"] == "show" or $_POST["action"] == "show_citation")))
00617 {
00618 $content = $this->lm_gui->showAbstract($_POST["target"]);
00619 }
00620 else if($_GET["obj_id"] or ($_POST["action"] == "show") or ($_POST["action"] == "show_citation"))
00621 {
00622
00623 $content = $this->ilPage($child);
00624
00625 if($_SESSION["tr_id"])
00626 {
00627 $translation_content = $this->ilTranslation($child);
00628 }
00629 }
00630 else
00631 {
00632
00633 $content = $this->lm_gui->showAbstract($_POST["target"]);
00634 }
00635
00636 break;
00637 }
00638 break;
00639
00640 case "ilGlossary":
00641 $content = $this->ilGlossary($child);
00642 break;
00643
00644 case "ilLMNavigation":
00645
00646
00647 if($_GET["obj_id"] or
00648 ((count($_POST["tr_id"]) < 2) and $_POST["target"] and
00649 ($_POST["action"] == "show" or $_POST["action"] == "show_citation")) or
00650 $this->lm->getType() == 'lm')
00651 {
00652 $this->ilLMNavigation();
00653 }
00654 break;
00655
00656 case "ilMedia":
00657 $this->ilMedia();
00658 break;
00659
00660 case "ilLocator":
00661 $this->ilLocator();
00662 break;
00663
00664 case "ilLMMenu":
00665 $this->ilLMMenu();
00666 break;
00667
00668 case "ilLMSubMenu":
00669 $this->ilLMSubMenu();
00670 break;
00671 }
00672 }
00673 $ilBench->stop("ContentPresentation", "layout_processContentTag");
00674 }
00675 $content = $this->tpl->get();
00676
00677 if ($doShow)
00678 {
00679
00680
00681
00682 $content = $this->tpl->get();
00683 $content = str_replace("{", "{", $content);
00684 $content = str_replace("}", "}", $content);
00685
00686 header('Content-type: text/html; charset=UTF-8');
00687 echo $content;
00688 }
00689
00690 $ilBench->stop("ContentPresentation", "layout");
00691
00692 return($content);
00693 }
00694
00695 function fullscreen()
00696 {
00697 return $this->layout("fullscreen.xml", !$this->offlineMode());
00698 }
00699
00700 function media()
00701 {
00702 if ($_GET["frame"] != "_new")
00703 {
00704 return $this->layout("main.xml", !$this->offlineMode());
00705 }
00706 else
00707 {
00708 return $this->layout("fullscreen.xml", !$this->offlineMode());
00709 }
00710 }
00711
00712 function glossary()
00713 {
00714 if ($_GET["frame"] != "_new")
00715 {
00716 $this->layout();
00717 }
00718 else
00719 {
00720 $this->tpl = new ilTemplate("tpl.glossary_term_output.html", true, true, true);
00721 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
00722
00723
00724 if (!$this->offlineMode())
00725 {
00726 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00727 }
00728 else
00729 {
00730 $style_name = $this->ilias->account->prefs["style"].".css";;
00731 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00732 }
00733
00734 $this->ilGlossary($child);
00735 if (!$this->offlineMode())
00736 {
00737 $this->tpl->show();
00738 }
00739 else
00740 {
00741 return $this->tpl->get();
00742 }
00743 }
00744 }
00745
00749 function ilMainMenu()
00750 {
00751 global $ilBench;
00752
00753
00754
00755 $showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
00756
00757
00758 $ilBench->start("ContentPresentation", "ilMainMenu");
00759 if ($showViewInFrameset) {
00760 $menu = new ilMainMenuGUI("bottom", true);
00761 }
00762 else
00763 {
00764 $menu = new ilMainMenuGUI("_top", true);
00765 }
00766 $menu->setTemplate($this->tpl);
00767 $menu->addMenuBlock("CONTENT", "navigation");
00768 $menu->setTemplateVars();
00769 $ilBench->stop("ContentPresentation", "ilMainMenu");
00770 }
00771
00775 function ilTOC($a_target)
00776 {
00777 global $ilBench;
00778
00779
00780 $ilBench->start("ContentPresentation", "ilTOC");
00781 require_once("./content/classes/class.ilLMTOCExplorer.php");
00782 $exp = new ilLMTOCExplorer($this->getLink($this->lm->getRefId(), "layout", "", $a_target),$this->lm);
00783 $exp->setTargetGet("obj_id");
00784 $exp->setFrameTarget($a_target);
00785 $exp->addFilter("du");
00786 $exp->addFilter("st");
00787 $exp->setOfflineMode($this->offlineMode());
00788 if ($this->lm->getTOCMode() == "pages")
00789 {
00790 $exp->addFilter("pg");
00791 }
00792 $exp->setFiltered(true);
00793 $exp->setFilterMode(IL_FM_POSITIVE);
00794
00795 if ($_GET["lmexpand"] == "")
00796 {
00797 $expanded = $this->lm_tree->readRootId();
00798 }
00799 else
00800 {
00801 $expanded = $_GET["lmexpand"];
00802 }
00803 $exp->setExpand($expanded);
00804
00805
00806 $exp->setOutput(0);
00807 $output = $exp->getOutput();
00808
00809 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
00810
00811
00812 if (!$this->offlineMode())
00813 {
00814 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
00815 }
00816 else
00817 {
00818 $style_name = $this->ilias->account->prefs["style"].".css";;
00819 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
00820 }
00821
00822 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_toc"));
00823 $this->tpl->setVariable("EXPLORER",$output);
00824 $this->tpl->setVariable("ACTION",
00825 $this->getLink($this->lm->getRefId(), $_GET["cmd"], "", $_GET["frame"]).
00826 "&lmexpand=".$_GET["lmexpand"]);
00827 $this->tpl->parseCurrentBlock();
00828 $ilBench->stop("ContentPresentation", "ilTOC");
00829 }
00830
00834 function ilLMMenu()
00835 {
00836 $this->tpl->setVariable("MENU", $this->lm_gui->setilLMMenu($this->offlineMode()
00837 ,$this->getExportFormat()));
00838 }
00839
00843 function ilLMSubMenu()
00844 {
00845 global $rbacsystem;
00846
00847 $showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
00848 if ($showViewInFrameset)
00849 {
00850 $buttonTarget = "bottom";
00851 }
00852 else
00853 {
00854 $buttonTarget = "_top";
00855 }
00856
00857
00858 include_once("./classes/class.ilTemplate.php");
00859 $tpl_menu =& new ilTemplate("tpl.lm_menu.html", true, true, true);
00860
00861
00862 if (!$this->offlineMode())
00863 {
00864 if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
00865 {
00866 $tpl_menu->setCurrentBlock("lm_menu_btn");
00867 $page_id = $this->getCurrentPageId();
00868 $tpl_menu->setVariable("BTN_LINK", "./lm_edit.php?ref_id=".$_GET["ref_id"].
00869 "&obj_id=".$page_id."&to_page=1");
00870 $tpl_menu->setVariable("BTN_TXT", $this->lng->txt("edit"));
00871 $tpl_menu->setVariable("BTN_TARGET", $buttonTarget);
00872 $tpl_menu->parseCurrentBlock();
00873 }
00874
00875 $tpl_menu->setCurrentBlock("lm_menu_btn");
00876 $page_id = $this->getCurrentPageId();
00877 $tpl_menu->setVariable("BTN_LINK", ILIAS_HTTP_PATH.
00878 "/goto.php?target=pg_".$page_id."&client_id=".CLIENT_ID);
00879 $tpl_menu->setVariable("BTN_TXT", $this->lng->txt("cont_page_link"));
00880 $tpl_menu->setVariable("BTN_TARGET", "_top");
00881 $tpl_menu->parseCurrentBlock();
00882
00883 }
00884
00885 $this->tpl->setVariable("SUBMENU", $tpl_menu->get());
00886 }
00887
00888 function ilLocator()
00889 {
00890 require_once("content/classes/class.ilStructureObject.php");
00891
00892 $this->tpl->setCurrentBlock("ilLocator");
00893
00894
00895 if (empty($_GET["obj_id"]))
00896 {
00897 $a_id = $this->lm_tree->getRootId();
00898 }
00899 else
00900 {
00901 $a_id = $_GET["obj_id"];
00902 }
00903
00904 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00905 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00906
00907 if($this->lm_tree->isInTree($a_id))
00908 {
00909 $path = $this->lm_tree->getPathFull($a_id);
00910
00911
00912 $modifier = 1;
00913
00914
00915
00916 $i = 0;
00917 foreach ($path as $key => $row)
00918 {
00919 if ($row["type"] != "pg")
00920 {
00921
00922 if ($path[$i + 1]["type"] == "st")
00923 {
00924 $this->tpl->touchBlock("locator_separator");
00925 }
00926
00927 $this->tpl->setCurrentBlock("locator_item");
00928
00929 if($row["child"] != $this->lm_tree->getRootId())
00930 {
00931 $this->tpl->setVariable("ITEM", ilUtil::shortenText(
00932 ilStructureObject::_getPresentationTitle($row["child"],
00933 $this->lm->isActiveNumbering()),50,true));
00934
00935 $this->tpl->setVariable("LINK_ITEM",
00936 $this->getLink($_GET["ref_id"], "layout", $row["child"], $_GET["frame"], "StructureObject"));
00937 }
00938 else
00939 {
00940 $this->tpl->setVariable("ITEM", ilUtil::shortenText($this->lm->getTitle(),50,true));
00941
00942 $this->tpl->setVariable("LINK_ITEM",
00943 $this->getLink($_GET["ref_id"], "layout", "", $_GET["frame"]));
00944 }
00945
00946 $this->tpl->parseCurrentBlock();
00947 }
00948 $i++;
00949 }
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962 }
00963 else
00964 {
00965 $this->tpl->touchBlock("locator_separator");
00966
00967 $this->tpl->setCurrentBlock("locator_item");
00968 $this->tpl->setVariable("ITEM", $this->lm->getTitle());
00969 $this->tpl->setVariable("LINK_ITEM",
00970 $this->getLink($_GET["ref_id"], "layout", "", $_GET["frame"]));
00971 $this->tpl->parseCurrentBlock();
00972
00973 $this->tpl->setCurrentBlock("locator_item");
00974 require_once("content/classes/class.ilLMObjectFactory.php");
00975 $lm_obj =& ilLMObjectFactory::getInstance($this->lm, $a_id);
00976 $this->tpl->setVariable("ITEM", $lm_obj->getTitle());
00977 $this->tpl->setVariable("LINK_ITEM",
00978 $this->getLink($_GET["ref_id"], "layout", $a_id, $_GET["frame"]));
00979 $this->tpl->parseCurrentBlock();
00980
00981 $this->tpl->setCurrentBlock("locator_item");
00982 }
00983
00984
00985 $this->tpl->setCurrentBlock("locator");
00986
00987 if (DEBUG)
00988 {
00989 $debug = "DEBUG: <font color=\"red\">".$this->type."::".$this->id."::".$_GET["cmd"]."</font><br/>";
00990 }
00991
00992
00993
00994
00995 $this->tpl->setVariable("TXT_LOCATOR",$debug.$this->lng->txt("locator"));
00996
00997 $this->tpl->parseCurrentBlock();
00998 }
00999
01000 function getCurrentPageId()
01001 {
01002 global $ilUser;
01003
01004
01005 if(empty($_GET["obj_id"]))
01006 {
01007 $obj_id = $this->lm_tree->getRootId();
01008 }
01009 else
01010 {
01011 $obj_id = $_GET["obj_id"];
01012 }
01013
01014
01015 if (!$this->lm_tree->isInTree($obj_id))
01016 {
01017 return $obj_id;
01018 }
01019
01020 $curr_node = $this->lm_tree->getNodeData($obj_id);
01021
01022 if($curr_node["type"] == "pg")
01023 {
01024 $page_id = $curr_node["obj_id"];
01025 }
01026 else
01027 {
01028 $succ_node = $this->lm_tree->fetchSuccessorNode($obj_id, "pg");
01029 $page_id = $succ_node["obj_id"];
01030
01031 if ($succ_node["type"] != "pg")
01032 {
01033 $this->tpl = new ilTemplate("tpl.main.html", true, true);
01034 $this->ilias->raiseError($this->lng->txt("cont_no_page"),$this->ilias->error_obj->FATAL);
01035 $this->tpl->show();
01036 exit;
01037 }
01038
01039
01040 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
01041 {
01042 $public = ilLMObject::_isPagePublic($page_id);
01043
01044 while ($public === false)
01045 {
01046 $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
01047 $page_id = $succ_node["obj_id"];
01048 $public = ilLMObject::_isPagePublic($page_id);
01049 }
01050 }
01051 }
01052
01053 return $page_id;
01054 }
01055
01056 function mapCurrentPageId($current_page_id)
01057 {
01058 $subtree = $this->lm_tree->getSubTree($this->lm_tree->getNodeData(1));
01059 $node = $this->lm_tree->getNodeData($current_page_id);
01060 $pos = array_search($node,$subtree);
01061
01062 $this->tr_obj =& $this->ilias->obj_factory->getInstanceByRefId($_SESSION["tr_id"]);
01063
01064 $lmtree = new ilTree($this->tr_obj->getId());
01065 $lmtree->setTableNames('lm_tree','lm_data');
01066 $lmtree->setTreeTablePK("lm_id");
01067
01068 $subtree = $lmtree->getSubTree($lmtree->getNodeData(1));
01069
01070 return $subtree[$pos]["child"];
01071 }
01072
01073 function ilTranslation(&$a_page_node)
01074 {
01075 global $ilUser;
01076
01077 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
01078 require_once("content/classes/class.ilLMPageObject.php");
01079
01080 $page_id = $this->mapCurrentPageId($this->getCurrentPageId());
01081
01082 if(!$page_id)
01083 {
01084 $this->tpl->setVariable("TRANSLATION_CONTENT","NO TRNSLATION FOUND");
01085 return false;
01086 }
01087
01088 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
01089 $page_object_gui =& new ilPageObjectGUI($page_object);
01090
01091
01092 $this->ilias->account->setDesktopItemParameters($_SESSION["tr_id"], $this->lm->getType(),$page_id);
01093
01094
01095 include_once './course/classes/class.ilCourseLMHistory.php';
01096
01097 ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
01098
01099
01100 $targets = $this->getLayoutLinkTargets();
01101
01102 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
01103 $lm_pg_obj->setLMId($_SESSION["tr_id"]);
01104
01105 #$page_object_gui->setLayoutLinkTargets($targets);
01106
01107
01108 $page_object_gui->setBibId($_SESSION["bib_id"]);
01109
01110
01111
01112 $page_object_gui->setLinkFrame($_GET["frame"]);
01113 $page_object_gui->setOutputMode("presentation");
01114 $page_object_gui->setOutputSubmode("translation");
01115
01116 $page_object_gui->setPresentationTitle(
01117 ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
01118 $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
01119 # $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
01120 $page_object_gui->setLinkParams("ref_id=".$_SESSION["tr_id"]);
01121 $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
01122 $page_object_gui->setTemplateOutputVar("TRANSLATION_CONTENT");
01123
01124
01125 return $page_object_gui->presentation();
01126
01127 }
01128
01129 function ilCitation()
01130 {
01131 $page_id = $this->getCurrentPageId();
01132 $this->tpl = new ilTemplate("tpl.page.html",true,true,true);
01133 $this->ilLocator();
01134 $this->tpl->setVariable("MENU",$this->lm_gui->setilCitationMenu());
01135
01136 include_once("content/classes/Pages/class.ilPageObject.php");
01137
01138 $this->pg_obj =& new ilPageObject($this->lm->getType(),$page_id);
01139 $xml = $this->pg_obj->getXMLContent();
01140 $this->lm_gui->showCitation($xml);
01141 $this->tpl->show();
01142 }
01143
01144
01145 function getLayoutLinkTargets()
01146 {
01147
01148 if (!is_object($this->layout_doc))
01149 return array ();
01150
01151 $xpc = xpath_new_context($this->layout_doc);
01152
01153 $path = "/ilLayout/ilLinkTargets/LinkTarget";
01154 $res = xpath_eval($xpc, $path);
01155 $targets = array();
01156 for ($i = 0; $i < count($res->nodeset); $i++)
01157 {
01158 $type = $res->nodeset[$i]->get_attribute("Type");
01159 $frame = $res->nodeset[$i]->get_attribute("Frame");
01160 $targets[$type] = array("Type" => $type, "Frame" => $frame);
01161 }
01162 return $targets;
01163 }
01164
01168 function ilPage(&$a_page_node)
01169 {
01170 global $ilBench,$ilUser;
01171
01172 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
01173 {
01174 $public = ilLMObject::_isPagePublic($this->getCurrentPageId());
01175
01176 if (!$public)
01177 return $this->showNoPublicAccess($this->getCurrentPageId());
01178 }
01179
01180 if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $this->getCurrentPageId()))
01181 {
01182 return $this->showPreconditionsOfPage($this->getCurrentPageId());
01183 }
01184
01185 $ilBench->start("ContentPresentation", "ilPage");
01186
01187 require_once("content/classes/Pages/class.ilPageObjectGUI.php");
01188 require_once("content/classes/class.ilLMPageObject.php");
01189 $page_id = $this->getCurrentPageId();
01190 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
01191 $page_object->buildDom();
01192 $int_links = $page_object->getInternalLinks();
01193 $page_object_gui =& new ilPageObjectGUI($page_object);
01194
01195
01196 $this->ilias->account->setDesktopItemParameters($this->lm->getRefId(), $this->lm->getType(), $page_id);
01197
01198
01199 include_once './course/classes/class.ilCourseLMHistory.php';
01200
01201 ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
01202
01203
01204 $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
01205
01206 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
01207 $lm_pg_obj->setLMId($this->lm->getId());
01208
01209 $page_object_gui->setLinkXML($link_xml);
01210
01211
01212 $page_object_gui->setBibId($_SESSION["bib_id"]);
01213 $page_object_gui->enableCitation((bool) $_SESSION["citation"]);
01214
01215
01216
01217 $page_object_gui->setLinkFrame($_GET["frame"]);
01218 if (!$this->offlineMode())
01219 {
01220 $page_object_gui->setOutputMode("presentation");
01221 }
01222 else
01223 {
01224 $page_object_gui->setOutputMode("offline");
01225 }
01226 $page_object_gui->setFileDownloadLink($this->getLink($_GET["ref_id"], "downloadFile"));
01227 $page_object_gui->setFullscreenLink($this->getLink($_GET["ref_id"], "fullscreen"));
01228 $page_object_gui->setPresentationTitle(
01229 ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
01230 $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
01231
01232
01233 $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
01234 $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
01235 $page_object_gui->setSourcecodeDownloadScript("lm_presentation.php?".session_name()."=".session_id()."&ref_id=".$this->lm->getRefId());
01236
01237 if($_SESSION["tr_id"])
01238 {
01239 $page_object_gui->setOutputSubmode("translation");
01240 }
01241
01242
01243 $this->tpl->setCurrentBlock("ContentStyle");
01244 if (!$this->offlineMode())
01245 {
01246 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01247 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01248 }
01249 else
01250 {
01251 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01252 }
01253 $this->tpl->parseCurrentBlock();
01254
01255
01256 $this->tpl->setCurrentBlock("SyntaxStyle");
01257 if (!$this->offlineMode())
01258 {
01259 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01260 ilObjStyleSheet::getSyntaxStylePath());
01261 }
01262 else
01263 {
01264 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01265 "syntaxhighlight.css");
01266 }
01267 $this->tpl->parseCurrentBlock();
01268
01269
01270 require_once "./tracking/classes/class.ilUserTracking.php";
01271 ilUserTracking::_trackAccess($this->lm->getId(), $this->lm->getType(),
01272 $page_id, "pg", "read");
01273
01274 $ilBench->stop("ContentPresentation", "ilPage");
01275
01276 return $page_object_gui->presentation($page_object_gui->getOutputMode());
01277
01278 }
01279
01283 function showPreconditionsOfPage()
01284 {
01285 global $ilBench;
01286
01287 $ilBench->start("ContentPresentation", "showPagePreconditions");
01288 $conds = ilObjContentObject::_getMissingPreconditionsOfPage($this->lm->getId(), $this->getCurrentPageId());
01289 $topchap = ilObjContentObject::_getMissingPreconditionsTopChapter($this->lm->getId(), $this->getCurrentPageId());
01290
01291 $page_id = $this->getCurrentPageId();
01292
01293
01294 $this->tpl->setCurrentBlock("ContentStyle");
01295 if (!$this->offlineMode())
01296 {
01297 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01298 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01299 }
01300 else
01301 {
01302 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01303 }
01304 $this->tpl->parseCurrentBlock();
01305
01306 $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_preconditions.html", true);
01307
01308
01309 include_once("classes/class.ilRepositoryExplorer.php");
01310 foreach($conds as $cond)
01311 {
01312 $obj_link = "../".ilRepositoryExplorer::buildLinkTarget($cond["trigger_ref_id"],$cond["trigger_type"]);
01313 $obj_frame = ilRepositoryExplorer::buildFrameTarget($cond["trigger_type"],$cond["trigger_ref_id"],$cond["trigger_obj_id"]);
01314 $this->tpl->setCurrentBlock("condition");
01315 $this->tpl->setVariable("ROWCOL", $rc = ($rc != "tblrow2") ? "tblrow2" : "tblrow1");
01316 $this->tpl->setVariable("VAL_ITEM", ilObject::_lookupTitle($cond["trigger_obj_id"]));
01317 $this->tpl->setVariable("LINK_ITEM", $obj_link);
01318 $this->tpl->setVariable("FRAME_ITEM", $obj_frame);
01319 if ($cond["operator"] == "passed")
01320 {
01321 $cond_str = $this->lng->txt("passed");
01322 }
01323 else
01324 {
01325 $cond_str = $cond["operator"];
01326 }
01327 $this->tpl->setVariable("VAL_CONDITION", $cond_str." ".$cond["value"]);
01328 $this->tpl->parseCurrentBlock();
01329 }
01330 $this->tpl->setCurrentBlock("pg_content");
01331
01332
01333 $this->tpl->setVariable("TXT_MISSING_PRECONDITIONS",
01334 sprintf($this->lng->txt("cont_missing_preconditions"),
01335 ilLMObject::_lookupTitle($topchap)));
01336 $this->tpl->setVariable("TXT_ITEM", $this->lng->txt("item"));
01337 $this->tpl->setVariable("TXT_CONDITION", $this->lng->txt("condition"));
01338
01339
01340 $parent = $this->lm_tree->getParentId($topchap);
01341 $childs = $this->lm_tree->getChildsByType($parent, "st");
01342 $next = "";
01343 $j=-2; $i=1;
01344 foreach($childs as $child)
01345 {
01346 if ($child["child"] == $topchap)
01347 {
01348 $j = $i;
01349 }
01350 if ($i++ == ($j+1))
01351 {
01352 $succ_node = $this->lm_tree->fetchSuccessorNode($child["child"], "pg");
01353 }
01354 }
01355 if($succ_node != "")
01356 {
01357 $framestr = (!empty($_GET["frame"]))
01358 ? "frame=".$_GET["frame"]."&"
01359 : "";
01360 $showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
01361 $link = "<br /><a href=\"".
01362 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]).
01363 "\">".$this->lng->txt("cont_skip_chapter")."</a>";
01364 $this->tpl->setVariable("LINK_SKIP_CHAPTER", $link);
01365 }
01366
01367 $this->tpl->parseCurrentBlock();
01368
01369 $ilBench->stop("ContentPresentation", "showPagePreconditions");
01370 }
01371
01375 function getLinkXML($a_int_links, $a_layoutframes)
01376 {
01377
01378
01379 $showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
01380
01381 if ($a_layoutframes == "")
01382 {
01383 $a_layoutframes = array();
01384 }
01385 $link_info = "<IntLinkInfos>";
01386 foreach ($a_int_links as $int_link)
01387 {
01388 $target = $int_link["Target"];
01389 if (substr($target, 0, 4) == "il__")
01390 {
01391 $target_arr = explode("_", $target);
01392 $target_id = $target_arr[count($target_arr) - 1];
01393 $type = $int_link["Type"];
01394 $targetframe = ($int_link["TargetFrame"] != "")
01395 ? $int_link["TargetFrame"]
01396 : "None";
01397
01398 switch($type)
01399 {
01400 case "PageObject":
01401 case "StructureObject":
01402 $lm_id = ilLMObject::_lookupContObjID($target_id);
01403 if ($lm_id == $this->lm->getId() ||
01404 ($targetframe != "None" && $targetframe != "New"))
01405 {
01406 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01407
01408
01409
01410 $nframe = ($ltarget == "")
01411 ? ""
01412 : $ltarget;
01413 if ($ltarget == "")
01414 {
01415 if ($showViewInFrameset) {
01416 $ltarget="_parent";
01417 } else {
01418 $ltarget="_top";
01419 }
01420 }
01421
01422
01423 if ($this->getExportFormat() == "scorm" &&
01424 $this->offlineMode())
01425 {
01426 $ltarget = "";
01427 }
01428 $href =
01429 $this->getLink($_GET["ref_id"], "layout", $target_id, $nframe, $type);
01430 }
01431 else
01432 {
01433 if ($type == "PageObject")
01434 {
01435 $href = "../goto.php?target=pg_".$target_id;
01436 }
01437 else
01438 {
01439 $href = "../goto.php?target=st_".$target_id;
01440 }
01441 $ltarget = "ilContObj".$lm_id;
01442 }
01443 break;
01444
01445 case "GlossaryItem":
01446 if ($targetframe == "None")
01447 {
01448 $targetframe = "Glossary";
01449 }
01450 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01451 $nframe = ($ltarget == "")
01452 ? $_GET["frame"]
01453 : $ltarget;
01454 $href =
01455 $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
01456 break;
01457
01458 case "MediaObject":
01459 $ltarget = $a_layoutframes[$targetframe]["Frame"];
01460 $nframe = ($ltarget == "")
01461 ? $_GET["frame"]
01462 : $ltarget;
01463 $href =
01464 $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
01465 break;
01466
01467 case "RepositoryItem":
01468 $obj_type = ilObject::_lookupType($target_id, true);
01469 $obj_id = ilObject::_lookupObjId($target_id);
01470 $href = "../goto.php?target=".$obj_type."_".$target_id;
01471 $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
01472 $ltarget = $t_frame;
01473 break;
01474
01475 }
01476 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
01477 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
01478
01479
01480
01481
01482
01483
01484
01485
01486 }
01487 }
01488 $link_info.= "</IntLinkInfos>";
01489
01490 return $link_info;
01491 }
01492
01493
01497 function ilGlossary()
01498 {
01499 global $ilBench;
01500
01501 $ilBench->start("ContentPresentation", "ilGlossary");
01502
01503
01504
01505
01506 require_once("content/classes/class.ilGlossaryTermGUI.php");
01507 $term_gui =& new ilGlossaryTermGUI($_GET["obj_id"]);
01508
01509
01510 $this->tpl->setCurrentBlock("ContentStyle");
01511 if (!$this->offlineMode())
01512 {
01513 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01514 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01515 }
01516 else
01517 {
01518 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01519 }
01520 $this->tpl->parseCurrentBlock();
01521
01522
01523 $this->tpl->setCurrentBlock("SyntaxStyle");
01524
01525 if (!$this->offlineMode())
01526 {
01527 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01528 ilObjStyleSheet::getSyntaxStylePath());
01529 }
01530 else
01531 {
01532 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
01533 "syntaxhighlight.css");
01534 }
01535 $this->tpl->parseCurrentBlock();
01536
01537 $int_links = $term_gui->getInternalLinks();
01538 $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
01539 $term_gui->setLinkXML($link_xml);
01540
01541 $term_gui->output($this->offlineMode());
01542
01543 $ilBench->stop("ContentPresentation", "ilGlossary");
01544 }
01545
01549 function ilMedia()
01550 {
01551 global $ilBench;
01552
01553 $ilBench->start("ContentPresentation", "ilMedia");
01554
01555 $this->tpl->setCurrentBlock("ContentStyle");
01556 if (!$this->offlineMode())
01557 {
01558 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01559 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01560 }
01561 else
01562 {
01563 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01564 }
01565 $this->tpl->parseCurrentBlock();
01566
01567 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
01568
01569
01570 if (!$this->offlineMode())
01571 {
01572 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
01573 }
01574 else
01575 {
01576 $style_name = $this->ilias->account->prefs["style"].".css";;
01577 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
01578 }
01579
01580 $this->tpl->setCurrentBlock("ilMedia");
01581
01582
01583 $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
01584 $link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
01585
01586 require_once("content/classes/Media/class.ilObjMediaObject.php");
01587 $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
01588 if (!empty ($_GET["pg_id"]))
01589 {
01590 require_once("content/classes/Pages/class.ilPageObject.php");
01591 $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
01592 $pg_obj->buildDom();
01593
01594 $xml = "<dummy>";
01595
01596
01597 $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
01598 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
01599 $xml.= $link_xml;
01600 $xml.="</dummy>";
01601 }
01602 else
01603 {
01604 $xml = "<dummy>";
01605
01606
01607 $xml.= $media_obj->getXML(IL_MODE_ALIAS);
01608 $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
01609 $xml.= $link_xml;
01610 $xml.="</dummy>";
01611 }
01612
01613
01614
01615
01616
01617
01618 $xsl = file_get_contents("./content/page.xsl");
01619 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
01620 $xh = xslt_create();
01621
01622
01623
01624
01625 if (!$this->offlineMode())
01626 {
01627 $wb_path = ilUtil::getWebspaceDir("output");
01628 }
01629 else
01630 {
01631 $wb_path = ".";
01632 }
01633
01634 $mode = ($_GET["cmd"] == "fullscreen")
01635 ? "fullscreen"
01636 : "media";
01637 $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output", $this->offlineMode());
01638 $fullscreen_link =
01639 $this->getLink($this->lm->getRefId(), "fullscreen");
01640 $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
01641 'link_params' => "ref_id=".$this->lm->getRefId(),'fullscreen_link' => $fullscreen_link,
01642 'ref_id' => $this->lm->getRefId(), 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
01643 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
01644 echo xslt_error($xh);
01645 xslt_free($xh);
01646
01647
01648 $this->tpl->setVariable("MEDIA_CONTENT", $output);
01649
01650 $ilBench->stop("ContentPresentation", "ilMedia");
01651 }
01652
01653
01658 function ilLMNavigation()
01659 {
01660 global $ilBench,$ilUser;
01661
01662 $ilBench->start("ContentPresentation", "ilLMNavigation");
01663
01664 $page_id = $this->getCurrentPageId();
01665
01666 if(empty($page_id))
01667 {
01668 return;
01669 }
01670
01671 if(!$this->lm_tree->isInTree($page_id))
01672 {
01673 return;
01674 }
01675
01676
01677 $ilBench->start("ContentPresentation", "ilLMNavigation_fetchSuccessor");
01678 $found = false;
01679 $c_id = $page_id;
01680 while (!$found)
01681 {
01682 $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
01683 $c_id = $succ_node["obj_id"];
01684 if ($succ_node["obj_id"] > 0 &&
01685 $ilUser->getId() == ANONYMOUS_USER_ID &&
01686 ( $this->lm->getPublicAccessMode() == "selected" &&
01687 !ilLMObject::_isPagePublic($succ_node["obj_id"])))
01688 {
01689 $found = false;
01690 }
01691 else
01692 {
01693 $found = true;
01694 }
01695 }
01696 $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchSuccessor");
01697
01698 $succ_str = ($succ_node !== false)
01699 ? " -> ".$succ_node["obj_id"]."_".$succ_node["type"]
01700 : "";
01701
01702
01703 $ilBench->start("ContentPresentation", "ilLMNavigation_fetchPredecessor");
01704 $found = false;
01705 $c_id = $page_id;
01706 while (!$found)
01707 {
01708 $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
01709 $c_id = $pre_node["obj_id"];
01710 if ($pre_node["obj_id"] > 0 &&
01711 $ilUser->getId() == ANONYMOUS_USER_ID &&
01712 ( $this->lm->getPublicAccessMode() == "selected" &&
01713 !ilLMObject::_isPagePublic($pre_node["obj_id"])))
01714 {
01715 $found = false;
01716 }
01717 else
01718 {
01719 $found = true;
01720 }
01721 }
01722 $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchPredecessor");
01723
01724 $pre_str = ($pre_node !== false)
01725 ? $pre_node["obj_id"]."_".$pre_node["type"]." -> "
01726 : "";
01727
01728
01729 $framestr = (!empty($_GET["frame"]))
01730 ? "frame=".$_GET["frame"]."&"
01731 : "";
01732
01733
01734
01735
01736 $showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
01737
01738 if($pre_node != "")
01739 {
01740 $ilBench->start("ContentPresentation", "ilLMNavigation_outputPredecessor");
01741 $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
01742
01743
01744
01745
01746
01747
01748
01749
01750 $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
01751 $pre_title = ilLMPageObject::_getPresentationTitle($pre_node["obj_id"],
01752 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
01753 $prev_img = "<img src=\"".
01754 ilUtil::getImagePath("nav_arr_L.gif", false, "output", $this->offlineMode())."\" border=\"0\"/>";
01755 if (!$this->lm->cleanFrames())
01756 {
01757 $output = "<a href=\"".
01758 $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]).
01759 "\">$prev_img ".ilUtil::shortenText($pre_title, 50, true)."</a>";
01760 }
01761 else if ($showViewInFrameset)
01762 {
01763 $output = "<a href=\"".
01764 $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]).
01765 "\" target=\"bottom\">$prev_img ".ilUtil::shortenText($pre_title, 50, true)."</a>";
01766 }
01767 else
01768 {
01769 $output = "<a href=\"".
01770 $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]).
01771 "\" target=\"_top\">$prev_img ".ilUtil::shortenText($pre_title, 50, true)."</a>";
01772 }
01773
01774 if ($ilUser->getId() == ANONYMOUS_USER_ID and ($this->lm->getPublicAccessMode() == "selected" and !ilLMObject::_isPagePublic($pre_node["obj_id"])))
01775 {
01776 $output = $this->lng->txt("msg_page_not_public");
01777 }
01778
01779 $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
01780
01781 $this->tpl->setVariable("LMNAVIGATION_PREV", $output);
01782 $this->tpl->parseCurrentBlock();
01783 $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
01784 $this->tpl->setVariable("LMNAVIGATION_PREV2", $output);
01785 $this->tpl->parseCurrentBlock();
01786 $ilBench->stop("ContentPresentation", "ilLMNavigation_outputPredecessor");
01787 }
01788 if($succ_node != "")
01789 {
01790 $ilBench->start("ContentPresentation", "ilLMNavigation_outputSuccessor");
01791 $this->tpl->setCurrentBlock("ilLMNavigation_Next");
01792
01793
01794
01795
01796
01797
01798
01799
01800 $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
01801 $succ_title = ilLMPageObject::_getPresentationTitle($succ_node["obj_id"],
01802 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
01803 $succ_img = "<img src=\"".
01804 ilUtil::getImagePath("nav_arr_R.gif", false, "output", $this->offlineMode())."\" border=\"0\"/>";
01805 if (!$this->lm->cleanFrames())
01806 {
01807 $output = " <a href=\"".
01808 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]).
01809 "\">".ilUtil::shortenText($succ_title,50,true)." $succ_img</a>";
01810 }
01811 else if ($showViewInFrameset)
01812 {
01813 $output = " <a href=\"".
01814 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]).
01815 "\" target=\"bottom\">".ilUtil::shortenText($succ_title,50,true)." $succ_img</a>";
01816 }
01817 else
01818 {
01819 $output = " <a href=\"".
01820 $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]).
01821 "\" target=\"_top\">".ilUtil::shortenText($succ_title,50,true)." $succ_img</a>";
01822 }
01823
01824 if ($ilUser->getId() == ANONYMOUS_USER_ID and ($this->lm->getPublicAccessMode() == "selected" and !ilLMObject::_isPagePublic($succ_node["obj_id"])))
01825 {
01826 $output = $this->lng->txt("msg_page_not_public");
01827 }
01828
01829 $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
01830
01831 $this->tpl->setVariable("LMNAVIGATION_NEXT", $output);
01832 $this->tpl->parseCurrentBlock();
01833 $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
01834 $this->tpl->setVariable("LMNAVIGATION_NEXT2", $output);
01835 $this->tpl->parseCurrentBlock();
01836 $ilBench->stop("ContentPresentation", "ilLMNavigation_outputSuccessor");
01837 }
01838
01839 $ilBench->stop("ContentPresentation", "ilLMNavigation");
01840 }
01841
01842
01843 function processNodes(&$a_content, &$a_node)
01844 {
01845 $child_nodes = $a_node->child_nodes();
01846 foreach ($child_nodes as $child)
01847 {
01848 if($child->node_name() == "ilFrame")
01849 {
01850 $attributes = $this->attrib2arr($child->attributes());
01851
01852 if ((!empty($attributes["rows"])) || (!empty($attrubtes["cols"])))
01853 {
01854
01855
01856 if(!empty($attributes["name"]))
01857 {
01858 unset($attributes["template"]);
01859 unset($attributes["template_location"]);
01860 $attributes["src"] =
01861 $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"]);
01862 $a_content .= $this->buildTag("", "frame", $attributes);
01863 $this->frames[$attributes["name"]] = $attributes["name"];
01864
01865 }
01866 else
01867 {
01868 $a_content .= $this->buildTag("start", "frameset", $attributes);
01869 $this->processNodes($a_content, $child);
01870 $a_content .= $this->buildTag("end", "frameset");
01871 }
01872 }
01873 else
01874 {
01875 unset($attributes["template"]);
01876 unset($attributes["template_location"]);
01877 $attributes["src"] =
01878 $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"]);
01879 $a_content .= $this->buildTag("", "frame", $attributes);
01880 $this->frames[$attributes["name"]] = $attributes["name"];
01881
01882
01883
01884 }
01885 }
01886 }
01887 }
01888
01896 function buildTag ($type, $name, $attr="")
01897 {
01898 $tag = "<";
01899
01900 if ($type == "end")
01901 $tag.= "/";
01902
01903 $tag.= $name;
01904
01905 if (is_array($attr))
01906 {
01907 while (list($k,$v) = each($attr))
01908 $tag.= " ".$k."=\"$v\"";
01909 }
01910
01911 if ($type == "")
01912 $tag.= "/";
01913
01914 $tag.= ">\n";
01915
01916 return $tag;
01917 }
01918
01919
01923 function showTableOfContents()
01924 {
01925 global $ilBench;
01926
01927 $ilBench->start("ContentPresentation", "TableOfContents");
01928
01929
01930 $this->tpl->setCurrentBlock("ContentStyle");
01931 if (!$this->offlineMode())
01932 {
01933 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
01934 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
01935 }
01936 else
01937 {
01938 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
01939 }
01940 $this->tpl->parseCurrentBlock();
01941
01942 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
01943
01944
01945 if (!$this->offlineMode())
01946 {
01947 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
01948 }
01949 else
01950 {
01951 $style_name = $this->ilias->account->prefs["style"].".css";;
01952 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
01953 }
01954
01955 $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_toc.html", true);
01956
01957
01958 $this->tpl->setVariable("HEADER", $this->lm->getTitle());
01959
01960
01961 include_once ("content/classes/class.ilLMTableOfContentsExplorer.php");
01962 $exp = new ilTableOfContentsExplorer(
01963 "lm_presentation.php?ref_id=".$_GET["ref_id"]
01964 , $this->lm, $this->getExportFormat());
01965 $exp->setTargetGet("obj_id");
01966 $exp->setOfflineMode($this->offlineMode());
01967
01968 $tree =& $this->lm->getTree();
01969 if ($_GET["lmtocexpand"] == "")
01970 {
01971 $expanded = $tree->readRootId();
01972 }
01973 else
01974 {
01975 $expanded = $_GET["lmtocexpand"];
01976 }
01977
01978 $exp->setExpand($expanded);
01979
01980
01981 $exp->setOutput(0);
01982 $output = $exp->getOutput();
01983
01984 $this->tpl->setVariable("EXPLORER", $output);
01985 $this->tpl->parseCurrentBlock();
01986
01987 if ($this->offlineMode())
01988 {
01989 return $this->tpl->get();
01990 }
01991 else
01992 {
01993 $this->tpl->show();
01994 }
01995
01996 $ilBench->stop("ContentPresentation", "TableOfContents");
01997 }
01998
02002 function showPrintViewSelection()
02003 {
02004 global $ilBench,$ilUser;
02005
02006 include_once("content/classes/class.ilStructureObject.php");
02007
02008 $ilBench->start("ContentPresentation", "PrintViewSelection");
02009
02010
02011 $this->tpl->setCurrentBlock("ContentStyle");
02012 if (!$this->offlineMode())
02013 {
02014 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02015 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02016 }
02017 else
02018 {
02019 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02020 }
02021 $this->tpl->parseCurrentBlock();
02022
02023 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02024 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02025 $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_selection.html", true);
02026
02027
02028 $this->tpl->setVariable("HEADER", $this->lm->getTitle());
02029 $this->tpl->setVariable("TXT_SHOW_PRINT", $this->lng->txt("cont_show_print_view"));
02030 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02031 $this->tpl->setVariable("LINK_BACK",
02032 "lm_presentation.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
02033
02034 $this->tpl->setVariable("FORMACTION", "lm_presentation.php?ref_id=".$_GET["ref_id"]
02035 ."&obj_id=".$_GET["obj_id"]."&cmd=post");
02036
02037 $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
02038
02039 if (!is_array($_POST["item"]))
02040 {
02041 if ($_GET["obj_id"] != "")
02042 {
02043 $_POST["item"][$_GET["obj_id"]] = "y";
02044 }
02045 else
02046 {
02047 $_POST["item"][1] = "y";
02048 }
02049 }
02050
02051 foreach ($nodes as $node)
02052 {
02053
02054
02055 for ($i=0; $i<$node["depth"]; $i++)
02056 {
02057 $this->tpl->setCurrentBlock("indent");
02058 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
02059 $this->tpl->parseCurrentBlock();
02060 }
02061
02062
02063 $this->tpl->setCurrentBlock("lm_item");
02064
02065 switch ($node["type"])
02066 {
02067
02068 case "pg":
02069 $this->tpl->setVariable("TXT_TITLE",
02070 ilLMPageObject::_getPresentationTitle($node["obj_id"],
02071 $this->lm->getPageHeader(), $this->lm->isActiveNumbering()));
02072
02073 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02074 {
02075 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02076 {
02077 $this->tpl->setVariable("DISABLED", "disabled=\"disabled\"");
02078 $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02079 }
02080 }
02081 $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_pg.gif"));
02082 break;
02083
02084
02085 case "du":
02086 $this->tpl->setVariable("TXT_TITLE", "<b>".$this->lm->getTitle()."</b>");
02087 $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_lm.gif"));
02088 break;
02089
02090
02091 case "st":
02092
02093
02094
02095
02096
02097 $this->tpl->setVariable("TXT_TITLE", "<b>".
02098 ilStructureObject::_getPresentationTitle($node["obj_id"],
02099 $this->lm->isActiveNumbering())
02100 ."</b>");
02101 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02102 {
02103 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02104 {
02105 $this->tpl->setVariable("DISABLED", "disabled=\"disabled\"");
02106 $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02107 }
02108 }
02109 $this->tpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_st.gif"));
02110
02111 break;
02112 }
02113
02114 if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node["obj_id"]))
02115 {
02116 $this->tpl->setVariable("TXT_NO_ACCESS", "(".$this->lng->txt("cont_no_access").")");
02117 }
02118
02119 $this->tpl->setVariable("ITEM_ID", $node["obj_id"]);
02120
02121 if ($_POST["item"][$node["obj_id"]] == "y")
02122 {
02123 $this->tpl->setVariable("CHECKED", "checked=\"checked\"");
02124 }
02125
02126 $this->tpl->parseCurrentBlock();
02127 }
02128
02129 $this->tpl->show();
02130
02131 $ilBench->stop("ContentPresentation", "PrintViewSelection");
02132 }
02133
02137 function showPrintView()
02138 {
02139 global $ilBench,$ilUser;
02140
02141 $ilBench->start("ContentPresentation", "PrintView");
02142
02143 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02144
02145
02146 if (!$this->offlineMode())
02147 {
02148 $this->tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
02149 }
02150 else
02151 {
02152 $style_name = $this->ilias->account->prefs["style"].".css";;
02153 $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
02154 }
02155
02156
02157 $this->tpl->setCurrentBlock("ContentStyle");
02158 if (!$this->offlineMode())
02159 {
02160 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02161 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02162 }
02163 else
02164 {
02165 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02166 }
02167 $this->tpl->parseCurrentBlock();
02168
02169
02170 $this->tpl->setCurrentBlock("SyntaxStyle");
02171 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
02172 ilObjStyleSheet::getSyntaxStylePath());
02173 $this->tpl->parseCurrentBlock();
02174
02175
02176 $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_view.html", true);
02177
02178
02179 $this->tpl->setVariable("HEADER", $this->lm->getTitle());
02180
02181 $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
02182
02183 include_once("content/classes/Pages/class.ilPageObjectGUI.php");
02184 include_once("content/classes/class.ilLMPageObject.php");
02185 include_once("content/classes/class.ilStructureObject.php");
02186
02187 $act_level = 99999;
02188 $activated = false;
02189
02190 $glossary_links = array();
02191 $output_header = false;
02192 $media_links = array();
02193
02194 foreach ($nodes as $node)
02195 {
02196
02197
02198
02199 if ($node["depth"] <= $act_level)
02200 {
02201 if ($_POST["item"][$node["obj_id"]] == "y")
02202 {
02203 $act_level = $node["depth"];
02204 $activated = true;
02205 }
02206 else
02207 {
02208 $act_level = 99999;
02209 $activated = false;
02210 }
02211 }
02212
02213 if ($activated &&
02214 ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node["obj_id"]))
02215 {
02216
02217 if ($node["type"] == "du")
02218 {
02219 $output_header = true;
02220 }
02221
02222
02223 if ($node["type"] == "st")
02224 {
02225 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02226 {
02227 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02228 {
02229 continue;
02230 }
02231 }
02232
02233 $chap =& new ilStructureObject($this->lm, $node["obj_id"]);
02234 $this->tpl->setCurrentBlock("print_chapter");
02235
02236 $chapter_title = $chap->_getPresentationTitle($node["obj_id"],
02237 $this->lm->isActiveNumbering());
02238 $this->tpl->setVariable("CHAP_TITLE",
02239 $chapter_title);
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249 $this->tpl->parseCurrentBlock();
02250 $this->tpl->setCurrentBlock("print_block");
02251 $this->tpl->parseCurrentBlock();
02252 }
02253
02254
02255 if ($node["type"] == "pg")
02256 {
02257 if ($ilUser->getId() == ANONYMOUS_USER_ID and $this->lm_gui->object->getPublicAccessMode() == "selected")
02258 {
02259 if (!ilLMObject::_isPagePublic($node["obj_id"]))
02260 {
02261 continue;
02262 }
02263 }
02264
02265 $this->tpl->setCurrentBlock("print_item");
02266 $page_id = $node["obj_id"];
02267
02268 $page_object =& new ilPageObject($this->lm->getType(), $page_id);
02269
02270 $page_object_gui =& new ilPageObjectGUI($page_object);
02271
02272 $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
02273 $lm_pg_obj->setLMId($this->lm->getId());
02274
02275
02276 $page_object_gui->setLinkFrame($_GET["frame"]);
02277 $page_object_gui->setOutputMode("print");
02278
02279 $page_object_gui->setPresentationTitle("");
02280 if ($this->lm->getPageHeader() == IL_PAGE_TITLE)
02281 {
02282 $page_title = ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
02283 $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
02284
02285
02286
02287 if ($this->lm->isActiveNumbering())
02288 {
02289 $chapter_title = trim(substr($chapter_title,
02290 strpos($chapter_title, " ")));
02291 }
02292
02293 if ($page_title != $chapter_title)
02294 {
02295 $page_object_gui->setPresentationTitle($page_title);
02296 }
02297 }
02298
02299 $page_content = $page_object_gui->showPage();
02300 if ($this->lm->getPageHeader() != IL_PAGE_TITLE)
02301 {
02302 $this->tpl->setVariable("CONTENT", $page_content);
02303 }
02304 else
02305 {
02306 $this->tpl->setVariable("CONTENT", $page_content."<br />");
02307 }
02308 $chapter_title = "";
02309 $this->tpl->parseCurrentBlock();
02310 $this->tpl->setCurrentBlock("print_block");
02311 $this->tpl->parseCurrentBlock();
02312
02313
02314 $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType().":pg", $node["obj_id"]);
02315
02316 $got_mobs = false;
02317
02318 foreach ($int_links as $key => $link)
02319 {
02320 if ($link["type"] == "git" &&
02321 ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
02322 {
02323 $glossary_links[$key] = $link;
02324 }
02325 if ($link["type"] == "mob" &&
02326 ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
02327 {
02328 $got_mobs = true;
02329 $mob_links[$key] = $link;
02330 }
02331 }
02332
02333
02334
02335
02336
02337
02338 if ($got_mobs)
02339 {
02340 $page_object->buildDom();
02341 $links = $page_object->getInternalLinks();
02342 foreach($links as $link)
02343 {
02344 if ($link["Type"] == "MediaObject"
02345 && $link["TargetFrame"] != ""
02346 && $link["TargetFrame"] != "None")
02347 {
02348 $media_links[] = $link;
02349 }
02350 }
02351 }
02352 }
02353 }
02354 }
02355
02356 $annex_cnt = 0;
02357 $annexes = array();
02358
02359
02360 if (count($glossary_links) > 0)
02361 {
02362 include_once("content/classes/class.ilGlossaryTerm.php");
02363 include_once("content/classes/class.ilGlossaryDefinition.php");
02364
02365
02366 $terms = array();
02367
02368 foreach($glossary_links as $key => $link)
02369 {
02370 $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]);
02371 $terms[$term.":".$key] = $link;
02372 }
02373 ksort($terms);
02374
02375 foreach($terms as $key => $link)
02376 {
02377 $defs = ilGlossaryDefinition::getDefinitionList($link["id"]);
02378 $def_cnt = 1;
02379
02380
02381 foreach($defs as $def)
02382 {
02383
02384 if (count($defs) > 1)
02385 {
02386 $this->tpl->setCurrentBlock("def_title");
02387 $this->tpl->setVariable("TXT_DEFINITION",
02388 $this->lng->txt("cont_definition")." ".($def_cnt++));
02389 $this->tpl->parseCurrentBlock();
02390 }
02391 $page =& new ilPageObject("gdf", $def["id"]);
02392 $page_gui =& new ilPageObjectGUI($page);
02393 $page_gui->setTemplateOutput(false);
02394 $page_gui->setOutputMode("print");
02395
02396 $this->tpl->setCurrentBlock("definition");
02397 $output = $page_gui->showPage();
02398 $this->tpl->setVariable("VAL_DEFINITION", $output);
02399 $this->tpl->parseCurrentBlock();
02400 }
02401
02402
02403 $this->tpl->setCurrentBlock("term");
02404 $this->tpl->setVariable("VAL_TERM",
02405 $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]));
02406 $this->tpl->parseCurrentBlock();
02407 }
02408
02409
02410 $annex_cnt++;
02411 $this->tpl->setCurrentBlock("glossary");
02412 $annex_title = $this->lng->txt("cont_annex")." ".
02413 chr(64+$annex_cnt).": ".$this->lng->txt("glo");
02414 $this->tpl->setVariable("TXT_GLOSSARY", $annex_title);
02415 $this->tpl->parseCurrentBlock();
02416
02417 $annexes[] = $annex_title;
02418 }
02419
02420
02421 if (count($media_links) > 0)
02422 {
02423 include_once("content/classes/Media/class.ilObjMediaObject.php");
02424 include_once("content/classes/Media/class.ilMediaItem.php");
02425
02426 foreach($media_links as $media)
02427 {
02428 if (substr($media["Target"],0,4) == "il__")
02429 {
02430 $arr = explode("_",$media["Target"]);
02431 $id = $arr[count($arr) - 1];
02432
02433 $med_obj = new ilObjMediaObject($id);
02434 $med_item =& $med_obj->getMediaItem("Standard");
02435 if (is_object($med_item))
02436 {
02437 if (is_int(strpos($med_item->getFormat(), "image")))
02438 {
02439 $this->tpl->setCurrentBlock("ref_image");
02440
02441
02442 if ($med_item->getLocationType() == "LocalFile")
02443 {
02444 $this->tpl->setVariable("IMG_SOURCE",
02445 ilUtil::getWebspaceDir("output")."/mobs/mm_".$id.
02446 "/".$med_item->getLocation());
02447 }
02448 else
02449 {
02450 $this->tpl->setVariable("IMG_SOURCE",
02451 $med_item->getLocation());
02452 }
02453
02454 if ($med_item->getCaption() != "")
02455 {
02456 $this->tpl->setVariable("IMG_TITLE", $med_item->getCaption());
02457 }
02458 else
02459 {
02460 $this->tpl->setVariable("IMG_TITLE", $med_obj->getTitle());
02461 }
02462 $this->tpl->parseCurrentBlock();
02463 }
02464 }
02465 }
02466 }
02467
02468
02469 $annex_cnt++;
02470 $this->tpl->setCurrentBlock("ref_images");
02471 $annex_title = $this->lng->txt("cont_annex")." ".
02472 chr(64+$annex_cnt).": ".$this->lng->txt("cont_ref_images");
02473 $this->tpl->setVariable("TXT_REF_IMAGES", $annex_title);
02474 $this->tpl->parseCurrentBlock();
02475
02476 $annexes[] = $annex_title;
02477 }
02478
02479
02480 if ($output_header)
02481 {
02482 $this->tpl->setCurrentBlock("print_header");
02483 $this->tpl->setVariable("LM_TITLE", $this->lm->getTitle());
02484 if ($this->lm->getDescription() != "none")
02485 {
02486 $this->lm->initMeta();
02487 $meta =& $this->lm->getMetaData();
02488 $this->tpl->setVariable("LM_DESCRIPTION", $meta->getDescription());
02489 }
02490 $this->tpl->parseCurrentBlock();
02491
02492
02493 $nodes2 = $nodes;
02494 foreach ($nodes2 as $node2)
02495 {
02496 if ($node2["type"] == "st"
02497 && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getId(), $node2["obj_id"]))
02498 {
02499 for ($j=1; $j < $node2["depth"]; $j++)
02500 {
02501 $this->tpl->setCurrentBlock("indent");
02502 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
02503 $this->tpl->parseCurrentBlock();
02504 }
02505 $this->tpl->setCurrentBlock("toc_entry");
02506 $this->tpl->setVariable("TXT_TOC_TITLE",
02507 ilStructureObject::_getPresentationTitle($node2["obj_id"],
02508 $this->lm->isActiveNumbering()));
02509 $this->tpl->parseCurrentBlock();
02510 }
02511 }
02512
02513
02514 foreach ($annexes as $annex)
02515 {
02516 $this->tpl->setCurrentBlock("indent");
02517 $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
02518 $this->tpl->parseCurrentBlock();
02519 $this->tpl->setCurrentBlock("toc_entry");
02520 $this->tpl->setVariable("TXT_TOC_TITLE", $annex);
02521 $this->tpl->parseCurrentBlock();
02522 }
02523
02524 $this->tpl->setCurrentBlock("toc");
02525 $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
02526 $this->tpl->parseCurrentBlock();
02527
02528 $this->tpl->setCurrentBlock("print_start_block");
02529 $this->tpl->parseCurrentBlock();
02530 }
02531
02532 $this->tpl->show(false);
02533
02534 $ilBench->stop("ContentPresentation", "PrintView");
02535 }
02536
02537
02538 function setSessionVars()
02539 {
02540 if($_POST["action"] == "show" or $_POST["action"] == "show_citation")
02541 {
02542 if($_POST["action"] == "show_citation")
02543 {
02544
02545 if(count($_POST["target"]) != 1)
02546 {
02547 sendInfo($this->lng->txt("cont_citation_err_one"));
02548 $_POST["action"] = "";
02549 $_POST["target"] = 0;
02550 return false;
02551 }
02552 $_SESSION["citation"] = 1;
02553 }
02554 else
02555 {
02556 unset($_SESSION["citation"]);
02557 }
02558 if(isset($_POST["tr_id"]))
02559 {
02560 $_SESSION["tr_id"] = $_POST["tr_id"][0];
02561 }
02562 else
02563 {
02564 unset($_SESSION["tr_id"]);
02565 }
02566 if(is_array($_POST["target"]))
02567 {
02568 $_SESSION["bib_id"] = ",".implode(',',$_POST["target"]).",";
02569 }
02570 else
02571 {
02572 $_SESSION["bib_id"] = ",0,";
02573 }
02574 }
02575 return true;
02576 }
02577
02581 function downloadFile()
02582 {
02583 $file = explode("_", $_GET["file_id"]);
02584 require_once("classes/class.ilObjFile.php");
02585 $fileObj =& new ilObjFile($file[count($file) - 1], false);
02586 $fileObj->sendFile();
02587 exit;
02588 }
02589
02593 function download_paragraph ()
02594 {
02595 require_once("content/classes/Pages/class.ilPageObject.php");
02596 $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
02597 $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
02598 }
02599
02603 function showDownloadList()
02604 {
02605 global $ilBench;
02606
02607
02608 $this->tpl->setCurrentBlock("ContentStyle");
02609 if (!$this->offlineMode())
02610 {
02611 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02612 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02613 }
02614 else
02615 {
02616 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02617 }
02618 $this->tpl->parseCurrentBlock();
02619
02620 $this->tpl->setVariable("PAGETITLE", " - ".$this->lm->getTitle());
02621 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
02622 $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_download_list.html", true);
02623
02624
02625 $this->tpl->setVariable("HEADER", $this->lm->getTitle());
02626 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
02627 $this->tpl->setVariable("LINK_BACK",
02628 "lm_presentation.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
02629
02630
02631 require_once("classes/class.ilTableGUI.php");
02632 $tbl = new ilTableGUI();
02633
02634
02635 $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
02636
02637
02638 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", true);
02639
02640 $export_files = array();
02641 $types = array("xml", "html");
02642 foreach($types as $type)
02643 {
02644 if ($this->lm->getPublicExportFile($type) != "")
02645 {
02646 $dir = $this->lm->getExportDirectory($type);
02647 $size = filesize($this->lm->getExportDirectory($type)."/".
02648 $this->lm->getPublicExportFile($type));
02649 $export_files[] = array("type" => $type,
02650 "file" => $this->lm->getPublicExportFile($type),
02651 "size" => $size);
02652 }
02653 }
02654
02655 $num = 0;
02656
02657 $tbl->setTitle($this->lng->txt("download"));
02658
02659 $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
02660 $this->lng->txt("cont_file"),
02661 $this->lng->txt("size"), $this->lng->txt("date"),
02662 ""));
02663
02664 $cols = array("format", "file", "size", "date", "download");
02665 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
02666 "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
02667 $tbl->setHeaderVars($cols, $header_params);
02668 $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
02669
02670
02671 $tbl->setOrderColumn($_GET["sort_by"]);
02672 $tbl->setOrderDirection($_GET["sort_order"]);
02673 $tbl->setLimit($_GET["limit"]);
02674 $tbl->setOffset($_GET["offset"]);
02675 $tbl->setMaxCount($this->maxcount);
02676
02677 $this->tpl->setVariable("COLUMN_COUNTS", 5);
02678
02679
02680
02681 $tbl->disable("footer");
02682
02683 $tbl->setMaxCount(count($export_files));
02684 $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
02685
02686 $tbl->render();
02687 if(count($export_files) > 0)
02688 {
02689 $i=0;
02690 foreach($export_files as $exp_file)
02691 {
02692 $this->tpl->setCurrentBlock("tbl_content");
02693 $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
02694
02695 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
02696 $this->tpl->setVariable("CSS_ROW", $css_row);
02697
02698 $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
02699 $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
02700 $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
02701
02702 $file_arr = explode("__", $exp_file["file"]);
02703 $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
02704
02705 $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
02706 $this->tpl->setVariable("LINK_DOWNLOAD", "lm_presentation.php?cmd=downloadExportFile&type=".
02707 $exp_file["type"]."&ref_id=".$_GET["ref_id"]);
02708
02709 $this->tpl->parseCurrentBlock();
02710 }
02711 }
02712 else
02713 {
02714 $this->tpl->setCurrentBlock("notfound");
02715 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
02716 $this->tpl->setVariable("NUM_COLS", 5);
02717 $this->tpl->parseCurrentBlock();
02718 }
02719
02720 $this->tpl->show();
02721 }
02722
02723
02727 function downloadExportFile()
02728 {
02729 $file = $this->lm->getPublicExportFile($_GET["type"]);
02730 if ($this->lm->getPublicExportFile($_GET["type"]) != "")
02731 {
02732 $dir = $this->lm->getExportDirectory($_GET["type"]);
02733 if (is_file($dir."/".$file))
02734 {
02735 ilUtil::deliverFile($dir."/".$file, $file);
02736 exit;
02737 }
02738 }
02739 $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
02740 }
02741
02742
02746 function getLink($a_ref_id, $a_cmd = "", $a_obj_id = "", $a_frame = "", $a_type = "")
02747 {
02748 if ($a_cmd == "")
02749 {
02750 $a_cmd = "layout";
02751 }
02752 $script = "lm_presentation.php";
02753
02754
02755 if (!$this->offlineMode())
02756 {
02757 $link = $script."?ref_id=".$a_ref_id;
02758 switch ($a_cmd)
02759 {
02760 case "fullscreen":
02761 $link.= "&cmd=fullscreen";
02762 break;
02763
02764 default:
02765 $link.= "&cmd=".$a_cmd;
02766 if ($a_frame != "")
02767 {
02768 $link.= "&frame=".$a_frame;
02769 }
02770 if ($a_obj_id != "")
02771 {
02772 switch ($a_type)
02773 {
02774 case "MediaObject":
02775 $link.= "&mob_id=".$a_obj_id;
02776 break;
02777
02778 default:
02779 $link.= "&obj_id=".$a_obj_id;
02780 break;
02781 }
02782 }
02783 if ($a_type != "")
02784 {
02785 $link.= "&obj_type=".$a_type;
02786 }
02787 break;
02788 }
02789 }
02790 else
02791 {
02792 switch ($a_cmd)
02793 {
02794 case "downloadFile":
02795 break;
02796
02797 case "fullscreen":
02798 $link = "fullscreen.html";
02799 break;
02800
02801 case "layout":
02802
02803 if ($a_obj_id == "")
02804 {
02805 $a_obj_id = $this->lm_tree->getRootId();
02806 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
02807 $a_obj_id = $pg_node["obj_id"];
02808 }
02809 if ($a_type == "StructureObject")
02810 {
02811 $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
02812 $a_obj_id = $pg_node["obj_id"];
02813 }
02814
02815 if ($a_frame != "")
02816 {
02817 if ($a_frame != "toc")
02818 {
02819 $link = "frame_".$a_obj_id."_".$a_frame.".html";
02820 }
02821 else
02822 {
02823 $link = "frame_".$a_frame.".html";
02824 }
02825 }
02826 else
02827 {
02828 $link = "lm_pg_".$a_obj_id.".html";
02829 }
02830 break;
02831
02832 case "glossary":
02833 $link = "term_".$a_obj_id.".html";
02834 break;
02835
02836 case "media":
02837 $link = "media_".$a_obj_id.".html";
02838 break;
02839
02840 default:
02841 break;
02842 }
02843 }
02844
02845 return $link;
02846 }
02847
02848 function showNoPublicAccess()
02849 {
02850 $page_id = $this->getCurrentPageId();
02851
02852
02853 $this->tpl->setCurrentBlock("ContentStyle");
02854
02855 if (!$this->offlineMode())
02856 {
02857 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
02858 ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
02859 }
02860 else
02861 {
02862 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
02863 }
02864
02865 $this->tpl->parseCurrentBlock();
02866 $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_nopublicaccess.html", true);
02867 $this->tpl->setCurrentBlock("pg_content");
02868 $this->tpl->setVariable("TXT_PAGE_NO_PUBLIC_ACCESS",$this->lng->txt("msg_page_no_public_access"));
02869 $this->tpl->parseCurrentBlock();
02870 }
02871 }
02872 ?>