ILIAS  Release_4_4_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_b.png"));
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("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_term_b.png"));
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;
575 
576  if (!$this->offlineMode())
577  {
578  $ilCtrl->setParameter($this, "term_id", "");
579  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
580  if (!empty ($_REQUEST["term"]))
581  {
582  $this->ctrl->setParameter($this, "term", $_REQUEST["term"]);
583  $this->ctrl->setParameter($this, "oldoffset", $_GET["oldoffset"]);
584  $back = $ilCtrl->getLinkTarget($this, "searchTerms");
585  }
586  else
587  {
588  $back = $ilCtrl->getLinkTarget($this, "listTerms");
589  }
590  $ilCtrl->setParameter($this, "term_id", $this->term_id);
591  $ilCtrl->saveParameter($this, "term_id");
592 
593  $ilTabs->setBackTarget($this->lng->txt("obj_glo"), $back);
594 
595  $ilTabs->addTab("content",
596  $lng->txt("content"),
597  $ilCtrl->getLinkTarget($this, "listDefinitions"));
598 
599  $ilTabs->addTab("print_view",
600  $lng->txt("print_view"),
601  $ilCtrl->getLinkTarget($this, "printViewSelection"));
602 
603  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $this->term_id);
604  $ilTabs->addNonTabbedLink("editing_view",
605  $lng->txt("glo_editing_view"),
606  $ilCtrl->getLinkTargetByClass(array("ilglossaryeditorgui", "ilobjglossarygui", "ilglossarytermgui"), "listDefinitions"));
607  //"ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=".$_GET["ref_id"]."&amp;edit_term=".$this->term_id);
608 
609  $ilTabs->activateTab($a_act);
610  }
611  }
612 
613 
617  function fullscreen()
618  {
619  $html = $this->media("fullscreen");
620  return $html;
621  }
622 
626  function media($a_mode = "media")
627  {
628  $this->tpl =& new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
629  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
630  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
631  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
632  ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
633 
634  //$int_links = $page_object->getInternalLinks();
635  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
636 
637  // later
638  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
639 
640  $link_xlm = "";
641 
642  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
643  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
644 
645  $xml = "<dummy>";
646  // todo: we get always the first alias now (problem if mob is used multiple
647  // times in page)
648  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
649  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
650  $xml.= $link_xml;
651  $xml.="</dummy>";
652 
653  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
654  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
655  $xh = xslt_create();
656 
657  if (!$this->offlineMode())
658  {
659  $enlarge_path = ilUtil::getImagePath("enlarge.png", false, "output");
660  $wb_path = ilUtil::getWebspaceDir("output")."/";
661  }
662  else
663  {
664  $enlarge_path = "images/enlarge.png";
665  $wb_path = "";
666  }
667 
668  $mode = $a_mode;
669 
670  $this->ctrl->setParameter($this, "obj_type", "MediaObject");
671  $fullscreen_link =
672  $this->getLink($_GET["ref_id"], "fullscreen");
673  $this->ctrl->clearParameters($this);
674 
675  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
676  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
677  'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
678  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
679  echo xslt_error($xh);
680  xslt_free($xh);
681 
682  // unmask user html
683  $this->tpl->setVariable("MEDIA_CONTENT", $output);
684 
685  $this->tpl->parseCurrentBlock();
686  if ($this->offlineMode())
687  {
688  $html = $this->tpl->get();
689  return $html;
690  }
691 
692  }
693 
697  function showDownloadList()
698  {
699  global $ilBench, $ilAccess, $ilias, $lng, $ilTabs;
700 
701  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
702  {
703  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
704  }
705 
706  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glo_download_list.html", "Modules/Glossary");
707 
708  $this->setTabs();
709  $ilTabs->activateTab("download");
710 
711  // set title header
712  $this->tpl->setTitle($this->glossary->getTitle());
713  //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.png"));
714  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo_b.png"));
715 
716  // create table
717  require_once("./Services/Table/classes/class.ilTableGUI.php");
718  $tbl = new ilTableGUI();
719 
720  // load files templates
721  $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
722 
723  // load template for table content data
724  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/Glossary");
725 
726  $export_files = array();
727  $types = array("xml", "html");
728  foreach($types as $type)
729  {
730  if ($this->glossary->getPublicExportFile($type) != "")
731  {
732  $dir = $this->glossary->getExportDirectory($type);
733  if (is_file($this->glossary->getExportDirectory($type)."/".
734  $this->glossary->getPublicExportFile($type)))
735  {
736  $size = filesize($this->glossary->getExportDirectory($type)."/".
737  $this->glossary->getPublicExportFile($type));
738  $export_files[] = array("type" => $type,
739  "file" => $this->glossary->getPublicExportFile($type),
740  "size" => $size);
741  }
742  }
743  }
744 
745  $num = 0;
746 
747  $tbl->setTitle($this->lng->txt("download"));
748 
749  $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
750  $this->lng->txt("cont_file"),
751  $this->lng->txt("size"), $this->lng->txt("date"),
752  ""));
753 
754  $cols = array("format", "file", "size", "date", "download");
755  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
756  "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
757  $tbl->setHeaderVars($cols, $header_params);
758  $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
759  $tbl->disable("sort");
760 
761  // control
762  $tbl->setOrderColumn($_GET["sort_by"]);
763  $tbl->setOrderDirection($_GET["sort_order"]);
764  $tbl->setLimit($_GET["limit"]);
765  $tbl->setOffset($_GET["offset"]);
766  $tbl->setMaxCount($this->maxcount); // ???
767 
768  $this->tpl->setVariable("COLUMN_COUNTS", 5);
769 
770  // footer
771  //$tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
772  $tbl->disable("footer");
773 
774  $tbl->setMaxCount(count($export_files));
775  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
776 
777  $tbl->render();
778  if(count($export_files) > 0)
779  {
780  $i=0;
781  foreach($export_files as $exp_file)
782  {
783  $this->tpl->setCurrentBlock("tbl_content");
784  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
785 
786  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
787  $this->tpl->setVariable("CSS_ROW", $css_row);
788 
789  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
790  $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
791  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
792 
793  $file_arr = explode("__", $exp_file["file"]);
794  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
795 
796  $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
797  $this->ctrl->setParameter($this, "type", $exp_file["type"]);
798  $this->tpl->setVariable("LINK_DOWNLOAD",
799  $this->ctrl->getLinkTarget($this, "downloadExportFile"));
800 
801  $this->tpl->parseCurrentBlock();
802  }
803  } //if is_array
804  else
805  {
806  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
807  $this->tpl->setVariable("NUM_COLS", 5);
808  $this->tpl->parseCurrentBlock();
809  }
810 
811  //$this->tpl->show();
812  }
813 
818  {
819  global $ilAccess, $ilias, $lng;
820 
821  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
822  {
823  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
824  }
825 
826  $file = $this->glossary->getPublicExportFile($_GET["type"]);
827  if ($this->glossary->getPublicExportFile($_GET["type"]) != "")
828  {
829  $dir = $this->glossary->getExportDirectory($_GET["type"]);
830  if (is_file($dir."/".$file))
831  {
832  ilUtil::deliverFile($dir."/".$file, $file);
833  exit;
834  }
835  }
836  $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
837  }
838 
846  function setLocator($a_tree = "", $a_id = "")
847  {
848  //$this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
849  require_once ("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
850  $gloss_loc =& new ilGlossaryLocatorGUI();
851  $gloss_loc->setMode("presentation");
852  if (!empty($this->term_id))
853  {
854  $term =& new ilGlossaryTerm($this->term_id);
855  $gloss_loc->setTerm($term);
856  }
857  $gloss_loc->setGlossary($this->glossary);
858  //$gloss_loc->setDefinition($this->definition);
859  $gloss_loc->display();
860  }
861 
865  function downloadFile()
866  {
867  global $ilAccess, $ilias, $lng;
868 
869  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
870  {
871  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
872  }
873 
874  $file = explode("_", $_GET["file_id"]);
875  include_once("./Modules/File/classes/class.ilObjFile.php");
876  $fileObj =& new ilObjFile($file[count($file) - 1], false);
877  $fileObj->sendFile();
878  exit;
879  }
880 
884  function setTabs()
885  {
886  global $ilTabs;
887  $this->getTabs($ilTabs);
888  }
889 
893  function getLinkXML($a_int_links)
894  {
895 
896  if ($a_layoutframes == "")
897  {
898  $a_layoutframes = array();
899  }
900  $link_info = "<IntLinkInfos>";
901  foreach ($a_int_links as $int_link)
902  {
903 //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
904  $target = $int_link["Target"];
905  if (substr($target, 0, 4) == "il__")
906  {
907  $target_arr = explode("_", $target);
908  $target_id = $target_arr[count($target_arr) - 1];
909  $type = $int_link["Type"];
910  $targetframe = ($int_link["TargetFrame"] != "")
911  ? $int_link["TargetFrame"]
912  : "None";
913 
914  // anchor
915  $anc = $anc_add = "";
916  if ($int_link["Anchor"] != "")
917  {
918  $anc = $int_link["Anchor"];
919  $anc_add = "_".rawurlencode($int_link["Anchor"]);
920  }
921 
922  if ($targetframe == "New")
923  {
924  $ltarget = "_blank";
925  }
926  else
927  {
928  $ltarget = "";
929  }
930 
931  switch($type)
932  {
933  case "PageObject":
934  case "StructureObject":
936  $cont_obj =& $this->content_object;
937  if ($type == "PageObject")
938  {
939  $href = "./goto.php?target=pg_".$target_id.$anc_add;
940  }
941  else
942  {
943  $href = "./goto.php?target=st_".$target_id;
944  }
945  //$ltarget = "ilContObj".$lm_id;
946  break;
947 
948  case "GlossaryItem":
949  if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId())
950  {
951  if ($this->offlineMode())
952  {
953  $href = "term_".$target_id.".html";
954  }
955  else
956  {
957  $this->ctrl->setParameter($this, "term_id", $target_id);
958  $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
959  $href = str_replace("&", "&amp;", $href);
960  }
961  }
962  else
963  {
964  $href = "./goto.php?target=git_".$target_id;
965  }
966  break;
967 
968  case "MediaObject":
969  if ($this->offlineMode())
970  {
971  $href = "media_".$target_id.".html";
972  }
973  else
974  {
975  $this->ctrl->setParameter($this, "obj_type", $type);
976  $this->ctrl->setParameter($this, "mob_id", $target_id);
977  $href = $this->ctrl->getLinkTarget($this, "media");
978  $href = str_replace("&", "&amp;", $href);
979  }
980  break;
981 
982  case "RepositoryItem":
983  $obj_type = ilObject::_lookupType($target_id, true);
985  $href = "./goto.php?target=".$obj_type."_".$target_id;
986  $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
987  $ltarget = $t_frame;
988  break;
989 
990  case "WikiPage":
991  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
993  break;
994  }
995 
996  $anc_par = 'Anchor="'.$anc.'"';
997 
998  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
999  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" $anc_par/>";
1000 
1001  $this->ctrl->clearParameters($this);
1002  }
1003  }
1004  $link_info.= "</IntLinkInfos>";
1005 
1006  return $link_info;
1007  }
1008 
1009 
1013  function getLink($a_ref_id, $a_cmd = "", $a_term_id = "", $a_def_id = "",
1014  $a_frame = "", $a_type = "")
1015  {
1016  if ($a_cmd == "")
1017  {
1018  $a_cmd = "layout";
1019  }
1020  //$script = "glossary_presentation.php";
1021 
1022  // handle online links
1023  if (!$this->offlineMode())
1024  {
1025  //$link = $script."?ref_id=".$a_ref_id;
1026  switch ($a_cmd)
1027  {
1028  case "fullscreen":
1029  $this->ctrl->setParameter($this, "def_id", $a_def_id);
1030  $link = $this->ctrl->getLinkTarget($this, "fullscreen");
1031  break;
1032 
1033  default:
1034  $link.= "&amp;cmd=".$a_cmd;
1035  if ($a_frame != "")
1036  {
1037  $this->ctrl->setParameter($this, "frame", $a_frame);
1038  }
1039  if ($a_obj_id != "")
1040  {
1041  switch ($a_type)
1042  {
1043  case "MediaObject":
1044  $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
1045  break;
1046 
1047  default:
1048  $this->ctrl->setParameter($this, "def_id", $a_def_id);
1049  break;
1050  }
1051  }
1052  if ($a_type != "")
1053  {
1054  $this->ctrl->setParameter($this, "obj_type", $a_type);
1055  }
1056  $link = $this->ctrl->getLinkTarget($this, $a_cmd);
1057 // $link = str_replace("&", "&amp;", $link);
1058  break;
1059  }
1060  }
1061  else // handle offline links
1062  {
1063  switch ($a_cmd)
1064  {
1065  case "downloadFile":
1066  break;
1067 
1068  case "fullscreen":
1069  $link = "fullscreen.html"; // id is handled by xslt
1070  break;
1071 
1072  case "layout":
1073  break;
1074 
1075  case "glossary":
1076  $link = "term_".$a_obj_id.".html";
1077  break;
1078 
1079  case "media":
1080  $link = "media_".$a_obj_id.".html";
1081  break;
1082 
1083  default:
1084  break;
1085  }
1086  }
1087  $this->ctrl->clearParameters($this);
1088  return $link;
1089  }
1090 
1098  {
1099  global $ilUser, $lng, $ilToolbar, $ilCtrl, $tpl, $ilTabs;
1100 
1101  $ilCtrl->saveParameter($this, "term_id");
1102 
1103  if ((int) $this->term_id == 0)
1104  {
1105  $this->setTabs();
1106  $ilTabs->activateTab("print_view");
1107  }
1108  else
1109  {
1110  $tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.png"));
1111  $term = new ilGlossaryTerm((int) $this->term_id);
1112  $tpl->setTitle($this->lng->txt("cont_term").": ".$term->getTerm());
1113  $this->showDefinitionTabs("print_view");
1114  }
1115 
1116  $this->initPrintViewSelectionForm();
1117 
1118  $tpl->setContent($this->form->getHTML());
1119  }
1120 
1124  public function initPrintViewSelectionForm()
1125  {
1126  global $lng, $ilCtrl;
1127 
1128  $terms = $this->glossary->getTermList();
1129 
1130  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1131  $this->form = new ilPropertyFormGUI();
1132  $this->form->setTarget("print_view");
1133  $this->form->setFormAction($ilCtrl->getFormAction($this));
1134 
1135  // selection type
1136  $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
1137  $radg->setValue("glossary");
1138 
1139  // current term
1140  if ((int) $this->term_id > 0)
1141  {
1142  $op1 = new ilRadioOption($lng->txt("cont_current_term"), "term");
1143  $radg->addOption($op1);
1144  $radg->setValue("term");
1145  }
1146 
1147  // whole glossary
1148  $op2 = new ilRadioOption($lng->txt("cont_whole_glossary")
1149  ." (".$lng->txt("cont_terms").": ".count($terms).")", "glossary");
1150  $radg->addOption($op2);
1151 
1152  // selected topic
1153  if (($t_id = $this->glossary->getTaxonomyId()) > 0 && $this->glossary->getShowTaxonomy())
1154  {
1155  $op4 = new ilRadioOption($lng->txt("cont_selected_topic"), "sel_topic");
1156  $radg->addOption($op4);
1157 
1158  // topic drop down
1159  include_once("./Services/Taxonomy/classes/class.ilTaxAssignInputGUI.php");
1160  $si = new ilTaxAssignInputGUI($t_id, false, $lng->txt("cont_topic"), "topic",
1161  false);
1162  if ($this->tax_node > 0)
1163  {
1164  $si->setValue((int) $this->tax_node);
1165  }
1166  $op4->addSubItem($si);
1167 
1168  }
1169 
1170  // selected terms
1171  $op3= new ilRadioOption($lng->txt("cont_selected_terms"), "selection");
1172  $radg->addOption($op3);
1173 
1174  include_once("./Services/Form/classes/class.ilNestedListInputGUI.php");
1175  $nl = new ilNestedListInputGUI("", "obj_id");
1176  $op3->addSubItem($nl);
1177 //var_dump($terms);
1178  foreach ($terms as $t)
1179  {
1180  $nl->addListNode($t["id"], $t["term"], 0, false, false);
1181  }
1182 
1183  $this->form->addItem($radg);
1184 
1185  $this->form->addCommandButton("printView", $lng->txt("cont_show_print_view"));
1186 
1187  $this->form->setTitle($lng->txt("cont_print_selection"));
1188  }
1189 
1196  function printView()
1197  {
1198  global $ilAccess, $tpl;
1199 
1200  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1201  {
1202  return;
1203  }
1204 
1205  $terms = array();
1206  switch ($_POST["sel_type"])
1207  {
1208  case "glossary":
1209  $ts = $this->glossary->getTermList();
1210  foreach ($ts as $t)
1211  {
1212  $terms[] = $t["id"];
1213  }
1214  break;
1215 
1216  case "sel_topic":
1217  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1218  $t_id = $this->glossary->getTaxonomyId();
1219  $items = ilObjTaxonomy::getSubTreeItems("glo", $this->glossary->getId(), "term", $t_id, (int) $_POST["topic"]);
1220  foreach ($items as $i)
1221  {
1222  if ($i["item_type"] == "term")
1223  {
1224  $terms[] = $i["item_id"];
1225  }
1226  }
1227  break;
1228 
1229  case "selection":
1230  if (is_array($_POST["obj_id"]))
1231  {
1232  $terms = $_POST["obj_id"];
1233  }
1234  else
1235  {
1236  $terms = array();
1237  }
1238  break;
1239 
1240  case "term":
1241  $terms = array($this->term_id);
1242  break;
1243  }
1244 
1245  $tpl = new ilTemplate("tpl.main.html", true, true);
1246  $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
1247 
1248 /*
1249  // syntax style
1250  $this->tpl->setCurrentBlock("SyntaxStyle");
1251  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1252  ilObjStyleSheet::getSyntaxStylePath());
1253  $this->tpl->parseCurrentBlock();
1254 
1255  // content style
1256  $this->tpl->setCurrentBlock("ContentStyle");
1257  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1258  ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
1259  $this->tpl->parseCurrentBlock();*/
1260 
1261  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1263 
1264  // determine target frames for internal links
1265 
1266  foreach ($terms as $t_id)
1267  {
1268  $page_content.= $this->listDefinitions($_GET["ref_id"], $t_id, true);
1269  }
1270  $tpl->setVariable("CONTENT", $page_content.
1271  '<script type="text/javascript" language="javascript1.2">
1272  <!--
1273  il.Util.addOnLoad(function () {
1274  il.Util.print();
1275  });
1276  //-->
1277  </script>');
1278  $tpl->show(false);
1279  exit;
1280  }
1281 
1285  function getTabs(&$tabs_gui)
1286  {
1287  global $ilAccess, $lng, $ilCtrl, $ilHelp;
1288 
1289  $ilHelp->setScreenIdComponent("glo");
1290 
1291  $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
1292 
1293  if (!$this->offlineMode())
1294  {
1295  if ($this->ctrl->getCmd() != "listDefinitions")
1296  {
1297  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1298  {
1299  $tabs_gui->addTab("terms",
1300  $lng->txt("cont_terms"),
1301  $ilCtrl->getLinkTarget($this, "listTerms"));
1302  }
1303 
1304  $tabs_gui->addTab("info",
1305  $lng->txt("info_short"),
1306  $ilCtrl->getLinkTarget($this, "infoScreen"));
1307 
1308  $tabs_gui->addTab("print_view",
1309  $lng->txt("cont_print_view"),
1310  $ilCtrl->getLinkTarget($this, "printViewSelection"));
1311 
1312  // glossary menu
1313  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1314  {
1315  //if ($this->glossary->isActiveGlossaryMenu())
1316  //{
1317  // download links
1318  if ($this->glossary->isActiveDownloads())
1319  {
1320  $tabs_gui->addTab("download",
1321  $lng->txt("download"),
1322  $ilCtrl->getLinkTarget($this, "showDownloadList"));
1323  }
1324  //}
1325  }
1326 
1327  if ($ilAccess->checkAccess("write", "", (int) $_GET["ref_id"]) ||
1328  $ilAccess->checkAccess("edit_content", "", (int) $_GET["ref_id"]))
1329  {
1330  $tabs_gui->addNonTabbedLink("editing_view",
1331  $lng->txt("glo_editing_view"),
1332  "ilias.php?baseClass=ilGlossaryEditorGUI&amp;ref_id=".(int) $_GET["ref_id"],
1333  "_top");
1334  }
1335 
1336  }
1337  }
1338  else
1339  {
1340  $tabs_gui->addTarget("cont_back",
1341  "index.html#term_".$this->term_id, "",
1342  "");
1343  }
1344  }
1345 
1346  function download_paragraph () {
1347  include_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
1348  $pg_obj = new ilGlossaryDefPage($_GET["pg_id"]);
1349  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1350  }
1351 
1352 
1358  function infoScreen()
1359  {
1360  $this->ctrl->setCmd("showSummary");
1361  $this->ctrl->setCmdClass("ilinfoscreengui");
1362  $this->outputInfoScreen();
1363  }
1364 
1368  /*
1369  function showInfoScreen()
1370  {
1371  $this->outputInfoScreen(true);
1372  }*/
1373 
1377  function outputInfoScreen()
1378  {
1379  global $ilBench, $ilAccess, $ilTabs;
1380 
1381  $this->setTabs();
1382  $ilTabs->activateTab("info");
1383  $this->lng->loadLanguageModule("meta");
1384 
1385  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1386 
1387  $info = new ilInfoScreenGUI($this->glossary_gui);
1388  $info->enablePrivateNotes();
1389  //$info->enableLearningProgress();
1390 
1391  $info->enableNews();
1392  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1393  {
1394  $info->enableNewsEditing();
1395  $news_set = new ilSetting("news");
1396  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1397  if ($enable_internal_rss)
1398  {
1399  $info->setBlockProperty("news", "settings", true);
1400  }
1401  }
1402 
1403  // add read / back button
1404  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1405  {
1406  /*
1407  if ($_GET["obj_id"] > 0)
1408  {
1409  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1410  $info->addButton($this->lng->txt("back"),
1411  $this->ctrl->getLinkTarget($this, "layout"));
1412  }
1413  else
1414  {
1415  $info->addButton($this->lng->txt("view"),
1416  $this->ctrl->getLinkTarget($this, "layout"));
1417  }*/
1418  }
1419 
1420  // show standard meta data section
1421  $info->addMetaDataSections($this->glossary->getId(),0, $this->glossary->getType());
1422 
1423  include_once("./Modules/Glossary/classes/class.ilObjGlossaryGUI.php");
1424  ilObjGlossaryGUI::addUsagesToInfo($info, $this->glossary->getId());
1425 
1426  if ($this->offlineMode())
1427  {
1428  $this->tpl->setContent($info->getHTML());
1429  return $this->tpl->get();
1430  }
1431  else
1432  {
1433  // forward the command
1434  $this->ctrl->forwardCommand($info);
1435  }
1436  }
1437 
1444  function chooseLetter()
1445  {
1446  global $ilCtrl;
1447 
1448  $ilCtrl->redirect($this, "listTerms");
1449  }
1450 
1457  function showTaxonomy()
1458  {
1459  global $tpl, $lng;
1460  if (!$this->offlineMode() && $this->glossary->getShowTaxonomy())
1461  {
1462  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1463  $tax_ids = ilObjTaxonomy::getUsageOfObject($this->glossary->getId());
1464  if (count($tax_ids) > 0)
1465  {
1466  include_once("./Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php");
1467  $tax_exp = new ilTaxonomyExplorerGUI($this, "showTaxonomy", $tax_ids[0],
1468  "ilglossarypresentationgui", "listTerms");
1469  if (!$tax_exp->handleCommand())
1470  {
1471  //$tpl->setLeftNavContent($tax_exp->getHTML());
1472  $tpl->setLeftContent($tax_exp->getHTML()."&nbsp;");
1473  }
1474  return;
1475 
1476 
1477  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomyGUI.php");
1478  $tpl->setLeftNavContent(ilObjTaxonomyGUI::getTreeHTML($tax_ids[0],
1479  "ilglossarypresentationgui", "listTerms", $lng->txt("cont_all_topics")));
1480  }
1481  }
1482 
1483  }
1484 
1485 
1486 }
1487 
1488 ?>