ILIAS  Release_4_4_x_branch Revision 61816
 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-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Services/Object/classes/class.ilObjectGUI.php");
6 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
7 require_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
8 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
9 require_once("./Modules/Glossary/classes/class.ilTermDefinitionEditorGUI.php");
10 require_once("./Services/COPage/classes/class.ilPCParagraph.php");
11 
27 {
29  var $mode;
30  var $term;
31 
36  function ilObjGlossaryGUI($a_data,$a_id = 0,$a_call_by_reference = true, $a_prepare_output = true)
37  {
38  global $ilCtrl, $lng;
39 
40  $this->ctrl =& $ilCtrl;
41  $this->ctrl->saveParameter($this, array("ref_id", "offset"));
42 
43  $lng->loadLanguageModule("content");
44 
45  $this->type = "glo";
46  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, false);
47 
48  // determine term id and check whether it is valid (belongs to
49  // current glossary)
50  $this->term_id = (int) $_GET["term_id"];
51  $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
52  if ($this->term_id > 0 && $term_glo_id != $this->object->getId())
53  {
54  $this->term_id = "";
55  }
56 
57  $this->tax_id = $this->object->getTaxonomyId();
58  if ($this->tax_id > 0)
59  {
60  $this->ctrl->saveParameter($this, array("show_tax", "tax_node"));
61 
62  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
63  $this->tax = new ilObjTaxonomy($this->tax_id);
64  }
65  if ((int) $_GET["tax_node"] > 1 && $this->tax->getTree()->readRootId() != $_GET["tax_node"])
66  {
67  $this->tax_node = (int) $_GET["tax_node"];
68  }
69  }
70 
74  function &executeCommand()
75  {
76  global $lng, $ilAccess, $ilTabs, $ilErr;
77 
78  $cmd = $this->ctrl->getCmd();
79  $next_class = $this->ctrl->getNextClass($this);
80 
81  switch ($next_class)
82  {
83  case 'ilmdeditorgui':
84  $this->checkPermission("write");
85 
86  $this->getTemplate();
87  $this->setTabs();
88  $this->setLocator();
89  $this->addHeaderAction();
90 
91  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
92 
93  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
94  $md_gui->addObserver($this->object,'MDUpdateListener','General');
95 
96  $this->ctrl->forwardCommand($md_gui);
97  break;
98 
99  case "ilglossarytermgui":
100 // $this->quickList();
101  $this->ctrl->setReturn($this, "listTerms");
102  $term_gui =& new ilGlossaryTermGUI($this->term_id);
103  $term_gui->setGlossary($this->object);
104  //$ret =& $term_gui->executeCommand();
105  $ret =& $this->ctrl->forwardCommand($term_gui);
106  break;
107 
108  case "ilinfoscreengui":
109  $this->addHeaderAction();
110  $this->showInfoScreen();
111  break;
112 
113  case "ilobjstylesheetgui":
114  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
115  $this->ctrl->setReturn($this, "editStyleProperties");
116  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
117  $style_gui->omitLocator();
118  if ($cmd == "create" || $_GET["new_type"]=="sty")
119  {
120  $style_gui->setCreationMode(true);
121  }
122 
123  if ($cmd == "confirmedDelete")
124  {
125  $this->object->setStyleSheetId(0);
126  $this->object->update();
127  }
128 
129  $ret = $this->ctrl->forwardCommand($style_gui);
130 
131  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
132  {
133  $style_id = $ret;
134  $this->object->setStyleSheetId($style_id);
135  $this->object->update();
136  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
137  }
138  break;
139 
140 
141  case 'ilpermissiongui':
142  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
143  {
144  $this->prepareOutput();
145  }
146  else
147  {
148  $this->getTemplate();
149  $this->setTabs();
150  $this->setLocator();
151  $this->addHeaderAction();
152  }
153  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
154  $perm_gui =& new ilPermissionGUI($this);
155  $ret =& $this->ctrl->forwardCommand($perm_gui);
156  break;
157 
158  case "ilcommonactiondispatchergui":
159  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
161  $this->ctrl->forwardCommand($gui);
162  break;
163 
164  case "ilobjtaxonomygui":
165  $this->getTemplate();
166  $this->setTabs();
167  $this->setLocator();
168  $this->addHeaderAction();
169  $ilTabs->activateTab("settings");
170  $this->setSettingsSubTabs("taxonomy");
171 
172  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomyGUI.php");
173  $this->ctrl->setReturn($this, "properties");
174  $tax_gui = new ilObjTaxonomyGUI();
175  $tax_gui->setMultiple(false);
176 
177  /*include_once("./Modules/Glossary/classes/class.ilTermTaxInfo.php");
178  $term_info = new ilTermTaxInfo();*/
179  //$tax_gui->activateAssignedItemSorting($term_info, "glo", "term");
180 
181  $tax_gui->setAssignedObject($this->object->getId());
182  $ret = $this->ctrl->forwardCommand($tax_gui);
183  break;
184 
185  case "ilexportgui":
186  $this->getTemplate();
187  $this->setTabs();
188  $ilTabs->activateTab("export");
189  $this->setLocator();
190  include_once("./Services/Export/classes/class.ilExportGUI.php");
191  $exp_gui = new ilExportGUI($this);
192  //$exp_gui->addFormat("xml", "", $this, "export");
193  $exp_gui->addFormat("xml");
194  $exp_gui->addFormat("html", "", $this, "exportHTML");
195  $exp_gui->addCustomColumn($lng->txt("cont_public_access"),
196  $this, "getPublicAccessColValue");
197  $exp_gui->addCustomMultiCommand($lng->txt("cont_public_access"),
198  $this, "publishExportFile");
199  $ret = $this->ctrl->forwardCommand($exp_gui);
200  break;
201 
202  default:
203  $cmd = $this->ctrl->getCmd("listTerms");
204 
205  if (($cmd == "create") && ($_POST["new_type"] == "term"))
206  {
207  $this->ctrl->setCmd("create");
208  $this->ctrl->setCmdClass("ilGlossaryTermGUI");
209  $ret =& $this->executeCommand();
210  return;
211  }
212  else
213  {
214  if (!in_array($cmd, array("frameset", "quickList")))
215  {
216  if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
217  $this->getCreationMode() == true)
218  {
219  $this->prepareOutput();
220  $cmd.= "Object";
221  }
222  else
223  {
224  $this->getTemplate();
225  $this->setTabs();
226  $this->setLocator();
227  $this->addHeaderAction();
228  }
229  }
230  $ret =& $this->$cmd();
231  }
232  break;
233  }
234 
235  if (!in_array($cmd, array("frameset", "quickList")))
236  {
237  if (strtolower($_GET["baseClass"]) != "iladministrationgui")
238  {
239  if (!$this->getCreationMode())
240  {
241  $this->tpl->show();
242  }
243  }
244  }
245  else
246  {
247  $this->tpl->show(false);
248  }
249  }
250 
251  function assignObject()
252  {
253  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
254 
255  $this->object =& new ilObjGlossary($this->id, true);
256  }
257 
258  protected function initCreationForms($a_new_type)
259  {
260  $forms = array(
261  self::CFORM_NEW => $this->initCreateForm($a_new_type),
262  self::CFORM_IMPORT => $this->initImportForm($a_new_type)
263  );
264 
265  return $forms;
266  }
267 
268  function initCreateForm($a_new_type)
269  {
270  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
271  $form = new ilPropertyFormGUI();
272  $form->setTarget("_top");
273  $form->setFormAction($this->ctrl->getFormAction($this));
274  $form->setTitle($this->lng->txt($a_new_type."_new"));
275 
276  // title
277  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
278  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
279  $ti->setMaxLength(ilObject::TITLE_LENGTH);
280  $ti->setRequired(true);
281  $form->addItem($ti);
282 
283  // description
284  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
285  $ta->setCols(40);
286  $ta->setRows(2);
287  $form->addItem($ta);
288 
289  // mode
290  $stati = array(
291  "none"=>$this->lng->txt("glo_mode_normal"),
292  "level"=>$this->lng->txt("glo_mode_level"),
293  "subtree"=>$this->lng->txt("glo_mode_subtree")
294  );
295  $tm = new ilSelectInputGUI($this->lng->txt("glo_mode"), "glo_mode");
296  $tm->setOptions($stati);
297  $tm->setInfo($this->lng->txt("glo_mode_desc"));
298  $tm->setRequired(true);
299  $form->addItem($tm);
300 
301  $form->addCommandButton("save", $this->lng->txt($a_new_type."_add"));
302  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
303 
304  return $form;
305  }
306 
307  function importObject()
308  {
309  $this->createObject();
310  }
311 
315  function saveObject()
316  {
317  global $tpl;
318 
319  $new_type = $_REQUEST["new_type"];
320 
321  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
322  if (!$this->checkPermissionBool("create", "", $new_type))
323  {
324  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
325  }
326 
327  $this->lng->loadLanguageModule($new_type);
328  $this->ctrl->setParameter($this, "new_type", $new_type);
329 
330  $form = $this->initCreateForm($new_type);
331  if ($form->checkInput())
332  {
333  $this->ctrl->setParameter($this, "new_type", "");
334 
335  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
336  $newObj = new ilObjGlossary();
337  $newObj->setType($new_type);
338  $newObj->setTitle($form->getInput("title"));
339  $newObj->setDescription($form->getInput("desc"));
340  $newObj->setVirtualMode($form->getInput("glo_mode"));
341  $newObj->create();
342 
343  $this->putObjectInTree($newObj);
344 
345  // always send a message
346  ilUtil::sendSuccess($this->lng->txt("glo_added"),true);
347  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
348  }
349 
350  // display only this form to correct input
351  $form->setValuesByPost();
352  $tpl->setContent($form->getHtml());
353  }
354 
361  function importFileObject()
362  {
363  $new_type = $_REQUEST["new_type"];
364 
365  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
366  if (!$this->checkPermissionBool("create", "", $new_type))
367  {
368  $ilErr->raiseError($this->lng->txt("no_create_permission"));
369  }
370 
371  $this->lng->loadLanguageModule($new_type);
372  $this->ctrl->setParameter($this, "new_type", $new_type);
373 
374  $form = $this->initImportForm($new_type);
375  if ($form->checkInput())
376  {
377  $this->ctrl->setParameter($this, "new_type", "");
378  $upload = $_FILES["importfile"];
379 
380  // create and insert object in objecttree
381  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
382  $newObj = new ilObjGlossary();
383  $newObj->setType($new_type);
384  $newObj->setTitle($upload["name"]);
385  $newObj->create(true);
386 
387  $this->putObjectInTree($newObj);
388 
389  // create import directory
390  $newObj->createImportDirectory();
391 
392  // copy uploaded file to import directory
393  $file = pathinfo($upload["name"]);
394  $full_path = $newObj->getImportDirectory()."/".$upload["name"];
395 
396  ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"],
397  $full_path);
398 
399  // unzip file
400  ilUtil::unzip($full_path);
401 
402  // determine filename of xml file
403  $subdir = basename($file["basename"],".".$file["extension"]);
404  $xml_file = $newObj->getImportDirectory()."/".$subdir."/".$subdir.".xml";
405 
406  // check whether this is a new export file.
407  // this is the case if manifest.xml exits
408 //echo "1-".$newObj->getImportDirectory()."/".$subdir."/manifest.xml"."-";
409  if (is_file($newObj->getImportDirectory()."/".$subdir."/manifest.xml"))
410  {
411  include_once("./Services/Export/classes/class.ilImport.php");
412  $imp = new ilImport((int) $_GET["ref_id"]);
413  $map = $imp->getMapping();
414  $map->addMapping("Modules/Glossary", "glo", "new_id", $newObj->getId());
415  $imp->importObject($newObj, $full_path, $upload["name"], "glo",
416  "Modules/Glossary", true);
417  ilUtil::sendSuccess($this->lng->txt("glo_added"),true);
418  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
419  }
420 
421  // check whether subdirectory exists within zip file
422  if (!is_dir($newObj->getImportDirectory()."/".$subdir))
423  {
424  $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir),
425  $this->ilias->error_obj->MESSAGE);
426  }
427 
428  // check whether xml file exists within zip file
429  if (!is_file($xml_file))
430  {
431  $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir."/".$subdir.".xml"),
432  $this->ilias->error_obj->MESSAGE);
433  }
434 
435  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
436  $contParser = new ilContObjParser($newObj, $xml_file, $subdir);
437  $contParser->startParsing();
438  ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
439 
440  // delete import directory
441  ilUtil::delDir($newObj->getImportDirectory());
442 
443  ilUtil::sendSuccess($this->lng->txt("glo_added"),true);
444  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=".$newObj->getRefId());
445  }
446 
447  // display form to correct errors
448  $form->setValuesByPost();
449  $tpl->setContent($form->getHtml());
450  }
451 
458  function showInfoScreen()
459  {
460  global $ilAccess;
461 
462  $this->getTemplate();
463  $this->setTabs();
464  $this->setLocator();
465  $this->lng->loadLanguageModule("meta");
466  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
467 
468  $info = new ilInfoScreenGUI($this);
469  $info->enablePrivateNotes();
470  $info->enableNews();
471  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
472  {
473  $info->enableNewsEditing();
474  $news_set = new ilSetting("news");
475  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
476  if ($enable_internal_rss)
477  {
478  $info->setBlockProperty("news", "settings", true);
479  }
480  }
481  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
482 
483  ilObjGlossaryGUI::addUsagesToInfo($info, $this->object->getId());
484 
485  $this->ctrl->forwardCommand($info);
486  }
487 
494  function addUsagesToInfo($info, $glo_id)
495  {
496  global $lng, $ilAccess;
497 
498  $info->addSection($lng->txt("glo_usages"));
499  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
501  foreach ($sms as $sm)
502  {
503  $link = false;
504  $refs = ilObject::_getAllReferences($sm);
505  foreach ($refs as $ref)
506  {
507  if ($link === false)
508  {
509  if ($ilAccess->checkAccess("write", "", $ref))
510  {
511  include_once("./Services/Link/classes/class.ilLink.php");
512  $link = ilLink::_getLink($ref,'sahs');
513  }
514  }
515  }
516 
517  $entry = ilObject::_lookupTitle($sm);
518  if ($link !== false)
519  {
520  $entry = "<a href='".$link."' target='_top'>".$entry."</a>";
521  }
522 
523  $info->addProperty($lng->txt("obj_sahs"), $entry);
524  }
525  }
526 
527 
528  function viewObject()
529  {
530  global $rbacsystem;
531 
532  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
533  {
535  return;
536  }
537 
538  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
539  {
540  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
541  }
542 
543  // edit button
544  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
545 
546  $this->tpl->setCurrentBlock("btn_cell");
547  $this->tpl->setVariable("BTN_LINK",
548  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID());
549  $this->tpl->setVariable("BTN_TARGET"," target=\"".
550  ilFrameTargetInfo::_getFrame("MainContent")."\" ");
551  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
552  $this->tpl->parseCurrentBlock();
553 
554  //parent::viewObject();
555  }
556 
562  function properties()
563  {
564  global $tpl;
565 
566  $this->checkPermission("write");
567 
568  $this->setSettingsSubTabs("general_settings");
569 
570  $this->initSettingsForm();
571 
572  // Edit ecs export settings
573  include_once 'Modules/Glossary/classes/class.ilECSGlossarySettings.php';
574  $ecs = new ilECSGlossarySettings($this->object);
575  $ecs->addSettingsToForm($this->form, 'glo');
576 
577  $tpl->setContent($this->form->getHTML());
578  }
579 
585  public function initSettingsForm($a_mode = "edit")
586  {
587  global $lng, $ilCtrl;
588 
589  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
590  $this->form = new ilPropertyFormGUI();
591 
592  // title
593  $title = new ilTextInputGUI($lng->txt("title"), "title");
594  $title->setRequired(true);
595  $this->form->addItem($title);
596 
597  // description
598  $desc = new ilTextAreaInputGUI($lng->txt("desc"), "description");
599  $this->form->addItem($desc);
600 
601  $lng->loadLanguageModule("rep");
603  $section->setTitle($this->lng->txt('rep_activation_availability'));
604  $this->form->addItem($section);
605 
606  // online
607  $online = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
608  $online->setValue("y");
609  $online->setInfo($lng->txt("glo_online_info"));
610  $this->form->addItem($online);
611 
613  $section->setTitle($this->lng->txt('glo_content_settings'));
614  $this->form->addItem($section);
615 
616  // glossary mode
617  $glo_mode = new ilRadioGroupInputGUI($lng->txt("glo_mode"), "glo_mode");
618  //$glo_mode->setInfo($lng->txt("glo_mode_desc"));
619  $op1 = new ilRadioOption($lng->txt("glo_mode_normal"), "none",$lng->txt("glo_mode_normal_info"));
620  $glo_mode->addOption($op1);
621  $op2 = new ilRadioOption($lng->txt("glo_mode_level"), "level",$lng->txt("glo_mode_level_info"));
622  $glo_mode->addOption($op2);
623  $op3 = new ilRadioOption($lng->txt("glo_mode_subtree"), "subtree",$lng->txt("glo_mode_subtree_info"));
624  $glo_mode->addOption($op3);
625  $this->form->addItem($glo_mode);
626 
627  // glossary mode
628  /*$options = array(
629  "none"=>$this->lng->txt("glo_mode_normal"),
630  "level"=>$this->lng->txt("glo_mode_level"),
631  "subtree"=>$this->lng->txt("glo_mode_subtree")
632  );
633  $glo_mode = new ilSelectInputGUI($lng->txt("glo_mode"), "glo_mode");
634  $glo_mode->setOptions($options);
635  $glo_mode->setInfo($lng->txt("glo_mode_desc"));
636  $this->form->addItem($glo_mode);*/
637 
638 
640  $section->setTitle($this->lng->txt('cont_presentation'));
641  $this->form->addItem($section);
642 
643  // presentation mode
644  $pres_mode = new ilRadioGroupInputGUI($lng->txt("glo_presentation_mode"), "pres_mode");
645  $pres_mode->setValue("table");
646  $op1 = new ilRadioOption($lng->txt("glo_table_form"), "table", $lng->txt("glo_table_form_info"));
647 
648  // short text length
649  $snl = new ilNumberInputGUI($lng->txt("glo_text_snippet_length"), "snippet_length");
650  $snl->setMaxValue(3000);
651  $snl->setMinValue(100);
652  $snl->setMaxLength(4);
653  $snl->setSize(4);
654  $snl->setInfo($lng->txt("glo_text_snippet_length_info"));
655  $snl->setValue(200);
656  $op1->addSubItem($snl);
657 
658  $pres_mode->addOption($op1);
659  $op2 = new ilRadioOption($lng->txt("glo_full_definitions"), "full_def", $lng->txt("glo_full_definitions_info"));
660  $pres_mode->addOption($op2);
661  $this->form->addItem($pres_mode);
662 
663  // show taxonomy
664  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
665  $tax_ids = ilObjTaxonomy::getUsageOfObject($this->object->getId());
666  if (count($tax_ids) > 0)
667  {
668  $show_tax = new ilCheckboxInputGUI($this->lng->txt("glo_show_taxonomy"), "show_tax");
669  $show_tax->setInfo($this->lng->txt("glo_show_taxonomy_info"));
670  $this->form->addItem($show_tax);
671  }
672 
673  // downloads
674  $down = new ilCheckboxInputGUI($lng->txt("cont_downloads"), "glo_act_downloads");
675  $down->setValue("y");
676  $down->setInfo($lng->txt("cont_downloads_desc"));
677  $this->form->addItem($down);
678 
679  if ($a_mode == "edit")
680  {
681  $title->setValue($this->object->getTitle());
682  $desc->setValue($this->object->getDescription());
683  $online->setChecked($this->object->getOnline());
684  $glo_mode->setValue($this->object->getVirtualMode());
685  $pres_mode->setValue($this->object->getPresentationMode());
686  $snl->setValue($this->object->getSnippetLength());
687  if (count($tax_ids) > 0)
688  {
689  $show_tax->setChecked($this->object->getShowTaxonomy());
690  }
691 
692  $down->setChecked($this->object->isActiveDownloads());
693  }
694 
695  // advanced metadata
696  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
697  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_REC_SELECTION,'glo',$this->object->getId(), "term");
698  $record_gui->setPropertyForm($this->form);
699  $record_gui->parseRecordSelection($this->lng->txt("glo_add_term_properties"));
700 
701  // sort columns, if adv fields are given
702  include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
703  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->object->getId());
704  $cols = $adv_ap->getColumnOrder();
705  if (count($cols) > 1)
706  {
707  include_once './Modules/Glossary/classes/class.ilGloAdvColSortInputGUI.php';
708  $ti = new ilGloAdvColSortInputGUI($lng->txt("cont_col_ordering"), "field_order");
709  $this->form->addItem($ti);
710  $ti->setValue($cols);
711  }
712 
713  // save and cancel commands
714  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
715 
716  $this->form->setTitle($lng->txt("cont_glo_properties"));
717  $this->form->setFormAction($ilCtrl->getFormAction($this));
718  }
719 
720 
724  function saveProperties()
725  {
726  global $tpl;
727 
728  $this->initSettingsForm();
729  if ($this->form->checkInput())
730  {
731  $this->object->setTitle($_POST['title']);
732  $this->object->setDescription($_POST['description']);
733  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
734  $this->object->setVirtualMode($_POST["glo_mode"]);
735 // $this->object->setActiveGlossaryMenu(ilUtil::yn2tf($_POST["glo_act_menu"]));
736  $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["glo_act_downloads"]));
737  $this->object->setPresentationMode($_POST["pres_mode"]);
738  $this->object->setSnippetLength($_POST["snippet_length"]);
739  $this->object->setShowTaxonomy($_POST["show_tax"]);
740  $this->object->update();
741 
742  // field order of advanced metadata
743  include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
744  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->object->getId());
745  $cols = $adv_ap->getColumnOrder();
746  if (count($cols) > 1)
747  {
748  $adv_ap->saveColumnOrder($_POST["field_order"]);
749  }
750 
751  // set definition short texts dirty
752  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
753  ilGlossaryDefinition::setShortTextsDirty($this->object->getId());
754 
755  // update metadata record selection
756  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
757  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_REC_SELECTION,'glo',$this->object->getId(), "term");
758  $record_gui->saveSelection();
759 
760  // Update ecs export settings
761  include_once 'Modules/Glossary/classes/class.ilECSGlossarySettings.php';
762  $ecs = new ilECSGlossarySettings($this->object);
763  if($ecs->handleSettingsUpdate())
764  {
765  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
766  $this->ctrl->redirect($this, "properties");
767  }
768 
769  }
770  $this->form->setValuesByPost();
771  $tpl->setContent($this->form->getHTML());
772  }
773 
777  function frameset()
778  {
779  global $ilCtrl;
780 
781  include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
782  $fs_gui = new ilFramesetGUI();
783  $fs_gui->setFramesetTitle($this->object->getTitle());
784  if ((int) $_GET["edit_term"] > 0)
785  {
786  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", (int) $_GET["edit_term"]);
787  $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass("ilglossarytermgui", "listDefinitions"));
788  }
789  else
790  {
791  $fs_gui->setMainFrameSource($this->ctrl->getLinkTarget($this, "listTerms"));
792  }
793  $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this, "quickList"));
794  $fs_gui->setMainFrameName("content");
795  $fs_gui->setSideFrameName("tree");
796  $fs_gui->show();
797  exit;
798  }
799 
803  function quickList()
804  {
805  global $ilUser, $tpl;
806 
807 return;
808  include_once("./Modules/Glossary/classes/class.ilTermQuickListTableGUI.php");
809  $tab = new ilTermQuickListTableGUI($this, "listTerms");
810  $tpl->setLeftContent($tab->getHTML());
811 
812  $this->tpl->addBlockFile("CONTENT", "content", "tpl.glossary_short_list.html",
813  "Modules/Glossary");
814 
815 // $this->tpl->addBlockFile("EXPLORER_TOP", "exp_top", "tpl.explorer_top.html");
816 // $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
817 
818  $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
819  $this->tpl->setVariable("CMD_REFR", "quickList");
820  $this->tpl->setVariable("TXT_REFR", $this->lng->txt("refresh"));
821  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_terms"));
822 
823  include_once "./Services/Table/classes/class.ilTableGUI.php";
824 
825  // glossary term list template
826 
827  // load template for table
828  $this->tpl->addBlockfile("SHORT_LIST", "list", "tpl.table.html");
829 
830  // load template for table content data
831  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.term_short_tbl_row.html", true);
832 
833  $num = 0;
834 
835  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
836 
837  // create table
838  $tbl = new ilTableGUI();
839 
840  // title & header columns
841  //$tbl->setTitle($this->lng->txt("cont_terms"));
842  //$tbl->setHelp("tbl_help.php","icon_help.png",$this->lng->txt("help"));
843 
844  $tbl->setHeaderNames(array($this->lng->txt("cont_term")));
845 
846  $cols = array("term");
847  $header_params = $this->ctrl->getParameterArrayByClass("ilobjglossarygui", "listTerms");
848  $header_params["cmd"] = "quickList";
849  $tbl->setHeaderVars($cols, $header_params);
850  $tbl->setColumnWidth(array("100%"));
851  $tbl->disable("title");
852 
853  // control
854  $tbl->setOrderColumn($_GET["sort_by"]);
855  $tbl->setOrderDirection($_GET["sort_order"]);
856  $tbl->setLimit($_GET["limit"]);
857  $tbl->setOffset($_GET["offset"]);
858  $tbl->disable("header");
859 
860  $term_list = $this->object->getTermList();
861  $tbl->setMaxCount(count($term_list));
862 
863  $this->tpl->setVariable("COLUMN_COUNT", 1);
864 
865  // footer
866  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
867 
868 
869  // sorting array
870  $term_list = array_slice($term_list, $_GET["offset"], $_GET["limit"]);
871 
872  // render table
873  $tbl->render();
874 
875  if (count($term_list) > 0)
876  {
877  $i=1;
878  foreach($term_list as $key => $term)
879  {
881 
882  $sep = ": ";
883  for($j=0; $j<count($defs); $j++)
884  {
885  $def = $defs[$j];
886 
887  // edit
888  $this->tpl->setCurrentBlock("definition");
889  $this->tpl->setVariable("SEP", $sep);
890  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term["id"]);
891  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def["id"]);
892  $this->tpl->setVariable("LINK_EDIT_DEF",
893  $this->ctrl->getLinkTargetByClass(array("ilglossarytermgui",
894  "iltermdefinitioneditorgui",
895  "ilglossarydefpagegui"), "edit"));
896  $this->tpl->setVariable("TEXT_DEF", $this->lng->txt("glo_definition_abbr").($j+1));
897  $this->tpl->parseCurrentBlock();
898  $sep = ", ";
899  }
900 
901  $this->tpl->setCurrentBlock("tbl_content");
902  $css_row = ilUtil::switchColor(++$i,"tblrow1","tblrow2");
903 
904  // edit term link
905  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
906  $this->ctrl->setParameter($this, "term_id", $term["id"]);
907  $this->tpl->setVariable("LINK_EDIT_TERM",
908  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
909 
910  $this->tpl->setVariable("CSS_ROW", $css_row);
911  $this->tpl->parseCurrentBlock();
912  }
913  } //if is_array
914  else
915  {
916  //$this->tpl->setCurrentBlock("notfound");
917  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
918  $this->tpl->setVariable("NUM_COLS", $num);
919  //$this->tpl->parseCurrentBlock();
920  }
921  }
922 
923 
927  function listTerms()
928  {
929  global $ilUser, $ilToolbar, $lng, $ilCtrl, $tpl;
930 
931  if ($_GET["show_tax"])
932  {
933  $this->showTaxonomy();
934  }
935 
936  // term
937  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
938  $ti = new ilTextInputGUI($lng->txt("cont_new_term"), "new_term");
939  $ti->setMaxLength(80);
940  $ti->setSize(20);
941  $ilToolbar->addInputItem($ti, true);
942 
943  // language
944  $this->lng->loadLanguageModule("meta");
946  if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
947  {
948  $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
949  }
950  else
951  {
952  $s_lang = $ilUser->getLanguage();
953  }
954  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
955  $si = new ilSelectInputGUI($lng->txt("language"), "term_language");
956  $si->setOptions($lang);
957  $si->setValue($s_lang);
958  $ilToolbar->addInputItem($si, true);
959 
960  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
961  $ilToolbar->addFormButton($lng->txt("glo_add_new_term"), "addTerm");
962  //$select_language = ilUtil::formSelect ($s_lang, "term_language",$lang,false,true);
963  //$this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
964 
965  if (is_object($this->tax))
966  {
967  $ilToolbar->addSeparator();
968  if ($_GET["show_tax"])
969  {
970  $ilToolbar->addButton($lng->txt("glo_hide_taxonomy"),
971  $ilCtrl->getLinkTarget($this, "deactTaxonomy"));
972  }
973  else
974  {
975  $ilToolbar->addButton($lng->txt("glo_show_taxonomy"),
976  $ilCtrl->getLinkTarget($this, "actTaxonomy"));
977  }
978  }
979 
980  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
981  $tab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
982  $tpl->setContent($tab->getHTML());
983  }
984 
991  function actTaxonomy()
992  {
993  global $ilCtrl;
994 
995  $ilCtrl->setParameter($this, "show_tax", 1);
996  $ilCtrl->redirect($this, "listTerms");
997  }
998 
1005  function deactTaxonomy()
1006  {
1007  global $ilCtrl;
1008 
1009  $ilCtrl->setParameter($this, "show_tax", "");
1010  $ilCtrl->redirect($this, "listTerms");
1011  }
1012 
1013 
1019  function showActions($a_actions)
1020  {
1021  foreach ($a_actions as $name => $lng)
1022  {
1023  $d[$name] = array("name" => $name, "lng" => $lng);
1024  }
1025 
1026  $notoperations = array();
1027  $operations = array();
1028 
1029  $operations = $d;
1030 
1031  if (count($operations) > 0)
1032  {
1033  foreach ($operations as $val)
1034  {
1035  $this->tpl->setCurrentBlock("tbl_action_btn");
1036  $this->tpl->setVariable("BTN_NAME", $val["name"]);
1037  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
1038  $this->tpl->parseCurrentBlock();
1039  }
1040 
1041  $this->tpl->setCurrentBlock("tbl_action_row");
1042  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.png"));
1043  $this->tpl->parseCurrentBlock();
1044  }
1045  }
1046 
1050  function addTerm()
1051  {
1052  global $lng, $ilCtrl;
1053 
1054  if (trim($_POST["new_term"]) == "")
1055  {
1056  ilUtil::sendFailure($lng->txt("cont_please_enter_a_term"), true);
1057  $ilCtrl->redirect($this, "listTerms");
1058  }
1059 
1060  // add term
1061  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1062  $term =& new ilGlossaryTerm();
1063  $term->setGlossary($this->object);
1064  $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
1065  $term->setLanguage($_POST["term_language"]);
1066  $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["term_language"];
1067  $term->create();
1068 
1069  // add first definition
1070  $def =& new ilGlossaryDefinition();
1071  $def->setTermId($term->getId());
1072  $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
1073  $def->create();
1074 
1075  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
1076  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def->getId());
1077  $this->ctrl->redirectByClass(array("ilglossarytermgui",
1078  "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
1079  }
1080 
1084  function moveDefinitionUp()
1085  {
1086  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
1087 
1088  $definition =& new ilGlossaryDefinition($_GET["def"]);
1089  $definition->moveUp();
1090 
1091  $this->ctrl->redirect($this, "listTerms");
1092  }
1093 
1098  {
1099  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
1100 
1101  $definition =& new ilGlossaryDefinition($_GET["def"]);
1102  $definition->moveDown();
1103 
1104  $this->ctrl->redirect($this, "listTerms");
1105  }
1106 
1111  {
1112  global $ilCtrl, $lng;
1113 
1114  //$this->getTemplate();
1115  //$this->displayLocator();
1116  //$this->setTabs();
1117 
1118  $term = new ilGlossaryTerm($this->term_id);
1119 
1120  $add = "";
1121  $nr = ilGlossaryTerm::getNumberOfUsages($this->term_id);
1122  if ($nr > 0)
1123  {
1124  $ilCtrl->setParameterByClass("ilglossarytermgui",
1125  "term_id", $this->term_id);
1126  $link = "[<a href='".
1127  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages").
1128  "'>".$lng->txt("glo_list_usages")."</a>]";
1129  $add = "<br/>".sprintf($lng->txt("glo_term_is_used_n_times"), $nr)." ".$link;
1130  }
1131 
1132  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1133  $cgui = new ilConfirmationGUI();
1134  $cgui->setHeaderText($this->lng->txt("info_delete_sure").$add);
1135 
1136  $cgui->setFormAction($this->ctrl->getFormAction($this));
1137  $cgui->setCancel($this->lng->txt("cancel"), "cancelDefinitionDeletion");
1138  $cgui->setConfirm($this->lng->txt("confirm"), "deleteDefinition");
1139 
1140  // content style
1141  $this->setContentStyleSheet($this->tpl);
1142 
1143  // syntax style
1144  $this->tpl->setCurrentBlock("SyntaxStyle");
1145  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1147  $this->tpl->parseCurrentBlock();
1148 
1149  $definition = new ilGlossaryDefinition($_GET["def"]);
1150  $page_gui = new ilGlossaryDefPageGUI($definition->getId());
1151  $page_gui->setTemplateOutput(false);
1152  $page_gui->setStyleId($this->object->getStyleSheetId());
1153  $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
1154  $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
1155  $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$_GET["ref_id"]);
1156  $output = $page_gui->preview();
1157 
1158  $cgui->addItem("def", $_GET["def"], $term->getTerm().$output);
1159 
1160  $this->tpl->setContent($cgui->getHTML());
1161  }
1162 
1164  {
1165  $this->ctrl->redirect($this, "listTerms");
1166  }
1167 
1168 
1169  function deleteDefinition()
1170  {
1171  $definition =& new ilGlossaryDefinition($_REQUEST["def"]);
1172  $definition->delete();
1173  $this->ctrl->redirect($this, "listTerms");
1174  }
1175 
1179  function editTerm()
1180  {
1181  // deprecated
1182  }
1183 
1184 
1188  function updateTerm()
1189  {
1190  $term = new ilGlossaryTerm($this->term_id);
1191 
1192  $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
1193  $term->setLanguage($_POST["term_language"]);
1194  $term->update();
1195  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1196  $this->ctrl->redirect($this, "listTerms");
1197  }
1198 
1199 
1200 
1204  function export()
1205  {
1206  $this->checkPermission("write");
1207 
1208  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1209  $glo_exp = new ilGlossaryExport($this->object);
1210  $glo_exp->buildExportFile();
1211  $this->ctrl->redirectByClass("ilexportgui", "");
1212  }
1213 
1217  function exportHTML()
1218  {
1219  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1220  $glo_exp = new ilGlossaryExport($this->object, "html");
1221  $glo_exp->buildExportFile();
1222 //echo $this->tpl->get();
1223  $this->ctrl->redirectByClass("ilexportgui", "");
1224  }
1225 
1230  {
1231  if(!isset($_POST["file"]))
1232  {
1233  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1234  }
1235  if (count($_POST["file"]) > 1)
1236  {
1237  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1238  }
1239 
1240  $file = explode(":", $_POST["file"][0]);
1241  $export_dir = $this->object->getExportDirectory($file[0]);
1242 
1243  if ($this->object->getPublicExportFile($file[0]) ==
1244  $file[1])
1245  {
1246  $this->object->setPublicExportFile($file[0], "");
1247  }
1248  else
1249  {
1250  $this->object->setPublicExportFile($file[0], $file[1]);
1251  }
1252  $this->object->update();
1253  $this->ctrl->redirectByClass("ilexportgui", "");
1254  }
1255 
1256  /*
1257  * list all export files
1258  */
1259  function viewExportLog()
1260  {
1261  global $tree;
1262 /*
1263  $this->setTabs();
1264 
1265  //add template for view button
1266  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1267 
1268  // create export file button
1269  $this->tpl->setCurrentBlock("btn_cell");
1270  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportList"));
1271  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_export_files"));
1272  $this->tpl->parseCurrentBlock();
1273 
1274  // load files templates
1275  $this->tpl->setVariable("ADM_CONTENT",
1276  nl2br(file_get_contents($this->object->getExportDirectory()."/export.log")));
1277 
1278  $this->tpl->parseCurrentBlock();*/
1279  }
1280 
1285  {
1286  global $ilCtrl, $lng;
1287 
1288  //$this->prepareOutput();
1289  if (!isset($_POST["id"]))
1290  {
1291  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1292  $ilCtrl->redirect($this, "listTerms");
1293  }
1294 
1295  // check ids
1296  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1297  foreach ($_POST["id"] as $term_id)
1298  {
1299  $term_glo_id = ilGlossaryTerm::_lookGlossaryID((int) $term_id);
1300  if ($term_glo_id != $this->object->getId())
1301  {
1302  ilUtil::sendFailure($this->lng->txt("glo_term_must_belong_to_glo"), true);
1303  $ilCtrl->redirect($this, "listTerms");
1304  }
1305  }
1306 
1307  // display confirmation message
1308  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1309  $cgui = new ilConfirmationGUI();
1310  $cgui->setFormAction($this->ctrl->getFormAction($this));
1311  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1312  $cgui->setCancel($this->lng->txt("cancel"), "cancelTermDeletion");
1313  $cgui->setConfirm($this->lng->txt("confirm"), "deleteTerms");
1314 
1315  foreach($_POST["id"] as $id)
1316  {
1317  $term = new ilGlossaryTerm($id);
1318 
1319  $add = "";
1321  if ($nr > 0)
1322  {
1323  $ilCtrl->setParameterByClass("ilglossarytermgui",
1324  "term_id", $id);
1325  $link = "[<a href='".
1326  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages").
1327  "'>".$lng->txt("glo_list_usages")."</a>]";
1328  $add = "<div class='small'>".
1329  sprintf($lng->txt("glo_term_is_used_n_times"), $nr)." ".$link."</div>";
1330  }
1331 
1332  $cgui->addItem("id[]", $id, $term->getTerm().$add);
1333  }
1334 
1335  $this->tpl->setContent($cgui->getHTML());
1336  }
1337 
1344  {
1345  $this->ctrl->redirect($this, "listTerms");
1346  }
1347 
1351  function deleteTerms()
1352  {
1353  foreach($_POST["id"] as $id)
1354  {
1355  $term = new ilGlossaryTerm($id);
1356  $term->delete();
1357  }
1358  $this->ctrl->redirect($this, "listTerms");
1359  }
1360 
1368  function setLocator($a_tree = "", $a_id = "")
1369  {
1370  if(strtolower($_GET["baseClass"]) != "ilglossaryeditorgui")
1371  {
1372  parent::setLocator($a_tree, $a_id);
1373  }
1374  else
1375  {
1376  if(is_object($this->object))
1377  {
1378  require_once("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
1379  $gloss_loc =& new ilGlossaryLocatorGUI();
1380  if (is_object($this->term))
1381  {
1382  $gloss_loc->setTerm($this->term);
1383  }
1384  $gloss_loc->setGlossary($this->object);
1385  //$gloss_loc->setDefinition($this->definition);
1386  $gloss_loc->display();
1387  }
1388  }
1389 
1390  }
1391 
1395  function view()
1396  {
1397  //$this->prepareOutput();
1398  $this->viewObject();
1399  }
1400 
1404  function create()
1405  {
1406  switch($_POST["new_type"])
1407  {
1408  case "term":
1409  $term_gui =& new ilGlossaryTermGUI();
1410  $term_gui->create();
1411  break;
1412  }
1413  }
1414 
1415  function saveTerm()
1416  {
1417  $term_gui =& new ilGlossaryTermGUI();
1418  $term_gui->setGlossary($this->object);
1419  $term_gui->save();
1420 
1421  ilUtil::sendSuccess($this->lng->txt("cont_added_term"),true);
1422 
1423  //ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
1424  $ilCtrl->redirect($this, "listTerms");
1425  }
1426 
1427 
1431  function addDefinition()
1432  {
1433  global $ilCtrl;
1434 
1435  $term_id = (int) $_GET["term_id"];
1436 
1437  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1438  $term_glo_id = ilGlossaryTerm::_lookGlossaryID((int) $term_id);
1439  if ($term_glo_id != $this->object->getId())
1440  {
1441  ilUtil::sendFailure($this->lng->txt("glo_term_must_belong_to_glo"), true);
1442  $ilCtrl->redirect($this, "listTerms");
1443  }
1444 
1445  // add term
1446  include_once ("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1447  $term = new ilGlossaryTerm($term_id);
1448 
1449  // add first definition
1450  $def = new ilGlossaryDefinition();
1451  $def->setTermId($term->getId());
1452  $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
1453  $def->create();
1454 
1455  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
1456  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def->getId());
1457  $this->ctrl->redirectByClass(array("ilglossarytermgui",
1458  "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
1459 
1460  }
1461 
1462  function getTemplate()
1463  {
1464  $this->tpl->getStandardTemplate();
1465 
1466  $title = $this->object->getTitle();
1467 
1468 
1469  if ($this->term_id > 0)
1470  {
1471  $this->tpl->setTitle($this->lng->txt("term").": ".
1472  ilGlossaryTerm::_lookGlossaryTerm($this->term_id));
1473  }
1474  else
1475  {
1476  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo_b.png"));
1477  $this->tpl->setTitle($this->lng->txt("glo").": ".$title);
1478  }
1479  }
1480 
1484  function setTabs()
1485  {
1486  $this->getTabs($this->tabs_gui);
1487  }
1488 
1492  function getTabs(&$tabs_gui)
1493  {
1494  global $rbacsystem, $ilHelp;
1495 
1496  $ilHelp->setScreenIdComponent("glo");
1497 
1498  // list terms
1499  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "listTerms")
1500  ? true
1501  : false;
1502  $tabs_gui->addTarget("cont_terms",
1503  $this->ctrl->getLinkTarget($this, "listTerms"), array("listTerms", ""),
1504  get_class($this), "", $force_active);
1505 
1506  $force_active = false;
1507  if ($this->ctrl->getCmd() == "showSummary" ||
1508  strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui")
1509  {
1510  $force_active = true;
1511  }
1512  $tabs_gui->addTarget("info_short",
1513  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), "",
1514  "ilInfoScreenGUI", "", $force_active);
1515 
1516  // properties
1517  if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
1518  {
1519  $tabs_gui->addTarget("settings",
1520  $this->ctrl->getLinkTarget($this, "properties"), "properties",
1521  get_class($this));
1522 
1523  // meta data
1524  $tabs_gui->addTarget("meta_data",
1525  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
1526  "", "ilmdeditorgui");
1527 
1528  // export
1529  /*$tabs_gui->addTarget("export",
1530  $this->ctrl->getLinkTarget($this, "exportList"),
1531  array("exportList", "viewExportLog"), get_class($this));*/
1532 
1533  // export
1534  $tabs_gui->addTarget("export",
1535  $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1536  "", "ilexportgui");
1537  }
1538 
1539  // permissions
1540  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
1541  {
1542  /*$tabs_gui->addTarget("permission_settings",
1543  $this->ctrl->getLinkTarget($this, "perm"),
1544  array("perm", "info"),
1545  get_class($this));
1546  */
1547  $tabs_gui->addTarget("perm_settings",
1548  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1549 
1550  }
1551 
1552  $tabs_gui->addNonTabbedLink("presentation_view",
1553  $this->lng->txt("glo_presentation_view"),
1554  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=".$this->object->getRefID(),
1555  "_top"
1556  );
1557 
1558  }
1559 
1563  function setSettingsSubTabs($a_active)
1564  {
1565  global $ilTabs, $ilCtrl, $lng;
1566 
1567  if (in_array($a_active,
1568  array("general_settings", "style", "taxonomy")))
1569  {
1570  // general properties
1571  $ilTabs->addSubTab("general_settings",
1572  $lng->txt("settings"),
1573  $ilCtrl->getLinkTarget($this, 'properties'));
1574 
1575  // style properties
1576  $ilTabs->addSubTab("style",
1577  $lng->txt("obj_sty"),
1578  $ilCtrl->getLinkTarget($this, 'editStyleProperties'));
1579 
1580  // taxonomy
1581  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1583  $ilTabs->addSubTab("taxonomy",
1584  $lng->txt("tax_taxonomy"),
1585  $ilCtrl->getLinkTargetByClass("ilobjtaxonomygui", ''));
1586 
1587  $ilTabs->activateSubTab($a_active);
1588  }
1589  }
1590 
1591 
1597  function _goto($a_target)
1598  {
1599  global $rbacsystem, $ilErr, $lng, $ilAccess;
1600 
1601  if ($ilAccess->checkAccess("read", "", $a_target))
1602  {
1603  $_GET["ref_id"] = $a_target;
1604  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1605  include("ilias.php");
1606  exit;
1607  }
1608  else if ($ilAccess->checkAccess("visible", "", $a_target))
1609  {
1610  $_GET["ref_id"] = $a_target;
1611  $_GET["cmd"] = "infoScreen";
1612  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1613  include("ilias.php");
1614  exit;
1615  }
1616  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1617  {
1618  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1619  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1621  }
1622 
1623  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1624  }
1625 
1629  function applyFilter()
1630  {
1631  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
1632  $prtab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
1633  $prtab->resetOffset();
1634  $prtab->writeFilterToSession();
1635  $this->listTerms();
1636  }
1637 
1642  function resetFilter()
1643  {
1644  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
1645  $prtab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
1646  $prtab->resetOffset();
1647  $prtab->resetFilter();
1648  $this->listTerms();
1649  }
1650 
1651 
1655 
1659  function setContentStyleSheet($a_tpl = null)
1660  {
1661  global $tpl;
1662 
1663  if ($a_tpl != null)
1664  {
1665  $ctpl = $a_tpl;
1666  }
1667  else
1668  {
1669  $ctpl = $tpl;
1670  }
1671 
1672  $ctpl->setCurrentBlock("ContentStyle");
1673  $ctpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1674  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
1675  $ctpl->parseCurrentBlock();
1676  }
1677 
1678 
1683  {
1684  global $ilTabs, $tpl;
1685 
1686  $this->checkPermission("write");
1687 
1688  $this->initStylePropertiesForm();
1689  $tpl->setContent($this->form->getHTML());
1690 
1691  $ilTabs->activateTab("settings");
1692  $this->setSettingsSubTabs("style");
1693  }
1694 
1699  {
1700  global $ilCtrl, $lng, $ilTabs, $ilSetting;
1701 
1702  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1703  $lng->loadLanguageModule("style");
1704 
1705  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1706  $this->form = new ilPropertyFormGUI();
1707 
1708  $fixed_style = $ilSetting->get("fixed_content_style_id");
1709  $style_id = $this->object->getStyleSheetId();
1710 
1711  if ($fixed_style > 0)
1712  {
1713  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1714  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
1715  $this->lng->txt("global_fixed").")");
1716  $this->form->addItem($st);
1717  }
1718  else
1719  {
1720  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
1721  $_GET["ref_id"]);
1722 
1723  $st_styles[0] = $this->lng->txt("default");
1724  ksort($st_styles);
1725 
1726  if ($style_id > 0)
1727  {
1728  // individual style
1729  if (!ilObjStyleSheet::_lookupStandard($style_id))
1730  {
1731  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1732  $st->setValue(ilObject::_lookupTitle($style_id));
1733  $this->form->addItem($st);
1734 
1735 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
1736 
1737  // delete command
1738  $this->form->addCommandButton("editStyle",
1739  $lng->txt("style_edit_style"));
1740  $this->form->addCommandButton("deleteStyle",
1741  $lng->txt("style_delete_style"));
1742 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
1743  }
1744  }
1745 
1746  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
1747  {
1748  $style_sel = ilUtil::formSelect ($style_id, "style_id",
1749  $st_styles, false, true);
1750  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
1751  $style_sel->setOptions($st_styles);
1752  $style_sel->setValue($style_id);
1753  $this->form->addItem($style_sel);
1754 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
1755  $this->form->addCommandButton("saveStyleSettings",
1756  $lng->txt("save"));
1757  $this->form->addCommandButton("createStyle",
1758  $lng->txt("sty_create_ind_style"));
1759  }
1760  }
1761  $this->form->setTitle($lng->txt("glo_style"));
1762  $this->form->setFormAction($ilCtrl->getFormAction($this));
1763  }
1764 
1768  function createStyle()
1769  {
1770  global $ilCtrl;
1771 
1772  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
1773  }
1774 
1778  function editStyle()
1779  {
1780  global $ilCtrl;
1781 
1782  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
1783  }
1784 
1788  function deleteStyle()
1789  {
1790  global $ilCtrl;
1791 
1792  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
1793  }
1794 
1799  {
1800  global $ilSetting;
1801 
1802  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1803  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1804  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1805  || $this->object->getStyleSheetId() == 0))
1806  {
1807  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1808  $this->object->update();
1809  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1810  }
1811  $this->ctrl->redirect($this, "editStyleProperties");
1812  }
1813 
1817  function getPublicAccessColValue($a_type, $a_file)
1818  {
1819  global $lng, $ilCtrl;
1820 
1821  if ($this->object->getPublicExportFile($a_type) == $a_file)
1822  {
1823  return $lng->txt("yes");
1824  }
1825 
1826  return " ";
1827  }
1828 
1835  function showTaxonomy()
1836  {
1837  global $tpl, $lng;
1838 
1839  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1840  $tax_ids = ilObjTaxonomy::getUsageOfObject($this->object->getId());
1841  if (count($tax_ids) > 0)
1842  {
1843  include_once("./Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php");
1844  $tax_exp = new ilTaxonomyExplorerGUI($this, "showTaxonomy", $tax_ids[0],
1845  "ilobjglossarygui", "listTerms");
1846  if (!$tax_exp->handleCommand())
1847  {
1848  //$tpl->setLeftNavContent($tax_exp->getHTML());
1849  $tpl->setLeftNavContent($tax_exp->getHTML()."&nbsp;");
1850  }
1851  }
1852 
1853  }
1854 
1855 }
1856 
1857 ?>