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