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