ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLMPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
5 require_once("./Services/MainMenu/classes/class.ilMainMenuGUI.php");
6 require_once("./Services/Style/classes/class.ilObjStyleSheet.php");
7 
22 {
23  var $ilias;
24  var $lm;
25  var $tpl;
26  var $lng;
28  var $offline;
30 
31  private $needs_to_be_purchased = false;
32 
34  {
35  global $ilias, $lng, $tpl, $rbacsystem, $ilCtrl, $ilAccess;
36 
37  // load language vars
38  $lng->loadLanguageModule("content");
39 
40  $this->ilias =& $ilias;
41  $this->lng =& $lng;
42  $this->tpl =& $tpl;
43  $this->offline = false;
44  $this->frames = array();
45  $this->ctrl =& $ilCtrl;
46  $this->ctrl->saveParameter($this, array("ref_id"));
47  $this->lm_set = new ilSetting("lm");
48 
49 # include_once './classes/class.ilSearch.php';
50 
51 # if(!ilSearch::_checkParentConditions($_GET['ref_id']))
52 # {
53 # $ilias->error_obj->raiseError($lng->txt('access_denied'),$ilias->error_obj->WARNING);
54 # }
55  // Todo: check lm id
56  $type = $this->ilias->obj_factory->getTypeByRefId($_GET["ref_id"]);
57 
58  // TODO: WE NEED AN OBJECT FACTORY FOR GUI CLASSES
59  switch($type)
60  {
61  case "dbk":
62  include_once("./Modules/LearningModule/classes/class.ilObjDlBookGUI.php");
63 
64  $this->lm_gui = new ilObjDlBookGUI($data,$_GET["ref_id"],true,false);
65  break;
66  case "lm":
67  include_once("./Modules/LearningModule/classes/class.ilObjLearningModuleGUI.php");
68 
69  $this->lm_gui = new ilObjLearningModuleGUI($data,$_GET["ref_id"],true,false);
70 
71  break;
72  }
73  $this->lm =& $this->lm_gui->object;
74 
75  if(IS_PAYMENT_ENABLED)
76  {
77  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
78  $this->needs_to_be_purchased = ilPaymentObject::_requiresPurchaseToAccess((int)$this->lm->getRefId());
79  }
80  else $this->needs_to_be_purchased = false;
81 
82  // check, if learning module is online
83  if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
84  {
85  if (!$this->lm->getOnline())
86  {
87  $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
88  }
89  }
90 
91  $this->lm_tree = new ilTree($this->lm->getId());
92  $this->lm_tree->setTableNames('lm_tree','lm_data');
93  $this->lm_tree->setTreeTablePK("lm_id");
94 
95  // do digilib book initialisation stuff
96  if ($type == "dbk")
97  {
98  $this->abstract = true;
99  $this->setSessionVars();
100  if((count($_POST["tr_id"]) > 1) or
101  (!$_POST["target"] and ($_POST["action"] == "show" or $_POST["action"] == "show_citation")))
102  {
103  $this->abstract = true;
104  }
105  else if($_GET["obj_id"] or ($_POST["action"] == "show") or ($_POST["action"] == "show_citation"))
106  {
107  $this->abstract = false;
108  }
109  }
110 
111  }
112 
113 
117  function &executeCommand()
118  {
119  global $ilNavigationHistory, $ilAccess, $ilias, $lng, $ilCtrl;
120 
121  if(IS_PAYMENT_ENABLED)
122  {
123  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
124  if($ilAccess->checkAccess('visible', '', $_GET['ref_id']) &&
126  {
127  if(!((int)$_GET['obj_id'] &&
128  ($this->lm->getPublicAccessMode() == 'selected' && ilLMObject::_isPagePublic($_GET['obj_id'])) &&
129  ($this->ctrl->getCmd() == 'layout' || $this->ctrl->getCmd() == '')))
130 
131  {
132  unset($_GET['obj_id']);
133 
134  $this->tpl->getStandardTemplate();
135  $this->ilLocator();
136 
137  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
138  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
139  $ret = $this->ctrl->forwardCommand($pp);
140  $this->tpl->show();
141  return true;
142  }
143  }
144  }
145  // check read permission, payment and parent conditions
146  // todo: replace all this by ilAccess call
147  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) &&
148  (!(($this->ctrl->getCmd() == "infoScreen" || $this->ctrl->getNextClass() == "ilinfoscreengui")
149  && $ilAccess->checkAccess("visible", "", $_GET["ref_id"]))))
150  {
151  $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
152  }
153 
154  $next_class = $this->ctrl->getNextClass($this);
155  $cmd = $this->ctrl->getCmd("layout", array("showPrintView"));
156 
157  $cmd = (isset($_POST['cmd']['citation']))
158  ? "ilCitation"
159  : $cmd;
160 
161  // ### AA 03.09.01 added page access logger ###
162  $this->lmAccess($this->ilias->account->getId(),$_GET["ref_id"],$_GET["obj_id"]);
163 
164  $obj_id = $_GET["obj_id"];
165  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
166  $ilNavigationHistory->addItem($_GET["ref_id"], $this->ctrl->getLinkTarget($this),"lm");
167  $this->ctrl->setParameter($this, "obj_id", $obj_id);
168 
169  switch($next_class)
170  {
171  case "ilnotegui":
172  $ret =& $this->layout();
173  break;
174 
175  case "ilinfoscreengui":
176  $ret =& $this->outputInfoScreen();
177  break;
178 
179  case "ilcommonactiondispatchergui":
180  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
182  $gui->enableCommentsSettings(false);
183  $this->ctrl->forwardCommand($gui);
184  break;
185 
186  case "ilpageobjectgui":
187  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
188  if ($_GET["pg_type"] != "glo")
189  {
190  $page_gui = new ilPageObjectGUI($this->lm->getType(), $_GET["obj_id"]);
191  }
192  else
193  {
194  $page_gui = new ilPageObjectGUI("gdf", $_GET["pg_id"]);
195  }
196  $this->basicPageGuiInit($page_gui);
197  $ret = $ilCtrl->forwardCommand($page_gui);
198  break;
199 
200  default:
201  $ret =& $this->$cmd();
202  break;
203  }
204  }
205 
206 
210  function setOfflineMode($a_offline = true)
211  {
212  $this->offline = $a_offline;
213  }
214 
215 
219  function offlineMode()
220  {
221  return $this->offline;
222  }
223 
229  function setExportFormat($a_format)
230  {
231  $this->export_format = $a_format;
232  }
233 
239  function getExportFormat()
240  {
241  return $this->export_format;
242  }
243 
247  function nop()
248  {
249  }
250 
251  // ### AA 03.09.01 added page access logger ###
258  function lmAccess($usr_id,$lm_id,$obj_id)
259  {
260  global $ilDB;
261 
262  // first check if an entry for this user and this lm already exist, when so, delete
263  $q = "DELETE FROM lo_access ".
264  "WHERE usr_id = ".$ilDB->quote((int) $usr_id, "integer")." ".
265  "AND lm_id = ".$ilDB->quote((int) $lm_id, "integer");
266  $ilDB->manipulate($q);
267  $title = (is_object($this->lm))?$this->lm->getTitle():"- no title -";
268  // insert new entry
269  $pg_title = "";
270  $q = "INSERT INTO lo_access ".
271  "(timestamp,usr_id,lm_id,obj_id,lm_title) ".
272  "VALUES ".
273  "(".$ilDB->now().",".
274  $ilDB->quote((int) $usr_id, "integer").",".
275  $ilDB->quote((int) $lm_id, "integer").",".
276  $ilDB->quote((int) $obj_id, "integer").",".
277  $ilDB->quote($title, "text").")";
278  $ilDB->manipulate($q);
279  }
280 
289  function export()
290  {
291  switch($this->lm->getType())
292  {
293  case "dbk":
294  $this->lm_gui->export();
295  break;
296  }
297  }
298 
306  function offlineexport()
307  {
308  global $ilDB;
309 
310  if ($_POST["cmd"]["cancel"] != "")
311  {
312  $this->ctrl->setParameter($this, "frame", "maincontent");
313  $this->ctrl->redirect($this, "layout");
314  }
315 
316  switch($this->lm->getType())
317  {
318  case "dbk":
319  //$this->lm_gui->offlineexport();
320  $_GET["frame"] = "maincontent";
321 
322  $objRow["obj_id"] = ilObject::_lookupObjId($_GET["ref_id"]);
323  $_GET["obj_id"] = $objRow["obj_id"];
324 
325  $query = "SELECT * FROM lm_data WHERE lm_id = ".
326  $ilDB->quote($objRow["obj_id"], "integer").
327  " AND type='pg' ";
328  $result = $ilDB->query($query);
329 
330  $page = 0;
331  $showpage = 0;
332  while (is_array($row = $ilDB->fetchAssoc($result)) )
333  {
334 
335  $page++;
336 
337  if ($_POST["pages"]=="all" || ($_POST["pages"]=="fromto" && $page>=$_POST["pagefrom"] && $page<=$_POST["pageto"] ))
338  {
339 
340  if ($showpage>0)
341  {
342  if($_POST["type"] == "pdf") $output .= "<hr BREAK >\n";
343  if($_POST["type"] == "print") $output .= "<p style=\"page-break-after:always\" />";
344  if($_POST["type"] == "html") $output .= "<br><br><br><br>";
345  }
346  $showpage++;
347 
348  $_GET["obj_id"] = $row["obj_id"];
349  $o = $this->layout("main.xml",false);
350 
351  $output .= "<div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" class=\"ilc_PageTitle\">".$this->lm->title."</div><p>";
352  $output .= $o;
353 
354  $output .= "\n<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td valign=top align=center>- ".$page." -</td></tr></table>\n";
355 
356  }
357  }
358 
359  $printTpl = new ilTemplate("tpl.print.html", true, true, "Modules/LearningModule");
360 
361  if($_POST["type"] == "print")
362  {
363  $printTpl->touchBlock("printreq");
364  $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
366  }
367  else
368  {
369  $css1 = "./css/delos.css";
370  $css2 = "./css/content.css";
371  }
372  $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
373 
374  $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
375  $printTpl->setVariable("CONTENT",$output);
376 
377  // syntax style
378  $printTpl->setCurrentBlock("SyntaxStyle");
379  $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
381  $printTpl->parseCurrentBlock();
382 
383 
384  $html = $printTpl->get();
385 
389  $this->lm->createExportDirectory();
390  $export_dir = $this->lm->getExportDirectory();
391 
395  $fileName = "offline";
396  $fileName = str_replace(" ","_",$fileName);
397 
398  if (!file_exists($export_dir."/".$fileName))
399  {
400  @mkdir($export_dir."/".$fileName);
401  @chmod($export_dir."/".$fileName, 0755);
402 
403  @mkdir($export_dir."/".$fileName."/css");
404  @chmod($export_dir."/".$fileName."/css", 0755);
405 
406  }
407 
408  if($_POST["type"] == "xml")
409  {
410  //vd($_GET["ref_id"]);
411  $tmp_obj =& $this->ilias->obj_factory->getInstanceByRefId($_GET["ref_id"]);
412 
413  if ($tmp_obj->getType() == "dbk" )
414  {
415  require_once "./Modules/LearningModule/classes/class.ilObjDlBook.php";
416  $dbk =& new ilObjDlBook($_GET["ref_id"]);
417  $dbk->export();
418  }
419 
420  }
421  else if($_POST["type"] == "print")
422  {
423  echo $html;
424  }
425  else if ($_POST["type"]=="html")
426  {
427 
433  $css1 = file("./templates/default/delos.css");
434  $css1 = implode($css1,"");
435 
436  $fp = fopen($export_dir."/".$fileName."/css/delos.css","wb");
437  fwrite($fp,$css1);
438  fclose($fp);
439 
440  $fp = fopen($export_dir."/".$fileName."/".$fileName.".html","wb");
441  fwrite($fp,$html);
442  fclose($fp);
443 
444  ilUtil::zip($export_dir."/".$fileName, $export_dir."/".$fileName.".zip");
445 
446  ilUtil::deliverFile($export_dir."/".$fileName.".zip", $fileName.".zip");
447 
448  }
449  else if ($_POST["type"]=="pdf")
450  {
451 
452  ilUtil::html2pdf($html, $export_dir."/".$fileName.".pdf");
453 
454  ilUtil::deliverFile($export_dir."/".$fileName.".pdf", $fileName.".pdf");
455 
456  }
457 
458  exit;
459  }
460 
461  }
462 
470  function offlineexportform()
471  {
472 
473  switch($this->lm->getType())
474  {
475  case "dbk":
476  $this->lm_gui->offlineexportform();
477  break;
478  }
479 
480  }
481 
482 
490  function exportbibinfo()
491  {
492  global $ilDB;
493 
494  $objRow["obj_id"] = ilObject::_lookupObjId($_GET["ref_id"]);
495  $objRow["title"] = ilObject::_lookupTitle($objRow["obj_id"]);
496 
497  $filename = preg_replace('/[^a-z0-9_]/i', '_', $objRow["title"]);
498 
499  $C = $this->lm_gui->showAbstract(array(1));
500 
501  if ($_GET["print"]==1)
502  {
503  $printTpl = new ilTemplate("tpl.print.html", true, true, "Modules/LearningModule");
504  $printTpl->touchBlock("printreq");
505  $css1 = ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId());
507  $printTpl->setVariable("LOCATION_CONTENT_STYLESHEET", $css1 );
508 
509  $printTpl->setVariable("LOCATION_STYLESHEET", $css2);
510 
511  // syntax style
512  $printTpl->setCurrentBlock("SyntaxStyle");
513  $printTpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
515  $printTpl->parseCurrentBlock();
516 
517  $printTpl->setVariable("CONTENT",$C);
518 
519  echo $printTpl->get();
520  exit;
521  }
522  else
523  {
524  ilUtil::deliverData($C, $filename.".html");
525  exit;
526  }
527 
528  }
529 
530 
531 
532 
533  function attrib2arr($a_attributes)
534  {
535  $attr = array();
536  if(!is_array($a_attributes))
537  {
538  return $attr;
539  }
540  foreach ($a_attributes as $attribute)
541  {
542  $attr[$attribute->name()] = $attribute->value();
543  }
544  return $attr;
545  }
546 
551  {
552  return $this->frames;
553  }
554 
558  function determineLayout()
559  {
560  if ($this->getExportFormat() == "scorm")
561  {
562  $layout = "1window";
563  }
564  else
565  {
566  $layout = $this->lm->getLayout();
567  if ($this->lm->getLayoutPerPage())
568  {
569  $pg_id = $this->getCurrentPageId();
570 
571  if (in_array($_GET["cmd"], array("media", "glossary")) && $_GET["from_page"] > 0)
572  {
573  $pg_id = (int) $_GET["from_page"];
574  }
575 
576  if ($pg_id > 0)
577  {
578  $lay = ilLMObject::lookupLayout($pg_id);
579  if ($lay != "")
580  {
581  $layout = $lay;
582  }
583  }
584  }
585  }
586 
587  return $layout;
588  }
589 
590 
594  function layout($a_xml = "main.xml", $doShow = true)
595  {
596  global $tpl, $ilBench, $ilSetting;
597 
598  $ilBench->start("ContentPresentation", "layout");
599 
600  $layout = $this->determineLayout();
601 
602  // xmldocfile is deprecated! Use domxml_open_file instead.
603  // But since using relative pathes with domxml under windows don't work,
604  // we need another solution:
605  $xmlfile = file_get_contents("./Modules/LearningModule/layouts/lm/".$layout."/".$a_xml);
606 
607  if (!$doc = domxml_open_mem($xmlfile)) { echo "ilLMPresentation: XML File invalid"; exit; }
608  $this->layout_doc =& $doc;
609 //echo ":".htmlentities($xmlfile).":$layout:$a_xml:";
610 
611  // get current frame node
612  $ilBench->start("ContentPresentation", "layout_getFrameNode");
613  $xpc = xpath_new_context($doc);
614  $path = (empty($_GET["frame"]) || ($_GET["frame"] == "_blank"))
615  ? "/ilLayout/ilFrame[1]"
616  : "//ilFrame[@name='".$_GET["frame"]."']";
617  $result = xpath_eval($xpc, $path);
618  $found = $result->nodeset;
619  if (count($found) != 1) { echo "ilLMPresentation: XML File invalid"; exit; }
620  $node = $found[0];
621 
622  $ilBench->stop("ContentPresentation", "layout_getFrameNode");
623 
624  // ProcessFrameset
625  // node is frameset, if it has cols or rows attribute
626  $attributes = $this->attrib2arr($node->attributes());
627 
628  $this->frames = array();
629  if((!empty($attributes["rows"])) || (!empty($attributes["cols"])))
630  {
631  $content .= $this->buildTag("start", "frameset", $attributes);
632  //$this->frames = array();
633  $this->processNodes($content, $node);
634  $content .= $this->buildTag("end", "frameset");
635  $this->tpl = new ilTemplate("tpl.frameset.html", true, true, "Modules/LearningModule");
636  $this->renderPageTitle();
637  $this->tpl->setVariable("FS_CONTENT", $content);
638  if (!$doshow)
639  {
640  $content = $this->tpl->get();
641  }
642  }
643  else // node is frame -> process the content tags
644  {
645  // ProcessContentTag
646  $ilBench->start("ContentPresentation", "layout_processContentTag");
647  //if ((empty($attributes["template"]) || !empty($_GET["obj_type"])))
648  if ((empty($attributes["template"]) || !empty($_GET["obj_type"]))
649  && ($_GET["frame"] != "_blank" || $_GET["obj_type"] != "MediaObject"))
650  {
651  // we got a variable content frame (can display different
652  // object types (PageObject, MediaObject, GlossarItem)
653  // and contains elements for them)
654 
655  // determine object type
656  if(empty($_GET["obj_type"]))
657  {
658  $obj_type = "PageObject";
659  }
660  else
661  {
662  $obj_type = $_GET["obj_type"];
663  }
664 
665  // get object specific node
666  $childs = $node->child_nodes();
667  $found = false;
668  foreach($childs as $child)
669  {
670  if ($child->node_name() == $obj_type)
671  {
672  $found = true;
673  $attributes = $this->attrib2arr($child->attributes());
674  $node =& $child;
675 //echo "<br>2node:".$node->node_name();
676  break;
677  }
678  }
679  if (!$found) { echo "ilLMPresentation: No template specified for frame '".
680  $_GET["frame"]."' and object type '".$obj_type."'."; exit; }
681  }
682 
683  // get template
684  $in_module = ($attributes["template_location"] == "module")
685  ? true
686  : false;
687  if ($in_module)
688  {
689  $this->tpl = new ilTemplate($attributes["template"], true, true, $in_module);
690  $this->tpl->setBodyClass("");
691  }
692  else
693  {
694  $this->tpl =& $tpl;
695  }
696 
697  // set style sheets
698  if (!$this->offlineMode())
699  {
700  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
701  }
702  else
703  {
704  $style_name = $this->ilias->account->prefs["style"].".css";
705  $this->tpl->setVariable("LOCATION_STYLESHEET","./style/".$style_name);
706  }
707 
708  $childs = $node->child_nodes();
709 
710  $ilBench->start("ContentPresentation", "layout_processContentNodes");
711  foreach($childs as $child)
712  {
713 
714  $child_attr = $this->attrib2arr($child->attributes());
715 
716  switch ($child->node_name())
717  {
718  case "ilMainMenu":
719  $this->ilMainMenu();
720  break;
721 
722  case "ilTOC":
723  $this->ilTOC($child_attr["target_frame"]);
724  break;
725 
726  case "ilPage":
727  switch($this->lm->getType())
728  {
729  case "lm":
730  unset($_SESSION["tr_id"]);
731  unset($_SESSION["bib_id"]);
732  unset($_SESSION["citation"]);
733  $content = $this->ilPage($child);
734  break;
735 
736  case "dbk":
737  $this->setSessionVars();
738  if($this->abstract)
739  {
740  $content = $this->lm_gui->showAbstract($_POST["target"]);
741  }
742  else
743  {
744  // SHOW PAGE IF PAGE WAS SELECTED
745  $content = $this->ilPage($child);
746 
747  if($_SESSION["tr_id"])
748  {
749  $translation_content = $this->ilTranslation($child);
750  }
751  }
752  break;
753  }
754  break;
755 
756  case "ilGlossary":
757  $content = $this->ilGlossary($child);
758  break;
759 
760  case "ilLMNavigation":
761 
762  // NOT FOR ABSTRACT
763  if($_GET["obj_id"] or
764  ((count($_POST["tr_id"]) < 2) and $_POST["target"] and
765  ($_POST["action"] == "show" or $_POST["action"] == "show_citation")) or
766  $this->lm->getType() == 'lm')
767  {
768  $ilBench->start("ContentPresentation", "layout_lmnavigation");
769  $this->ilLMNavigation();
770  $ilBench->stop("ContentPresentation", "layout_lmnavigation");
771  }
772  break;
773 
774  case "ilMedia":
775  $this->ilMedia();
776  break;
777 
778  case "ilLocator":
779  $this->ilLocator();
780  break;
781 
782  case "ilJavaScript":
783  $this->ilJavaScript($child_attr["inline"], $child_attr["file"],
784  $child_attr["location"]);
785  break;
786 
787  case "ilLMMenu":
788  $this->ilLMMenu();
789  break;
790 
791  case "ilLMHead":
792  $this->ilLMHead();
793  break;
794 
795  case "ilLMSubMenu":
796  $this->ilLMSubMenu();
797  break;
798 
799  case "ilLMNotes":
800  //if (!$this->ilias->getSetting('disable_notes'))
801  //{
802  $this->ilLMNotes();
803  //}
804  break;
805  }
806  }
807  $ilBench->stop("ContentPresentation", "layout_processContentNodes");
808 
809  $ilBench->stop("ContentPresentation", "layout_processContentTag");
810 
811  // TODO: Very dirty hack to force the import of JavaScripts in learning content in the FAQ frame (e.g. if jsMath is in the content)
812  // Unfortunately there is no standardized way to do this somewhere else. Calling fillJavaScripts always in ilTemplate causes multiple additions of the the js files.
813  if (strcmp($_GET["frame"], "topright") == 0) $this->tpl->fillJavaScriptFiles();
814  if (strcmp($_GET["frame"], "right") == 0) $this->tpl->fillJavaScriptFiles();
815  if (strcmp($_GET["frame"], "botright") == 0) $this->tpl->fillJavaScriptFiles();
816 
817  if (!$this->offlineMode())
818  {
819  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
822 
823  // from main menu
824  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
825  $this->tpl->addJavascript("./Services/Navigation/js/ServiceNavigation.js");
826  $this->tpl->fillJavaScriptFiles();
827  $this->tpl->fillScreenReaderFocus();
828 
829  $this->tpl->fillCssFiles();
830  }
831  else
832  {
833  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
835  {
836  if ($f["type"] == "js")
837  {
838  $this->tpl->addJavascript($f["target"]);
839  }
840  if ($f["type"] == "css")
841  {
842  $this->tpl->addCSS($f["target"]);
843  }
844  }
845  $this->tpl->fillJavaScriptFiles(true);
846  $this->tpl->fillCssFiles(true);
847  }
848 
849 
850  $this->tpl->fillBodyClass();
851  }
852 
853  $this->renderPageTitle();
854 
855  if ($doShow)
856  {
857  // (horrible) workaround for preventing template engine
858  // from hiding paragraph text that is enclosed
859  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
860 
861  $this->tpl->fillTabs();
862  if ($this->fill_on_load_code)
863  {
864  $this->tpl->fillOnLoadCode();
865  }
866  $content = $this->tpl->get();
867  $content = str_replace("&#123;", "{", $content);
868  $content = str_replace("&#125;", "}", $content);
869 
870  header('Content-type: text/html; charset=UTF-8');
871  echo $content;
872  }
873  else
874  {
875  $content = $this->tpl->get();
876  }
877 
878  $ilBench->stop("ContentPresentation", "layout");
879 
880  return($content);
881  }
882 
883  function fullscreen()
884  {
885  return $this->layout("fullscreen.xml", !$this->offlineMode());
886  }
887 
888  function media()
889  {
890  if ($_GET["frame"] != "_blank")
891  {
892  return $this->layout("main.xml", !$this->offlineMode());
893  }
894  else
895  {
896  return $this->layout("fullscreen.xml", !$this->offlineMode());
897  }
898  }
899 
900  function glossary()
901  {
902  if ($_GET["frame"] != "_blank")
903  {
904  $this->layout();
905  }
906  else
907  {
908  $this->tpl = new ilTemplate("tpl.glossary_term_output.html", true, true, true);
909  $this->renderPageTitle();
910 
911  // set style sheets
912  if (!$this->offlineMode())
913  {
914  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
915  }
916  else
917  {
918  $style_name = $this->ilias->account->prefs["style"].".css";;
919  $this->tpl->setVariable("LOCATION_STYLESHEET","./style/".$style_name);
920  }
921 
922  $this->ilGlossary($child);
923  if (!$this->offlineMode())
924  {
925  $this->tpl->show();
926  }
927  else
928  {
929  return $this->tpl->get();
930  }
931  }
932  }
933 
937  function ilMainMenu()
938  {
939  global $ilBench, $ilMainMenu;
940 
941  if ($this->offlineMode())
942  {
943  return;
944  }
945 
946  if ($this->determineLayout() == "2window" ||
947  $this->determineLayout() == "3window")
948  {
949  $ilMainMenu->setSmallMode(true);
950  }
951  else
952  {
953  $ilMainMenu->setSmallMode(false);
954  }
955 
956  $page_id = $this->getCurrentPageId();
957  if ($page_id > 0)
958  {
959  $ilMainMenu->setLoginTargetPar("pg_".$page_id."_".$this->lm->getRefId());
960  }
961 
962  $this->tpl->touchBlock("mm_intro");
963  $this->tpl->touchBlock("mm_outro");
964  $this->tpl->touchBlock("pg_intro");
965  $this->tpl->touchBlock("pg_outro");
966  $this->tpl->setBodyClass("std");
967  $this->tpl->setVariable("MAINMENU", $ilMainMenu->getHTML());
968  }
969 
973  function ilTOC($a_target)
974  {
975  global $ilBench;
976 
977  $ilBench->start("ContentPresentation", "ilTOC");
978  require_once("./Modules/LearningModule/classes/class.ilLMTOCExplorer.php");
979  if ($this->lm->cleanFrames())
980  {
981  $a_target = "";
982  }
983  $exp = new ilLMTOCExplorer($this->getLink($this->lm->getRefId(), "layout", "", $a_target),$this->lm);
984  $exp->setExpandTarget($this->getLink($this->lm->getRefId(), $_GET["cmd"], $_GET["obj_id"], $_GET["frame"]));
985  $exp->setTargetGet("obj_id");
986  if ($this->lm->cleanFrames())
987  {
988  if ($this->offlineMode())
989  {
990  $exp->setFrameTarget("_top");
991  }
992  else
993  {
994  $exp->setFrameTarget(ilFrameTargetInfo::_getFrame("MainContent"));
995  }
996  }
997  else
998  {
999  $exp->setFrameTarget($a_target);
1000  }
1001  $exp->addFilter("du");
1002  $exp->addFilter("st");
1003 
1004  // force expansion
1005  if ($this->lm->cleanFrames())
1006  {
1007  $page_id = $this->getCurrentPageId();
1008  if ($page_id > 0)
1009  {
1010  $path = $this->lm_tree->getPathId($page_id);
1011  $exp->setForceOpenPath($path);
1012  }
1013  if (!$this->offlineMode())
1014  {
1015  // empty chapter
1016  if ($this->chapter_has_no_active_page &&
1017  ilLMObject::_lookupType($_GET["obj_id"]) == "st")
1018  {
1019  $exp->highlightNode($_GET["obj_id"]);
1020  }
1021  else
1022  {
1023  $exp->highlightNode($page_id);
1024  }
1025  }
1026  }
1027 
1028  $exp->setOfflineMode($this->offlineMode());
1029  if ($this->lm->getTOCMode() == "pages")
1030  {
1031  $exp->addFilter("pg");
1032  }
1033  $exp->setFiltered(true);
1034  $exp->setFilterMode(IL_FM_POSITIVE);
1035 
1036  if ($_GET["lmexpand"] == "")
1037  {
1038  $expand_keys = array();
1039  if (is_array($_SESSION["lmexpand"]))
1040  {
1041  $expand_keys = array_keys($_SESSION["lmexpand"]);
1042  }
1043  $_SESSION["lmexpand"] = array($this->lm_tree->readRootId());
1044  $expanded = $this->lm_tree->readRootId();
1045  }
1046  else
1047  {
1048  $expanded = $_GET["lmexpand"];
1049  }
1050  $exp->setExpand($expanded);
1051 
1052  // build html-output
1053  $exp->setOutput(0);
1054  $output = $exp->getOutput();
1055 
1056  $this->renderPageTitle();
1057 
1058  // set style sheets
1059  if (!$this->offlineMode())
1060  {
1061  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1062  }
1063  else
1064  {
1065  $style_name = $this->ilias->account->prefs["style"].".css";;
1066  $this->tpl->setVariable("LOCATION_STYLESHEET","./style/".$style_name);
1067  }
1068 
1069  if (!$this->offlineMode())
1070  {
1071  $this->tpl->addBlockFile("EXPL_TOP", "exp_top", "tpl.explorer_top.html");
1072  //$this->tpl->setVariable("DUMMY", "&nbsp;");
1073  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
1074  }
1075  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("overview"));
1076  $this->tpl->setVariable("EXPLORER",$output);
1077  $this->tpl->setVariable("ACTION",
1078  $this->getLink($this->lm->getRefId(), $_GET["cmd"], "", $_GET["frame"]).
1079  "&lmexpand=".$_GET["lmexpand"]);
1080  $this->tpl->parseCurrentBlock();
1081  $ilBench->stop("ContentPresentation", "ilTOC");
1082  if ($_GET["lmexpand"] == "")
1083  {
1084  // collapse all other branches on navigation
1085  foreach ($expand_keys as $k)
1086  {
1087  unset($_SESSION["lmexpand"][$k]);
1088  }
1089  }
1090 //var_dump($_SESSION["lmexpand"]);
1091  }
1092 
1096  function ilLMMenu()
1097  {
1098  $this->tpl->setVariable("MENU", $this->lm_gui->setilLMMenu($this->offlineMode()
1099  ,$this->getExportFormat(), "content", false, true, $this->getCurrentPageId()));
1100  }
1101 
1105  function ilLMHead()
1106  {
1107  $this->tpl->setCurrentBlock("header_image");
1108  if ($this->offlineMode())
1109  {
1110  $this->tpl->setVariable("IMG_HEADER", "./images/icon_lm.gif");
1111  }
1112  else
1113  {
1114  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm.gif"));
1115  }
1116  $this->tpl->parseCurrentBlock();
1117  $this->tpl->setCurrentBlock("lm_head");
1118  $this->tpl->setVariable("HEADER", $this->lm->getTitle());
1119  $this->tpl->parseCurrentBlock();
1120  }
1121 
1125  function ilLMSubMenu()
1126  {
1127  global $rbacsystem;
1128 
1129  // no sub menu for abstract of digilib book
1130  if ($this->lm->getType() == "dbk" && $this->abstract)
1131  {
1132  return;
1133  }
1134 
1135  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
1136  $showViewInFrameset = true;
1137 
1138  if ($showViewInFrameset)
1139  {
1140  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
1141  }
1142  else
1143  {
1144  $buttonTarget = "_top";
1145  }
1146 
1147 
1148  include_once("./classes/class.ilTemplate.php");
1149  $tpl_menu =& new ilTemplate("tpl.lm_sub_menu.html", true, true, true);
1150 
1151  $pg_id = $this->getCurrentPageId();
1152  if ($pg_id == 0)
1153  {
1154  return;
1155  }
1156 
1157  // edit learning module
1158  if (!$this->offlineMode())
1159  {
1160  if ($rbacsystem->checkAccess("write", $_GET["ref_id"]))
1161  {
1162  $tpl_menu->setCurrentBlock("edit_page");
1163  $page_id = $this->getCurrentPageId();
1164  $tpl_menu->setVariable("EDIT_LINK", ILIAS_HTTP_PATH."/ilias.php?baseClass=ilLMEditorGUI&ref_id=".$_GET["ref_id"].
1165  "&obj_id=".$page_id."&to_page=1");
1166  $tpl_menu->setVariable("EDIT_TXT", $this->lng->txt("edit_page"));
1167  $tpl_menu->setVariable("EDIT_TARGET", $buttonTarget);
1168  $tpl_menu->parseCurrentBlock();
1169  }
1170 
1171  $page_id = $this->getCurrentPageId();
1172 
1173  include_once("./Services/PermanentLink/classes/class.ilPermanentLinkGUI.php");
1174  $plinkgui = new ilPermanentLinkGUI("pg",
1175  $page_id."_".$this->lm->getRefId(),
1176  "",
1177  "_top");
1178 
1179  $title = $this->lm->getTitle();
1180  $pg_title = ilLMPageObject::_getPresentationTitle($page_id,
1181  $this->lm->getPageHeader(), $this->lm->isActiveNumbering());
1182  if ($pg_title != "")
1183  {
1184  $title.= ": ".$pg_title;
1185  }
1186 
1187  $plinkgui->setTitle($title);
1188 
1189  $tpl_menu->setCurrentBlock("perma_link");
1190  $tpl_menu->setVariable("PERMA_LINK", $plinkgui->getHTML());
1191  $tpl_menu->parseCurrentBlock();
1192 
1193  }
1194 
1195  $this->tpl->setVariable("SUBMENU", $tpl_menu->get());
1196  }
1197 
1198 
1203  {
1204  echo $this->addHeaderAction(true);
1205  exit;
1206  }
1207 
1211  function addHeaderAction($a_redraw = false)
1212  {
1213  global $ilUser, $ilAccess;
1214 
1215  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
1217  $ilAccess, $this->lm->getType(), $_GET["ref_id"], $this->lm->getId());
1218  $dispatcher->setSubObject("pg", $this->getCurrentPageId());
1219 
1220  include_once "Services/Object/classes/class.ilObjectListGUI.php";
1221  ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
1222  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
1223  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
1224 
1225  $lg = $dispatcher->initHeaderAction();
1226  $lg->enableNotes(true);
1227  $lg->enableComments($this->lm->publicNotes(), false);
1228 
1229  if(!$a_redraw)
1230  {
1231  $this->tpl->setVariable("HEAD_ACTION", $lg->getHeaderAction());
1232  }
1233  else
1234  {
1235  return $lg->getHeaderAction();
1236  }
1237  }
1238 
1242  function ilLMNotes()
1243  {
1244  global $ilAccess, $ilSetting;
1245 
1246 
1247  // no notes for abstract of digilib book
1248  if ($this->lm->getType() == "dbk" && $this->abstract)
1249  {
1250  return;
1251  }
1252 
1253  // no notes in offline (export) mode
1254  if ($this->offlineMode())
1255  {
1256  return;
1257  }
1258 
1259  // output notes (on top)
1260 
1261  if (!$ilSetting->get("disable_notes"))
1262  {
1263  $this->addHeaderAction();
1264  }
1265 
1266  // now output comments
1267 
1268  if ($ilSetting->get("disable_comments"))
1269  {
1270  return;
1271  }
1272 
1273  if (!$this->lm->publicNotes())
1274  {
1275  return;
1276  }
1277 
1278  $next_class = $this->ctrl->getNextClass($this);
1279 
1280  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1281  $pg_id = $this->getCurrentPageId();
1282  if ($pg_id == 0)
1283  {
1284  return;
1285  }
1286 
1287  $notes_gui = new ilNoteGUI($this->lm->getId(), $this->getCurrentPageId(), "pg");
1288  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1289  {
1290  $notes_gui->enablePublicNotesDeletion(true);
1291  }
1292 
1293  $this->ctrl->setParameter($this, "frame", $_GET["frame"]);
1294  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1295 
1296  $notes_gui->enablePrivateNotes();
1297  if ($this->lm->publicNotes())
1298  {
1299  $notes_gui->enablePublicNotes();
1300  }
1301 
1302  if ($next_class == "ilnotegui")
1303  {
1304  $html = $this->ctrl->forwardCommand($notes_gui);
1305  }
1306  else
1307  {
1308  $html = $notes_gui->getNotesHTML();
1309  }
1310  $this->tpl->setVariable("NOTES", $html);
1311  }
1312 
1313 
1317  function ilLocator()
1318  {
1319  global $ilLocator, $tree;
1320 
1321  require_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1322 
1323  if (empty($_GET["obj_id"]))
1324  {
1325  $a_id = $this->lm_tree->getRootId();
1326  }
1327  else
1328  {
1329  $a_id = $_GET["obj_id"];
1330  }
1331 
1332  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1333 
1334  if (!$this->lm->cleanFrames())
1335  {
1336  $frame_param = $_GET["frame"];
1337  $frame_target = "";
1338  }
1339  else if (!$this->offlineMode())
1340  {
1341  $frame_param = "";
1342  $frame_target = ilFrameTargetInfo::_getFrame("MainContent");
1343  }
1344  else
1345  {
1346  $frame_param = "";
1347  $frame_target = "_top";
1348  }
1349 
1350  if (!$this->offlineMode())
1351  {
1352  $ilLocator->addItem("...", "");
1353 
1354  $par_id = $tree->getParentId($_GET["ref_id"]);
1355  $ilLocator->addItem(
1357  "repository.php?cmd=frameset&amp;ref_id=".$par_id,
1358  ilFrameTargetInfo::_getFrame("MainContent"), $par_id);
1359  }
1360  else
1361  {
1362  $ilLocator->setOffline(true);
1363  }
1364 
1365  if($this->lm_tree->isInTree($a_id))
1366  {
1367  $path = $this->lm_tree->getPathFull($a_id);
1368 
1369  foreach ($path as $key => $row)
1370  {
1371  if ($row["type"] != "pg")
1372  {
1373  if($row["child"] != $this->lm_tree->getRootId())
1374  {
1375  $ilLocator->addItem(
1378  $this->lm->isActiveNumbering()),50,true),
1379  $this->getLink($_GET["ref_id"], "layout", $row["child"], $frame_param, "StructureObject"),
1380  $frame_target);
1381  }
1382  else
1383  {
1384  $ilLocator->addItem(
1385  ilUtil::shortenText($this->lm->getTitle(),50,true),
1386  $this->getLink($_GET["ref_id"], "layout", "", $frame_param),
1387  $frame_target, $_GET["ref_id"]);
1388  }
1389  }
1390  }
1391  }
1392  else // lonely page
1393  {
1394 
1395  $ilLocator->addItem(
1396  $this->lm->getTitle(),
1397  $this->getLink($_GET["ref_id"], "layout", "", $_GET["frame"]));
1398 
1399  require_once("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
1400  $lm_obj =& ilLMObjectFactory::getInstance($this->lm, $a_id);
1401 
1402  $ilLocator->addItem(
1403  $lm_obj->getTitle(),
1404  $this->getLink($_GET["ref_id"], "layout", $a_id, $frame_param),
1405  $frame_target);
1406  }
1407 
1408  if (DEBUG)
1409  {
1410  $debug = "DEBUG: <font color=\"red\">".$this->type."::".$this->id."::".$_GET["cmd"]."</font><br/>";
1411  }
1412 
1413  //$prop_name = $this->objDefinition->getPropertyName($_GET["cmd"],$this->type);
1414 
1415 
1416  $this->tpl->setLocator();
1417  }
1418 
1419  function getCurrentPageId()
1420  {
1421  global $ilUser;
1422 
1423  include_once("./Services/COPage/classes/class.ilPageObject.php");
1424 
1425  $this->chapter_has_no_active_page = false;
1426  $this->deactivated_page = false;
1427 
1428  // determine object id
1429  if(empty($_GET["obj_id"]))
1430  {
1431  $obj_id = $this->lm_tree->getRootId();
1432  }
1433  else
1434  {
1435  $obj_id = $_GET["obj_id"];
1436  $active = ilPageObject::_lookupActive($obj_id,
1437  $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
1438 
1439  if (!$active &&
1440  ilLMPageObject::_lookupType($obj_id) == "pg")
1441  {
1442  $this->deactivated_page = true;
1443  }
1444  }
1445 
1446  // obj_id not in tree -> it is a unassigned page -> return page id
1447  if (!$this->lm_tree->isInTree($obj_id))
1448  {
1449  return $obj_id;
1450  }
1451 
1452  $curr_node = $this->lm_tree->getNodeData($obj_id);
1453 
1454  $active = ilPageObject::_lookupActive($obj_id,
1455  $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
1456 
1457  if ($curr_node["type"] == "pg" &&
1458  $active) // page in tree -> return page id
1459  {
1460  $page_id = $curr_node["obj_id"];
1461  }
1462  else // no page -> search for next page and return its id
1463  {
1464  $succ_node = true;
1465  $active = false;
1466  $page_id = $obj_id;
1467  while($succ_node && !$active)
1468  {
1469  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
1470  $page_id = $succ_node["obj_id"];
1471  $active = ilPageObject::_lookupActive($page_id,
1472  $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
1473  }
1474 
1475  if ($succ_node["type"] != "pg")
1476  {
1477  $this->chapter_has_no_active_page = true;
1478  return 0;
1479  $this->tpl = new ilTemplate("tpl.main.html", true, true);
1480  $this->ilias->raiseError($this->lng->txt("cont_no_page"),$this->ilias->error_obj->FATAL);
1481  $this->tpl->show();
1482  exit;
1483  }
1484 
1485  // if public access get first public page in chapter
1486  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
1487  $this->lm_gui->object->getPublicAccessMode() == 'selected')
1488  {
1489  $public = ilLMObject::_isPagePublic($page_id);
1490 
1491  while ($public === false && $page_id > 0)
1492  {
1493  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, 'pg');
1494  $page_id = $succ_node['obj_id'];
1495  $public = ilLMObject::_isPagePublic($page_id);
1496  }
1497  }
1498 
1499  // check whether page found is within "clicked" chapter
1500  if ($this->lm_tree->isInTree($page_id))
1501  {
1502  $path = $this->lm_tree->getPathId($page_id);
1503  if (!in_array($_GET["obj_id"], $path))
1504  {
1505  $this->chapter_has_no_active_page = true;
1506  }
1507  }
1508  }
1509 
1510  return $page_id;
1511  }
1512 
1513  function mapCurrentPageId($current_page_id)
1514  {
1515  $subtree = $this->lm_tree->getSubTree($this->lm_tree->getNodeData(1));
1516  $node = $this->lm_tree->getNodeData($current_page_id);
1517  $pos = array_search($node,$subtree);
1518 
1519  $this->tr_obj =& $this->ilias->obj_factory->getInstanceByRefId($_SESSION["tr_id"]);
1520 
1521  $lmtree = new ilTree($this->tr_obj->getId());
1522  $lmtree->setTableNames('lm_tree','lm_data');
1523  $lmtree->setTreeTablePK("lm_id");
1524 
1525  $subtree = $lmtree->getSubTree($lmtree->getNodeData(1));
1526 
1527  return $subtree[$pos]["child"];
1528  }
1529 
1530  function ilTranslation(&$a_page_node)
1531  {
1532  global $ilUser;
1533 
1534  require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
1535  require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1536 
1537  $page_id = $this->mapCurrentPageId($this->getCurrentPageId());
1538 
1539  if(!$page_id)
1540  {
1541  $this->tpl->setVariable("TRANSLATION_CONTENT","NO TRNSLATION FOUND");
1542  return false;
1543  }
1544 
1545  $page_object =& new ilPageObject($this->lm->getType(), $page_id);
1546  $page_object_gui =& new ilPageObjectGUI($this->lm->getType(), $page_id);
1547 
1548  // Update personal desktop items
1549  $this->ilias->account->setDesktopItemParameters($_SESSION["tr_id"], $this->lm->getType(),$page_id);
1550 
1551  // Update course items
1552  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
1553 
1554  ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
1555 
1556  // read link targets
1557  $targets = $this->getLayoutLinkTargets();
1558 
1559  $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
1560  $lm_pg_obj->setLMId($_SESSION["tr_id"]);
1561  //$pg_obj->setParentId($this->lm->getId());
1562  #$page_object_gui->setLayoutLinkTargets($targets);
1563 
1564  // USED FOR DBK PAGE TURNS
1565  $page_object_gui->setBibId($_SESSION["bib_id"]);
1566 
1567  // determine target frames for internal links
1568  //$pg_frame = $_GET["frame"];
1569  $page_object_gui->setLinkFrame($_GET["frame"]);
1570  $page_object_gui->setOutputMode("presentation");
1571  $page_object_gui->setOutputSubmode("translation");
1572 
1573  $page_object_gui->setPresentationTitle(
1574  ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
1575  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
1576  $this->lm_set->get("time_scheduled_page_activation")));
1577 # $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
1578  $page_object_gui->setLinkParams("ref_id=".$_SESSION["tr_id"]);
1579  $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
1580  $page_object_gui->setTemplateOutputVar("TRANSLATION_CONTENT");
1581 
1582 
1583  return $page_object_gui->presentation();
1584 
1585  }
1586 
1587  function ilCitation()
1588  {
1589  $page_id = $this->getCurrentPageId();
1590  $this->tpl = new ilTemplate("tpl.page.html",true,true,true);
1591  $this->ilLocator();
1592  $this->tpl->setVariable("MENU",$this->lm_gui->setilCitationMenu());
1593 
1594  include_once("./Services/COPage/classes/class.ilPageObject.php");
1595 
1596  $this->pg_obj =& new ilPageObject($this->lm->getType(),$page_id);
1597  $xml = $this->pg_obj->getXMLContent();
1598  $this->lm_gui->showCitation($xml);
1599  $this->tpl->show();
1600  }
1601 
1602 
1604  {
1605 
1606  if (!is_object($this->layout_doc))
1607  return array ();
1608 
1609  $xpc = xpath_new_context($this->layout_doc);
1610 
1611  $path = "/ilLayout/ilLinkTargets/LinkTarget";
1612  $res = xpath_eval($xpc, $path);
1613  $targets = array();
1614  for ($i = 0; $i < count($res->nodeset); $i++)
1615  {
1616  $type = $res->nodeset[$i]->get_attribute("Type");
1617  $frame = $res->nodeset[$i]->get_attribute("Frame");
1618  $onclick = $res->nodeset[$i]->get_attribute("OnClick");
1619  $targets[$type] = array("Type" => $type, "Frame" => $frame, "OnClick" => $onclick);
1620  }
1621 
1622  return $targets;
1623  }
1624 
1631  function ilPage(&$a_page_node, $a_page_id = 0)
1632  {
1633  global $ilBench,$ilUser;
1634 
1635  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
1636  $this->lm_gui->object->getPublicAccessMode() == 'selected')
1637  {
1638  $public = ilLMObject::_isPagePublic($this->getCurrentPageId());
1639 
1640  if (!$public)
1641  return $this->showNoPublicAccess($this->getCurrentPageId());
1642  }
1643 
1644  if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(),$this->lm->getId(), $this->getCurrentPageId()))
1645  {
1646  return $this->showPreconditionsOfPage($this->getCurrentPageId());
1647  }
1648 
1649  require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
1650  require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1651 
1652  // page id is e.g. > 0 when footer or header page is processed
1653  if ($a_page_id == 0)
1654  {
1655  $page_id = $this->getCurrentPageId();
1656 
1657  // highlighting?
1658 
1659  if ($_GET["srcstring"] != "" && !$this->offlineMode())
1660  {
1661  include_once './Services/Search/classes/class.ilUserSearchCache.php';
1662  $cache = ilUserSearchCache::_getInstance($ilUser->getId());
1663  $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
1664  $search_string = $cache->getQuery();
1665 
1666  include_once("./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php");
1667  include_once("./Services/Search/classes/class.ilQueryParser.php");
1668  $p = new ilQueryParser($search_string);
1669  $p->parse();
1670 
1671  $words = $p->getQuotedWords();
1672  if (is_array($words))
1673  {
1674  foreach ($words as $w)
1675  {
1676  ilTextHighlighterGUI::highlight("ilLMPageContent", $w, $this->tpl);
1677  }
1678  }
1679 
1680  $this->fill_on_load_code = true;
1681  }
1682  }
1683  else
1684  {
1685  $page_id = $a_page_id;
1686  }
1687 
1688  // content style
1689  $this->tpl->setCurrentBlock("ContentStyle");
1690  if (!$this->offlineMode())
1691  {
1692  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1693  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
1694  }
1695  else
1696  {
1697  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
1698  }
1699  $this->tpl->parseCurrentBlock();
1700 
1701  // no active page found in chapter
1702  if ($this->chapter_has_no_active_page &&
1703  ilLMObject::_lookupType($_GET["obj_id"]) == "st")
1704  {
1705  $mtpl = new ilTemplate("tpl.no_content_message.html", true, true,
1706  "Modules/LearningModule");
1707  $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_no_page_in_chapter"));
1708  $mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_st.gif",
1709  false, "output", $this->offlineMode()));
1710  $mtpl->setVariable("ITEM_TITLE",
1711  ilLMObject::_lookupTitle($_GET["obj_id"]));
1712  $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
1713  return $mtpl->get();
1714  }
1715 
1716  // current page is deactivated
1717  if ($this->deactivated_page)
1718  {
1719  $mtpl = new ilTemplate("tpl.no_content_message.html", true, true,
1720  "Modules/LearningModule");
1721  $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_page_currently_deactivated"));
1722  $mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_pg.gif",
1723  false, "output", $this->offlineMode()));
1724  $mtpl->setVariable("ITEM_TITLE",
1725  ilLMObject::_lookupTitle($_GET["obj_id"]));
1726  $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
1727  return $mtpl->get();
1728  }
1729 
1730  // no page found
1731  if ($page_id == 0)
1732  {
1733  $cont = $this->lng->txt("cont_no_page");
1734  $this->tpl->setVariable("PAGE_CONTENT", $cont);
1735  return $cont;
1736  }
1737 
1738  $page_object =& new ilPageObject($this->lm->getType(), $page_id);
1739  $page_object->buildDom();
1740  $page_object->registerOfflineHandler($this);
1741 
1742  $int_links = $page_object->getInternalLinks();
1743 
1744  $page_object_gui =& new ilPageObjectGUI($this->lm->getType(), $page_id);
1745  $this->basicPageGuiInit($page_object_gui);
1746 
1747  $page_object_gui->setTemplateOutput(false);
1748 
1749  // Update personal desktop items
1750  $this->ilias->account->setDesktopItemParameters($this->lm->getRefId(), $this->lm->getType(), $page_id);
1751 
1752  // Update course items
1753  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
1754  ilCourseLMHistory::_updateLastAccess($ilUser->getId(),$this->lm->getRefId(),$page_id);
1755 
1756  // read link targets
1757  $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
1758  $link_xml.= $this->getLinkTargetsXML();
1759 
1760  // get lm page object
1761  $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
1762  $lm_pg_obj->setLMId($this->lm->getId());
1763  //$pg_obj->setParentId($this->lm->getId());
1764  $page_object_gui->setLinkXML($link_xml);
1765 
1766  // USED FOR DBK PAGE TURNS
1767  $page_object_gui->setBibId($_SESSION["bib_id"]);
1768  $page_object_gui->enableCitation((bool) $_SESSION["citation"]);
1769 
1770  // determine target frames for internal links
1771  //$pg_frame = $_GET["frame"];
1772  $page_object_gui->setLinkFrame($_GET["frame"]);
1773 
1774  // page title and tracking (not for header or footer page)
1775  if ($page_id == 0 || ($page_id != $this->lm->getHeaderPage() &&
1776  $page_id != $this->lm->getFooterPage()))
1777  {
1778  $page_object_gui->setPresentationTitle(
1779  ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
1780  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
1781  $this->lm_set->get("time_scheduled_page_activation")));
1782 
1783  // track user access to page
1784  include_once "Services/Tracking/classes/class.ilTracking.php";
1785  ilTracking::_trackAccess($this->lm->getId(), $this->lm->getRefId(), $this->lm->getType(),
1786  $page_id, "pg", "read");
1787 
1788  // update learning progress
1789  if ($ilUser->getId() != ANONYMOUS_USER_ID)
1790  {
1791  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
1792  ilLPStatusWrapper::_updateStatus($this->lm->getId(), $ilUser->getId());
1793  }
1794  }
1795  else
1796  {
1797  $page_object_gui->setEnabledPageFocus(false);
1798  $page_object_gui->setEnabledSelfAssessment(false);
1799  }
1800 
1801  // ADDED FOR CITATION
1802  $page_object_gui->setLinkParams("ref_id=".$this->lm->getRefId());
1803  $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
1804  $page_object_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadLink());
1805 
1806  if($_SESSION["tr_id"])
1807  {
1808  $page_object_gui->setOutputSubmode("translation");
1809  }
1810 
1811  // syntax style
1812  $this->tpl->setCurrentBlock("SyntaxStyle");
1813  if (!$this->offlineMode())
1814  {
1815  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1817  }
1818  else
1819  {
1820  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1821  "syntaxhighlight.css");
1822  }
1823  $this->tpl->parseCurrentBlock();
1824 
1825 
1826  $ret = $page_object_gui->presentation($page_object_gui->getOutputMode());
1827 
1828  // process header
1829  if ($this->lm->getHeaderPage() > 0 &&
1830  $page_id != $this->lm->getHeaderPage() &&
1831  ($page_id == 0 || $page_id != $this->lm->getFooterPage()))
1832  {
1833  if (ilLMObject::_exists($this->lm->getHeaderPage()))
1834  {
1835  $head = $this->ilPage($a_page_node, $this->lm->getHeaderPage());
1836  }
1837  }
1838 
1839  // process footer
1840  if ($this->lm->getFooterPage() > 0 &&
1841  $page_id != $this->lm->getFooterPage() &&
1842  ($page_id == 0 || $page_id != $this->lm->getHeaderPage()))
1843  {
1844  if (ilLMObject::_exists($this->lm->getFooterPage()))
1845  {
1846  $foot = $this->ilPage($a_page_node, $this->lm->getFooterPage());
1847  }
1848  }
1849  $this->tpl->setVariable("PAGE_CONTENT", $head.$ret.$foot);
1850 //echo htmlentities("-".$ret."-");
1851  return $head.$ret.$foot;
1852 
1853  }
1854 
1861  function basicPageGuiInit($a_page_gui)
1862  {
1863  $a_page_gui->setEnabledSelfAssessment(true, false);
1864  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1865  $a_page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
1866  $this->lm->getStyleSheetId(), "lm"));
1867  if (!$this->offlineMode())
1868  {
1869  $a_page_gui->setOutputMode("presentation");
1870  $this->fill_on_load_code = true;
1871  }
1872  else
1873  {
1874  $a_page_gui->setOutputMode("offline");
1875  $a_page_gui->setOfflineDirectory($this->getOfflineDirectory());
1876  }
1877  $a_page_gui->setFileDownloadLink($this->getLink($_GET["ref_id"], "downloadFile"));
1878  $a_page_gui->setFullscreenLink($this->getLink($_GET["ref_id"], "fullscreen"));
1879 
1880  }
1881 
1886  {
1887  global $ilBench;
1888 
1889  $ilBench->start("ContentPresentation", "showPagePreconditions");
1890  $conds = ilObjContentObject::_getMissingPreconditionsOfPage($this->lm->getRefId(),$this->lm->getId(), $this->getCurrentPageId());
1891  $topchap = ilObjContentObject::_getMissingPreconditionsTopChapter($this->lm->getRefId(),$this->lm->getId(), $this->getCurrentPageId());
1892 
1893  $page_id = $this->getCurrentPageId();
1894 
1895  // content style
1896  $this->tpl->setCurrentBlock("ContentStyle");
1897  if (!$this->offlineMode())
1898  {
1899  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1900  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
1901  }
1902  else
1903  {
1904  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
1905  }
1906  $this->tpl->parseCurrentBlock();
1907 
1908  $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_preconditions.html", true);
1909 
1910  // list all missing preconditions
1911  include_once("./Services/Repository/classes/class.ilRepositoryExplorer.php");
1912  foreach($conds as $cond)
1913  {
1914  $obj_link = ilRepositoryExplorer::buildLinkTarget($cond["trigger_ref_id"],$cond["trigger_type"]);
1915  $obj_frame = ilRepositoryExplorer::buildFrameTarget($cond["trigger_type"],$cond["trigger_ref_id"],$cond["trigger_obj_id"]);
1916  $this->tpl->setCurrentBlock("condition");
1917  $this->tpl->setVariable("ROWCOL", $rc = ($rc != "tblrow2") ? "tblrow2" : "tblrow1");
1918  $this->tpl->setVariable("VAL_ITEM", ilObject::_lookupTitle($cond["trigger_obj_id"]));
1919  $this->tpl->setVariable("LINK_ITEM", $obj_link);
1920  $this->tpl->setVariable("FRAME_ITEM", $obj_frame);
1921  if ($cond["operator"] == "passed")
1922  {
1923  $cond_str = $this->lng->txt("passed");
1924  }
1925  else
1926  {
1927  $cond_str = $cond["operator"];
1928  }
1929  $this->tpl->setVariable("VAL_CONDITION", $cond_str." ".$cond["value"]);
1930  $this->tpl->parseCurrentBlock();
1931  }
1932  $this->tpl->setCurrentBlock("pg_content");
1933 
1934  $this->tpl->setVariable("TXT_MISSING_PRECONDITIONS",
1935  sprintf($this->lng->txt("cont_missing_preconditions"),
1936  ilLMObject::_lookupTitle($topchap)));
1937  $this->tpl->setVariable("TXT_ITEM", $this->lng->txt("item"));
1938  $this->tpl->setVariable("TXT_CONDITION", $this->lng->txt("condition"));
1939 
1940  // output skip chapter link
1941  $parent = $this->lm_tree->getParentId($topchap);
1942  $childs = $this->lm_tree->getChildsByType($parent, "st");
1943  $next = "";
1944  $j=-2; $i=1;
1945  foreach($childs as $child)
1946  {
1947  if ($child["child"] == $topchap)
1948  {
1949  $j = $i;
1950  }
1951  if ($i++ == ($j+1))
1952  {
1953  $succ_node = $this->lm_tree->fetchSuccessorNode($child["child"], "pg");
1954  }
1955  }
1956  if($succ_node != "")
1957  {
1958  $framestr = (!empty($_GET["frame"]))
1959  ? "frame=".$_GET["frame"]."&"
1960  : "";
1961  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
1962  $showViewInFrameset = true;
1963  $link = "<br /><a href=\"".
1964  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]).
1965  "\">".$this->lng->txt("cont_skip_chapter")."</a>";
1966  $this->tpl->setVariable("LINK_SKIP_CHAPTER", $link);
1967  }
1968 
1969  $this->tpl->parseCurrentBlock();
1970 
1971  $ilBench->stop("ContentPresentation", "showPagePreconditions");
1972  }
1973 
1977  function getLinkXML($a_int_links, $a_layoutframes)
1978  {
1979  global $ilCtrl;
1980 
1981  // Determine whether the view of a learning resource should
1982  // be shown in the frameset of ilias, or in a separate window.
1983  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
1984  $showViewInFrameset = true;
1985 
1986  if ($a_layoutframes == "")
1987  {
1988  $a_layoutframes = array();
1989  }
1990  $link_info = "<IntLinkInfos>";
1991  foreach ($a_int_links as $int_link)
1992  {
1993  $target = $int_link["Target"];
1994  if (substr($target, 0, 4) == "il__")
1995  {
1996  $target_arr = explode("_", $target);
1997  $target_id = $target_arr[count($target_arr) - 1];
1998  $type = $int_link["Type"];
1999  $targetframe = ($int_link["TargetFrame"] != "")
2000  ? $int_link["TargetFrame"]
2001  : "None";
2002 
2003  // anchor
2004  $anc = $anc_add = "";
2005  if ($int_link["Anchor"] != "")
2006  {
2007  $anc = $int_link["Anchor"];
2008  $anc_add = "_".rawurlencode($int_link["Anchor"]);
2009  }
2010 
2011  switch($type)
2012  {
2013  case "PageObject":
2014  case "StructureObject":
2016  if ($lm_id == $this->lm->getId() ||
2017  ($targetframe != "None" && $targetframe != "New"))
2018  {
2019  $ltarget = $a_layoutframes[$targetframe]["Frame"];
2020  //$nframe = ($ltarget == "")
2021  // ? $_GET["frame"]
2022  // : $ltarget;
2023  $nframe = ($ltarget == "")
2024  ? ""
2025  : $ltarget;
2026  if ($ltarget == "")
2027  {
2028  if ($showViewInFrameset) {
2029  $ltarget="_parent";
2030  } else {
2031  $ltarget="_top";
2032  }
2033  }
2034  // scorm always in 1window view and link target
2035  // is always same frame
2036  if ($this->getExportFormat() == "scorm" &&
2037  $this->offlineMode())
2038  {
2039  $ltarget = "";
2040  }
2041  $href =
2042  $this->getLink($_GET["ref_id"], "layout", $target_id, $nframe, $type,
2043  "append", $anc);
2044  }
2045  else
2046  {
2047  if (!$this->offlineMode())
2048  {
2049  if ($type == "PageObject")
2050  {
2051  $href = "./goto.php?target=pg_".$target_id.$anc_add;
2052  }
2053  else
2054  {
2055  $href = "./goto.php?target=st_".$target_id;
2056  }
2057  }
2058  else
2059  {
2060  if ($type == "PageObject")
2061  {
2062  $href = ILIAS_HTTP_PATH."/goto.php?target=pg_".$target_id.$anc_add."&amp;client_id=".CLIENT_ID;
2063  }
2064  else
2065  {
2066  $href = ILIAS_HTTP_PATH."/goto.php?target=st_".$target_id."&amp;client_id=".CLIENT_ID;
2067  }
2068  }
2069  if ($targetframe != "New")
2070  {
2071  $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
2072  }
2073  else
2074  {
2075  $ltarget = "_blank";
2076  }
2077  }
2078  break;
2079 
2080  case "GlossaryItem":
2081  if ($targetframe == "None")
2082  {
2083  $targetframe = "Glossary";
2084  }
2085  $ltarget = $a_layoutframes[$targetframe]["Frame"];
2086  $nframe = ($ltarget == "")
2087  ? $_GET["frame"]
2088  : $ltarget;
2089  $href =
2090  $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
2091  break;
2092 
2093  case "MediaObject":
2094  $ltarget = $a_layoutframes[$targetframe]["Frame"];
2095  $nframe = ($ltarget == "")
2096  ? $_GET["frame"]
2097  : $ltarget;
2098  $href =
2099  $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
2100  break;
2101 
2102  case "RepositoryItem":
2103  $obj_type = ilObject::_lookupType($target_id, true);
2105  if (!$this->offlineMode())
2106  {
2107  $href = "./goto.php?target=".$obj_type."_".$target_id;
2108  }
2109  else
2110  {
2111  $href = ILIAS_HTTP_PATH."/goto.php?target=".$obj_type."_".$target_id."&amp;client_id=".CLIENT_ID;
2112  }
2113  $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
2114  break;
2115 
2116  case "File":
2117  if (!$this->offlineMode())
2118  {
2119  $ilCtrl->setParameter($this, "file_id", "il__file_".$target_id);
2120  $href = $ilCtrl->getLinkTarget($this, "downloadFile");
2121  $ilCtrl->setParameter($this, "file_id", "");
2122  }
2123  break;
2124  }
2125 
2126  $anc_par = 'Anchor="'.$anc.'"';
2127 
2128  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
2129  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" $anc_par/>";
2130 
2131  // set equal link info for glossary links of target "None" and "Glossary"
2132  /*
2133  if ($targetframe=="None" && $type=="GlossaryItem")
2134  {
2135  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
2136  "TargetFrame=\"Glossary\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
2137  }*/
2138  }
2139  }
2140  $link_info.= "</IntLinkInfos>";
2141 
2142  return $link_info;
2143  }
2144 
2149  {
2150  $link_info = "<LinkTargets>";
2151  foreach ($this->getLayoutLinkTargets() as $k => $t)
2152  {
2153  $link_info.="<LinkTarget TargetFrame=\"".$t["Type"]."\" LinkTarget=\"".$t["Frame"]."\" OnClick=\"".$t["OnClick"]."\" />";
2154  }
2155  $link_info.= "</LinkTargets>";
2156  return $link_info;
2157  }
2158 
2162  function ilGlossary()
2163  {
2164  global $ilBench, $ilCtrl;
2165 
2166  $ilBench->start("ContentPresentation", "ilGlossary");
2167 
2168  require_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
2169  $term_gui =& new ilGlossaryTermGUI($_GET["obj_id"]);
2170 
2171  // content style
2172  $this->tpl->setCurrentBlock("ContentStyle");
2173  if (!$this->offlineMode())
2174  {
2175  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2176  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
2177  }
2178  else
2179  {
2180  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2181  }
2182  $this->tpl->parseCurrentBlock();
2183 
2184  // syntax style
2185  $this->tpl->setCurrentBlock("SyntaxStyle");
2186 
2187  if (!$this->offlineMode())
2188  {
2189  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
2191  }
2192  else
2193  {
2194  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
2195  "syntaxhighlight.css");
2196  }
2197  $this->tpl->parseCurrentBlock();
2198 
2199  $int_links = $term_gui->getInternalLinks();
2200  $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
2201  $term_gui->setLinkXML($link_xml);
2202 
2203  $term_gui->setOfflineDirectory($this->getOfflineDirectory());
2204  if (!$this->offlineMode())
2205  {
2206  $ilCtrl->setParameter($this, "pg_type", "glo");
2207  }
2208  $term_gui->output($this->offlineMode());
2209  if (!$this->offlineMode())
2210  {
2211  $ilCtrl->setParameter($this, "pg_type", "");
2212  }
2213 
2214  //$term_gui->listDefinitions($this->offlineMode());
2215 
2216  $ilBench->stop("ContentPresentation", "ilGlossary");
2217  }
2218 
2222  function ilMedia()
2223  {
2224  global $ilBench;
2225 
2226  $ilBench->start("ContentPresentation", "ilMedia");
2227 
2228  $this->tpl->setCurrentBlock("ContentStyle");
2229  if (!$this->offlineMode())
2230  {
2231  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2232  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
2233  }
2234  else
2235  {
2236  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2237  }
2238  $this->tpl->parseCurrentBlock();
2239 
2240  $this->renderPageTitle();
2241 
2242  // set style sheets
2243  if (!$this->offlineMode())
2244  {
2245  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2246  }
2247  else
2248  {
2249  $style_name = $this->ilias->account->prefs["style"].".css";;
2250  $this->tpl->setVariable("LOCATION_STYLESHEET","./style/".$style_name);
2251  }
2252 
2253  $this->tpl->setCurrentBlock("ilMedia");
2254 
2255  //$int_links = $page_object->getInternalLinks();
2256  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
2257  $link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
2258 //echo "<br><br>".htmlentities($link_xml);
2259  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2260  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
2261  if (!empty ($_GET["pg_id"]))
2262  {
2263  require_once("./Services/COPage/classes/class.ilPageObject.php");
2264  $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
2265  $pg_obj->buildDom();
2266 
2267  $xml = "<dummy>";
2268  // todo: we get always the first alias now (problem if mob is used multiple
2269  // times in page)
2270  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
2271  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2272  $xml.= $link_xml;
2273  $xml.="</dummy>";
2274  }
2275  else
2276  {
2277  $xml = "<dummy>";
2278  // todo: we get always the first alias now (problem if mob is used multiple
2279  // times in page)
2280  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
2281  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2282  $xml.= $link_xml;
2283  $xml.="</dummy>";
2284  }
2285 
2286 //echo htmlentities($xml); exit;
2287 
2288  // todo: utf-header should be set globally
2289  //header('Content-type: text/html; charset=UTF-8');
2290 
2291  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
2292  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
2293  $xh = xslt_create();
2294 
2295 //echo "<b>XML:</b>".htmlentities($xml);
2296  // determine target frames for internal links
2297  //$pg_frame = $_GET["frame"];
2298  if (!$this->offlineMode())
2299  {
2300  $wb_path = ilUtil::getWebspaceDir("output")."/";
2301  }
2302  else
2303  {
2304  $wb_path = "";
2305  }
2306 // $wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
2307  $mode = ($_GET["cmd"] == "fullscreen")
2308  ? "fullscreen"
2309  : "media";
2310  $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output", $this->offlineMode());
2311  $fullscreen_link =
2312  $this->getLink($this->lm->getRefId(), "fullscreen");
2313  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
2314  'link_params' => "ref_id=".$this->lm->getRefId(),'fullscreen_link' => $fullscreen_link,
2315  'ref_id' => $this->lm->getRefId(), 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
2316  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
2317  echo xslt_error($xh);
2318  xslt_free($xh);
2319 
2320  // unmask user html
2321  $this->tpl->setVariable("MEDIA_CONTENT", $output);
2322 
2323  $ilBench->stop("ContentPresentation", "ilMedia");
2324  }
2325 
2329  function ilJavaScript($a_inline = "", $a_file = "", $a_location = "")
2330  {
2331  if ($a_inline != "")
2332  {
2333  $js_tpl = new ilTemplate($a_inline, true, false, $a_location);
2334  $js = $js_tpl->get();
2335  $this->tpl->setVariable("INLINE_JS", $js);
2336  }
2337  }
2338 
2343  function ilLMNavigation()
2344  {
2345  global $ilBench,$ilUser;
2346 
2347  $ilBench->start("ContentPresentation", "ilLMNavigation");
2348  include_once("./Services/COPage/classes/class.ilPageObject.php");
2349 
2350  include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
2351 
2352  $page_id = $this->getCurrentPageId();
2353 
2354  if(empty($page_id))
2355  {
2356  return;
2357  }
2358 
2359  // process navigation for free page
2360  if(!$this->lm_tree->isInTree($page_id))
2361  {
2362  if ($this->offlineMode() || $_GET["back_pg"] == "")
2363  {
2364  return;
2365  }
2366  $limpos = strpos($_GET["back_pg"], ":");
2367  if ($limpos > 0)
2368  {
2369  $back_pg = substr($_GET["back_pg"], 0, $limpos);
2370  }
2371  else
2372  {
2373  $back_pg = $_GET["back_pg"];
2374  }
2375  if (!$this->lm->cleanFrames())
2376  {
2377  $back_href =
2378  $this->getLink($this->lm->getRefId(), "layout", $back_pg, $_GET["frame"],
2379  "", "reduce");
2380  $back_target = "";
2381  }
2382  else
2383  {
2384  $back_href =
2385  $this->getLink($this->lm->getRefId(), "layout", $back_pg, "",
2386  "", "reduce");
2387  $back_target = 'target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ';
2388  }
2389  $back_img =
2390  ilUtil::getImagePath("nav_arr2_L.gif", false, "output", $this->offlineMode());
2391  $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
2392  $this->tpl->setVariable("IMG_PREV", $back_img);
2393  $this->tpl->setVariable("HREF_PREV", $back_href);
2394  $this->tpl->setVariable("FRAME_PREV", $back_target);
2395  $this->tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
2396  $this->tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
2397  $this->tpl->setVariable("PREV_ACC_KEY",
2399  $this->tpl->setVariable("SPACER_PREV", $this->offlineMode()
2400  ? "images/spacer.gif"
2401  : ilUtil::getImagePath("spacer.gif"));
2402  $this->tpl->parseCurrentBlock();
2403  $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
2404  $this->tpl->setVariable("IMG_PREV2", $back_img);
2405  $this->tpl->setVariable("HREF_PREV2", $back_href);
2406  $this->tpl->setVariable("FRAME_PREV2", $back_target);
2407  $this->tpl->setVariable("TXT_PREV2", $this->lng->txt("back"));
2408  $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("back"));
2409  $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode()
2410  ? "images/spacer.gif"
2411  : ilUtil::getImagePath("spacer.gif"));
2412  $this->tpl->parseCurrentBlock();
2413  return;
2414  }
2415 
2416  // determine successor page_id
2417  $ilBench->start("ContentPresentation", "ilLMNavigation_fetchSuccessor");
2418  $found = false;
2419 
2420  // empty chapter
2421  if ($this->chapter_has_no_active_page &&
2422  ilLMObject::_lookupType($_GET["obj_id"]) == "st")
2423  {
2424  $c_id = $_GET["obj_id"];
2425  }
2426  else
2427  {
2428  $c_id = $page_id;
2429  }
2430  while (!$found)
2431  {
2432  $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
2433  $c_id = $succ_node["obj_id"];
2434 
2435  $active = ilPageObject::_lookupActive($c_id,
2436  $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
2437 
2438  if ($succ_node["obj_id"] > 0 &&
2439  ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
2440  ( $this->lm->getPublicAccessMode() == "selected" &&
2441  !ilLMObject::_isPagePublic($succ_node["obj_id"])))
2442  {
2443  $found = false;
2444  }
2445  else if ($succ_node["obj_id"] > 0 && !$active)
2446  {
2447  $found = false;
2448  }
2449  else
2450  {
2451  $found = true;
2452  }
2453  }
2454  $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchSuccessor");
2455 
2456  $succ_str = ($succ_node !== false)
2457  ? " -> ".$succ_node["obj_id"]."_".$succ_node["type"]
2458  : "";
2459 
2460  // determine predecessor page id
2461  $ilBench->start("ContentPresentation", "ilLMNavigation_fetchPredecessor");
2462  $found = false;
2463  $c_id = $page_id;
2464  while (!$found)
2465  {
2466  $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
2467  $c_id = $pre_node["obj_id"];
2468  $active = ilPageObject::_lookupActive($c_id,
2469  $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
2470  if ($pre_node["obj_id"] > 0 &&
2471  ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
2472  ($this->lm->getPublicAccessMode() == "selected" &&
2473  !ilLMObject::_isPagePublic($pre_node["obj_id"])))
2474  {
2475  $found = false;
2476  }
2477  else if ($pre_node["obj_id"] > 0 && !$active)
2478  {
2479  $found = false;
2480  }
2481  else
2482  {
2483  $found = true;
2484  }
2485  }
2486 
2487  $ilBench->stop("ContentPresentation", "ilLMNavigation_fetchPredecessor");
2488 
2489  $pre_str = ($pre_node !== false)
2490  ? $pre_node["obj_id"]."_".$pre_node["type"]." -> "
2491  : "";
2492 
2493  // determine target frame
2494  $framestr = (!empty($_GET["frame"]))
2495  ? "frame=".$_GET["frame"]."&"
2496  : "";
2497 
2498 
2499  // Determine whether the view of a learning resource should
2500  // be shown in the frameset of ilias, or in a separate window.
2501  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
2502  $showViewInFrameset = true;
2503 
2504  if($pre_node != "")
2505  {
2506  $ilBench->start("ContentPresentation", "ilLMNavigation_outputPredecessor");
2507 
2508  // get page object
2509  //$ilBench->start("ContentPresentation", "ilLMNavigation_getPageObject");
2510  //$pre_page =& new ilLMPageObject($this->lm, $pre_node["obj_id"]);
2511  //$pre_page->setLMId($this->lm->getId());
2512  //$ilBench->stop("ContentPresentation", "ilLMNavigation_getPageObject");
2513 
2514  // get presentation title
2515  $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
2516  $prev_title = ilLMPageObject::_getPresentationTitle($pre_node["obj_id"],
2517  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
2518  $this->lm_set->get("time_scheduled_page_activation"));
2519  $prev_title = ilUtil::shortenText($prev_title, 50, true);
2520  $prev_img =
2521  ilUtil::getImagePath("nav_arr_L.gif", false, "output", $this->offlineMode());
2522 
2523  if (!$this->lm->cleanFrames())
2524  {
2525  $prev_href =
2526  $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]);
2527  $prev_target = "";
2528  }
2529  else if ($showViewInFrameset && !$this->offlineMode())
2530  {
2531  $prev_href =
2532  $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
2533  $prev_target = 'target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ';
2534  }
2535  else
2536  {
2537  $prev_href =
2538  $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
2539  $prev_target = 'target="_top" ';
2540  }
2541 
2542  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
2543  ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"])))
2544  {
2545  $output = $this->lng->txt("msg_page_not_public");
2546  }
2547 
2548  $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
2549 
2550  $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
2551  $this->tpl->setVariable("IMG_PREV", $prev_img);
2552  $this->tpl->setVariable("HREF_PREV", $prev_href);
2553  $this->tpl->setVariable("FRAME_PREV", $prev_target);
2554  $this->tpl->setVariable("TXT_PREV", $prev_title);
2555  $this->tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
2556  $this->tpl->setVariable("SPACER_PREV", $this->offlineMode()
2557  ? "images/spacer.gif"
2558  : ilUtil::getImagePath("spacer.gif"));
2559  $this->tpl->setVariable("PREV_ACC_KEY",
2561  $this->tpl->parseCurrentBlock();
2562  $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
2563  $this->tpl->setVariable("IMG_PREV2", $prev_img);
2564  $this->tpl->setVariable("HREF_PREV2", $prev_href);
2565  $this->tpl->setVariable("FRAME_PREV2", $prev_target);
2566  $this->tpl->setVariable("TXT_PREV2", $prev_title);
2567  $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("previous"));
2568  $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode()
2569  ? "images/spacer.gif"
2570  : ilUtil::getImagePath("spacer.gif"));
2571  $this->tpl->parseCurrentBlock();
2572  $ilBench->stop("ContentPresentation", "ilLMNavigation_outputPredecessor");
2573  }
2574  if($succ_node != "")
2575  {
2576  $ilBench->start("ContentPresentation", "ilLMNavigation_outputSuccessor");
2577 
2578  // get presentation title
2579  $ilBench->start("ContentPresentation", "ilLMNavigation_getPresentationTitle");
2580  $succ_title = ilLMPageObject::_getPresentationTitle($succ_node["obj_id"],
2581  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
2582  $this->lm_set->get("time_scheduled_page_activation"));
2583  $succ_title = ilUtil::shortenText($succ_title, 50, true);
2584  $succ_img =
2585  ilUtil::getImagePath("nav_arr_R.gif", false, "output", $this->offlineMode());
2586  if (!$this->lm->cleanFrames())
2587  {
2588  $succ_href =
2589  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]);
2590  $succ_target = "";
2591  }
2592  else if ($showViewInFrameset && !$this->offlineMode())
2593  {
2594  $succ_href =
2595  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
2596  $succ_target = ' target="'.ilFrameTargetInfo::_getFrame("MainContent").'" ';
2597  }
2598  else
2599  {
2600  $succ_href =
2601  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
2602  $succ_target = ' target="_top" ';
2603  }
2604 
2605  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
2606  ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"])))
2607  {
2608  $output = $this->lng->txt("msg_page_not_public");
2609  }
2610 
2611  $ilBench->stop("ContentPresentation", "ilLMNavigation_getPresentationTitle");
2612 
2613  $this->tpl->setCurrentBlock("ilLMNavigation_Next");
2614  $this->tpl->setVariable("IMG_SUCC", $succ_img);
2615  $this->tpl->setVariable("HREF_SUCC", $succ_href);
2616  $this->tpl->setVariable("FRAME_SUCC", $succ_target);
2617  $this->tpl->setVariable("TXT_SUCC", $succ_title);
2618  $this->tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
2619  $this->tpl->setVariable("SPACER_SUCC", $this->offlineMode()
2620  ? "images/spacer.gif"
2621  : ilUtil::getImagePath("spacer.gif"));
2622  $this->tpl->setVariable("NEXT_ACC_KEY",
2624  $this->tpl->parseCurrentBlock();
2625  $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
2626  $this->tpl->setVariable("IMG_SUCC2", $succ_img);
2627  $this->tpl->setVariable("HREF_SUCC2", $succ_href);
2628  $this->tpl->setVariable("FRAME_SUCC2", $succ_target);
2629  $this->tpl->setVariable("TXT_SUCC2", $succ_title);
2630  $this->tpl->setVariable("ALT_SUCC2", $this->lng->txt("next"));
2631  $this->tpl->setVariable("SPACER_SUCC2", $this->offlineMode()
2632  ? "images/spacer.gif"
2633  : ilUtil::getImagePath("spacer.gif"));
2634  $this->tpl->parseCurrentBlock();
2635  $ilBench->stop("ContentPresentation", "ilLMNavigation_outputSuccessor");
2636  }
2637 
2638  $ilBench->stop("ContentPresentation", "ilLMNavigation");
2639  }
2640 
2641 
2642  function processNodes(&$a_content, &$a_node)
2643  {
2644  $child_nodes = $a_node->child_nodes();
2645  foreach ($child_nodes as $child)
2646  {
2647  if($child->node_name() == "ilFrame")
2648  {
2649  $attributes = $this->attrib2arr($child->attributes());
2650  // node is frameset, if it has cols or rows attribute
2651  if ((!empty($attributes["rows"])) || (!empty($attrubtes["cols"])))
2652  {
2653  // if framset has name, another http request is necessary
2654  // (html framesets don't have names, so we need a wrapper frame)
2655  if(!empty($attributes["name"]))
2656  {
2657  unset($attributes["template"]);
2658  unset($attributes["template_location"]);
2659  $attributes["src"] =
2660  $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"],
2661  "", "keep", "", $_GET["srcstring"]);
2662  $attributes["title"] = $this->lng->txt("cont_frame_".$attributes["name"]);
2663  $a_content .= $this->buildTag("", "frame", $attributes);
2664  $this->frames[$attributes["name"]] = $attributes["name"];
2665 //echo "<br>processNodes:add1 ".$attributes["name"];
2666  }
2667  else // ok, no name means that we can easily output the frameset tag
2668  {
2669  $a_content .= $this->buildTag("start", "frameset", $attributes);
2670  $this->processNodes($a_content, $child);
2671  $a_content .= $this->buildTag("end", "frameset");
2672  }
2673  }
2674  else // frame with
2675  {
2676  unset($attributes["template"]);
2677  unset($attributes["template_location"]);
2678  $attributes["src"] =
2679  $this->getLink($this->lm->getRefId(), "layout", $_GET["obj_id"], $attributes["name"],
2680  "", "keep", "", $_GET["srcstring"]);
2681  $attributes["title"] = $this->lng->txt("cont_frame_".$attributes["name"]);
2682  if ($attributes["name"] == "toc")
2683  {
2684  $attributes["src"].= "#".$_GET["obj_id"];
2685  }
2686  else
2687  {
2688  // Handle Anchors
2689  if ($_GET["anchor"] != "")
2690  {
2691  $attributes["src"].= "#".rawurlencode($_GET["anchor"]);
2692  }
2693  }
2694  $a_content .= $this->buildTag("", "frame", $attributes);
2695  $this->frames[$attributes["name"]] = $attributes["name"];
2696  }
2697  }
2698  }
2699  }
2700 
2708  function buildTag ($type, $name, $attr="")
2709  {
2710  $tag = "<";
2711 
2712  if ($type == "end")
2713  $tag.= "/";
2714 
2715  $tag.= $name;
2716 
2717  if (is_array($attr))
2718  {
2719  while (list($k,$v) = each($attr))
2720  $tag.= " ".$k."=\"$v\"";
2721  }
2722 
2723  if ($type == "")
2724  $tag.= "/";
2725 
2726  $tag.= ">\n";
2727 
2728  return $tag;
2729  }
2730 
2731 
2736  {
2737  global $ilBench;
2738 
2739  $ilBench->start("ContentPresentation", "TableOfContents");
2740 
2741  //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
2742  $this->tpl->setCurrentBlock("ContentStyle");
2743  if (!$this->offlineMode())
2744  {
2745  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2746  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
2747  }
2748  else
2749  {
2750  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2751  }
2752  $this->tpl->parseCurrentBlock();
2753 
2754  $this->renderPageTitle();
2755 
2756  // set style sheets
2757  if (!$this->offlineMode())
2758  {
2759  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2760  }
2761  else
2762  {
2763  $style_name = $this->ilias->account->prefs["style"].".css";;
2764  $this->tpl->setVariable("LOCATION_STYLESHEET","./style/".$style_name);
2765  }
2766 
2767  //$this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_toc.html", true);
2768  $this->tpl->getStandardTemplate();
2769  $this->ilLocator();
2770 
2771  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu($this->offlineMode()
2772  ,$this->getExportFormat(), "toc", true));
2773 
2774  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_toc.html", "Modules/LearningModule");
2775 
2776  // set title header
2777  $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
2778  $this->tpl->setTitle($this->lm->getTitle());
2779  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
2780 
2781  /*
2782  if (!$this->offlineMode())
2783  {
2784  $this->tpl->setCurrentBlock("back_to_lm");
2785  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
2786  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2787  $this->tpl->setVariable("LINK_BACK",
2788  $this->ctrl->getLinkTarget($this, ""));
2789  $this->tpl->parseCurrentBlock();
2790  }*/
2791 
2792  include_once ("./Modules/LearningModule/classes/class.ilLMTableOfContentsExplorer.php");
2793  $exp = new ilTableOfContentsExplorer(
2794  $this->getLink($this->lm->getRefId(), ""),
2795  $this->lm, $this->getExportFormat());
2796  $exp->setExpandTarget($this->getLink($this->lm->getRefId(), $_GET["cmd"], "", $_GET["frame"]));
2797  $exp->setTargetGet("obj_id");
2798  $exp->setOfflineMode($this->offlineMode());
2799  $exp->forceExpandAll(true, false);
2800 
2801  // highlight current node
2802  if (!$this->offlineMode())
2803  {
2804  $page_id = $this->getCurrentPageId();
2805 
2806  // empty chapter
2807  if ($this->chapter_has_no_active_page &&
2808  ilLMObject::_lookupType($_GET["obj_id"]) == "st")
2809  {
2810  $exp->highlightNode($_GET["obj_id"]);
2811  }
2812  else
2813  {
2814  $exp->highlightNode($page_id);
2815  }
2816  }
2817 
2818  $tree =& $this->lm->getTree();
2819  if ($_GET["lmtocexpand"] == "")
2820  {
2821  $expanded = $tree->readRootId();
2822  }
2823  else
2824  {
2825  $expanded = $_GET["lmtocexpand"];
2826  }
2827 
2828  $exp->setExpand($expanded);
2829 
2830  // build html-output
2831  $exp->setOutput(0);
2832  $output = $exp->getOutput();
2833 
2834  $this->tpl->setVariable("EXPLORER", $output);
2835  $this->tpl->parseCurrentBlock();
2836 
2837  if ($this->offlineMode())
2838  {
2839  return $this->tpl->get();
2840  }
2841  else
2842  {
2843  $this->tpl->show();
2844  }
2845 
2846  $ilBench->stop("ContentPresentation", "TableOfContents");
2847  }
2848 
2849 
2855  function infoScreen()
2856  {
2857  $this->ctrl->setCmd("showSummary");
2858  $this->ctrl->setCmdClass("ilinfoscreengui");
2859  $this->outputInfoScreen();
2860  }
2861 
2865  function showInfoScreen()
2866  {
2867  $this->outputInfoScreen(true);
2868  }
2869 
2873  function outputInfoScreen($a_standard_locator = false)
2874  {
2875  global $ilBench, $ilLocator, $ilAccess;
2876 
2877  $this->renderPageTitle();
2878 
2879  // set style sheets
2880  if (!$this->offlineMode())
2881  {
2882  $this->tpl->setStyleSheetLocation(ilUtil::getStyleSheetLocation());
2883  }
2884  else
2885  {
2886  $style_name = $this->ilias->account->prefs["style"].".css";;
2887  $this->tpl->setStyleSheetLocation("./".$style_name);
2888  }
2889 
2890  $this->tpl->getStandardTemplate();
2891  $this->tpl->setTitle($this->lm->getTitle());
2892  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
2893 
2894  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu($this->offlineMode()
2895  ,$this->getExportFormat(), "info", true));
2896 
2897  // Full locator, if read permission is given
2898  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2899  {
2900  $this->ilLocator();
2901  }
2902  else
2903  {
2904  $ilLocator->addRepositoryItems();
2905  $this->tpl->setLocator();
2906  }
2907 
2908  $this->lng->loadLanguageModule("meta");
2909 
2910  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2911 
2912  $info = new ilInfoScreenGUI($this->lm_gui);
2913  $info->enablePrivateNotes();
2914  $info->enableLearningProgress();
2915 
2916  $info->enableNews();
2917  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
2918  {
2919  $news_set = new ilSetting("news");
2920  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
2921 
2922  $info->enableNewsEditing();
2923 
2924  if ($enable_internal_rss)
2925  {
2926  $info->setBlockProperty("news", "settings", true);
2927  }
2928  }
2929 
2930  // add read / back button
2931  /*
2932  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2933  {
2934  if ($_GET["obj_id"] > 0)
2935  {
2936  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2937  $info->addButton($this->lng->txt("back"),
2938  $this->ctrl->getLinkTarget($this, "layout"));
2939  }
2940  else
2941  {
2942  $info->addButton($this->lng->txt("view"),
2943  $this->ctrl->getLinkTarget($this, "layout"));
2944  }
2945  }*/
2946 
2947  // show standard meta data section
2948  $info->addMetaDataSections($this->lm->getId(),0, $this->lm->getType());
2949 
2950  if ($this->offlineMode())
2951  {
2952  $this->tpl->setContent($info->getHTML());
2953  return $this->tpl->get();
2954  }
2955  else
2956  {
2957  // forward the command
2958  $this->ctrl->forwardCommand($info);
2959  //$this->tpl->setContent("aa");
2960  $this->tpl->show();
2961  }
2962  }
2963 
2968  {
2969  global $ilUser, $lng;
2970 
2971  include_once("./Services/COPage/classes/class.ilPageObject.php");
2972  if (!$this->lm->isActivePrintView())
2973  {
2974  return;
2975  }
2976 
2977  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
2978 
2979  //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
2980  $this->tpl->setCurrentBlock("ContentStyle");
2981  if (!$this->offlineMode())
2982  {
2983  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2984  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
2985  }
2986  else
2987  {
2988  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2989  }
2990  $this->tpl->parseCurrentBlock();
2991 
2992  $this->renderPageTitle();
2993  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2994  $this->tpl->getStandardTemplate();
2995 
2996  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu($this->offlineMode()
2997  ,$this->getExportFormat(), "print", true));
2998 
2999  $this->ilLocator();
3000  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content",
3001  "tpl.lm_print_selection.html", "Modules/LearningModule");
3002 
3003  // set title header
3004  $this->tpl->setTitle($this->lm->getTitle());
3005  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
3006 
3007  /*$this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
3008  $this->ctrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
3009  $this->tpl->setVariable("LINK_BACK",
3010  $this->ctrl->getLinkTargetByClass("illmpresentationgui", ""));*/
3011 
3012  $this->ctrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
3013  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
3014 
3015  $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
3016 
3017  if (!is_array($_POST["item"]))
3018  {
3019  if ($_GET["obj_id"] != "")
3020  {
3021  $_POST["item"][$_GET["obj_id"]] = "y";
3022  }
3023  else
3024  {
3025  $_POST["item"][1] = "y";
3026  }
3027  }
3028 
3029  $this->initPrintViewSelectionForm();
3030 
3031  foreach ($nodes as $node)
3032  {
3033 
3034  // check page activation
3035  $active = ilPageObject::_lookupActive($node["obj_id"], $this->lm->getType(),
3036  $this->lm_set->get("time_scheduled_page_activation"));
3037 
3038  if ($node["type"] == "pg" &&
3039  !$active)
3040  {
3041  continue;
3042  }
3043 
3044  $text = $img_scr = $img_alt = "";
3045  $disabled = false;
3046  $checked = false;
3047 
3048  switch ($node["type"])
3049  {
3050  // page
3051  case "pg":
3052  $text =
3053  ilLMPageObject::_getPresentationTitle($node["obj_id"],
3054  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
3055  $this->lm_set->get("time_scheduled_page_activation"));
3056 
3057  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased)&&
3058  $this->lm_gui->object->getPublicAccessMode() == "selected")
3059  {
3060  if (!ilLMObject::_isPagePublic($node["obj_id"]))
3061  {
3062  $disabled = true;
3063  $text.= " (".$this->lng->txt("cont_no_access").")";
3064  }
3065  }
3066  $img_src = ilUtil::getImagePath("icon_pg_s.gif");
3067  $img_alt = $lng->txt("icon")." ".$lng->txt("pg");
3068  break;
3069 
3070  // learning module
3071  case "du":
3072  $text = $this->lm->getTitle();
3073  $img_src = ilUtil::getImagePath("icon_lm_s.gif");
3074  $img_alt = $lng->txt("icon")." ".$lng->txt("obj_lm");
3075  break;
3076 
3077  // chapter
3078  case "st":
3079  $text =
3081  $this->lm->isActiveNumbering());
3082  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
3083  $this->lm_gui->object->getPublicAccessMode() == "selected")
3084  {
3085  if (!ilLMObject::_isPagePublic($node["obj_id"]))
3086  {
3087  $disabled = true;
3088  $text.= " (".$this->lng->txt("cont_no_access").")";
3089  }
3090  }
3091  $img_src = ilUtil::getImagePath("icon_st_s.gif");
3092  $img_alt = $lng->txt("icon")." ".$lng->txt("st");
3093  break;
3094  }
3095 
3096  if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(),$this->lm->getId(), $node["obj_id"]))
3097  {
3098  $text.= " (".$this->lng->txt("cont_no_access").")";
3099  }
3100 
3101  $this->nl->addListNode($node["obj_id"], $text, $node["parent"], $checked, $disabled,
3102  $img_src, $img_alt);
3103  }
3104 
3105 
3106  // check for free page
3107  if ($_GET["obj_id"] > 0 && !$this->lm_tree->isInTree($_GET["obj_id"]))
3108  {
3109  $text =
3111  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
3112  $this->lm_set->get("time_scheduled_page_activation"));
3113 
3114  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
3115  $this->lm_gui->object->getPublicAccessMode() == "selected")
3116  {
3117  if (!ilLMObject::_isPagePublic($_GET["obj_id"]))
3118  {
3119  $disabled = true;
3120  $text.= " (".$this->lng->txt("cont_no_access").")";
3121  }
3122  }
3123  $img_src = ilUtil::getImagePath("icon_pg_s.gif");
3124  $id = $_GET["obj_id"];
3125 
3126  $checked = true;
3127 
3128  $this->nl->addListNode($id, $text, 0, $checked, $disabled,
3129  $img_src, $img_alt);
3130  }
3131 
3132  $f = $this->form->getHTML();
3133 
3134  // submit toolbar
3135  $tb = new ilToolbarGUI();
3136  $tb->addFormButton($lng->txt("cont_show_print_view"), "showPrintView");
3137  $this->tpl->setVariable("TOOLBAR", $tb->getHTML());
3138 
3139  $this->tpl->setVariable("ITEM_SELECTION", $f);
3140  $this->tpl->show();
3141 
3142  }
3143 
3147  public function initPrintViewSelectionForm()
3148  {
3149  global $lng, $ilCtrl;
3150 
3151  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3152  $this->form = new ilPropertyFormGUI();
3153 
3154  // selection type
3155  $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
3156  $radg->setValue("page");
3157  $op1 = new ilRadioOption($lng->txt("cont_current_page"), "page");
3158  $radg->addOption($op1);
3159  $op2 = new ilRadioOption($lng->txt("cont_current_chapter"), "chapter");
3160  $radg->addOption($op2);
3161  $op3= new ilRadioOption($lng->txt("cont_selected_pg_chap"), "selection");
3162  $radg->addOption($op3);
3163 
3164  include_once("./Services/Form/classes/class.ilNestedListInputGUI.php");
3165  $nl = new ilNestedListInputGUI("", "obj_id");
3166  $this->nl = $nl;
3167  $op3->addSubItem($nl);
3168 
3169 
3170  $this->form->addItem($radg);
3171 
3172  $this->form->addCommandButton("showPrintView", $lng->txt("cont_show_print_view"));
3173  $this->form->setOpenTag(false);
3174  $this->form->setCloseTag(false);
3175 
3176  $this->form->setTitle($lng->txt("cont_print_selection"));
3177  $this->form->setFormAction($ilCtrl->getFormAction($this));
3178  }
3179 
3183  function showPrintView()
3184  {
3185  global $ilBench,$ilUser,$lng,$ilCtrl;
3186 
3187  include_once("./Services/COPage/classes/class.ilPageObject.php");
3188 
3189  if (!$this->lm->isActivePrintView())
3190  {
3191  return;
3192  }
3193 
3194  $ilBench->start("ContentPresentation", "PrintView");
3195 
3196  $this->renderPageTitle();
3197 
3198  $c_obj_id = $this->getCurrentPageId();
3199  // set values according to selection
3200  if ($_POST["sel_type"] == "page")
3201  {
3202  if (!is_array($_POST["obj_id"]) || !in_array($c_obj_id, $_POST["obj_id"]))
3203  {
3204  $_POST["obj_id"][] = $c_obj_id;
3205  }
3206  }
3207  if ($_POST["sel_type"] == "chapter" && $c_obj_id > 0)
3208  {
3209 
3210  $path = $this->lm_tree->getPathFull($c_obj_id);
3211  $chap_id = $path[1]["child"];
3212  if ($chap_id > 0)
3213  {
3214  $_POST["obj_id"][] = $chap_id;
3215  }
3216  }
3217 
3218 //var_dump($_GET);
3219 //var_dump($_POST);
3220  // set style sheets
3221  if (!$this->offlineMode())
3222  {
3223  $this->tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
3224  }
3225  else
3226  {
3227  $style_name = $this->ilias->account->prefs["style"].".css";;
3228  $this->tpl->setVariable("LOCATION_STYLESHEET","./style/".$style_name);
3229  }
3230 
3231  // content style
3232  $this->tpl->setCurrentBlock("ContentStyle");
3233  if (!$this->offlineMode())
3234  {
3235  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
3236  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
3237  }
3238  else
3239  {
3240  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
3241  }
3242  $this->tpl->parseCurrentBlock();
3243 
3244  // syntax style
3245  $this->tpl->setCurrentBlock("SyntaxStyle");
3246  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
3248  $this->tpl->parseCurrentBlock();
3249 
3250  //$this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
3251  $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_view.html", true);
3252 
3253  // set title header
3254  $this->tpl->setVariable("HEADER", $this->lm->getTitle());
3255 
3256  $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
3257 
3258  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
3259  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
3260  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
3261 
3262  $act_level = 99999;
3263  $activated = false;
3264 
3265  $glossary_links = array();
3266  $output_header = false;
3267  $media_links = array();
3268 
3269  // get header and footer
3270  if ($this->lm->getFooterPage() > 0)
3271  {
3272  if (ilLMObject::_exists($this->lm->getFooterPage()))
3273  {
3274  //$page_object =& new ilPageObject($this->lm->getType(), $this->lm->getFooterPage());
3275  $page_object_gui =& new ilPageObjectGUI($this->lm->getType(), $this->lm->getFooterPage());
3276  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3277  $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
3278  $this->lm->getStyleSheetId(), "lm"));
3279 
3280 
3281  // determine target frames for internal links
3282  $page_object_gui->setLinkFrame($_GET["frame"]);
3283  $page_object_gui->setOutputMode("print");
3284  $page_object_gui->setPresentationTitle("");
3285  $page_object_gui->setFileDownloadLink("#");
3286  $page_object_gui->setFullscreenLink("#");
3287  $page_object_gui->setSourceCodeDownloadScript("#");
3288  $footer_page_content = $page_object_gui->showPage();
3289  }
3290  }
3291  if ($this->lm->getHeaderPage() > 0)
3292  {
3293  if (ilLMObject::_exists($this->lm->getHeaderPage()))
3294  {
3295  //$page_object =& new ilPageObject($this->lm->getType(), $this->lm->getHeaderPage());
3296  $page_object_gui =& new ilPageObjectGUI($this->lm->getType(), $this->lm->getHeaderPage());
3297  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3298  $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
3299  $this->lm->getStyleSheetId(), "lm"));
3300 
3301 
3302  // determine target frames for internal links
3303  $page_object_gui->setLinkFrame($_GET["frame"]);
3304  $page_object_gui->setOutputMode("print");
3305  $page_object_gui->setPresentationTitle("");
3306  $page_object_gui->setFileDownloadLink("#");
3307  $page_object_gui->setFullscreenLink("#");
3308  $page_object_gui->setSourceCodeDownloadScript("#");
3309  $header_page_content = $page_object_gui->showPage();
3310  }
3311  }
3312 
3313  // add free selected pages
3314  if (is_array($_POST["obj_id"]))
3315  {
3316  foreach($_POST["obj_id"] as $k)
3317  {
3318  if ($k > 0 && !$this->lm_tree->isInTree($k))
3319  {
3320  if (ilLMObject::_lookupType($k) == "pg")
3321  {
3322  $nodes[] = array("obj_id" => $k, "type" => "pg", "free" => true);
3323  }
3324  }
3325  }
3326  }
3327  else
3328  {
3329  ilUtil::sendFailure($lng->txt("cont_print_no_page_selected"),true);
3330  $ilCtrl->redirect($this, "showPrintViewSelection");
3331  }
3332 
3333  foreach ($nodes as $node_key => $node)
3334  {
3335  // check page activation
3336  $active = ilPageObject::_lookupActive($node["obj_id"], $this->lm->getType(),
3337  $this->lm_set->get("time_scheduled_page_activation"));
3338  if ($node["type"] == "pg" && !$active)
3339  {
3340  continue;
3341  }
3342 
3343  // print all subchapters/subpages if higher chapter
3344  // has been selected
3345  if ($node["depth"] <= $act_level)
3346  {
3347  if (is_array($_POST["obj_id"]) && in_array($node["obj_id"], $_POST["obj_id"]))
3348  {
3349  $act_level = $node["depth"];
3350  $activated = true;
3351  }
3352  else
3353  {
3354  $act_level = 99999;
3355  $activated = false;
3356  }
3357  }
3358 
3359  if ($activated &&
3360  ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(),$this->lm->getId(), $node["obj_id"]))
3361  {
3362  // output learning module header
3363  if ($node["type"] == "du")
3364  {
3365  $output_header = true;
3366  }
3367 
3368  // output chapter title
3369  if ($node["type"] == "st")
3370  {
3371  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
3372  $this->lm_gui->object->getPublicAccessMode() == "selected")
3373  {
3374  if (!ilLMObject::_isPagePublic($node["obj_id"]))
3375  {
3376  continue;
3377  }
3378  }
3379 
3380  $chap =& new ilStructureObject($this->lm, $node["obj_id"]);
3381  $this->tpl->setCurrentBlock("print_chapter");
3382 
3383  $chapter_title = $chap->_getPresentationTitle($node["obj_id"],
3384  $this->lm->isActiveNumbering());
3385  $this->tpl->setVariable("CHAP_TITLE",
3386  $chapter_title);
3387 
3388  if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE)
3389  {
3390  if ($nodes[$node_key + 1]["type"] == "pg")
3391  {
3392  $this->tpl->setVariable("CHAP_HEADER",
3393  $header_page_content);
3394  $did_chap_page_header = true;
3395  }
3396  }
3397 
3398  $this->tpl->parseCurrentBlock();
3399  $this->tpl->setCurrentBlock("print_block");
3400  $this->tpl->parseCurrentBlock();
3401  }
3402 
3403  // output page
3404  if ($node["type"] == "pg")
3405  {
3406  if(($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) &&
3407  $this->lm_gui->object->getPublicAccessMode() == "selected")
3408  {
3409  if (!ilLMObject::_isPagePublic($node["obj_id"]))
3410  {
3411  continue;
3412  }
3413  }
3414 
3415  $this->tpl->setCurrentBlock("print_item");
3416 
3417  // get page
3418  $page_id = $node["obj_id"];
3419  $page_object =& new ilPageObject($this->lm->getType(), $page_id);
3420  $page_object_gui =& new ilPageObjectGUI($this->lm->getType(), $page_id);
3421  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3422  $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
3423  $this->lm->getStyleSheetId(), "lm"));
3424 
3425 
3426  // get lm page
3427  $lm_pg_obj =& new ilLMPageObject($this->lm, $page_id);
3428  $lm_pg_obj->setLMId($this->lm->getId());
3429 
3430  // determine target frames for internal links
3431  $page_object_gui->setLinkFrame($_GET["frame"]);
3432  $page_object_gui->setOutputMode("print");
3433  $page_object_gui->setPresentationTitle("");
3434 
3435  if ($this->lm->getPageHeader() == IL_PAGE_TITLE || $node["free"] === true)
3436  {
3437  $page_title = ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(),
3438  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
3439  $this->lm_set->get("time_scheduled_page_activation"));
3440 
3441  // prevent page title after chapter title
3442  // that have the same content
3443  if ($this->lm->isActiveNumbering())
3444  {
3445  $chapter_title = trim(substr($chapter_title,
3446  strpos($chapter_title, " ")));
3447  }
3448 
3449  if ($page_title != $chapter_title)
3450  {
3451  $page_object_gui->setPresentationTitle($page_title);
3452  }
3453  }
3454 
3455  // handle header / footer
3456  $hcont = $header_page_content;
3457  $fcont = $footer_page_content;
3458 
3459  if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE)
3460  {
3461  if ($did_chap_page_header)
3462  {
3463  $hcont = "";
3464  }
3465  if ($nodes[$node_key + 1]["type"] == "pg" &&
3466  !($nodes[$node_key + 1]["depth"] <= $act_level
3467  && !in_array($nodes[$node_key + 1]["obj_id"], $_POST["obj_id"])))
3468  {
3469  $fcont = "";
3470  }
3471  }
3472 
3473  $page_object_gui->setFileDownloadLink("#");
3474  $page_object_gui->setFullscreenLink("#");
3475  $page_object_gui->setSourceCodeDownloadScript("#");
3476  $page_object_gui->setEnabledSelfAssessment(true);
3477  $page_content = $page_object_gui->showPage();
3478  if ($this->lm->getPageHeader() != IL_PAGE_TITLE)
3479  {
3480  $this->tpl->setVariable("CONTENT",
3481  $hcont.$page_content.$fcont);
3482  }
3483  else
3484  {
3485  $this->tpl->setVariable("CONTENT",
3486  $hcont.$page_content.$fcont."<br />");
3487  }
3488  $chapter_title = "";
3489  $this->tpl->parseCurrentBlock();
3490  $this->tpl->setCurrentBlock("print_block");
3491  $this->tpl->parseCurrentBlock();
3492 
3493  // get internal links
3494  $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType().":pg", $node["obj_id"]);
3495 
3496  $got_mobs = false;
3497 
3498  foreach ($int_links as $key => $link)
3499  {
3500  if ($link["type"] == "git" &&
3501  ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
3502  {
3503  $glossary_links[$key] = $link;
3504  }
3505  if ($link["type"] == "mob" &&
3506  ($link["inst"] == IL_INST_ID || $link["inst"] == 0))
3507  {
3508  $got_mobs = true;
3509  $mob_links[$key] = $link;
3510  }
3511  }
3512 
3513  // this is not cool because of performance reasons
3514  // unfortunately the int link table does not
3515  // store the target frame (we want to append all linked
3516  // images but not inline images (i.e. mobs with no target
3517  // frame))
3518  if ($got_mobs)
3519  {
3520  $page_object->buildDom();
3521  $links = $page_object->getInternalLinks();
3522  foreach($links as $link)
3523  {
3524  if ($link["Type"] == "MediaObject"
3525  && $link["TargetFrame"] != ""
3526  && $link["TargetFrame"] != "None")
3527  {
3528  $media_links[] = $link;
3529  }
3530  }
3531  }
3532  }
3533  }
3534  }
3535 
3536  $annex_cnt = 0;
3537  $annexes = array();
3538 
3539  // glossary
3540  if (count($glossary_links) > 0 && !$this->lm->isActivePreventGlossaryAppendix())
3541  {
3542  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
3543  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
3544 
3545  // sort terms
3546  $terms = array();
3547 
3548  foreach($glossary_links as $key => $link)
3549  {
3550  $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]);
3551  $terms[$term.":".$key] = array("key" => $key, "link" => $link, "term" => $term);
3552  }
3553  $terms = ilUtil::sortArray($terms, "term", "asc");
3554  //ksort($terms);
3555 
3556  foreach($terms as $t)
3557  {
3558  $link = $t["link"];
3559  $key = $t["key"];
3560  $defs = ilGlossaryDefinition::getDefinitionList($link["id"]);
3561  $def_cnt = 1;
3562 
3563  // output all definitions of term
3564  foreach($defs as $def)
3565  {
3566  // definition + number, if more than 1 definition
3567  if (count($defs) > 1)
3568  {
3569  $this->tpl->setCurrentBlock("def_title");
3570  $this->tpl->setVariable("TXT_DEFINITION",
3571  $this->lng->txt("cont_definition")." ".($def_cnt++));
3572  $this->tpl->parseCurrentBlock();
3573  }
3574  $page =& new ilPageObject("gdf", $def["id"]);
3575  $page_gui =& new ilPageObjectGUI("gdf", $def["id"]);
3576  $page_gui->setTemplateOutput(false);
3577  $page_gui->setOutputMode("print");
3578 
3579  $this->tpl->setCurrentBlock("definition");
3580  $page_gui->setFileDownloadLink("#");
3581  $page_gui->setFullscreenLink("#");
3582  $page_gui->setSourceCodeDownloadScript("#");
3583  $output = $page_gui->showPage();
3584  $this->tpl->setVariable("VAL_DEFINITION", $output);
3585  $this->tpl->parseCurrentBlock();
3586  }
3587 
3588  // output term
3589  $this->tpl->setCurrentBlock("term");
3590  $this->tpl->setVariable("VAL_TERM",
3591  $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]));
3592  $this->tpl->parseCurrentBlock();
3593  }
3594 
3595  // output glossary header
3596  $annex_cnt++;
3597  $this->tpl->setCurrentBlock("glossary");
3598  $annex_title = $this->lng->txt("cont_annex")." ".
3599  chr(64+$annex_cnt).": ".$this->lng->txt("glo");
3600  $this->tpl->setVariable("TXT_GLOSSARY", $annex_title);
3601  $this->tpl->parseCurrentBlock();
3602 
3603  $annexes[] = $annex_title;
3604  }
3605 
3606  // referenced images
3607  if (count($media_links) > 0)
3608  {
3609  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
3610  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
3611 
3612  foreach($media_links as $media)
3613  {
3614  if (substr($media["Target"],0,4) == "il__")
3615  {
3616  $arr = explode("_",$media["Target"]);
3617  $id = $arr[count($arr) - 1];
3618 
3619  $med_obj = new ilObjMediaObject($id);
3620  $med_item =& $med_obj->getMediaItem("Standard");
3621  if (is_object($med_item))
3622  {
3623  if (is_int(strpos($med_item->getFormat(), "image")))
3624  {
3625  $this->tpl->setCurrentBlock("ref_image");
3626 
3627  // image source
3628  if ($med_item->getLocationType() == "LocalFile")
3629  {
3630  $this->tpl->setVariable("IMG_SOURCE",
3631  ilUtil::getWebspaceDir("output")."/mobs/mm_".$id.
3632  "/".$med_item->getLocation());
3633  }
3634  else
3635  {
3636  $this->tpl->setVariable("IMG_SOURCE",
3637  $med_item->getLocation());
3638  }
3639 
3640  if ($med_item->getCaption() != "")
3641  {
3642  $this->tpl->setVariable("IMG_TITLE", $med_item->getCaption());
3643  }
3644  else
3645  {
3646  $this->tpl->setVariable("IMG_TITLE", $med_obj->getTitle());
3647  }
3648  $this->tpl->parseCurrentBlock();
3649  }
3650  }
3651  }
3652  }
3653 
3654  // output glossary header
3655  $annex_cnt++;
3656  $this->tpl->setCurrentBlock("ref_images");
3657  $annex_title = $this->lng->txt("cont_annex")." ".
3658  chr(64+$annex_cnt).": ".$this->lng->txt("cont_ref_images");
3659  $this->tpl->setVariable("TXT_REF_IMAGES", $annex_title);
3660  $this->tpl->parseCurrentBlock();
3661 
3662  $annexes[] = $annex_title;
3663  }
3664 
3665  // output learning module title and toc
3666  if ($output_header)
3667  {
3668  $this->tpl->setCurrentBlock("print_header");
3669  $this->tpl->setVariable("LM_TITLE", $this->lm->getTitle());
3670  if ($this->lm->getDescription() != "none")
3671  {
3672  include_once("Services/MetaData/classes/class.ilMD.php");
3673  $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
3674  $md_gen = $md->getGeneral();
3675  foreach($md_gen->getDescriptionIds() as $id)
3676  {
3677  $md_des = $md_gen->getDescription($id);
3678  $description = $md_des->getDescription();
3679  }
3680 
3681  $this->tpl->setVariable("LM_DESCRIPTION",
3682  $description);
3683  }
3684  $this->tpl->parseCurrentBlock();
3685 
3686  // output toc
3687  $nodes2 = $nodes;
3688  foreach ($nodes2 as $node2)
3689  {
3690  if ($node2["type"] == "st"
3691  && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(),$this->lm->getId(), $node2["obj_id"]))
3692  {
3693  for ($j=1; $j < $node2["depth"]; $j++)
3694  {
3695  $this->tpl->setCurrentBlock("indent");
3696  $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
3697  $this->tpl->parseCurrentBlock();
3698  }
3699  $this->tpl->setCurrentBlock("toc_entry");
3700  $this->tpl->setVariable("TXT_TOC_TITLE",
3702  $this->lm->isActiveNumbering()));
3703  $this->tpl->parseCurrentBlock();
3704  }
3705  }
3706 
3707  // annexes
3708  foreach ($annexes as $annex)
3709  {
3710  $this->tpl->setCurrentBlock("indent");
3711  $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.gif"));
3712  $this->tpl->parseCurrentBlock();
3713  $this->tpl->setCurrentBlock("toc_entry");
3714  $this->tpl->setVariable("TXT_TOC_TITLE", $annex);
3715  $this->tpl->parseCurrentBlock();
3716  }
3717 
3718  $this->tpl->setCurrentBlock("toc");
3719  $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
3720  $this->tpl->parseCurrentBlock();
3721 
3722  $this->tpl->setCurrentBlock("print_start_block");
3723  $this->tpl->parseCurrentBlock();
3724  }
3725 
3726  // output author information
3727  include_once 'Services/MetaData/classes/class.ilMD.php';
3728  $md = new ilMD($this->lm->getId(),0, $this->lm->getType());
3729  if(is_object($lifecycle = $md->getLifecycle()))
3730  {
3731  $sep = $author = "";
3732  foreach(($ids = $lifecycle->getContributeIds()) as $con_id)
3733  {
3734  $md_con = $lifecycle->getContribute($con_id);
3735  if ($md_con->getRole() == "Author")
3736  {
3737  foreach($ent_ids = $md_con->getEntityIds() as $ent_id)
3738  {
3739  $md_ent = $md_con->getEntity($ent_id);
3740  $author = $author.$sep.$md_ent->getEntity();
3741  $sep = ", ";
3742  }
3743  }
3744  }
3745  if ($author != "")
3746  {
3747  $this->lng->loadLanguageModule("meta");
3748  $this->tpl->setCurrentBlock("author");
3749  $this->tpl->setVariable("TXT_AUTHOR", $this->lng->txt("meta_author"));
3750  $this->tpl->setVariable("LM_AUTHOR", $author);
3751  $this->tpl->parseCurrentBlock();
3752  }
3753  }
3754 
3755 
3756  // output copyright information
3757  if (is_object($md_rights = $md->getRights()))
3758  {
3759  $copyright = $md_rights->getDescription();
3760  include_once('Services/MetaData/classes/class.ilMDUtils.php');
3761  $copyright = ilMDUtils::_parseCopyright($copyright);
3762 
3763  if ($copyright != "")
3764  {
3765  $this->lng->loadLanguageModule("meta");
3766  $this->tpl->setCurrentBlock("copyright");
3767  $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
3768  $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
3769  $this->tpl->parseCurrentBlock();
3770  }
3771  }
3772 
3773  $this->tpl->show(false);
3774 
3775  $ilBench->stop("ContentPresentation", "PrintView");
3776  }
3777 
3778  // PRIVATE METHODS
3779  function setSessionVars()
3780  {
3781  if($_POST["action"] == "show" or $_POST["action"] == "show_citation")
3782  {
3783  if($_POST["action"] == "show_citation")
3784  {
3785  // ONLY ONE EDITION
3786  if(count($_POST["target"]) != 1)
3787  {
3788  ilUtil::sendFailure($this->lng->txt("cont_citation_err_one"));
3789  $_POST["action"] = "";
3790  $_POST["target"] = 0;
3791  return false;
3792  }
3793  $_SESSION["citation"] = 1;
3794  }
3795  else
3796  {
3797  unset($_SESSION["citation"]);
3798  }
3799  if(isset($_POST["tr_id"]))
3800  {
3801  $_SESSION["tr_id"] = $_POST["tr_id"][0];
3802  }
3803  else
3804  {
3805  unset($_SESSION["tr_id"]);
3806  }
3807  if(is_array($_POST["target"]))
3808  {
3809  $_SESSION["bib_id"] = ",".implode(',',$_POST["target"]).",";
3810  }
3811  else
3812  {
3813  $_SESSION["bib_id"] = ",0,";
3814  }
3815  }
3816  return true;
3817  }
3818 
3822  function downloadFile()
3823  {
3824  $file = explode("_", $_GET["file_id"]);
3825  $file_id = (int) $file[count($file) - 1];
3826  require_once("./Modules/File/classes/class.ilObjFile.php");
3827  $fileObj =& new ilObjFile($file_id, false);
3828  $fileObj->sendFile();
3829  exit;
3830  }
3831 
3836  {
3837  require_once("./Services/COPage/classes/class.ilPageObject.php");
3838  $pg_obj =& new ilPageObject($this->lm->getType(), $_GET["pg_id"]);
3839  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
3840  }
3841 
3845  function showDownloadList()
3846  {
3847  global $ilBench;
3848 
3849  //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
3850  $this->tpl->setCurrentBlock("ContentStyle");
3851  if (!$this->offlineMode())
3852  {
3853  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
3854  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
3855  }
3856  else
3857  {
3858  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
3859  }
3860  $this->tpl->parseCurrentBlock();
3861 
3862  $this->renderPageTitle();
3863  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
3864  $this->tpl->getStandardTemplate();
3865 
3866  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu($this->offlineMode()
3867  ,$this->getExportFormat(), "download", true));
3868 
3869  $this->ilLocator();
3870  //$this->tpl->stopTitleFloating();
3871  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_download_list.html", "Modules/LearningModule");
3872 
3873  // set title header
3874  $this->tpl->setTitle($this->lm->getTitle());
3875  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm_b.gif"));
3876 
3877  /*
3878  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
3879  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
3880  $this->tpl->setVariable("LINK_BACK",
3881  $this->ctrl->getLinkTarget($this, "")); */
3882 
3883  // output copyright information
3884  include_once 'Services/MetaData/classes/class.ilMD.php';
3885  $md = new ilMD($this->lm->getId(),0, $this->lm->getType());
3886  if (is_object($md_rights = $md->getRights()))
3887  {
3888  $copyright = $md_rights->getDescription();
3889 
3890  include_once('Services/MetaData/classes/class.ilMDUtils.php');
3891  $copyright = ilMDUtils::_parseCopyright($copyright);
3892 
3893  if ($copyright != "")
3894  {
3895  $this->lng->loadLanguageModule("meta");
3896  $this->tpl->setCurrentBlock("copyright");
3897  $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
3898  $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
3899  $this->tpl->parseCurrentBlock();
3900  }
3901  }
3902 
3903  // create table
3904  require_once("./Services/Table/classes/class.ilTableGUI.php");
3905  $tbl = new ilTableGUI();
3906 
3907  // load files templates
3908  $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
3909 
3910  // load template for table content data
3911  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/LearningModule");
3912 
3913  $export_files = array();
3914  $types = array("xml", "html", "scorm");
3915  foreach($types as $type)
3916  {
3917  if ($this->lm->getPublicExportFile($type) != "")
3918  {
3919  if (is_file($this->lm->getExportDirectory($type)."/".
3920  $this->lm->getPublicExportFile($type)))
3921  {
3922  $dir = $this->lm->getExportDirectory($type);
3923  $size = filesize($this->lm->getExportDirectory($type)."/".
3924  $this->lm->getPublicExportFile($type));
3925  $export_files[] = array("type" => $type,
3926  "file" => $this->lm->getPublicExportFile($type),
3927  "size" => $size);
3928  }
3929  }
3930  }
3931 
3932  $num = 0;
3933 
3934  $tbl->setTitle($this->lng->txt("download"));
3935 
3936  $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
3937  $this->lng->txt("cont_file"),
3938  $this->lng->txt("size"), $this->lng->txt("date"),
3939  ""));
3940 
3941  $cols = array("format", "file", "size", "date", "download");
3942  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
3943  "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
3944  $tbl->setHeaderVars($cols, $header_params);
3945  $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
3946  $tbl->disable("sort");
3947 
3948  // control
3949  $tbl->setOrderColumn($_GET["sort_by"]);
3950  $tbl->setOrderDirection($_GET["sort_order"]);
3951  $tbl->setLimit($_GET["limit"]);
3952  $tbl->setOffset($_GET["offset"]);
3953  $tbl->setMaxCount($this->maxcount); // ???
3954 
3955  //$this->tpl->setVariable("COLUMN_COUNTS", 5);
3956 
3957  // footer
3958  //$tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3959  $tbl->disable("footer");
3960 
3961  $tbl->setMaxCount(count($export_files));
3962  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
3963 
3964  $tbl->render();
3965  if(count($export_files) > 0)
3966  {
3967  $i=0;
3968  foreach($export_files as $exp_file)
3969  {
3970  if (!$exp_file["size"] > 0)
3971  {
3972  continue;
3973  }
3974 
3975  $this->tpl->setCurrentBlock("tbl_content");
3976  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
3977 
3978  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
3979  $this->tpl->setVariable("CSS_ROW", $css_row);
3980 
3981  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
3982  $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
3983  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
3984 
3985  $file_arr = explode("__", $exp_file["file"]);
3986  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
3987 
3988  $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
3989  $this->ctrl->setParameter($this, "type", $exp_file["type"]);
3990  $this->tpl->setVariable("LINK_DOWNLOAD",
3991  $this->ctrl->getLinkTarget($this, "downloadExportFile"));
3992 
3993  $this->tpl->parseCurrentBlock();
3994  }
3995  } //if is_array
3996  else
3997  {
3998  $this->tpl->setCurrentBlock("notfound");
3999  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
4000  $this->tpl->setVariable("NUM_COLS", 5);
4001  $this->tpl->parseCurrentBlock();
4002  }
4003 
4004  $this->tpl->show();
4005  }
4006 
4007 
4012  {
4013  $file = $this->lm->getPublicExportFile($_GET["type"]);
4014  if ($this->lm->getPublicExportFile($_GET["type"]) != "")
4015  {
4016  $dir = $this->lm->getExportDirectory($_GET["type"]);
4017  if (is_file($dir."/".$file))
4018  {
4020  exit;
4021  }
4022  }
4023  $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
4024  }
4025 
4029  function getLink($a_ref_id, $a_cmd = "", $a_obj_id = "", $a_frame = "", $a_type = "",
4030  $a_back_link = "append", $a_anchor = "", $a_srcstring = "")
4031  {
4032  global $ilCtrl;
4033 
4034  if ($a_cmd == "")
4035  {
4036  $a_cmd = "layout";
4037  }
4038 
4039  // handling of free pages
4040  $cur_page_id = $this->getCurrentPageId();
4041  $back_pg = $_GET["back_pg"];
4042  if ($a_obj_id != "" && !$this->lm_tree->isInTree($a_obj_id) && $cur_page_id != "" &&
4043  $a_back_link == "append")
4044  {
4045  if ($back_pg != "")
4046  {
4047  $back_pg = $cur_page_id.":".$back_pg;
4048  }
4049  else
4050  {
4051  $back_pg = $cur_page_id;
4052  }
4053  }
4054  else
4055  {
4056  if ($a_back_link == "reduce")
4057  {
4058  $limpos = strpos($_GET["back_pg"], ":");
4059 
4060  if ($limpos > 0)
4061  {
4062  $back_pg = substr($back_pg, strpos($back_pg, ":") + 1);
4063  }
4064  else
4065  {
4066  $back_pg = "";
4067  }
4068  }
4069  else if ($a_back_link != "keep")
4070  {
4071  $back_pg = "";
4072  }
4073  }
4074 
4075  // handle online links
4076  if (!$this->offlineMode())
4077  {
4078  $this->ctrl->setParameter($this, "from_page", $cur_page_id);
4079 
4080  if ($a_anchor != "")
4081  {
4082  $this->ctrl->setParameter($this, "anchor", rawurlencode($a_anchor));
4083  }
4084  if ($a_srcstring != "")
4085  {
4086  $this->ctrl->setParameter($this, "srcstring", $a_srcstring);
4087  }
4088  switch ($a_cmd)
4089  {
4090  case "fullscreen":
4091  $link = $this->ctrl->getLinkTarget($this, "fullscreen", "", false, false);
4092  break;
4093 
4094  default:
4095 
4096  if ($back_pg != "")
4097  {
4098  $this->ctrl->setParameter($this, "back_pg", $back_pg);
4099  }
4100  if ($a_frame != "")
4101  {
4102  $this->ctrl->setParameter($this, "frame", $a_frame);
4103  }
4104  if ($a_obj_id != "")
4105  {
4106  switch ($a_type)
4107  {
4108  case "MediaObject":
4109  $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
4110  break;
4111 
4112  default:
4113  $this->ctrl->setParameter($this, "obj_id", $a_obj_id);
4114  $link.= "&amp;obj_id=".$a_obj_id;
4115  break;
4116  }
4117  }
4118  if ($a_type != "")
4119  {
4120  $this->ctrl->setParameter($this, "obj_type", $a_type);
4121  }
4122  $link = $this->ctrl->getLinkTarget($this, $a_cmd, $a_anchor);
4123 // $link = str_replace("&", "&amp;", $link);
4124 
4125  $this->ctrl->setParameter($this, "frame", "");
4126  $this->ctrl->setParameter($this, "obj_id", "");
4127  $this->ctrl->setParameter($this, "mob_id", "");
4128  break;
4129  }
4130  }
4131  else // handle offline links
4132  {
4133  switch ($a_cmd)
4134  {
4135  case "downloadFile":
4136  break;
4137 
4138  case "fullscreen":
4139  $link = "fullscreen.html"; // id is handled by xslt
4140  break;
4141 
4142  case "layout":
4143 
4144  if ($a_obj_id == "")
4145  {
4146  $a_obj_id = $this->lm_tree->getRootId();
4147  $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
4148  $a_obj_id = $pg_node["obj_id"];
4149  }
4150  if ($a_type == "StructureObject")
4151  {
4152  $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
4153  $a_obj_id = $pg_node["obj_id"];
4154  }
4155  if ($a_frame != "" && $a_frame != "_blank")
4156  {
4157  if ($a_frame != "toc")
4158  {
4159  $link = "frame_".$a_obj_id."_".$a_frame.".html";
4160  }
4161  else // don't save multiple toc frames (all the same)
4162  {
4163  $link = "frame_".$a_frame.".html";
4164  }
4165  }
4166  else
4167  {
4168  //if ($nid = ilLMObject::_lookupNID($this->lm->getId(), $a_obj_id, "pg"))
4169  if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_obj_id))
4170  {
4171  $link = "lm_pg_".$nid.".html";
4172  }
4173  else
4174  {
4175  $link = "lm_pg_".$a_obj_id.".html";
4176  }
4177  }
4178  break;
4179 
4180  case "glossary":
4181  $link = "term_".$a_obj_id.".html";
4182  break;
4183 
4184  case "media":
4185  $link = "media_".$a_obj_id.".html";
4186  break;
4187 
4188  default:
4189  break;
4190  }
4191  }
4192 
4193  $this->ctrl->clearParameters($this);
4194 
4195  return $link;
4196  }
4197 
4198 
4199 
4201  {
4202  $page_id = $this->getCurrentPageId();
4203 
4204  // content style
4205  $this->tpl->setCurrentBlock("ContentStyle");
4206 
4207  if (!$this->offlineMode())
4208  {
4209  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
4210  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
4211  }
4212  else
4213  {
4214  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
4215  }
4216 
4217  $this->tpl->parseCurrentBlock();
4218  $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_nopublicaccess.html", "Modules/LearningModule");
4219  $this->tpl->setCurrentBlock("pg_content");
4220  $this->tpl->setVariable("TXT_PAGE_NO_PUBLIC_ACCESS",$this->lng->txt("msg_page_no_public_access"));
4221  $this->tpl->parseCurrentBlock();
4222  }
4223 
4225  if (!$this->offlineMode())
4226  {
4227  //$this->ctrl->setParameter($this, session_name(), session_id());
4228  $target = $this->ctrl->getLinkTarget($this, "");
4229  $target = ilUtil::appendUrlParameterString($target, session_name()."=".session_id());
4230  return $this->ctrl->getLinkTarget($this, "");
4231  }
4232  else
4233  {
4234  return "";
4235  }
4236  }
4237 
4245  function setOfflineDirectory ($offdir) {
4246  $this->offline_directory = $offdir;
4247  }
4248 
4249 
4256  function getOfflineDirectory () {
4257  return $this->offline_directory;
4258  }
4259 
4264  function handleCodeParagraph ($page_id, $paragraph_id, $title, $text) {
4265  $directory = $this->getOfflineDirectory()."/codefiles/".$page_id."/".$paragraph_id;
4266  ilUtil::makeDirParents ($directory);
4267  $file = $directory."/".$title;
4268  if (!($fp = @fopen($file,"w+")))
4269  {
4270  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
4271  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
4272  }
4273  chmod($file, 0770);
4274  fwrite($fp, $text);
4275  fclose($fp);
4276  }
4277 
4278  // #8613
4279  protected function renderPageTitle()
4280  {
4281  $this->tpl->setHeaderPageTitle($this->lm->getTitle());
4282  $this->tpl->fillWindowTitle();
4283  }
4284 }
4285 ?>