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