ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilGlossaryPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Services/Object/classes/class.ilObjectGUI.php");
6 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
7 require_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
8 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
9 require_once("./Modules/Glossary/classes/class.ilTermDefinitionEditorGUI.php");
10 require_once("./Services/COPage/classes/class.ilPCParagraph.php");
11 
25 {
27  var $glossary;
28  var $ilias;
29  var $tpl;
30  var $lng;
31 
37  {
38  global $lng, $ilias, $tpl, $ilCtrl;
39 
40  $this->tpl =& $tpl;
41  $this->lng =& $lng;
42  $this->ilias =& $ilias;
43  $this->ctrl =& $ilCtrl;
44  $this->offline = false;
45  $this->ctrl->saveParameter($this, array("ref_id", "letter", "tax_node"));
46 
47  // Todo: check lm id
48  include_once("./Modules/Glossary/classes/class.ilObjGlossaryGUI.php");
49  $this->glossary_gui =& new ilObjGlossaryGUI("", $_GET["ref_id"], true, "");
50  $this->glossary =& $this->glossary_gui->object;
51 
52  // determine term id and check whether it is valid (belongs to
53  // current glossary or a virtual (online) sub-glossary)
54  $this->term_id = (int) $_GET["term_id"];
55  $glo_ids = $this->glossary->getAllGlossaryIds();
56  if (!is_array($glo_ids))
57  {
58  $glo_ids = array($glo_ids);
59  }
60  $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
61  if (!in_array($term_glo_id, $glo_ids))
62  {
63  $this->term_id = "";
64  }
65 
66  $this->tax_node = 0;
67  $this->tax_id = $this->glossary->getTaxonomyId();
68  if ($this->tax_id > 0 && $this->glossary->getShowTaxonomy())
69  {
70  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
71  $this->tax = new ilObjTaxonomy($this->tax_id);
72  }
73  if ((int) $_GET["tax_node"] > 1 && $this->tax->getTree()->readRootId() != $_GET["tax_node"])
74  {
75  $this->tax_node = (int) $_GET["tax_node"];
76  }
77  }
78 
79 
83  function setOfflineMode($a_offline = true)
84  {
85  $this->offline = $a_offline;
86  }
87 
91  function offlineMode()
92  {
93  return $this->offline;
94  }
95 
99  function setOfflineDirectory($a_dir)
100  {
101  $this->offline_dir = $a_dir;
102  }
103 
104 
109  {
110  return $this->offline_dir;
111  }
112 
113 
117  function executeCommand()
118  {
119  global $lng, $ilAccess, $ilias;
120 
121  $lng->loadLanguageModule("content");
122 
123  $next_class = $this->ctrl->getNextClass($this);
124  $cmd = $this->ctrl->getCmd("listTerms");
125 
126  // check write permission
127  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) &&
128  !($ilAccess->checkAccess("visible", "", $_GET["ref_id"]) &&
129  ($cmd == "infoScreen" || strtolower($next_class) == "ilinfoscreengui")))
130  {
131  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
132  }
133 
134  if ($cmd != "listDefinitions")
135  {
136  $this->prepareOutput();
137  }
138 
139  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
140  if(IS_PAYMENT_ENABLED == true
141  && (ilPaymentObject::_requiresPurchaseToAccess($_GET["ref_id"], $type = (isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL) )))
142  {
143  $this->tpl->getStandardTemplate();
144 
145  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
146  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
147  $ret = $this->ctrl->forwardCommand($pp);
148  }
149  else
150  {
151  switch($next_class)
152  {
153  case "ilnotegui":
154  $this->setTabs();
155  $ret =& $this->listDefinitions();
156  break;
157 
158  case "ilinfoscreengui":
159  $ret =& $this->outputInfoScreen();
160  break;
161 
162  case "ilpresentationlisttablegui":
163  $prtab = $this->getPresentationTable();
164  $this->ctrl->forwardCommand($prtab);
165  return;
166  break;
167 
168  default:
169  $ret =& $this->$cmd();
170  break;
171  }
172  }
173  $this->tpl->show();
174  }
175 
176  function prepareOutput()
177  {
178  $this->tpl->getStandardTemplate();
179  $title = $this->glossary->getTitle();
180 
181  $this->tpl->setTitle($title);
182  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
183 
184  $this->setLocator();
185  }
186 
187 
191  function listTerms()
192  {
193  global $ilNavigationHistory, $ilAccess, $ilias, $lng, $ilToolbar, $ilCtrl, $ilTabs;
194 
195 
196  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
197  {
198  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
199  }
200 
201  if (!$this->offlineMode())
202  {
203  $ilNavigationHistory->addItem($_GET["ref_id"],
204  $this->ctrl->getLinkTarget($this, "listTerms"), "glo");
205 
206  // alphabetical navigation
207  include_once("./Services/Form/classes/class.ilAlphabetInputGUI.php");
208  $ai = new ilAlphabetInputGUI($lng->txt("glo_quick_navigation"), "first");
209  $ai->setLetters($this->glossary->getFirstLetters($this->tax_node));
210  $ai->setParentCommand($this, "chooseLetter");
211  $ai->setHighlighted($_GET["letter"]);
212  $ilToolbar->addInputItem($ai, true);
213 
214  }
215 
216 // $term_list = $this->glossary->getTermList();
217 
218  $ret = $this->listTermByGiven($term_list);
219  $ilCtrl->setParameter($this, "term_id", "");
220 
221  $ilTabs->activateTab("terms");
222 
223  // show taxonomy
224  $this->showTaxonomy();
225 
226  return $ret;
227  }
228 
232  function listTermByGiven($term_list, $filter ="")
233  {
234  global $ilCtrl, $ilAccess, $ilias, $lng, $tpl;
235 
236  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
237  {
238  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
239  }
240 
241  $this->lng->loadLanguageModule("meta");
242 
243  $this->setTabs();
244 
245  // load template for table
246 // $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
247 
248  $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
249 
250  if ($this->glossary->getPresentationMode() == "full_def")
251  {
252  // content style
253  $this->tpl->setCurrentBlock("ContentStyle");
254  if (!$this->offlineMode())
255  {
256  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
257  ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
258  }
259  else
260  {
261  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","content.css");
262  }
263  $this->tpl->parseCurrentBlock();
264 
265  // syntax style
266  $this->tpl->setCurrentBlock("SyntaxStyle");
267  if (!$this->offlineMode())
268  {
269  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
271  }
272  else
273  {
274  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
275  "syntaxhighlight.css");
276  }
277  $this->tpl->parseCurrentBlock();
278  }
279 
280  $table = $this->getPresentationTable();
281 
282  if (!$this->offlineMode())
283  {
284 // $tpl->setContent($table->getHTML());
285  $tpl->setContent($ilCtrl->getHTML($table));
286  }
287  else
288  {
289  $this->tpl->setVariable("ADM_CONTENT", $table->getHTML());
290  return $this->tpl->get();
291  }
292  }
293 
301  {
302  include_once("./Modules/Glossary/classes/class.ilPresentationListTableGUI.php");
303  $table = new ilPresentationListTableGUI($this, "listTerms", $this->glossary,
304  $this->offlineMode(), $this->tax_node, $this->glossary->getTaxonomyId());
305  return $table;
306  }
307 
311  function applyFilter()
312  {
313  global $ilTabs;
314 
315  $prtab = $this->getPresentationTable();
316  $prtab->resetOffset();
317  $prtab->writeFilterToSession();
318  $this->listTerms();
319 
320  }
321 
326  function resetFilter()
327  {
328  $prtab = $this->getPresentationTable();
329  $prtab->resetOffset();
330  $prtab->resetFilter();
331  $this->listTerms();
332  }
333 
337  function listDefinitions($a_ref_id = 0, $a_term_id = 0, $a_get_html = false)
338  {
339  global $ilUser, $ilAccess, $ilias, $lng, $ilCtrl;
340 
341  if ($a_ref_id == 0)
342  {
343  $ref_id = (int) $_GET["ref_id"];
344  }
345  else
346  {
347  $ref_id = $a_ref_id;
348  }
349  if ($a_term_id == 0)
350  {
351  $term_id = $this->term_id;
352  }
353  else
354  {
355  $term_id = $a_term_id;
356  }
357 
358  if (!$ilAccess->checkAccess("read", "", $ref_id))
359  {
360  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
361  }
362 
363  // tabs
364  if ($this->glossary->getPresentationMode() != "full_def")
365  {
366  $this->showDefinitionTabs("term_content");
367  }
368 
369  $term = new ilGlossaryTerm($term_id);
370 
371  if (!$a_get_html)
372  {
373  $tpl = $this->tpl;
374 
375  require_once("./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php");
376  $tpl->getStandardTemplate();
377 // $this->setTabs();
378 
379  if ($this->offlineMode())
380  {
381  $style_name = $ilUser->prefs["style"].".css";;
382  $tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
383  }
384  else
385  {
386  $this->setLocator();
387  }
388 
389  // content style
390  $tpl->setCurrentBlock("ContentStyle");
391  if (!$this->offlineMode())
392  {
393  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
394  ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
395  }
396  else
397  {
398  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET","content.css");
399  }
400  $tpl->parseCurrentBlock();
401 
402  // syntax style
403  $tpl->setCurrentBlock("SyntaxStyle");
404  if (!$this->offlineMode())
405  {
406  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
408  }
409  else
410  {
411  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
412  "syntaxhighlight.css");
413  }
414  $tpl->parseCurrentBlock();
415 
416  $tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
417  $tpl->setTitle($this->lng->txt("cont_term").": ".$term->getTerm());
418 
419  // load template for table
420  $tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", "Modules/Glossary");
421  }
422  else
423  {
424  $tpl = new ilTemplate("tpl.glossary_definition_list.html", true, true, "Modules/Glossary");
425  }
426 
427  $defs = ilGlossaryDefinition::getDefinitionList($term_id);
428 
429  $tpl->setVariable("TXT_TERM", $term->getTerm());
430  $this->mobs = array();
431 
432  for($j=0; $j<count($defs); $j++)
433  {
434  $def = $defs[$j];
435  $page_gui = new ilGlossaryDefPageGUI($def["id"]);
436  $page_gui->setStyleId($this->glossary->getStyleSheetId());
437  $page = $page_gui->getPageObject();
438 
439  // internal links
440  $page->buildDom();
441  $int_links = $page->getInternalLinks();
442  $link_xml = $this->getLinkXML($int_links);
443  $page_gui->setLinkXML($link_xml);
444 
445  if ($this->offlineMode())
446  {
447  $page_gui->setOutputMode("offline");
448  $page_gui->setOfflineDirectory($this->getOfflineDirectory());
449  }
450  $page_gui->setSourcecodeDownloadScript($this->getLink($ref_id));
451  $page_gui->setFullscreenLink($this->getLink($ref_id, "fullscreen", $term_id, $def["id"]));
452 
453  $page_gui->setTemplateOutput(false);
454  $page_gui->setRawPageContent(true);
455  $page_gui->setFileDownloadLink($this->getLink($ref_id, "downloadFile"));
456  if (!$this->offlineMode())
457  {
458  $output = $page_gui->preview();
459  }
460  else
461  {
462  $output = $page_gui->presentation($page_gui->getOutputMode());
463  }
464 
465  if (count($defs) > 1)
466  {
467  $tpl->setCurrentBlock("definition_header");
468  $tpl->setVariable("TXT_DEFINITION",
469  $this->lng->txt("cont_definition")." ".($j+1));
470  $tpl->parseCurrentBlock();
471  }
472 
473  $tpl->setCurrentBlock("definition");
474  $tpl->setVariable("PAGE_CONTENT", $output);
475  $tpl->parseCurrentBlock();
476  }
477 
478  // display possible backlinks
479  $sources = ilInternalLink::_getSourcesOfTarget('git',$_GET['term_id'],0);
480 
481  if ($sources)
482  {
483  $backlist_shown = false;
484  foreach ($sources as $src)
485  {
486  $type = explode(':',$src['type']);
487 
488  if ($type[0] == 'lm')
489  {
490  if ($type[1] == 'pg')
491  {
492  $title = ilLMPageObject::_getPresentationTitle($src['id']);
493  $lm_id = ilLMObject::_lookupContObjID($src['id']);
494  $lm_title = ilObject::_lookupTitle($lm_id);
495  $tpl->setCurrentBlock('backlink_item');
496  $ref_ids = ilObject::_getAllReferences($lm_id);
497  $access = false;
498  foreach($ref_ids as $rid)
499  {
500  if ($ilAccess->checkAccess("read", "", $rid))
501  {
502  $access = true;
503  }
504  }
505  if ($access)
506  {
507  $tpl->setCurrentBlock("backlink_item");
508  $tpl->setVariable("BACKLINK_LINK",ILIAS_HTTP_PATH."/goto.php?target=".$type[1]."_".$src['id']);
509  $tpl->setVariable("BACKLINK_ITEM",$lm_title.": ".$title);
510  $tpl->parseCurrentBlock();
511  $backlist_shown = true;
512  }
513  }
514  }
515  }
516  if ($backlist_shown)
517  {
518  $tpl->setCurrentBlock("backlink_list");
519  $tpl->setVariable("BACKLINK_TITLE",$this->lng->txt('glo_term_used_in'));
520  $tpl->parseCurrentBlock();
521  }
522  }
523 
524  if (!$a_get_html)
525  {
526  $tpl->setCurrentBlock("perma_link");
527  $tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
528  "/goto.php?target=".
529  "git".
530  "_".$term_id."_".$ref_id."&client_id=".CLIENT_ID);
531  $tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
532  $tpl->setVariable("PERMA_TARGET", "_top");
533  $tpl->parseCurrentBlock();
534  }
535 
536  // highlighting?
537  if ($_GET["srcstring"] != "" && !$this->offlineMode())
538  {
539  include_once './Services/Search/classes/class.ilUserSearchCache.php';
540  $cache = ilUserSearchCache::_getInstance($ilUser->getId());
541  $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
542  $search_string = $cache->getQuery();
543 
544  include_once("./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php");
545  include_once("./Services/Search/classes/class.ilQueryParser.php");
546  $p = new ilQueryParser($search_string);
547  $p->parse();
548 
549  $words = $p->getQuotedWords();
550  if (is_array($words))
551  {
552  foreach ($words as $w)
553  {
554  ilTextHighlighterGUI::highlight("ilGloContent", $w, $tpl);
555  }
556  }
557  $this->fill_on_load_code = true;
558  }
559 
560  if ($this->offlineMode() || $a_get_html)
561  {
562  return $tpl->get();
563  }
564  }
565 
572  function showDefinitionTabs($a_act)
573  {
574  global $ilTabs, $lng, $ilCtrl, $ilHelp;
575 
576  if (!$this->offlineMode())
577  {
578  $ilHelp->setScreenIdComponent("glo");
579 
580  $ilCtrl->setParameter($this, "term_id", "");
581  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
582  if (!empty ($_REQUEST["term"]))
583  {
584  $this->ctrl->setParameter($this, "term", $_REQUEST["term"]);
585  $this->ctrl->setParameter($this, "oldoffset", $_GET["oldoffset"]);
586  $back = $ilCtrl->getLinkTarget($this, "searchTerms");
587  }
588  else
589  {
590  $back = $ilCtrl->getLinkTarget($this, "listTerms");
591  }
592  $ilCtrl->setParameter($this, "term_id", $this->term_id);
593  $ilCtrl->saveParameter($this, "term_id");
594 
595  $ilTabs->setBackTarget($this->lng->txt("obj_glo"), $back);
596 
597  $ilTabs->addTab("term_content",
598  $lng->txt("content"),
599  $ilCtrl->getLinkTarget($this, "listDefinitions"));
600 
601  $ilTabs->addTab("print_view",
602  $lng->txt("print_view"),
603  $ilCtrl->getLinkTarget($this, "printViewSelection"));
604 
605  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $this->term_id);
606  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
607  if (ilGlossaryTerm::_lookGlossaryID($this->term_id) == $this->glossary->getId())
608  {
609  $ilTabs->addNonTabbedLink("editing_view",
610  $lng->txt("glo_editing_view"),
611  $ilCtrl->getLinkTargetByClass(array("ilglossaryeditorgui", "ilobjglossarygui", "ilglossarytermgui"), "listDefinitions"));
612  //"ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=".$_GET["ref_id"]."&amp;edit_term=".$this->term_id);
613  }
614  $ilTabs->activateTab($a_act);
615  }
616  }
617 
618 
622  function fullscreen()
623  {
624  $html = $this->media("fullscreen");
625  return $html;
626  }
627 
631  function media($a_mode = "media")
632  {
633  $this->tpl =& new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
634  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
635  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
636  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
637  ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
638 
639  //$int_links = $page_object->getInternalLinks();
640  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
641 
642  // later
643  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
644 
645  $link_xlm = "";
646 
647  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
648  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
649 
650  $xml = "<dummy>";
651  // todo: we get always the first alias now (problem if mob is used multiple
652  // times in page)
653  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
654  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
655  $xml.= $link_xml;
656  $xml.="</dummy>";
657 
658  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
659  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
660  $xh = xslt_create();
661 
662  if (!$this->offlineMode())
663  {
664  $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output");
665  $wb_path = ilUtil::getWebspaceDir("output")."/";
666  }
667  else
668  {
669  $enlarge_path = "images/enlarge.svg";
670  $wb_path = "";
671  }
672 
673  $mode = $a_mode;
674 
675  $this->ctrl->setParameter($this, "obj_type", "MediaObject");
676  $fullscreen_link =
677  $this->getLink($_GET["ref_id"], "fullscreen");
678  $this->ctrl->clearParameters($this);
679 
680  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
681  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
682  'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
683  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
684  echo xslt_error($xh);
685  xslt_free($xh);
686 
687  // unmask user html
688  $this->tpl->setVariable("MEDIA_CONTENT", $output);
689 
690  $this->tpl->parseCurrentBlock();
691  if ($this->offlineMode())
692  {
693  $html = $this->tpl->get();
694  return $html;
695  }
696 
697  }
698 
702  function showDownloadList()
703  {
704  global $ilBench, $ilAccess, $ilias, $lng, $ilTabs;
705 
706  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
707  {
708  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
709  }
710 
711  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glo_download_list.html", "Modules/Glossary");
712 
713  $this->setTabs();
714  $ilTabs->activateTab("download");
715 
716  // set title header
717  $this->tpl->setTitle($this->glossary->getTitle());
718  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
719 
720  // create table
721  require_once("./Services/Table/classes/class.ilTableGUI.php");
722  $tbl = new ilTableGUI();
723 
724  // load files templates
725  $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
726 
727  // load template for table content data
728  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/Glossary");
729 
730  $export_files = array();
731  $types = array("xml", "html");
732  foreach($types as $type)
733  {
734  if ($this->glossary->getPublicExportFile($type) != "")
735  {
736  $dir = $this->glossary->getExportDirectory($type);
737  if (is_file($this->glossary->getExportDirectory($type)."/".
738  $this->glossary->getPublicExportFile($type)))
739  {
740  $size = filesize($this->glossary->getExportDirectory($type)."/".
741  $this->glossary->getPublicExportFile($type));
742  $export_files[] = array("type" => $type,
743  "file" => $this->glossary->getPublicExportFile($type),
744  "size" => $size);
745  }
746  }
747  }
748 
749  $num = 0;
750 
751  $tbl->setTitle($this->lng->txt("download"));
752 
753  $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
754  $this->lng->txt("cont_file"),
755  $this->lng->txt("size"), $this->lng->txt("date"),
756  ""));
757 
758  $cols = array("format", "file", "size", "date", "download");
759  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
760  "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
761  $tbl->setHeaderVars($cols, $header_params);
762  $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
763  $tbl->disable("sort");
764 
765  // control
766  $tbl->setOrderColumn($_GET["sort_by"]);
767  $tbl->setOrderDirection($_GET["sort_order"]);
768  $tbl->setLimit($_GET["limit"]);
769  $tbl->setOffset($_GET["offset"]);
770  $tbl->setMaxCount($this->maxcount); // ???
771 
772  // $this->tpl->setVariable("COLUMN_COUNTS", 5);
773 
774  // footer
775  //$tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
776  $tbl->disable("footer");
777 
778  $tbl->setMaxCount(count($export_files));
779  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
780 
781  $tbl->render();
782  if(count($export_files) > 0)
783  {
784  $i=0;
785  foreach($export_files as $exp_file)
786  {
787  $this->tpl->setCurrentBlock("tbl_content");
788  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
789 
790  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
791  $this->tpl->setVariable("CSS_ROW", $css_row);
792 
793  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
794  $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
795  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
796 
797  $file_arr = explode("__", $exp_file["file"]);
798  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
799 
800  $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
801  $this->ctrl->setParameter($this, "type", $exp_file["type"]);
802  $this->tpl->setVariable("LINK_DOWNLOAD",
803  $this->ctrl->getLinkTarget($this, "downloadExportFile"));
804 
805  $this->tpl->parseCurrentBlock();
806  }
807  } //if is_array
808  else
809  {
810  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
811  $this->tpl->setVariable("NUM_COLS", 5);
812  $this->tpl->parseCurrentBlock();
813  }
814 
815  //$this->tpl->show();
816  }
817 
822  {
823  global $ilAccess, $ilias, $lng;
824 
825  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
826  {
827  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
828  }
829 
830  $file = $this->glossary->getPublicExportFile($_GET["type"]);
831  if ($this->glossary->getPublicExportFile($_GET["type"]) != "")
832  {
833  $dir = $this->glossary->getExportDirectory($_GET["type"]);
834  if (is_file($dir."/".$file))
835  {
836  ilUtil::deliverFile($dir."/".$file, $file);
837  exit;
838  }
839  }
840  $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
841  }
842 
850  function setLocator($a_tree = "", $a_id = "")
851  {
852  //$this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
853  require_once ("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
854  $gloss_loc =& new ilGlossaryLocatorGUI();
855  $gloss_loc->setMode("presentation");
856  if (!empty($this->term_id))
857  {
858  $term =& new ilGlossaryTerm($this->term_id);
859  $gloss_loc->setTerm($term);
860  }
861  $gloss_loc->setGlossary($this->glossary);
862  //$gloss_loc->setDefinition($this->definition);
863  $gloss_loc->display();
864  }
865 
869  function downloadFile()
870  {
871  global $ilAccess, $ilias, $lng;
872 
873  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
874  {
875  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
876  }
877 
878  $file = explode("_", $_GET["file_id"]);
879  include_once("./Modules/File/classes/class.ilObjFile.php");
880  $fileObj =& new ilObjFile($file[count($file) - 1], false);
881  $fileObj->sendFile();
882  exit;
883  }
884 
888  function setTabs()
889  {
890  global $ilTabs;
891  $this->getTabs($ilTabs);
892  }
893 
897  function getLinkXML($a_int_links)
898  {
899 
900  if ($a_layoutframes == "")
901  {
902  $a_layoutframes = array();
903  }
904  $link_info = "<IntLinkInfos>";
905  foreach ($a_int_links as $int_link)
906  {
907 //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
908  $target = $int_link["Target"];
909  if (substr($target, 0, 4) == "il__")
910  {
911  $target_arr = explode("_", $target);
912  $target_id = $target_arr[count($target_arr) - 1];
913  $type = $int_link["Type"];
914  $targetframe = ($int_link["TargetFrame"] != "")
915  ? $int_link["TargetFrame"]
916  : "None";
917 
918  // anchor
919  $anc = $anc_add = "";
920  if ($int_link["Anchor"] != "")
921  {
922  $anc = $int_link["Anchor"];
923  $anc_add = "_".rawurlencode($int_link["Anchor"]);
924  }
925 
926  if ($targetframe == "New")
927  {
928  $ltarget = "_blank";
929  }
930  else
931  {
932  $ltarget = "";
933  }
934 
935  switch($type)
936  {
937  case "PageObject":
938  case "StructureObject":
940  $cont_obj =& $this->content_object;
941  if ($type == "PageObject")
942  {
943  $href = "./goto.php?target=pg_".$target_id.$anc_add;
944  }
945  else
946  {
947  $href = "./goto.php?target=st_".$target_id;
948  }
949  //$ltarget = "ilContObj".$lm_id;
950  break;
951 
952  case "GlossaryItem":
953  if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId())
954  {
955  if ($this->offlineMode())
956  {
957  $href = "term_".$target_id.".html";
958  }
959  else
960  {
961  $this->ctrl->setParameter($this, "term_id", $target_id);
962  $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
963  $href = str_replace("&", "&amp;", $href);
964  }
965  }
966  else
967  {
968  $href = "./goto.php?target=git_".$target_id;
969  }
970  break;
971 
972  case "MediaObject":
973  if ($this->offlineMode())
974  {
975  $href = "media_".$target_id.".html";
976  }
977  else
978  {
979  $this->ctrl->setParameter($this, "obj_type", $type);
980  $this->ctrl->setParameter($this, "mob_id", $target_id);
981  $href = $this->ctrl->getLinkTarget($this, "media");
982  $href = str_replace("&", "&amp;", $href);
983  }
984  break;
985 
986  case "RepositoryItem":
987  $obj_type = ilObject::_lookupType($target_id, true);
989  $href = "./goto.php?target=".$obj_type."_".$target_id;
990  $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
991  $ltarget = $t_frame;
992  break;
993 
994  case "WikiPage":
995  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
997  break;
998  }
999 
1000  $anc_par = 'Anchor="'.$anc.'"';
1001 
1002  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
1003  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" $anc_par/>";
1004 
1005  $this->ctrl->clearParameters($this);
1006  }
1007  }
1008  $link_info.= "</IntLinkInfos>";
1009 
1010  return $link_info;
1011  }
1012 
1013 
1017  function getLink($a_ref_id, $a_cmd = "", $a_term_id = "", $a_def_id = "",
1018  $a_frame = "", $a_type = "")
1019  {
1020  if ($a_cmd == "")
1021  {
1022  $a_cmd = "layout";
1023  }
1024  //$script = "glossary_presentation.php";
1025 
1026  // handle online links
1027  if (!$this->offlineMode())
1028  {
1029  //$link = $script."?ref_id=".$a_ref_id;
1030  switch ($a_cmd)
1031  {
1032  case "fullscreen":
1033  $this->ctrl->setParameter($this, "def_id", $a_def_id);
1034  $link = $this->ctrl->getLinkTarget($this, "fullscreen");
1035  break;
1036 
1037  default:
1038  $link.= "&amp;cmd=".$a_cmd;
1039  if ($a_frame != "")
1040  {
1041  $this->ctrl->setParameter($this, "frame", $a_frame);
1042  }
1043  if ($a_obj_id != "")
1044  {
1045  switch ($a_type)
1046  {
1047  case "MediaObject":
1048  $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
1049  break;
1050 
1051  default:
1052  $this->ctrl->setParameter($this, "def_id", $a_def_id);
1053  break;
1054  }
1055  }
1056  if ($a_type != "")
1057  {
1058  $this->ctrl->setParameter($this, "obj_type", $a_type);
1059  }
1060  $link = $this->ctrl->getLinkTarget($this, $a_cmd);
1061 // $link = str_replace("&", "&amp;", $link);
1062  break;
1063  }
1064  }
1065  else // handle offline links
1066  {
1067  switch ($a_cmd)
1068  {
1069  case "downloadFile":
1070  break;
1071 
1072  case "fullscreen":
1073  $link = "fullscreen.html"; // id is handled by xslt
1074  break;
1075 
1076  case "layout":
1077  break;
1078 
1079  case "glossary":
1080  $link = "term_".$a_obj_id.".html";
1081  break;
1082 
1083  case "media":
1084  $link = "media_".$a_obj_id.".html";
1085  break;
1086 
1087  default:
1088  break;
1089  }
1090  }
1091  $this->ctrl->clearParameters($this);
1092  return $link;
1093  }
1094 
1102  {
1103  global $ilUser, $lng, $ilToolbar, $ilCtrl, $tpl, $ilTabs;
1104 
1105  $ilCtrl->saveParameter($this, "term_id");
1106 
1107  if ((int) $this->term_id == 0)
1108  {
1109  $this->setTabs();
1110  $ilTabs->activateTab("print_view");
1111  }
1112  else
1113  {
1114  $tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
1115  $term = new ilGlossaryTerm((int) $this->term_id);
1116  $tpl->setTitle($this->lng->txt("cont_term").": ".$term->getTerm());
1117  $this->showDefinitionTabs("print_view");
1118  }
1119 
1120  $this->initPrintViewSelectionForm();
1121 
1122  $tpl->setContent($this->form->getHTML());
1123  }
1124 
1128  public function initPrintViewSelectionForm()
1129  {
1130  global $lng, $ilCtrl;
1131 
1132  $terms = $this->glossary->getTermList();
1133 
1134  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1135  $this->form = new ilPropertyFormGUI();
1136  $this->form->setTarget("print_view");
1137  $this->form->setFormAction($ilCtrl->getFormAction($this));
1138 
1139  // selection type
1140  $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
1141  $radg->setValue("glossary");
1142 
1143  // current term
1144  if ((int) $this->term_id > 0)
1145  {
1146  $op1 = new ilRadioOption($lng->txt("cont_current_term"), "term");
1147  $radg->addOption($op1);
1148  $radg->setValue("term");
1149  }
1150 
1151  // whole glossary
1152  $op2 = new ilRadioOption($lng->txt("cont_whole_glossary")
1153  ." (".$lng->txt("cont_terms").": ".count($terms).")", "glossary");
1154  $radg->addOption($op2);
1155 
1156  // selected topic
1157  if (($t_id = $this->glossary->getTaxonomyId()) > 0 && $this->glossary->getShowTaxonomy())
1158  {
1159  $op4 = new ilRadioOption($lng->txt("cont_selected_topic"), "sel_topic");
1160  $radg->addOption($op4);
1161 
1162  // topic drop down
1163  include_once("./Services/Taxonomy/classes/class.ilTaxAssignInputGUI.php");
1164  $si = new ilTaxAssignInputGUI($t_id, false, $lng->txt("cont_topic"), "topic",
1165  false);
1166  if ($this->tax_node > 0)
1167  {
1168  $si->setValue((int) $this->tax_node);
1169  }
1170  $op4->addSubItem($si);
1171 
1172  }
1173 
1174  // selected terms
1175  $op3= new ilRadioOption($lng->txt("cont_selected_terms"), "selection");
1176  $radg->addOption($op3);
1177 
1178  include_once("./Services/Form/classes/class.ilNestedListInputGUI.php");
1179  $nl = new ilNestedListInputGUI("", "obj_id");
1180  $op3->addSubItem($nl);
1181 //var_dump($terms);
1182  foreach ($terms as $t)
1183  {
1184  $nl->addListNode($t["id"], $t["term"], 0, false, false);
1185  }
1186 
1187  $this->form->addItem($radg);
1188 
1189  $this->form->addCommandButton("printView", $lng->txt("cont_show_print_view"));
1190  $this->form->setPreventDoubleSubmission(false);
1191 
1192  $this->form->setTitle($lng->txt("cont_print_selection"));
1193  }
1194 
1201  function printView()
1202  {
1203  global $ilAccess, $tpl;
1204 
1205  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1206  {
1207  return;
1208  }
1209 
1210  $terms = array();
1211  switch ($_POST["sel_type"])
1212  {
1213  case "glossary":
1214  $ts = $this->glossary->getTermList();
1215  foreach ($ts as $t)
1216  {
1217  $terms[] = $t["id"];
1218  }
1219  break;
1220 
1221  case "sel_topic":
1222  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1223  $t_id = $this->glossary->getTaxonomyId();
1224  $items = ilObjTaxonomy::getSubTreeItems("glo", $this->glossary->getId(), "term", $t_id, (int) $_POST["topic"]);
1225  foreach ($items as $i)
1226  {
1227  if ($i["item_type"] == "term")
1228  {
1229  $terms[] = $i["item_id"];
1230  }
1231  }
1232  break;
1233 
1234  case "selection":
1235  if (is_array($_POST["obj_id"]))
1236  {
1237  $terms = $_POST["obj_id"];
1238  }
1239  else
1240  {
1241  $terms = array();
1242  }
1243  break;
1244 
1245  case "term":
1246  $terms = array($this->term_id);
1247  break;
1248  }
1249 
1250  $tpl = new ilTemplate("tpl.main.html", true, true);
1251  $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
1252 
1253 /*
1254  // syntax style
1255  $this->tpl->setCurrentBlock("SyntaxStyle");
1256  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1257  ilObjStyleSheet::getSyntaxStylePath());
1258  $this->tpl->parseCurrentBlock();
1259 
1260  // content style
1261  $this->tpl->setCurrentBlock("ContentStyle");
1262  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1263  ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
1264  $this->tpl->parseCurrentBlock();*/
1265 
1266  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1268 
1269  // determine target frames for internal links
1270 
1271  foreach ($terms as $t_id)
1272  {
1273  $page_content.= $this->listDefinitions($_GET["ref_id"], $t_id, true);
1274  }
1275  $tpl->setVariable("CONTENT", $page_content.
1276  '<script type="text/javascript" language="javascript1.2">
1277  <!--
1278  il.Util.addOnLoad(function () {
1279  il.Util.print();
1280  });
1281  //-->
1282  </script>');
1283  $tpl->show(false);
1284  exit;
1285  }
1286 
1290  function getTabs(&$tabs_gui)
1291  {
1292  global $ilAccess, $lng, $ilCtrl, $ilHelp;
1293 
1294  $ilHelp->setScreenIdComponent("glo");
1295 
1296  $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
1297 
1298  if (!$this->offlineMode())
1299  {
1300  if ($this->ctrl->getCmd() != "listDefinitions")
1301  {
1302  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1303  {
1304  $tabs_gui->addTab("terms",
1305  $lng->txt("cont_terms"),
1306  $ilCtrl->getLinkTarget($this, "listTerms"));
1307  }
1308 
1309  $tabs_gui->addTab("info",
1310  $lng->txt("info_short"),
1311  $ilCtrl->getLinkTarget($this, "infoScreen"));
1312 
1313  $tabs_gui->addTab("print_view",
1314  $lng->txt("cont_print_view"),
1315  $ilCtrl->getLinkTarget($this, "printViewSelection"));
1316 
1317  // glossary menu
1318  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1319  {
1320  //if ($this->glossary->isActiveGlossaryMenu())
1321  //{
1322  // download links
1323  if ($this->glossary->isActiveDownloads())
1324  {
1325  $tabs_gui->addTab("download",
1326  $lng->txt("download"),
1327  $ilCtrl->getLinkTarget($this, "showDownloadList"));
1328  }
1329  //}
1330  }
1331 
1332  if ($ilAccess->checkAccess("write", "", (int) $_GET["ref_id"]) ||
1333  $ilAccess->checkAccess("edit_content", "", (int) $_GET["ref_id"]))
1334  {
1335  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1336  $tabs_gui->addNonTabbedLink("editing_view",
1337  $lng->txt("glo_editing_view"),
1338  "ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=".(int) $_GET["ref_id"],
1339  "_top");
1340  }
1341 
1342  }
1343  }
1344  else
1345  {
1346  $tabs_gui->addTarget("cont_back",
1347  "index.html#term_".$this->term_id, "",
1348  "");
1349  }
1350  }
1351 
1352  function download_paragraph () {
1353  include_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
1354  $pg_obj = new ilGlossaryDefPage($_GET["pg_id"]);
1355  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1356  }
1357 
1358 
1364  function infoScreen()
1365  {
1366  $this->ctrl->setCmd("showSummary");
1367  $this->ctrl->setCmdClass("ilinfoscreengui");
1368  $this->outputInfoScreen();
1369  }
1370 
1374  /*
1375  function showInfoScreen()
1376  {
1377  $this->outputInfoScreen(true);
1378  }*/
1379 
1383  function outputInfoScreen()
1384  {
1385  global $ilBench, $ilAccess, $ilTabs;
1386 
1387  $this->setTabs();
1388  $ilTabs->activateTab("info");
1389  $this->lng->loadLanguageModule("meta");
1390 
1391  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1392 
1393  $info = new ilInfoScreenGUI($this->glossary_gui);
1394  $info->enablePrivateNotes();
1395  //$info->enableLearningProgress();
1396 
1397  $info->enableNews();
1398  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1399  {
1400  $info->enableNewsEditing();
1401  $news_set = new ilSetting("news");
1402  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1403  if ($enable_internal_rss)
1404  {
1405  $info->setBlockProperty("news", "settings", true);
1406  }
1407  }
1408 
1409  // add read / back button
1410  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1411  {
1412  /*
1413  if ($_GET["obj_id"] > 0)
1414  {
1415  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1416  $info->addButton($this->lng->txt("back"),
1417  $this->ctrl->getLinkTarget($this, "layout"));
1418  }
1419  else
1420  {
1421  $info->addButton($this->lng->txt("view"),
1422  $this->ctrl->getLinkTarget($this, "layout"));
1423  }*/
1424  }
1425 
1426  // show standard meta data section
1427  $info->addMetaDataSections($this->glossary->getId(),0, $this->glossary->getType());
1428 
1429  include_once("./Modules/Glossary/classes/class.ilObjGlossaryGUI.php");
1430  ilObjGlossaryGUI::addUsagesToInfo($info, $this->glossary->getId());
1431 
1432  if ($this->offlineMode())
1433  {
1434  $this->tpl->setContent($info->getHTML());
1435  return $this->tpl->get();
1436  }
1437  else
1438  {
1439  // forward the command
1440  $this->ctrl->forwardCommand($info);
1441  }
1442  }
1443 
1450  function chooseLetter()
1451  {
1452  global $ilCtrl;
1453 
1454  $ilCtrl->redirect($this, "listTerms");
1455  }
1456 
1463  function showTaxonomy()
1464  {
1465  global $tpl, $lng;
1466  if (!$this->offlineMode() && $this->glossary->getShowTaxonomy())
1467  {
1468  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1469  $tax_ids = ilObjTaxonomy::getUsageOfObject($this->glossary->getId());
1470  if (count($tax_ids) > 0)
1471  {
1472  include_once("./Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php");
1473  $tax_exp = new ilTaxonomyExplorerGUI($this, "showTaxonomy", $tax_ids[0],
1474  "ilglossarypresentationgui", "listTerms");
1475  if (!$tax_exp->handleCommand())
1476  {
1477  //$tpl->setLeftNavContent($tax_exp->getHTML());
1478  $tpl->setLeftContent($tax_exp->getHTML()."&nbsp;");
1479  }
1480  return;
1481 
1482 
1483  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomyGUI.php");
1484  $tpl->setLeftNavContent(ilObjTaxonomyGUI::getTreeHTML($tax_ids[0],
1485  "ilglossarypresentationgui", "listTerms", $lng->txt("cont_all_topics")));
1486  }
1487  }
1488 
1489  }
1490 
1491 
1492 }
1493 
1494 ?>