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