ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilGlossaryPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("classes/class.ilObjectGUI.php");
25 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
26 require_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
27 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
28 require_once("./Modules/Glossary/classes/class.ilTermDefinitionEditorGUI.php");
29 require_once("./Services/COPage/classes/class.ilPCParagraph.php");
30 
44 {
46  var $glossary;
47  var $ilias;
48  var $tpl;
49  var $lng;
50 
56  {
57  global $lng, $ilias, $tpl, $ilCtrl;
58 
59  $this->tpl =& $tpl;
60  $this->lng =& $lng;
61  $this->ilias =& $ilias;
62  $this->ctrl =& $ilCtrl;
63  $this->offline = false;
64  $this->ctrl->saveParameter($this, array("ref_id"));
65 
66  // Todo: check lm id
67  include_once("./Modules/Glossary/classes/class.ilObjGlossaryGUI.php");
68  $this->glossary_gui =& new ilObjGlossaryGUI("", $_GET["ref_id"], true, "");
69  $this->glossary =& $this->glossary_gui->object;
70 
71  }
72 
73 
77  function setOfflineMode($a_offline = true)
78  {
79  $this->offline = $a_offline;
80  }
81 
82 
86  function offlineMode()
87  {
88  return $this->offline;
89  }
90 
94  function setOfflineDirectory($a_dir)
95  {
96  $this->offline_dir = $a_dir;
97  }
98 
99 
104  {
105  return $this->offline_dir;
106  }
107 
108 
112  function &executeCommand()
113  {
114  global $lng, $ilAccess, $ilias;
115 
116  $lng->loadLanguageModule("content");
117 
118  $next_class = $this->ctrl->getNextClass($this);
119  $cmd = $this->ctrl->getCmd("listTerms");
120 
121  // check write permission
122  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) &&
123  !($ilAccess->checkAccess("visible", "", $_GET["ref_id"]) &&
124  ($cmd == "infoScreen" || strtolower($next_class) == "ilinfoscreengui")))
125  {
126  $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
127  }
128 
129  if ($cmd != "listDefinitions")
130  {
131  $this->prepareOutput();
132  }
133 
134  switch($next_class)
135  {
136  case "ilnotegui":
137  $this->setTabs();
138  $ret =& $this->listDefinitions();
139  break;
140 
141  case "ilinfoscreengui":
142  $ret =& $this->outputInfoScreen();
143  break;
144 
145  default:
146  $ret =& $this->$cmd();
147  break;
148  }
149 
150  $this->tpl->show();
151  }
152 
153  function prepareOutput()
154  {
155  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
156  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
157  $title = $this->glossary->getTitle();
158 
159  // catch feedback message
161 
162  $this->tpl->setTitle($title);
163  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo_b.gif"));
164 
165  $this->setLocator();
166  }
167 
168  function clearTerms()
169  {
170  $_REQUEST["term"] = "";
171  $_GET["offset"] = $_GET["oldoffset"];
172  $this->searchTerms();
173  }
174 
175  function searchTerms ()
176  {
177  $term_list = $this->glossary->getTermList($_REQUEST["term"]);
178  $this->listTermByGiven($term_list, $_REQUEST["term"]);
179  }
180 
181 
182  function listTerms()
183  {
184  global $ilNavigationHistory;
185 
186  if (!$this->offlineMode())
187  {
188  $ilNavigationHistory->addItem($_GET["ref_id"],
189  $this->ctrl->getLinkTarget($this, "listTerms"), "glo");
190  }
191 
192  $term_list = $this->glossary->getTermList();
193 
194  return $this->listTermByGiven($term_list);
195  }
196 
200  function listTermByGiven($term_list, $filter ="")
201  {
202  global $ilCtrl, $ilAccess;
203 
204  $this->lng->loadLanguageModule("meta");
205  include_once "./Services/Table/classes/class.ilTableGUI.php";
206 
207  $this->setTabs();
208 
209  // load template for table
210 // $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
211 
212  $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
213 
214  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_presentation.html", "Modules/Glossary");
215 
216  // search form
217  if (!$this->offlineMode())
218  {
219  $this->tpl->setCurrentBlock("search_form");
220  $this->ctrl->setParameter($this, "offset", 0);
221  $this->ctrl->setParameter($this, "oldoffset", $oldoffset);
222  $this->tpl->setVariable("FORMACTION1",
223  $this->ctrl->getFormAction($this, "searchTerms"));
224  $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
225  $this->tpl->setVariable("TXT_SEARCH", $this->lng->txt("search"));
226  $this->tpl->setVariable("TXT_CLEAR", $this->lng->txt("clear"));
227  $this->tpl->setVariable("TERM", $filter);
228  $this->tpl->parseCurrentBlock();
229  }
230 
231 
232  // load template for table
233  $this->tpl->addBlockfile("TERM_TABLE", "term_table", "tpl.table.html");
234  // load template for table content data
235  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_tbl_pres_row.html", "Modules/Glossary");
236 
237  $num = 2;
238 
239  // create table
240  $tbl = new ilTableGUI();
241 
242  // title & header columns
243  $tbl->setTitle($this->lng->txt("cont_terms").(($filter=="")?"":"*"));
244  $tbl->disable("sort");
245  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
246 
247  // display additional column 'glossary' for meta glossaries
248  if ($this->glossary->isVirtual())
249  {
250  $tbl->setHeaderNames(array($this->lng->txt("cont_term"),
251  $this->lng->txt("cont_definitions"),$this->lng->txt("obj_glo")));
252 
253  $cols = array("term", "definitions", "glossary");
254 
255  $tbl->setColumnWidth(array("30%", "35%", "35%"));
256  }
257  else
258  {
259  $tbl->setHeaderNames(array($this->lng->txt("cont_term"),
260  $this->lng->txt("cont_definitions")));
261 
262  $cols = array("term", "definitions");
263 
264  $tbl->setColumnWidth(array("30%", "70%"));
265  }
266 
267  if (!$this->offlineMode())
268  {
269  $header_params = $this->ctrl->getParameterArrayByClass("ilglossarypresentationgui", "listTerms");
270  }
271  //$header_params = array("ref_id" => $_GET["ref_id"], "cmd" => "listTerms");
272 
273  if (!empty ($filter)) {
274  $header_params ["cmd"] = "searchTerms";
275  $header_params ["term"] = $filter;
276  $header_params ["oldoffset"] = $_GET["oldoffset"];
277  }
278 
279  $tbl->setHeaderVars($cols, $header_params);
280 
281  // control
282  $tbl->setOrderColumn($_GET["sort_by"]);
283  $tbl->setOrderDirection($_GET["sort_order"]);
284  if ($this->offlineMode())
285  {
286  $_GET["limit"] = 99999;
287  $_GET["offset"] = 0;
288  $tbl->disable("sort");
289  $tbl->disable("footer");
290  }
291  $tbl->setOffset($_GET["offset"]);
292  $tbl->setLimit($_GET["limit"]);
293 
294  // footer
295  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
296 
297 // $term_list = $this->glossary->getTermList();
298  $tbl->setMaxCount(count($term_list));
299 
300  // sorting array
301  //$term_list = ilUtil::sortArray($term_list, $_GET["sort_by"], $_GET["sort_order"]);
302 
303  $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
304  // render table
305 
306  $tbl->setBase("ilias.php");
307  $tbl->render();
308 
309  if (count($term_list) > 0)
310  {
311  $i=1;
312  foreach($term_list as $key => $term)
313  {
314  $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
315  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
316 
317  for($j=0; $j<count($defs); $j++)
318  {
319  $def = $defs[$j];
320  if (count($defs) > 1)
321  {
322  $this->tpl->setCurrentBlock("definition");
323  $this->tpl->setVariable("DEF_TEXT", $this->lng->txt("cont_definition")." ".($j + 1));
324  $this->tpl->parseCurrentBlock();
325  }
326 
327  //
328  $this->tpl->setCurrentBlock("definition");
329  $short_str = $def["short_text"];
330  // replace tex
331  // if a tex end tag is missing a tex end tag
332  $ltexs = strrpos($short_str, "[tex]");
333  $ltexe = strrpos($short_str, "[/tex]");
334  if ($ltexs > $ltexe)
335  {
336  $page =& new ilPageObject("gdf", $def["id"]);
337  $page->buildDom();
338  $short_str = $page->getFirstParagraphText();
339  $short_str = strip_tags($short_str, "<br>");
340  $ltexe = strpos($short_str, "[/tex]", $ltexs);
341  $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
342  }
343  if (!$this->offlineMode())
344  {
345  $short_str = ilUtil::insertLatexImages($short_str);
346  }
347  else
348  {
349  $short_str = ilUtil::buildLatexImages($short_str,
350  $this->getOfflineDirectory());
351  }
352  $short_str = ilPCParagraph::xml2output($short_str);
353 
354  $this->tpl->setVariable("DEF_SHORT", $short_str);
355  $this->tpl->parseCurrentBlock();
356 
357  $this->tpl->setCurrentBlock("definition_row");
358  $this->tpl->parseCurrentBlock();
359  }
360 
361  // display additional column 'glossary' for meta glossaries
362  if ($this->glossary->isVirtual())
363  {
364  $this->tpl->setCurrentBlock("glossary_row");
365  $glo_title = ilObject::_lookupTitle($term["glo_id"]);
366  $this->tpl->setVariable("GLO_TITLE", $glo_title);
367  $this->tpl->parseCurrentBlock();
368  }
369 
370  $this->tpl->setCurrentBlock("view_term");
371  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
372  if (!$this->offlineMode())
373  {
374  if (!empty ($filter))
375  {
376  $this->ctrl->setParameter($this, "term", $filter);
377  $this->ctrl->setParameter($this, "oldoffset", $_GET["oldoffset"]);
378  }
379  $this->ctrl->setParameter($this, "term_id", $term["id"]);
380  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
381  $this->tpl->setVariable("LINK_VIEW_TERM",
382  $this->ctrl->getLinkTarget($this, "listDefinitions"));
383  $this->ctrl->clearParameters($this);
384  }
385  else
386  {
387  $this->tpl->setVariable("LINK_VIEW_TERM", "term_".$term["id"].".html");
388  }
389  $this->tpl->setVariable("ANCHOR_TERM", "term_".$term["id"]);
390  $this->tpl->parseCurrentBlock();
391 
392  $this->tpl->setVariable("CSS_ROW", $css_row);
393  $this->tpl->setVariable("TEXT_LANGUAGE", $this->lng->txt("meta_l_".$term["language"]));
394  $this->tpl->setCurrentBlock("tbl_content");
395  $this->tpl->parseCurrentBlock();
396 
397  $this->ctrl->clearParameters($this);
398  }
399  } //if is_array
400  else
401  {
402  $this->tpl->setCurrentBlock("notfound");
403  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
404  $this->tpl->setVariable("NUM_COLS", $num);
405  $this->tpl->parseCurrentBlock();
406  }
407 
408  // edit link
409  if (!$this->offlineMode() && $ilAccess->checkAccess("write", "", $_GET["ref_id"]))
410  {
411  $this->tpl->setCurrentBlock("edit_glossary");
412  $this->tpl->setVariable("EDIT_TXT", $this->lng->txt("edit"));
413  $this->tpl->setVariable("EDIT_LINK",
414  "ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$_GET["ref_id"]);
415  $this->tpl->setVariable("EDIT_TARGET", "_top");
416  $this->tpl->parseCurrentBlock();
417  }
418 
419  // permanent link
420  $this->tpl->setCurrentBlock("perma_link");
421  $this->tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
422  "/goto.php?target=glo_".$_GET["ref_id"]."&client_id=".CLIENT_ID);
423  $this->tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
424  $this->tpl->setVariable("PERMA_TARGET", "_top");
425  $this->tpl->parseCurrentBlock();
426 
427  if ($this->offlineMode())
428  {
429  return $this->tpl->get();
430  }
431  }
432 
436  function listDefinitions()
437  {
438  global $ilUser, $ilAccess;
439 
440  require_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
441  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
442  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
443  //$this->setLocator();
444  $this->setTabs();
445 
446  if ($this->offlineMode())
447  {
448  $style_name = $ilUser->prefs["style"].".css";;
449  $this->tpl->setVariable("LOCATION_STYLESHEET","./".$style_name);
450  }
451  else
452  {
453  $this->setLocator();
454  }
455 
456  // content style
457  $this->tpl->setCurrentBlock("ContentStyle");
458  if (!$this->offlineMode())
459  {
460  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
462  }
463  else
464  {
465  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","content.css");
466  }
467  $this->tpl->parseCurrentBlock();
468 
469  // syntax style
470  $this->tpl->setCurrentBlock("SyntaxStyle");
471  if (!$this->offlineMode())
472  {
473  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
475  }
476  else
477  {
478  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
479  "syntaxhighlight.css");
480  }
481  $this->tpl->parseCurrentBlock();
482 
483  $term =& new ilGlossaryTerm($_GET["term_id"]);
484  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.gif"));
485  $this->tpl->setTitle($this->lng->txt("cont_term").": ".$term->getTerm());
486 
487  // load template for table
488  $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", "Modules/Glossary");
489  //$this->tpl->addBlockfile("STATUSLINE", "statusline", "tpl.statusline.html");
490 
492 
493  $this->tpl->setVariable("TXT_TERM", $term->getTerm());
494  $this->mobs = array();
495 
496  for($j=0; $j<count($defs); $j++)
497  {
498  $def = $defs[$j];
499  $page_gui =& new ilPageObjectGUI("gdf", $def["id"]);
500  $page = $page_gui->getPageObject();
501 
502  // internal links
503  $page->buildDom();
504  $int_links = $page->getInternalLinks();
505  $link_xml = $this->getLinkXML($int_links);
506  $page_gui->setLinkXML($link_xml);
507 
508  if ($this->offlineMode())
509  {
510  $page_gui->setOutputMode("offline");
511  $page_gui->setOfflineDirectory($this->getOfflineDirectory());
512  }
513  $page_gui->setSourcecodeDownloadScript($this->getLink($_GET["ref_id"]));
514  $page_gui->setFullscreenLink($this->getLink($_GET["ref_id"], "fullscreen", $_GET["term_id"], $def["id"]));
515 
516  $page_gui->setTemplateOutput(false);
517  $page_gui->setRawPageContent(true);
518  $page_gui->setFileDownloadLink($this->getLink($_GET["ref_id"], "downloadFile"));
519  if (!$this->offlineMode())
520  {
521  $output = $page_gui->preview();
522  }
523  else
524  {
525  $output = $page_gui->presentation($page_gui->getOutputMode());
526  }
527 
528  if (count($defs) > 1)
529  {
530  $this->tpl->setCurrentBlock("definition_header");
531  $this->tpl->setVariable("TXT_DEFINITION",
532  $this->lng->txt("cont_definition")." ".($j+1));
533  $this->tpl->parseCurrentBlock();
534  }
535 
536  $this->tpl->setCurrentBlock("definition");
537  $this->tpl->setVariable("PAGE_CONTENT", $output);
538  $this->tpl->parseCurrentBlock();
539  }
540 
541  // display possible backlinks
542  $sources = ilInternalLink::_getSourcesOfTarget('git',$_GET['term_id'],0);
543 
544  if ($sources)
545  {
546  $backlist_shown = false;
547  foreach ($sources as $src)
548  {
549  $type = explode(':',$src['type']);
550 
551  if ($type[0] == 'lm')
552  {
553  if ($type[1] == 'pg')
554  {
556  $lm_id = ilLMObject::_lookupContObjID($src['id']);
557  $lm_title = ilObject::_lookupTitle($lm_id);
558  $this->tpl->setCurrentBlock('backlink_item');
559  $ref_ids = ilObject::_getAllReferences($lm_id);
560  $access = false;
561  foreach($ref_ids as $rid)
562  {
563  if ($ilAccess->checkAccess("read", "", $rid))
564  {
565  $access = true;
566  }
567  }
568  if ($access)
569  {
570  $this->tpl->setCurrentBlock("backlink_item");
571  $this->tpl->setVariable("BACKLINK_LINK",ILIAS_HTTP_PATH."/goto.php?target=".$type[1]."_".$src['id']);
572  $this->tpl->setVariable("BACKLINK_ITEM",$lm_title.": ".$title);
573  $this->tpl->parseCurrentBlock();
574  $backlist_shown = true;
575  }
576  }
577  }
578  }
579  if ($backlist_shown)
580  {
581  $this->tpl->setCurrentBlock("backlink_list");
582  $this->tpl->setVariable("BACKLINK_TITLE",$this->lng->txt('glo_term_used_in'));
583  $this->tpl->parseCurrentBlock();
584  }
585  }
586 
587  $this->tpl->setCurrentBlock("perma_link");
588  $this->tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
589  "/goto.php?target=".
590  "git".
591  "_".$_GET["term_id"]."_".$_GET["ref_id"]."&client_id=".CLIENT_ID);
592  $this->tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
593  $this->tpl->setVariable("PERMA_TARGET", "_top");
594  $this->tpl->parseCurrentBlock();
595 
596 
597  if ($this->offlineMode())
598  {
599 //echo "<br>glo_pres_return";
600  return $this->tpl->get();
601  }
602  }
603 
604 
608  function fullscreen()
609  {
610  $html = $this->media("fullscreen");
611  return $html;
612  }
613 
617  function media($a_mode = "media")
618  {
619  $this->tpl =& new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
620  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
621  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
622  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
624 
625  //$int_links = $page_object->getInternalLinks();
626  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
627 
628  // later
629  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
630 
631  $link_xlm = "";
632 
633  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
634  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
635 
636  $xml = "<dummy>";
637  // todo: we get always the first alias now (problem if mob is used multiple
638  // times in page)
639  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
640  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
641  $xml.= $link_xml;
642  $xml.="</dummy>";
643 
644  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
645  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
646  $xh = xslt_create();
647 
648  if (!$this->offlineMode())
649  {
650  $enlarge_path = ilUtil::getImagePath("enlarge.gif", false, "output");
651  $wb_path = ilUtil::getWebspaceDir("output");
652  }
653  else
654  {
655  $enlarge_path = "images/enlarge.gif";
656  $wb_path = ".";
657  }
658 
659  $mode = $a_mode;
660 
661  $this->ctrl->setParameter($this, "obj_type", "MediaObject");
662  $fullscreen_link =
663  $this->getLink($_GET["ref_id"], "fullscreen");
664  $this->ctrl->clearParameters($this);
665 
666  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
667  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => $fullscreen_link,
668  'ref_id' => $_GET["ref_id"], 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
669  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
670  echo xslt_error($xh);
671  xslt_free($xh);
672 
673  // unmask user html
674  $this->tpl->setVariable("MEDIA_CONTENT", $output);
675 
676  $this->tpl->parseCurrentBlock();
677  if ($this->offlineMode())
678  {
679  $html = $this->tpl->get();
680  return $html;
681  }
682 
683  }
684 
688  function showDownloadList()
689  {
690  global $ilBench;
691 
692  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.glo_download_list.html", "Modules/Glossary");
693 
694  $this->setTabs();
695 
696  // set title header
697  $this->tpl->setTitle($this->glossary->getTitle());
698  //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_glo_b.gif"));
699  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo_b.gif"));
700 
701  // create table
702  require_once("./Services/Table/classes/class.ilTableGUI.php");
703  $tbl = new ilTableGUI();
704 
705  // load files templates
706  $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
707 
708  // load template for table content data
709  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/Glossary");
710 
711  $export_files = array();
712  $types = array("xml", "html");
713  foreach($types as $type)
714  {
715  if ($this->glossary->getPublicExportFile($type) != "")
716  {
717  $dir = $this->glossary->getExportDirectory($type);
718  if (is_file($this->glossary->getExportDirectory($type)."/".
719  $this->glossary->getPublicExportFile($type)))
720  {
721  $size = filesize($this->glossary->getExportDirectory($type)."/".
722  $this->glossary->getPublicExportFile($type));
723  $export_files[] = array("type" => $type,
724  "file" => $this->glossary->getPublicExportFile($type),
725  "size" => $size);
726  }
727  }
728  }
729 
730  $num = 0;
731 
732  $tbl->setTitle($this->lng->txt("download"));
733 
734  $tbl->setHeaderNames(array($this->lng->txt("cont_format"),
735  $this->lng->txt("cont_file"),
736  $this->lng->txt("size"), $this->lng->txt("date"),
737  ""));
738 
739  $cols = array("format", "file", "size", "date", "download");
740  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
741  "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
742  $tbl->setHeaderVars($cols, $header_params);
743  $tbl->setColumnWidth(array("10%", "30%", "20%", "20%","20%"));
744  $tbl->disable("sort");
745 
746  // control
747  $tbl->setOrderColumn($_GET["sort_by"]);
748  $tbl->setOrderDirection($_GET["sort_order"]);
749  $tbl->setLimit($_GET["limit"]);
750  $tbl->setOffset($_GET["offset"]);
751  $tbl->setMaxCount($this->maxcount); // ???
752 
753  $this->tpl->setVariable("COLUMN_COUNTS", 5);
754 
755  // footer
756  //$tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
757  $tbl->disable("footer");
758 
759  $tbl->setMaxCount(count($export_files));
760  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
761 
762  $tbl->render();
763  if(count($export_files) > 0)
764  {
765  $i=0;
766  foreach($export_files as $exp_file)
767  {
768  $this->tpl->setCurrentBlock("tbl_content");
769  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
770 
771  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
772  $this->tpl->setVariable("CSS_ROW", $css_row);
773 
774  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
775  $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
776  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
777 
778  $file_arr = explode("__", $exp_file["file"]);
779  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
780 
781  $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
782  $this->ctrl->setParameter($this, "type", $exp_file["type"]);
783  $this->tpl->setVariable("LINK_DOWNLOAD",
784  $this->ctrl->getLinkTarget($this, "downloadExportFile"));
785 
786  $this->tpl->parseCurrentBlock();
787  }
788  } //if is_array
789  else
790  {
791  $this->tpl->setCurrentBlock("notfound");
792  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
793  $this->tpl->setVariable("NUM_COLS", 5);
794  $this->tpl->parseCurrentBlock();
795  }
796 
797  //$this->tpl->show();
798  }
799 
804  {
805  $file = $this->glossary->getPublicExportFile($_GET["type"]);
806  if ($this->glossary->getPublicExportFile($_GET["type"]) != "")
807  {
808  $dir = $this->glossary->getExportDirectory($_GET["type"]);
809  if (is_file($dir."/".$file))
810  {
812  exit;
813  }
814  }
815  $this->ilias->raiseError($this->lng->txt("file_not_found"),$this->ilias->error_obj->MESSAGE);
816  }
817 
825  function setLocator($a_tree = "", $a_id = "")
826  {
827  global $ilias_locator;
828 
829  //$this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
830  require_once ("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
831  $gloss_loc =& new ilGlossaryLocatorGUI();
832  $gloss_loc->setMode("presentation");
833  if (!empty($_GET["term_id"]))
834  {
835  $term =& new ilGlossaryTerm($_GET["term_id"]);
836  $gloss_loc->setTerm($term);
837  }
838  $gloss_loc->setGlossary($this->glossary);
839  //$gloss_loc->setDefinition($this->definition);
840  $gloss_loc->display();
841  }
842 
846  function downloadFile()
847  {
848  $file = explode("_", $_GET["file_id"]);
849  include_once("./Modules/File/classes/class.ilObjFile.php");
850  $fileObj =& new ilObjFile($file[count($file) - 1], false);
851  $fileObj->sendFile();
852  exit;
853  }
854 
858  function setTabs()
859  {
860  global $ilTabs;
861  // catch feedback message
862  #include_once("classes/class.ilTabsGUI.php");
863  #$tabs_gui =& new ilTabsGUI();
864  $this->getTabs($ilTabs);
865 
866  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
867 
868  }
869 
873  function getLinkXML($a_int_links)
874  {
875 
876  if ($a_layoutframes == "")
877  {
878  $a_layoutframes = array();
879  }
880  $link_info = "<IntLinkInfos>";
881  foreach ($a_int_links as $int_link)
882  {
883 //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
884  $target = $int_link["Target"];
885  if (substr($target, 0, 4) == "il__")
886  {
887  $target_arr = explode("_", $target);
888  $target_id = $target_arr[count($target_arr) - 1];
889  $type = $int_link["Type"];
890  $targetframe = ($int_link["TargetFrame"] != "")
891  ? $int_link["TargetFrame"]
892  : "None";
893 
894  if ($targetframe == "New")
895  {
896  $ltarget = "_blank";
897  }
898  else
899  {
900  $ltarget = "";
901  }
902 
903  switch($type)
904  {
905  case "PageObject":
906  case "StructureObject":
908  $cont_obj =& $this->content_object;
909  if ($type == "PageObject")
910  {
911  $href = "./goto.php?target=pg_".$target_id;
912  }
913  else
914  {
915  $href = "./goto.php?target=st_".$target_id;
916  }
917  //$ltarget = "ilContObj".$lm_id;
918  break;
919 
920  case "GlossaryItem":
921  if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId())
922  {
923  if ($this->offlineMode())
924  {
925  $href = "term_".$target_id.".html";
926  }
927  else
928  {
929  $this->ctrl->setParameter($this, "term_id", $target_id);
930  $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
931  $href = str_replace("&", "&amp;", $href);
932  }
933  }
934  else
935  {
936  $href = "./goto.php?target=git_".$target_id;
937  }
938  break;
939 
940  case "MediaObject":
941  if ($this->offlineMode())
942  {
943  $href = "media_".$target_id.".html";
944  }
945  else
946  {
947  $this->ctrl->setParameter($this, "obj_type", $type);
948  $this->ctrl->setParameter($this, "mob_id", $target_id);
949  $href = $this->ctrl->getLinkTarget($this, "media");
950  $href = str_replace("&", "&amp;", $href);
951  }
952  break;
953 
954  case "RepositoryItem":
955  $obj_type = ilObject::_lookupType($target_id, true);
957  $href = "./goto.php?target=".$obj_type."_".$target_id;
958  $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
959  $ltarget = $t_frame;
960  break;
961 
962  }
963  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
964  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
965 
966  $this->ctrl->clearParameters($this);
967  }
968  }
969  $link_info.= "</IntLinkInfos>";
970 
971  return $link_info;
972  }
973 
974 
978  function getLink($a_ref_id, $a_cmd = "", $a_term_id = "", $a_def_id = "",
979  $a_frame = "", $a_type = "")
980  {
981  if ($a_cmd == "")
982  {
983  $a_cmd = "layout";
984  }
985  //$script = "glossary_presentation.php";
986 
987  // handle online links
988  if (!$this->offlineMode())
989  {
990  //$link = $script."?ref_id=".$a_ref_id;
991  switch ($a_cmd)
992  {
993  case "fullscreen":
994  $this->ctrl->setParameter($this, "def_id", $a_def_id);
995  $link = $this->ctrl->getLinkTarget($this, "fullscreen");
996  $link = str_replace("&", "&amp;", $link);
997  break;
998 
999  default:
1000  $link.= "&amp;cmd=".$a_cmd;
1001  if ($a_frame != "")
1002  {
1003  $this->ctrl->setParameter($this, "frame", $a_frame);
1004  }
1005  if ($a_obj_id != "")
1006  {
1007  switch ($a_type)
1008  {
1009  case "MediaObject":
1010  $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
1011  break;
1012 
1013  default:
1014  $this->ctrl->setParameter($this, "def_id", $a_def_id);
1015  break;
1016  }
1017  }
1018  if ($a_type != "")
1019  {
1020  $this->ctrl->setParameter($this, "obj_type", $a_type);
1021  }
1022  $link = $this->ctrl->getLinkTarget($this, $a_cmd);
1023  $link = str_replace("&", "&amp;", $link);
1024  break;
1025  }
1026  }
1027  else // handle offline links
1028  {
1029  switch ($a_cmd)
1030  {
1031  case "downloadFile":
1032  break;
1033 
1034  case "fullscreen":
1035  $link = "fullscreen.html"; // id is handled by xslt
1036  break;
1037 
1038  case "layout":
1039  break;
1040 
1041  case "glossary":
1042  $link = "term_".$a_obj_id.".html";
1043  break;
1044 
1045  case "media":
1046  $link = "media_".$a_obj_id.".html";
1047  break;
1048 
1049  default:
1050  break;
1051  }
1052  }
1053  $this->ctrl->clearParameters($this);
1054  return $link;
1055  }
1056 
1057 
1061  function getTabs(&$tabs_gui)
1062  {
1063  global $ilAccess;
1064 
1065  $oldoffset = (is_numeric ($_GET["oldoffset"]))?$_GET["oldoffset"]:$_GET["offset"];
1066 
1067  if (!$this->offlineMode())
1068  {
1069  if ($this->ctrl->getCmd() != "listDefinitions")
1070  {
1071  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1072  {
1073  $tabs_gui->addTarget("cont_terms",
1074  $this->ctrl->getLinkTarget($this, "listTerms"),
1075  array("listTerms", "searchTerms", "clearTerms", ""),
1076  "");
1077  }
1078 
1079  $force_active = false;
1080  if ($this->ctrl->getCmd() == "showSummary" ||
1081  strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui")
1082  {
1083  $force_active = true;
1084  }
1085  $tabs_gui->addTarget("information_abbr",
1086  $this->ctrl->getLinkTarget($this, "infoScreen"), array("infoScreen"),
1087  "ilInfoScreenGUI", "", $force_active);
1088 
1089  // glossary menu
1090  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1091  {
1092  if ($this->glossary->isActiveGlossaryMenu())
1093  {
1094  // download links
1095  if ($this->glossary->isActiveDownloads())
1096  {
1097  $tabs_gui->addTarget("download",
1098  $this->ctrl->getLinkTarget($this, "showDownloadList"), "showDownloadList",
1099  "");
1100  }
1101  }
1102  }
1103  }
1104  else
1105  {
1106  $this->ctrl->setParameter($this, "offset", $_GET["offset"]);
1107  if (!empty ($_REQUEST["term"]))
1108  {
1109  $this->ctrl->setParameter($this, "term", $_REQUEST["term"]);
1110  $this->ctrl->setParameter($this, "oldoffset", $_GET["oldoffset"]);
1111  $back = $this->ctrl->getLinkTarget($this, "searchTerms");
1112  }
1113  else
1114  {
1115  $back = $this->ctrl->getLinkTarget($this, "listTerms");
1116  }
1117  $tabs_gui->setBackTarget($this->lng->txt("obj_glo"),
1118  $back, "", "");
1119  }
1120 
1121  }
1122  else
1123  {
1124  $tabs_gui->addTarget("cont_back",
1125  "index.html#term_".$_GET["term_id"], "",
1126  "");
1127  }
1128  }
1129 
1130  function download_paragraph () {
1131  include_once("./Services/COPage/classes/class.ilPageObject.php");
1132  $pg_obj =& new ilPageObject("gdf", $_GET["pg_id"]);
1133  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1134  }
1135 
1136 
1142  function infoScreen()
1143  {
1144  $this->ctrl->setCmd("showSummary");
1145  $this->ctrl->setCmdClass("ilinfoscreengui");
1146  $this->outputInfoScreen();
1147  }
1148 
1152  /*
1153  function showInfoScreen()
1154  {
1155  $this->outputInfoScreen(true);
1156  }*/
1157 
1161  function outputInfoScreen()
1162  {
1163  global $ilBench, $ilAccess;
1164 
1165  $this->setTabs();
1166  $this->lng->loadLanguageModule("meta");
1167 
1168  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1169 
1170  $info = new ilInfoScreenGUI($this->glossary_gui);
1171  $info->enablePrivateNotes();
1172  //$info->enableLearningProgress();
1173 
1174  $info->enableNews();
1175  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1176  {
1177  $info->enableNewsEditing();
1178  $news_set = new ilSetting("news");
1179  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1180  if ($enable_internal_rss)
1181  {
1182  $info->setBlockProperty("news", "settings", true);
1183  }
1184  }
1185 
1186  // add read / back button
1187  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
1188  {
1189  /*
1190  if ($_GET["obj_id"] > 0)
1191  {
1192  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1193  $info->addButton($this->lng->txt("back"),
1194  $this->ctrl->getLinkTarget($this, "layout"));
1195  }
1196  else
1197  {
1198  $info->addButton($this->lng->txt("view"),
1199  $this->ctrl->getLinkTarget($this, "layout"));
1200  }*/
1201  }
1202 
1203  // show standard meta data section
1204  $info->addMetaDataSections($this->glossary->getId(),0, $this->glossary->getType());
1205 
1206  if ($this->offlineMode())
1207  {
1208  $this->tpl->setContent($info->getHTML());
1209  return $this->tpl->get();
1210  }
1211  else
1212  {
1213  // forward the command
1214  $this->ctrl->forwardCommand($info);
1215  }
1216  }
1217 
1218 }
1219 
1220 ?>