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