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