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