ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGlossaryGUI.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("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 
26 {
28  var $mode;
29  var $term;
30 
35  function ilObjGlossaryGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
36  {
37  global $ilCtrl, $lng;
38 
39  $this->ctrl =& $ilCtrl;
40  $this->ctrl->saveParameter($this, array("ref_id", "offset"));
41  $lng->loadLanguageModule("content");
42 
43  $this->type = "glo";
44  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
45  }
46 
50  function &executeCommand()
51  {
52  global $lng, $ilAccess;
53 
54  $cmd = $this->ctrl->getCmd();
55  $next_class = $this->ctrl->getNextClass($this);
56 
57  switch ($next_class)
58  {
59  case 'ilmdeditorgui':
60  $this->getTemplate();
61  $this->setTabs();
62  $this->setLocator();
63  $this->addHeaderAction();
64 
65  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
66 
67  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
68  $md_gui->addObserver($this->object,'MDUpdateListener','General');
69 
70  $this->ctrl->forwardCommand($md_gui);
71  break;
72 
73  case "ilglossarytermgui":
74  $this->ctrl->setReturn($this, "listTerms");
75  $term_gui =& new ilGlossaryTermGUI($_GET["term_id"]);
76  $term_gui->setGlossary($this->object);
77  //$ret =& $term_gui->executeCommand();
78  $ret =& $this->ctrl->forwardCommand($term_gui);
79  break;
80 
81  case "ilinfoscreengui":
82  $this->addHeaderAction();
83  $this->showInfoScreen();
84  break;
85 
86  case 'ilpermissiongui':
87  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
88  {
89  $this->prepareOutput();
90  }
91  else
92  {
93  $this->getTemplate();
94  $this->setTabs();
95  $this->setLocator();
96  $this->addHeaderAction();
97  }
98  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
99  $perm_gui =& new ilPermissionGUI($this);
100  $ret =& $this->ctrl->forwardCommand($perm_gui);
101  break;
102 
103  case "ilcommonactiondispatchergui":
104  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
106  $this->ctrl->forwardCommand($gui);
107  break;
108 
109  default:
110  $cmd = $this->ctrl->getCmd("frameset");
111 
112  if (($cmd == "create") && ($_POST["new_type"] == "term"))
113  {
114  $this->ctrl->setCmd("create");
115  $this->ctrl->setCmdClass("ilGlossaryTermGUI");
116  $ret =& $this->executeCommand();
117  return;
118  }
119  else
120  {
121  if (!in_array($cmd, array("frameset", "quickList")))
122  {
123  if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
124  $this->getCreationMode() == true)
125  {
126  $this->prepareOutput();
127  $cmd.= "Object";
128  }
129  else
130  {
131  $this->getTemplate();
132  $this->setTabs();
133  $this->setLocator();
134  $this->addHeaderAction();
135  }
136  }
137  $ret =& $this->$cmd();
138  }
139  break;
140  }
141 
142  if (!in_array($cmd, array("frameset", "quickList")))
143  {
144  if (strtolower($_GET["baseClass"]) != "iladministrationgui")
145  {
146  if (!$this->getCreationMode())
147  {
148  $this->tpl->show();
149  }
150  }
151  }
152  else
153  {
154  $this->tpl->show(false);
155  }
156  }
157 
158  function assignObject()
159  {
160  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
161 
162  $this->object =& new ilObjGlossary($this->id, true);
163  }
164 
165  protected function initCreationForms($a_new_type)
166  {
167  $forms = array(
168  self::CFORM_NEW => $this->initCreateForm($a_new_type),
169  self::CFORM_IMPORT => $this->initImportForm($a_new_type)
170  );
171 
172  return $forms;
173  }
174 
175  function initCreateForm($a_new_type)
176  {
177  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
178  $form = new ilPropertyFormGUI();
179  $form->setTarget("_top");
180  $form->setFormAction($this->ctrl->getFormAction($this));
181  $form->setTitle($this->lng->txt($a_new_type."_new"));
182 
183  // title
184  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
185  $ti->setMaxLength(128);
186  $ti->setSize(40);
187  $ti->setRequired(true);
188  $form->addItem($ti);
189 
190  // description
191  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
192  $ta->setCols(40);
193  $ta->setRows(2);
194  $form->addItem($ta);
195 
196  // mode
197  $stati = array(
198  "none"=>$this->lng->txt("glo_mode_normal"),
199  "level"=>$this->lng->txt("glo_mode_level"),
200  "subtree"=>$this->lng->txt("glo_mode_subtree")
201  );
202  $tm = new ilSelectInputGUI($this->lng->txt("glo_mode"), "glo_mode");
203  $tm->setOptions($stati);
204  $tm->setInfo($this->lng->txt("glo_mode_desc"));
205  $tm->setRequired(true);
206  $form->addItem($tm);
207 
208  $form->addCommandButton("save", $this->lng->txt($a_new_type."_add"));
209  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
210 
211  return $form;
212  }
213 
214  function importObject()
215  {
216  $this->createObject();
217  }
218 
222  function saveObject()
223  {
224  global $tpl;
225 
226  $new_type = $_REQUEST["new_type"];
227 
228  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
229  if (!$this->checkPermissionBool("create", "", $new_type))
230  {
231  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
232  }
233 
234  $this->lng->loadLanguageModule($new_type);
235  $this->ctrl->setParameter($this, "new_type", $new_type);
236 
237  $form = $this->initCreateForm($new_type);
238  if ($form->checkInput())
239  {
240  $this->ctrl->setParameter($this, "new_type", "");
241 
242  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
243  $newObj = new ilObjGlossary();
244  $newObj->setType($new_type);
245  $newObj->setTitle($form->getInput("title"));
246  $newObj->setDescription($form->getInput("desc"));
247  $newObj->setVirtualMode($form->getInput("glo_mode"));
248  $newObj->create();
249 
250  $this->putObjectInTree($newObj);
251 
252  // always send a message
253  ilUtil::sendSuccess($this->lng->txt("glo_added"),true);
254  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
255  }
256 
257  // display only this form to correct input
258  $form->setValuesByPost();
259  $tpl->setContent($form->getHtml());
260  }
261 
268  function importFileObject()
269  {
270  $new_type = $_REQUEST["new_type"];
271 
272  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
273  if (!$this->checkPermissionBool("create", "", $new_type))
274  {
275  $ilErr->raiseError($this->lng->txt("no_create_permission"));
276  }
277 
278  $this->lng->loadLanguageModule($new_type);
279  $this->ctrl->setParameter($this, "new_type", $new_type);
280 
281  $form = $this->initImportForm($new_type);
282  if ($form->checkInput())
283  {
284  $this->ctrl->setParameter($this, "new_type", "");
285  $upload = $_FILES["importfile"];
286 
287  // create and insert object in objecttree
288  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
289  $newObj = new ilObjGlossary();
290  $newObj->setType($new_type);
291  $newObj->setTitle($upload["name"]);
292  $newObj->create(true);
293 
294  $this->putObjectInTree($newObj);
295 
296  // create import directory
297  $newObj->createImportDirectory();
298 
299  // copy uploaded file to import directory
300  $file = pathinfo($upload["name"]);
301  $full_path = $newObj->getImportDirectory()."/".$upload["name"];
302 
303  ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"],
304  $full_path);
305 
306  // unzip file
307  ilUtil::unzip($full_path);
308 
309  // determine filename of xml file
310  $subdir = basename($file["basename"],".".$file["extension"]);
311  $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
312 
313  // check whether subdirectory exists within zip file
314  if (!is_dir($newObj->getImportDirectory()."/".$subdir))
315  {
316  $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir),
317  $this->ilias->error_obj->MESSAGE);
318  }
319 
320  // check whether xml file exists within zip file
321  if (!is_file($xml_file))
322  {
323  $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml"),
324  $this->ilias->error_obj->MESSAGE);
325  }
326 
327  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
328  $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
329  $contParser->startParsing();
330  ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
331 
332  // delete import directory
333  ilUtil::delDir($newObj->getImportDirectory());
334 
335  ilUtil::sendSuccess($this->lng->txt("glo_added"),true);
336  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
337  }
338 
339  // display form to correct errors
340  $form->setValuesByPost();
341  $tpl->setContent($form->getHtml());
342  }
343 
350  function showInfoScreen()
351  {
352  global $ilAccess;
353 
354  $this->getTemplate();
355  $this->setTabs();
356  $this->setLocator();
357  $this->lng->loadLanguageModule("meta");
358  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
359 
360  $info = new ilInfoScreenGUI($this);
361  $info->enablePrivateNotes();
362  $info->enableNews();
363  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
364  {
365  $info->enableNewsEditing();
366  $news_set = new ilSetting("news");
367  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
368  if ($enable_internal_rss)
369  {
370  $info->setBlockProperty("news", "settings", true);
371  }
372  }
373  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
374 
375  ilObjGlossaryGUI::addUsagesToInfo($info, $this->object->getId());
376 
377  $this->ctrl->forwardCommand($info);
378  }
379 
386  function addUsagesToInfo($info, $glo_id)
387  {
388  global $lng, $ilAccess;
389 
390  $info->addSection($lng->txt("glo_usages"));
391  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
393  foreach ($sms as $sm)
394  {
395  $link = false;
396  $refs = ilObject::_getAllReferences($sm);
397  foreach ($refs as $ref)
398  {
399  if ($link === false)
400  {
401  if ($ilAccess->checkAccess("write", "", $ref))
402  {
403  include_once("./classes/class.ilLink.php");
404  $link = ilLink::_getLink($ref,'sahs');
405  }
406  }
407  }
408 
409  $entry = ilObject::_lookupTitle($sm);
410  if ($link !== false)
411  {
412  $entry = "<a href='".$link."' target='_top'>".$entry."</a>";
413  }
414 
415  $info->addProperty($lng->txt("obj_sahs"), $entry);
416  }
417  }
418 
419 
420  function viewObject()
421  {
422  global $rbacsystem;
423 
424  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
425  {
427  return;
428  }
429 
430  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
431  {
432  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
433  }
434 
435  // edit button
436  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
437 
438  $this->tpl->setCurrentBlock("btn_cell");
439  $this->tpl->setVariable("BTN_LINK",
440  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID());
441  $this->tpl->setVariable("BTN_TARGET"," target=\"".
442  ilFrameTargetInfo::_getFrame("MainContent")."\" ");
443  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
444  $this->tpl->parseCurrentBlock();
445 
446  //parent::viewObject();
447  }
448 
454  function properties()
455  {
456  global $rbacsystem, $tree, $tpl;
457 
458  $this->initSettingsForm();
459  $this->getSettingsValues();
460  $tpl->setContent($this->form->getHTML());
461  }
462 
468  public function initSettingsForm($a_mode = "edit")
469  {
470  global $lng, $ilCtrl;
471 
472  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
473  $this->form = new ilPropertyFormGUI();
474 
475  // online
476  $cb = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
477  $cb->setValue("y");
478  $this->form->addItem($cb);
479 
480  // glossary mode
481  $options = array(
482  "none"=>$this->lng->txt("glo_mode_normal"),
483  "level"=>$this->lng->txt("glo_mode_level"),
484  "subtree"=>$this->lng->txt("glo_mode_subtree")
485  );
486  $si = new ilSelectInputGUI($lng->txt("glo_mode"), "glo_mode");
487  $si->setOptions($options);
488  $si->setInfo($lng->txt("glo_mode_desc"));
489  $this->form->addItem($si);
490 
491  // presentation mode
492  $radg = new ilRadioGroupInputGUI($lng->txt("glo_presentation_mode"), "pres_mode");
493  $radg->setValue("table");
494  $op1 = new ilRadioOption($lng->txt("glo_table_form"), "table", $lng->txt("glo_table_form_info"));
495 
496  // short text length
497  $ni = new ilNumberInputGUI($lng->txt("glo_text_snippet_length"), "snippet_length");
498  $ni->setMaxValue(3000);
499  $ni->setMinValue(100);
500  $ni->setMaxLength(4);
501  $ni->setSize(4);
502  $ni->setInfo($lng->txt("glo_text_snippet_length_info"));
503  $ni->setValue(200);
504  $op1->addSubItem($ni);
505 
506  $radg->addOption($op1);
507  $op2 = new ilRadioOption($lng->txt("glo_full_definitions"), "full_def", $lng->txt("glo_full_definitions_info"));
508  $radg->addOption($op2);
509  $this->form->addItem($radg);
510 
511 
512  // menu enabled?
513 /*
514  $cb = new ilCheckboxInputGUI($lng->txt("cont_glo_menu"), "glo_act_menu");
515  $cb->setValue("y");
516  $this->form->addItem($cb);*/
517 
518  // downloads
519  $cb = new ilCheckboxInputGUI($lng->txt("cont_downloads"), "glo_act_downloads");
520  $cb->setValue("y");
521  $cb->setInfo($lng->txt("cont_downloads_desc"));
522  $this->form->addItem($cb);
523 
524  // save and cancel commands
525  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
526 
527  $this->form->setTitle($lng->txt("cont_glo_properties"));
528  $this->form->setFormAction($ilCtrl->getFormAction($this));
529  }
530 
534  public function getSettingsValues()
535  {
536  $values = array();
537 
538  $values["cobj_online"] = $this->object->getOnline();
539  $values["glo_mode"] = $this->object->getVirtualMode();
540 // $values["glo_act_menu"] = $this->object->isActiveGlossaryMenu();
541  $values["glo_act_downloads"] = $this->object->isActiveDownloads();
542  $values["pres_mode"] = $this->object->getPresentationMode();
543  $values["snippet_length"] = $this->object->getSnippetLength();
544 
545  $this->form->setValuesByArray($values);
546  }
547 
551  function saveProperties()
552  {
553  global $tpl;
554 
555  $this->initSettingsForm();
556  if ($this->form->checkInput())
557  {
558  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
559  $this->object->setVirtualMode($_POST["glo_mode"]);
560 // $this->object->setActiveGlossaryMenu(ilUtil::yn2tf($_POST["glo_act_menu"]));
561  $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["glo_act_downloads"]));
562  $this->object->setPresentationMode($_POST["pres_mode"]);
563  $this->object->setSnippetLength($_POST["snippet_length"]);
564  $this->object->update();
565 
566  // set definition short texts dirty
567  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
568  ilGlossaryDefinition::setShortTextsDirty($this->object->getId());
569 
570  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
571  $this->ctrl->redirect($this, "properties");
572  }
573  $this->form->setValuesByPost();
574  $tpl->setContent($this->form->getHTML());
575  }
576 
580  function frameset()
581  {
582  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
583  $fs_gui = new ilFramesetGUI();
584  $fs_gui->setFramesetTitle($this->object->getTitle());
585  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "listTerms"));
586  $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this, "quickList"));
587  $fs_gui->setMainFrameName("content");
588  $fs_gui->setSideFrameName("tree");
589  $fs_gui->show();
590  exit;
591  }
592 
596  function quickList()
597  {
598  global $ilUser;
599 
600  $this->tpl->addBlockFile("CONTENT", "content", "tpl.glossary_short_list.html",
601  "Modules/Glossary");
602 
603 // $this->tpl->addBlockFile("EXPLORER_TOP", "exp_top", "tpl.explorer_top.html");
604 // $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
605 
606  $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
607  $this->tpl->setVariable("CMD_REFR", "quickList");
608  $this->tpl->setVariable("TXT_REFR", $this->lng->txt("refresh"));
609  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_terms"));
610 
611  include_once "./Services/Table/classes/class.ilTableGUI.php";
612 
613  // glossary term list template
614 
615  // load template for table
616  $this->tpl->addBlockfile("SHORT_LIST", "list", "tpl.table.html");
617 
618  // load template for table content data
619  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_short_tbl_row.html", true);
620 
621  $num = 0;
622 
623  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
624 
625  // create table
626  $tbl = new ilTableGUI();
627 
628  // title & header columns
629  //$tbl->setTitle($this->lng->txt("cont_terms"));
630  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
631 
632  $tbl->setHeaderNames(array($this->lng->txt("cont_term")));
633 
634  $cols = array("term");
635  $header_params = $this->ctrl->getParameterArrayByClass("ilobjglossarygui", "listTerms");
636  $header_params["cmd"] = "quickList";
637  $tbl->setHeaderVars($cols, $header_params);
638  $tbl->setColumnWidth(array("100%"));
639  $tbl->disable("title");
640 
641  // control
642  $tbl->setOrderColumn($_GET["sort_by"]);
643  $tbl->setOrderDirection($_GET["sort_order"]);
644  $tbl->setLimit($_GET["limit"]);
645  $tbl->setOffset($_GET["offset"]);
646  $tbl->disable("header");
647 
648  $term_list = $this->object->getTermList();
649  $tbl->setMaxCount(count($term_list));
650 
651  $this->tpl->setVariable("COLUMN_COUNT", 1);
652 
653  // footer
654  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
655 
656 
657  // sorting array
658  $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
659 
660  // render table
661  $tbl->render();
662 
663  if (count($term_list) > 0)
664  {
665  $i=1;
666  foreach($term_list as $key => $term)
667  {
669 
670  $sep = ": ";
671  for($j=0; $j<count($defs); $j++)
672  {
673  $def = $defs[$j];
674 
675  // edit
676  $this->tpl->setCurrentBlock("definition");
677  $this->tpl->setVariable("SEP", $sep);
678  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
679  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
680  $this->tpl->setVariable("LINK_EDIT_DEF",
681  $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
682  "iltermdefinitioneditorgui",
683  "ilpageobjectgui"), "edit"));
684  $this->tpl->setVariable("TEXT_DEF", $this->lng->txt("glo_definition_abbr").($j+1));
685  $this->tpl->parseCurrentBlock();
686  $sep = ", ";
687  }
688 
689  $this->tpl->setCurrentBlock("tbl_content");
690  $css_row = ilUtil::switchColor(++$i,"tblrow1","tblrow2");
691 
692  // edit term link
693  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
694  $this->ctrl->setParameter($this, "term_id", $term["id"]);
695  $this->tpl->setVariable("LINK_EDIT_TERM",
696  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
697 
698  $this->tpl->setVariable("CSS_ROW", $css_row);
699  $this->tpl->parseCurrentBlock();
700  }
701  } //if is_array
702  else
703  {
704  //$this->tpl->setCurrentBlock("notfound");
705  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
706  $this->tpl->setVariable("NUM_COLS", $num);
707  //$this->tpl->parseCurrentBlock();
708  }
709  }
710 
711 
715  function listTerms()
716  {
717  global $ilUser, $ilToolbar, $lng, $ilCtrl, $tpl;
718 
719  // term
720  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
721  $ti = new ilTextInputGUI($lng->txt("cont_new_term"), "new_term");
722  $ti->setMaxLength(80);
723  $ti->setSize(20);
724  $ilToolbar->addInputItem($ti, true);
725 
726  // language
727  $this->lng->loadLanguageModule("meta");
729  if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
730  {
731  $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
732  }
733  else
734  {
735  $s_lang = $ilUser->getLanguage();
736  }
737  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
738  $si = new ilSelectInputGUI($lng->txt("language"), "term_language");
739  $si->setOptions($lang);
740  $si->setValue($s_lang);
741  $ilToolbar->addInputItem($si, true);
742 
743  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
744  $ilToolbar->addFormButton($lng->txt("glo_add_new_term"), "addTerm");
745  //$select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
746  //$this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
747 
748  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
749  $tab = new ilTermListTableGUI($this, "listTerms");
750  $tpl->setContent($tab->getHTML());
751  }
752 
758  function showActions($a_actions)
759  {
760  foreach ($a_actions as $name => $lng)
761  {
762  $d[$name] = array("name" => $name, "lng" => $lng);
763  }
764 
765  $notoperations = array();
766  $operations = array();
767 
768  $operations = $d;
769 
770  if (count($operations) > 0)
771  {
772  foreach ($operations as $val)
773  {
774  $this->tpl->setCurrentBlock("tbl_action_btn");
775  $this->tpl->setVariable("BTN_NAME", $val["name"]);
776  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
777  $this->tpl->parseCurrentBlock();
778  }
779 
780  $this->tpl->setCurrentBlock("tbl_action_row");
781  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
782  $this->tpl->parseCurrentBlock();
783  }
784  }
785 
789  function addTerm()
790  {
791  global $lng, $ilCtrl;
792 
793  if (trim($_POST["new_term"]) == "")
794  {
795  ilUtil::sendFailure($lng->txt("cont_please_enter_a_term"), true);
796  $ilCtrl->redirect($this, "listTerms");
797  }
798 
799  // add term
800  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
801  $term =& new ilGlossaryTerm();
802  $term->setGlossary($this->object);
803  $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
804  $term->setLanguage($_POST["term_language"]);
805  $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
806  $term->create();
807 
808  // add first definition
809  $def =& new ilGlossaryDefinition();
810  $def->setTermId($term->getId());
811  $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
812  $def->create();
813 
814  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
815  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
816  $this->ctrl->redirectByClass(array("ilglossarytermgui",
817  "iltermdefinitioneditorgui", "ilpageobjectgui"), "edit");
818  }
819 
823  function moveDefinitionUp()
824  {
825  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
826 
827  $definition =& new ilGlossaryDefinition($_GET["def"]);
828  $definition->moveUp();
829 
830  $this->ctrl->redirect($this, "listTerms");
831  }
832 
837  {
838  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
839 
840  $definition =& new ilGlossaryDefinition($_GET["def"]);
841  $definition->moveDown();
842 
843  $this->ctrl->redirect($this, "listTerms");
844  }
845 
850  {
851  global $ilCtrl, $lng;
852 
853  //$this->getTemplate();
854  //$this->displayLocator();
855  //$this->setTabs();
856 
857  $term = new ilGlossaryTerm($_GET["term_id"]);
858 
859  $add = "";
860  $nr = ilGlossaryTerm::getNumberOfUsages($_GET["term_id"]);
861  if ($nr > 0)
862  {
863  $ilCtrl->setParameterByClass("ilglossarytermgui",
864  "term_id", $_GET["term_id"]);
865  $link = "[<a href='".
866  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages").
867  "'>".$lng->txt("glo_list_usages")."</a>]";
868  $add = "<br/>".sprintf($lng->txt("glo_term_is_used_n_times"), $nr)." ".$link;
869  }
870 
871 
872  // content style
873  $this->tpl->setCurrentBlock("ContentStyle");
874  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
876  $this->tpl->parseCurrentBlock();
877 
878  // syntax style
879  $this->tpl->setCurrentBlock("SyntaxStyle");
880  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
882  $this->tpl->parseCurrentBlock();
883 
884 
885  //$this->tpl->setVariable("HEADER",
886  // $this->lng->txt("cont_term").": ".$term->getTerm());
887 
888  $this->tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_delete.html", true);
889  ilUtil::sendQuestion($this->lng->txt("info_delete_sure").$add);
890 
891  $this->tpl->setVariable("TXT_TERM", $term->getTerm());
892 
893  $definition =& new ilGlossaryDefinition($_GET["def"]);
894  //$page =& new ilPageObject("gdf", $definition->getId());
895  $page_gui =& new ilPageObjectGUI("gdf", $definition->getId());
896  $page_gui->setTemplateOutput(false);
897  $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
898  $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
899  $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
900  $output = $page_gui->preview();
901 
902  $this->tpl->setCurrentBlock("definition");
903  $this->tpl->setVariable("PAGE_CONTENT", $output);
904  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
905  $this->tpl->setVariable("LINK_CANCEL",
906  $this->ctrl->getLinkTarget($this, "cancelDefinitionDeletion"));
907  $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("confirm"));
908  $this->ctrl->setParameter($this, "def", $definition->getId());
909  $this->tpl->setVariable("LINK_CONFIRM",
910  $this->ctrl->getLinkTarget($this, "deleteDefinition"));
911  $this->tpl->parseCurrentBlock();
912  }
913 
919  function cancelObject($in_rep = false)
920  {
921  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
922  //$this->ctrl->redirectByClass("ilrepositorygui", "frameset");
923  }
924 
926  {
927  $this->ctrl->redirect($this, "listTerms");
928  }
929 
930 
931  function deleteDefinition()
932  {
933  $definition =& new ilGlossaryDefinition($_GET["def"]);
934  $definition->delete();
935  $this->ctrl->redirect($this, "listTerms");
936  }
937 
941  function editTerm()
942  {
943  /*
944  $term = new ilGlossaryTerm($_GET["term_id"]);
945  //$this->tpl->setVariable("HEADER", $this->lng->txt("cont_term").": ".$term->getTerm());
946 
947  // load template for table
948  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.glossary_term_edit.html", true);
949  $this->ctrl->setParameter($this, "term_id", $_GET["term_id"]);
950  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
951  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_term"));
952  $this->tpl->setVariable("TXT_TERM", $this->lng->txt("cont_term"));
953  $this->tpl->setVariable("INPUT_TERM", "term");
954  $this->tpl->setVariable("VALUE_TERM", htmlspecialchars($term->getTerm()));
955  $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
956  $lang = ilMDLanguageItem::_getLanguages();
957  $select_language = ilUtil::formSelect ($term->getLanguage(),"term_language",$lang,false,true);
958  $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
959  $this->tpl->setVariable("BTN_NAME", "updateTerm");
960  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
961  */
962  }
963 
964 
968  function updateTerm()
969  {
970  $term = new ilGlossaryTerm($_GET["term_id"]);
971 
972  $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
973  $term->setLanguage($_POST["term_language"]);
974  $term->update();
975  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
976  $this->ctrl->redirect($this, "listTerms");
977  }
978 
979 
980  /*
981  * list all export files
982  */
983  function exportList()
984  {
985  global $tree;
986 
987  //$this->setTabs();
988 
989  //add template for view button
990  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
991 
992  // create export file button (xml)
993  $this->tpl->setCurrentBlock("btn_cell");
994  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "export"));
995  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_xml"));
996  $this->tpl->parseCurrentBlock();
997 
998  // create export file button (html)
999  $this->tpl->setCurrentBlock("btn_cell");
1000  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportHTML"));
1001  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_html"));
1002  $this->tpl->parseCurrentBlock();
1003 
1004  // view last export log button
1005  if (is_file($this->object->getExportDirectory()."/export.log"))
1006  {
1007  $this->tpl->setCurrentBlock("btn_cell");
1008  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "viewExportLog"));
1009  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_view_last_export_log"));
1010  $this->tpl->parseCurrentBlock();
1011  }
1012 
1013 
1014  $export_dir = $this->object->getExportDirectory();
1015 
1016  $export_files = $this->object->getExportFiles();
1017 
1018  // create table
1019  require_once("./Services/Table/classes/class.ilTableGUI.php");
1020  $tbl = new ilTableGUI();
1021 
1022  // load files templates
1023  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1024 
1025  // load template for table content data
1026  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.glo_export_file_row.html", true);
1027 
1028  $num = 0;
1029 
1030  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1031 
1032  $tbl->setTitle($this->lng->txt("cont_export_files"));
1033 
1034  $tbl->setHeaderNames(array("", $this->lng->txt("type"),
1035  $this->lng->txt("cont_file"),
1036  $this->lng->txt("cont_size"), $this->lng->txt("date") ));
1037 
1038  $cols = array("", "type", "file", "size", "date");
1039  $header_params = array("ref_id" => $_GET["ref_id"],
1040  "cmd" => "exportList", "cmdClass" => get_class($this));
1041  $tbl->setHeaderVars($cols, $header_params);
1042  $tbl->setColumnWidth(array("1%", "9%", "40%", "25%", "25%"));
1043  $tbl->disable("sort");
1044 
1045  // control
1046  $tbl->setOrderColumn($_GET["sort_by"]);
1047  $tbl->setOrderDirection($_GET["sort_order"]);
1048  $tbl->setLimit($_GET["limit"]);
1049  $tbl->setOffset($_GET["offset"]);
1050  $tbl->setMaxCount($this->maxcount); // ???
1051 
1052  $this->tpl->setVariable("COLUMN_COUNTS", 5);
1053 
1054  // delete button
1055  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1056  $this->tpl->setCurrentBlock("tbl_action_btn");
1057  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
1058  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1059  $this->tpl->parseCurrentBlock();
1060 
1061  $this->tpl->setCurrentBlock("tbl_action_btn");
1062  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
1063  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
1064  $this->tpl->parseCurrentBlock();
1065 
1066  // public access
1067  $this->tpl->setCurrentBlock("tbl_action_btn");
1068  $this->tpl->setVariable("BTN_NAME", "publishExportFile");
1069  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_public_access"));
1070  $this->tpl->parseCurrentBlock();
1071 
1072  // footer
1073  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1074  //$tbl->disable("footer");
1075 
1076  $tbl->setMaxCount(count($export_files));
1077  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
1078 
1079  $tbl->render();
1080  if(count($export_files) > 0)
1081  {
1082  $i=0;
1083  foreach($export_files as $exp_file)
1084  {
1085  $this->tpl->setCurrentBlock("tbl_content");
1086  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
1087 
1088  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1089  $this->tpl->setVariable("CSS_ROW", $css_row);
1090 
1091  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
1092 
1093  $public_str = ($exp_file["file"] == $this->object->getPublicExportFile($exp_file["type"]))
1094  ? " <b>(".$this->lng->txt("public").")<b>"
1095  : "";
1096  $this->tpl->setVariable("TXT_TYPE", $exp_file["type"].$public_str);
1097  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"].":".$exp_file["file"]);
1098 
1099  $file_arr = explode("__", $exp_file["file"]);
1100  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
1101 
1102  $this->tpl->parseCurrentBlock();
1103  }
1104  } //if is_array
1105  else
1106  {
1107  //$this->tpl->setCurrentBlock("notfound");
1108  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1109  $this->tpl->setVariable("NUM_COLS", 3);
1110  //$this->tpl->parseCurrentBlock();
1111  }
1112 
1113  $this->tpl->parseCurrentBlock();
1114  }
1115 
1116 
1120  function export()
1121  {
1122  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1123  $glo_exp = new ilGlossaryExport($this->object);
1124  $glo_exp->buildExportFile();
1125  $this->ctrl->redirect($this, "exportList");
1126  }
1127 
1131  function exportHTML()
1132  {
1133  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1134  $glo_exp = new ilGlossaryExport($this->object, "html");
1135  $glo_exp->buildExportFile();
1136 //echo $this->tpl->get();
1137  $this->ctrl->redirect($this, "exportList");
1138  }
1139 
1140 
1145  {
1146  if(!isset($_POST["file"]))
1147  {
1148  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1149  }
1150 
1151  if (count($_POST["file"]) > 1)
1152  {
1153  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1154  }
1155 
1156  $file = explode(":", $_POST["file"][0]);
1157  $export_dir = $this->object->getExportDirectory($file[0]);
1158  ilUtil::deliverFile($export_dir."/".$file[1],
1159  $file[1]);
1160  }
1161 
1166  {
1167  if(!isset($_POST["file"]))
1168  {
1169  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1170  }
1171  if (count($_POST["file"]) > 1)
1172  {
1173  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1174  }
1175 
1176  $file = explode(":", $_POST["file"][0]);
1177  $export_dir = $this->object->getExportDirectory($file[0]);
1178 
1179  if ($this->object->getPublicExportFile($file[0]) ==
1180  $file[1])
1181  {
1182  $this->object->setPublicExportFile($file[0], "");
1183  }
1184  else
1185  {
1186  $this->object->setPublicExportFile($file[0], $file[1]);
1187  }
1188  $this->object->update();
1189  $this->ctrl->redirect($this, "exportList");
1190  }
1191 
1192  /*
1193  * list all export files
1194  */
1195  function viewExportLog()
1196  {
1197  global $tree;
1198 
1199  $this->setTabs();
1200 
1201  //add template for view button
1202  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1203 
1204  // create export file button
1205  $this->tpl->setCurrentBlock("btn_cell");
1206  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
1207  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_export_files"));
1208  $this->tpl->parseCurrentBlock();
1209 
1210  // load files templates
1211  $this->tpl->setVariable("ADM_CONTENT",
1212  nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
1213 
1214  $this->tpl->parseCurrentBlock();
1215  }
1216 
1221  {
1222  if(!isset($_POST["file"]))
1223  {
1224  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1225  }
1226 
1227  $this->setTabs();
1228 
1229  // SAVE POST VALUES
1230  $_SESSION["ilExportFiles"] = $_POST["file"];
1231 
1232  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Glossary");
1233 
1234  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1235 
1236  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1237 
1238  // BEGIN TABLE HEADER
1239  $this->tpl->setCurrentBlock("table_header");
1240  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
1241  $this->tpl->parseCurrentBlock();
1242 
1243  // BEGIN TABLE DATA
1244  $counter = 0;
1245  foreach($_POST["file"] as $file)
1246  {
1247  $file = explode(":", $file);
1248  $this->tpl->setCurrentBlock("table_row");
1249  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1250  $this->tpl->setVariable("TEXT_CONTENT", $file[1]." (".$file[0].")");
1251  $this->tpl->parseCurrentBlock();
1252  }
1253 
1254  // cancel/confirm button
1255  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
1256  $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
1257  "deleteExportFile" => $this->lng->txt("confirm"));
1258  foreach ($buttons as $name => $value)
1259  {
1260  $this->tpl->setCurrentBlock("operation_btn");
1261  $this->tpl->setVariable("BTN_NAME",$name);
1262  $this->tpl->setVariable("BTN_VALUE",$value);
1263  $this->tpl->parseCurrentBlock();
1264  }
1265  }
1266 
1271  {
1272  session_unregister("ilExportFiles");
1273  $this->ctrl->redirect($this, "exportList");
1274  }
1275 
1279  function deleteExportFile()
1280  {
1281  foreach($_SESSION["ilExportFiles"] as $file)
1282  {
1283  $file = explode(":", $file);
1284  $export_dir = $this->object->getExportDirectory($file[0]);
1285 
1286  $exp_file = $export_dir."/".$file[1];
1287  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
1288  if (@is_file($exp_file))
1289  {
1290  unlink($exp_file);
1291  }
1292  if (@is_dir($exp_dir))
1293  {
1294  ilUtil::delDir($exp_dir);
1295  }
1296  }
1297  $this->ctrl->redirect($this, "exportList");
1298  }
1299 
1304  {
1305  global $ilCtrl, $lng;
1306 
1307  //$this->prepareOutput();
1308  if (!isset($_POST["id"]))
1309  {
1310  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1311  $ilCtrl->redirect($this, "listTerms");
1312  }
1313 
1314  // save values to
1315  $_SESSION["term_delete"] = $_POST["id"];
1316 
1317  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.obj_confirm.html");
1318 
1319  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
1320  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1321 
1322  // output table header
1323  $cols = array("cont_term");
1324  foreach ($cols as $key)
1325  {
1326  $this->tpl->setCurrentBlock("table_header");
1327  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
1328  $this->tpl->parseCurrentBlock();
1329  }
1330 
1331  foreach($_POST["id"] as $id)
1332  {
1333  $term = new ilGlossaryTerm($id);
1334 
1335  $add = "";
1337  if ($nr > 0)
1338  {
1339  $ilCtrl->setParameterByClass("ilglossarytermgui",
1340  "term_id", $id);
1341  $link = "[<a href='".
1342  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages").
1343  "'>".$lng->txt("glo_list_usages")."</a>]";
1344  $add = "<div class='small'>".
1345  sprintf($lng->txt("glo_term_is_used_n_times"), $nr)." ".$link."</div>";
1346  }
1347 
1348 
1349  // output title
1350  $this->tpl->setCurrentBlock("table_cell");
1351  $this->tpl->setVariable("TEXT_CONTENT", $term->getTerm().$add);
1352  $this->tpl->parseCurrentBlock();
1353 
1354  // output table row
1355  $this->tpl->setCurrentBlock("table_row");
1356  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
1357  $this->tpl->parseCurrentBlock();
1358  }
1359 
1360  // cancel and confirm button
1361  $buttons = array("deleteTerms" => $this->lng->txt("confirm"),
1362  "cancelTermDeletion" => $this->lng->txt("cancel"));
1363  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1364  foreach($buttons as $name => $value)
1365  {
1366  $this->tpl->setCurrentBlock("operation_btn");
1367  $this->tpl->setVariable("BTN_NAME",$name);
1368  $this->tpl->setVariable("BTN_VALUE",$value);
1369  $this->tpl->parseCurrentBlock();
1370  }
1371 
1372  }
1373 
1380  {
1381  session_unregister("term_delete");
1382  $this->ctrl->redirect($this, "listTerms");
1383  }
1384 
1388  function deleteTerms()
1389  {
1390  foreach($_SESSION["term_delete"] as $id)
1391  {
1392  $term = new ilGlossaryTerm($id);
1393  $term->delete();
1394  }
1395  session_unregister("term_delete");
1396  $this->ctrl->redirect($this, "listTerms");
1397  }
1398 
1406  function setLocator($a_tree = "", $a_id = "")
1407  {
1408  global $ilias_locator;
1409 
1410  if(strtolower($_GET["baseClass"]) != "ilglossaryeditorgui")
1411  {
1412  parent::setLocator($a_tree, $a_id);
1413  }
1414  else
1415  {
1416  if(is_object($this->object))
1417  {
1418  require_once("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
1419  $gloss_loc =& new ilGlossaryLocatorGUI();
1420  if (is_object($this->term))
1421  {
1422  $gloss_loc->setTerm($this->term);
1423  }
1424  $gloss_loc->setGlossary($this->object);
1425  //$gloss_loc->setDefinition($this->definition);
1426  $gloss_loc->display();
1427  }
1428  }
1429 
1430  }
1431 
1435  function view()
1436  {
1437  //$this->prepareOutput();
1438  $this->viewObject();
1439  }
1440 
1444  function create()
1445  {
1446  switch($_POST["new_type"])
1447  {
1448  case "term":
1449  $term_gui =& new ilGlossaryTermGUI();
1450  $term_gui->create();
1451  break;
1452  }
1453  }
1454 
1455  function saveTerm()
1456  {
1457  $term_gui =& new ilGlossaryTermGUI();
1458  $term_gui->setGlossary($this->object);
1459  $term_gui->save();
1460 
1461  ilUtil::sendSuccess($this->lng->txt("cont_added_term"),true);
1462 
1463  //ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
1464  $ilCtrl->redirect($this, "listTerms");
1465  }
1466 
1467 
1471  function addDefinition()
1472  {
1473  global $ilCtrl;
1474 
1475  if (count($_POST["id"]) < 1)
1476  {
1477  ilUtil::sendFailure($this->lng->txt("cont_select_term"), true);
1478  $ilCtrl->redirect($this, "listTerms");
1479  }
1480 
1481  if (count($_POST["id"]) > 1)
1482  {
1483  ilUtil::sendFailure($this->lng->txt("cont_select_max_one_term"), true);
1484  $ilCtrl->redirect($this, "listTerms");
1485  }
1486 
1487  // add term
1488  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1489  $term =& new ilGlossaryTerm($_POST["id"][0]);
1490 
1491  // add first definition
1492  $def =& new ilGlossaryDefinition();
1493  $def->setTermId($term->getId());
1494  $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
1495  $def->create();
1496 
1497  $this->ctrl->setParameterByClass("ilpageobjectgui", "term_id", $term->getId());
1498  $this->ctrl->setParameterByClass("ilpageobjectgui", "def", $def->getId());
1499  $this->ctrl->redirectByClass(array("ilglossarytermgui",
1500  "iltermdefinitioneditorgui", "ilpageobjectgui"), "edit");
1501 
1502  }
1503 
1504  function getTemplate()
1505  {
1506  $this->tpl->getStandardTemplate();
1507 
1508  $title = $this->object->getTitle();
1509 
1510 
1511  if ($_GET["term_id"] > 0)
1512  {
1513  $this->tpl->setTitle($this->lng->txt("term").": ".
1515  }
1516  else
1517  {
1518  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo_b.gif"));
1519  $this->tpl->setTitle($this->lng->txt("glo").": ".$title);
1520  }
1521  }
1522 
1526  function setTabs()
1527  {
1528 
1529  // catch feedback message
1530  #include_once("classes/class.ilTabsGUI.php");
1531  #$tabs_gui =& new ilTabsGUI();
1532  $this->getTabs($this->tabs_gui);
1533 
1534  #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
1535 
1536  }
1537 
1541  function getTabs(&$tabs_gui)
1542  {
1543  global $rbacsystem;
1544 
1545  // list terms
1546  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "listTerms")
1547  ? true
1548  : false;
1549  $tabs_gui->addTarget("cont_terms",
1550  $this->ctrl->getLinkTarget($this, "listTerms"), array("listTerms", ""),
1551  get_class($this), "", $force_active);
1552 
1553  $force_active = false;
1554  if ($this->ctrl->getCmd() == "showSummary" ||
1555  strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui")
1556  {
1557  $force_active = true;
1558  }
1559  $tabs_gui->addTarget("info_short",
1560  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "",
1561  "ilInfoScreenGUI", "", $force_active);
1562 
1563  // properties
1564  $tabs_gui->addTarget("settings",
1565  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1566  get_class($this));
1567 
1568  // meta data
1569  $tabs_gui->addTarget("meta_data",
1570  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1571  "", "ilmdeditorgui");
1572 
1573  // export
1574  $tabs_gui->addTarget("export",
1575  $this->ctrl->getLinkTarget($this, "exportList"),
1576  array("exportList", "viewExportLog"), get_class($this));
1577 
1578  // permissions
1579  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
1580  {
1581  /*$tabs_gui->addTarget("permission_settings",
1582  $this->ctrl->getLinkTarget($this, "perm"),
1583  array("perm", "info"),
1584  get_class($this));
1585  */
1586  $tabs_gui->addTarget("perm_settings",
1587  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1588 
1589  }
1590 
1591  $tabs_gui->addNonTabbedLink("presentation_view",
1592  $this->lng->txt("glo_presentation_view"),
1593  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID(),
1594  "_top"
1595  );
1596 
1597  }
1598 
1604  function _goto($a_target)
1605  {
1606  global $rbacsystem, $ilErr, $lng, $ilAccess;
1607 
1608  if ($ilAccess->checkAccess("read", "", $a_target))
1609  {
1610  $_GET["ref_id"] = $a_target;
1611  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1612  include("ilias.php");
1613  exit;
1614  }
1615  else if ($ilAccess->checkAccess("visible", "", $a_target))
1616  {
1617  $_GET["ref_id"] = $a_target;
1618  $_GET["cmd"] = "infoScreen";
1619  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1620  include("ilias.php");
1621  exit;
1622  }
1623  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1624  {
1625  $_GET["cmd"] = "frameset";
1626  $_GET["target"] = "";
1627  $_GET["ref_id"] = ROOT_FOLDER_ID;
1628  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1629  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1630  include("repository.php");
1631  exit;
1632  }
1633 
1634  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1635  }
1636 
1640  function applyFilter()
1641  {
1642  global $ilTabs;
1643 
1644  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
1645  $prtab = new ilTermListTableGUI($this, "listTerms");
1646  $prtab->resetOffset();
1647  $prtab->writeFilterToSession();
1648  $this->listTerms();
1649 
1650  }
1651 
1656  function resetFilter()
1657  {
1658  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
1659  $prtab = new ilTermListTableGUI($this, "listTerms");
1660  $prtab->resetOffset();
1661  $prtab->resetFilter();
1662  $this->listTerms();
1663  }
1664 
1665 
1666 }
1667 
1668 ?>