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