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