ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
28 {
32  protected $error;
33 
34  public $admin_tabs;
35  public $mode;
36  public $term;
37 
41  protected $term_id;
42 
46  protected $ctrl;
47 
51  protected $user;
52 
56  protected $toolbar;
57 
61  protected $tabs;
62 
66  protected $setting;
67 
71  protected $access;
72 
76  protected $rbacsystem;
77 
81  protected $help;
82 
86  protected $term_perm;
87 
91  protected $log;
92 
97  public function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true)
98  {
99  $this->error = $DIC["ilErr"];
100  global $DIC;
101 
102  $this->ctrl = $DIC->ctrl();
103  $this->lng = $DIC->language();
104  $this->user = $DIC->user();
105  $this->toolbar = $DIC->toolbar();
106  $this->tabs = $DIC->tabs();
107  $this->setting = $DIC["ilSetting"];
108  $this->access = $DIC->access();
109  $this->rbacsystem = $DIC->rbac()->system();
110  $this->help = $DIC["ilHelp"];
111 
112  $this->log = ilLoggerFactory::getLogger('glo');
113 
114  include_once("./Modules/Glossary/classes/class.ilGlossaryTermPermission.php");
115  $this->term_perm = ilGlossaryTermPermission::getInstance();
116 
117  $this->ctrl->saveParameter($this, array("ref_id", "offset"));
118 
119  $this->lng->loadLanguageModule("content");
120  $this->lng->loadLanguageModule("glo");
121 
122  $this->type = "glo";
123  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
124 
125  // determine term id and check whether it is valid (belongs to
126  // current glossary)
127  $this->term_id = (int) $_GET["term_id"];
128  $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
129  include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
130  if ($this->term_id > 0 && $term_glo_id != $this->object->getId()
132  $this->term_id = "";
133  }
134 
135  $this->tax_id = $this->object->getTaxonomyId();
136  if ($this->tax_id > 0) {
137  $this->ctrl->saveParameter($this, array("show_tax", "tax_node"));
138 
139  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
140  $this->tax = new ilObjTaxonomy($this->tax_id);
141  }
142  if ((int) $_GET["tax_node"] > 1 && $this->tax->getTree()->readRootId() != $_GET["tax_node"]) {
143  $this->tax_node = (int) $_GET["tax_node"];
144  }
145  }
146 
150  public function executeCommand()
151  {
152  $cmd = $this->ctrl->getCmd();
153  $next_class = $this->ctrl->getNextClass($this);
154 
155  $this->log->debug("glossary term, next class " . $next_class . ", cmd: " . $cmd);
156 
157  switch ($next_class) {
158  case 'ilobjectmetadatagui':
159  $this->checkPermission("write");
160 
161  $this->getTemplate();
162  $this->setTabs();
163  $this->setLocator();
164  $this->addHeaderAction();
165 
166  $this->tabs_gui->activateTab('meta_data');
167  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
168  $md_gui = new ilObjectMetaDataGUI($this->object, 'term');
169  $this->ctrl->forwardCommand($md_gui);
170  break;
171 
172  case "ilglossarytermgui":
173  if (!$this->term_perm->checkPermission("edit_content", $this->term_id) &&
174  !$this->term_perm->checkPermission("write", $this->term_id)) {
175  include_once("./Modules/Glossary/exceptions/class.ilGlossaryException.php");
176  throw new ilGlossaryException("No permission.");
177  }
178  $this->getTemplate();
179 // $this->quickList();
180  $this->ctrl->setReturn($this, "listTerms");
181  $term_gui = new ilGlossaryTermGUI($this->term_id);
182  $term_gui->setGlossary($this->object);
183  //$ret = $term_gui->executeCommand();
184  $ret = $this->ctrl->forwardCommand($term_gui);
185  break;
186 
187  case "ilinfoscreengui":
188  $this->addHeaderAction();
189  $this->showInfoScreen();
190  break;
191 
192  case "ilobjstylesheetgui":
193  include_once("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
194  $this->ctrl->setReturn($this, "editStyleProperties");
195  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
196  $style_gui->omitLocator();
197  if ($cmd == "create" || $_GET["new_type"]=="sty") {
198  $style_gui->setCreationMode(true);
199  }
200 
201  if ($cmd == "confirmedDelete") {
202  $this->object->setStyleSheetId(0);
203  $this->object->update();
204  }
205 
206  $ret = $this->ctrl->forwardCommand($style_gui);
207 
208  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
209  $style_id = $ret;
210  $this->object->setStyleSheetId($style_id);
211  $this->object->update();
212  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
213  }
214  break;
215 
216 
217  case 'ilpermissiongui':
218  if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
219  $this->prepareOutput();
220  } else {
221  $this->getTemplate();
222  $this->setTabs();
223  $this->setLocator();
224  $this->addHeaderAction();
225  }
226  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
227  $perm_gui = new ilPermissionGUI($this);
228  $ret = $this->ctrl->forwardCommand($perm_gui);
229  break;
230 
231  case "ilcommonactiondispatchergui":
232  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
234  $this->ctrl->forwardCommand($gui);
235  break;
236 
237  case "ilobjtaxonomygui":
238  $this->getTemplate();
239  $this->setTabs();
240  $this->setLocator();
241  $this->addHeaderAction();
242  $this->tabs->activateTab("settings");
243  $this->setSettingsSubTabs("taxonomy");
244 
245  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomyGUI.php");
246  $this->ctrl->setReturn($this, "properties");
247  $tax_gui = new ilObjTaxonomyGUI();
248  $tax_gui->setMultiple(false);
249 
250  /*include_once("./Modules/Glossary/classes/class.ilTermTaxInfo.php");
251  $term_info = new ilTermTaxInfo();*/
252  //$tax_gui->activateAssignedItemSorting($term_info, "glo", "term");
253 
254  $tax_gui->setAssignedObject($this->object->getId());
255  $ret = $this->ctrl->forwardCommand($tax_gui);
256  break;
257 
258  case "ilexportgui":
259  $this->getTemplate();
260  $this->setTabs();
261  $this->tabs->activateTab("export");
262  $this->setLocator();
263  include_once("./Services/Export/classes/class.ilExportGUI.php");
264  $exp_gui = new ilExportGUI($this);
265  //$exp_gui->addFormat("xml", "", $this, "export");
266  $exp_gui->addFormat("xml");
267  $exp_gui->addFormat("html", "", $this, "exportHTML");
268  $exp_gui->addCustomColumn(
269  $this->lng->txt("cont_public_access"),
270  $this,
271  "getPublicAccessColValue"
272  );
273  $exp_gui->addCustomMultiCommand(
274  $this->lng->txt("cont_public_access"),
275  $this,
276  "publishExportFile"
277  );
278  $ret = $this->ctrl->forwardCommand($exp_gui);
279  break;
280 
281  case 'ilobjectcopygui':
282  $this->prepareOutput();
283  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
284  $cp = new ilObjectCopyGUI($this);
285  $cp->setType('glo');
286  $this->ctrl->forwardCommand($cp);
287  break;
288 
289  case "ilglossaryforeigntermcollectorgui":
290  $this->ctrl->setReturn($this, "");
291  $this->getTemplate();
292  $this->setTabs();
293  $this->setLocator();
294  $this->addHeaderAction();
295  include_once("./Modules/Glossary/classes/class.ilGlossaryForeignTermCollectorGUI.php");
297  $this->ctrl->forwardCommand($coll);
298  break;
299 
300  default:
301  $cmd = $this->ctrl->getCmd("listTerms");
302 
303  if (($cmd == "create") && ($_POST["new_type"] == "term")) {
304  $this->ctrl->setCmd("create");
305  $this->ctrl->setCmdClass("ilGlossaryTermGUI");
306  $ret = $this->executeCommand();
307  return;
308  } else {
309  if (!in_array($cmd, array("quickList"))) {
310  if (strtolower($_GET["baseClass"]) == "iladministrationgui" ||
311  $this->getCreationMode() == true) {
312  $this->prepareOutput();
313  $cmd.= "Object";
314  } else {
315  $this->getTemplate();
316  $this->setTabs();
317  $this->setLocator();
318  $this->addHeaderAction();
319 
320  if ($cmd == "redrawHeaderAction") {
321  $cmd = "redrawHeaderActionObject";
322  }
323  }
324  }
325  $ret = $this->$cmd();
326  }
327  break;
328  }
329 
330  if (!in_array($cmd, array("quickList"))) {
331  if (strtolower($_GET["baseClass"]) != "iladministrationgui") {
332  if (!$this->getCreationMode()) {
333  $this->tpl->show();
334  }
335  }
336  } else {
337  $this->tpl->show(false);
338  }
339  }
340 
341  public function assignObject()
342  {
343  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
344 
345  $this->object = new ilObjGlossary($this->id, true);
346  }
347 
348  /*protected function initCreationForms($a_new_type)
349  {
350  $forms = array(
351  self::CFORM_NEW => $this->initCreateForm($a_new_type),
352  self::CFORM_IMPORT => $this->initImportForm($a_new_type)
353  );
354 
355  return $forms;
356  }*/
357 
358  public function initCreateForm($a_new_type)
359  {
360  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
361  $form = new ilPropertyFormGUI();
362  $form->setTarget("_top");
363  $form->setFormAction($this->ctrl->getFormAction($this));
364  $form->setTitle($this->lng->txt($a_new_type . "_new"));
365 
366  // title
367  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
368  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
369  $ti->setMaxLength(ilObject::TITLE_LENGTH);
370  $ti->setRequired(true);
371  $form->addItem($ti);
372 
373  // description
374  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
375  $ta->setCols(40);
376  $ta->setRows(2);
377  $form->addItem($ta);
378 
379  // mode
380  $stati = array(
381  "none"=>$this->lng->txt("glo_mode_normal"),
382  "level"=>$this->lng->txt("glo_mode_level"),
383  "subtree"=>$this->lng->txt("glo_mode_subtree")
384  );
385  $tm = new ilSelectInputGUI($this->lng->txt("glo_mode"), "glo_mode");
386  $tm->setOptions($stati);
387  $tm->setInfo($this->lng->txt("glo_mode_desc"));
388  $tm->setRequired(true);
389  $form->addItem($tm);
390 
391  $form->addCommandButton("save", $this->lng->txt($a_new_type . "_add"));
392  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
393 
394  return $form;
395  }
396 
397  public function importObject()
398  {
399  $this->createObject();
400  }
401 
405  public function saveObject()
406  {
408 
409  $new_type = $_REQUEST["new_type"];
410 
411  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
412  if (!$this->checkPermissionBool("create", "", $new_type)) {
413  $ilErr->raiseError($this->lng->txt("no_create_permission"), $ilErr->MESSAGE);
414  }
415 
416  $this->lng->loadLanguageModule($new_type);
417  $this->ctrl->setParameter($this, "new_type", $new_type);
418 
419  $form = $this->initCreateForm($new_type);
420  if ($form->checkInput()) {
421  $this->ctrl->setParameter($this, "new_type", "");
422 
423  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
424  $newObj = new ilObjGlossary();
425  $newObj->setType($new_type);
426  $newObj->setTitle($form->getInput("title"));
427  $newObj->setDescription($form->getInput("desc"));
428  $newObj->setVirtualMode($form->getInput("glo_mode"));
429  $newObj->create();
430 
431  $this->putObjectInTree($newObj);
432 
433  // always send a message
434  ilUtil::sendSuccess($this->lng->txt("glo_added"), true);
435  ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId());
436  }
437 
438  // display only this form to correct input
439  $form->setValuesByPost();
440  $this->tpl->setContent($form->getHtml());
441  }
442 
449  public function showInfoScreen()
450  {
451  $this->getTemplate();
452  $this->setTabs();
453  $this->setLocator();
454  $this->lng->loadLanguageModule("meta");
455  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
456 
457  $info = new ilInfoScreenGUI($this);
458  $info->enablePrivateNotes();
459  $info->enableNews();
460  if ($this->access->checkAccess("write", "", $_GET["ref_id"])) {
461  $info->enableNewsEditing();
462  $news_set = new ilSetting("news");
463  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
464  if ($enable_internal_rss) {
465  $info->setBlockProperty("news", "settings", true);
466  }
467  }
468  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
469 
471 
472  $this->ctrl->forwardCommand($info);
473  }
474 
481  public static function addUsagesToInfo($info, $glo_id)
482  {
483  global $DIC;
484 
485  $lng = $DIC->language();
486  $ilAccess = $DIC->access();
487 
488  $info->addSection($lng->txt("glo_usages"));
489  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
491  foreach ($sms as $sm) {
492  $link = false;
493  $refs = ilObject::_getAllReferences($sm);
494  foreach ($refs as $ref) {
495  if ($link === false) {
496  if ($ilAccess->checkAccess("write", "", $ref)) {
497  include_once("./Services/Link/classes/class.ilLink.php");
498  $link = ilLink::_getLink($ref, 'sahs');
499  }
500  }
501  }
502 
503  $entry = ilObject::_lookupTitle($sm);
504  if ($link !== false) {
505  $entry = "<a href='" . $link . "' target='_top'>" . $entry . "</a>";
506  }
507 
508  $info->addProperty($lng->txt("obj_sahs"), $entry);
509  }
510  }
511 
512 
513  public function viewObject()
514  {
516 
517  if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
518  parent::viewObject();
519  return;
520  }
521 
522  if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
523  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
524  }
525  }
526 
532  public function properties()
533  {
534  $this->checkPermission("write");
535 
536  $this->setSettingsSubTabs("general_settings");
537 
538  $this->initSettingsForm();
539 
540  // Edit ecs export settings
541  include_once 'Modules/Glossary/classes/class.ilECSGlossarySettings.php';
542  $ecs = new ilECSGlossarySettings($this->object);
543  $ecs->addSettingsToForm($this->form, 'glo');
544 
545  $this->tpl->setContent($this->form->getHTML());
546  }
547 
553  public function initSettingsForm($a_mode = "edit")
554  {
555  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
556  $this->form = new ilPropertyFormGUI();
557 
558  // title
559  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
560  $title->setRequired(true);
561  $this->form->addItem($title);
562 
563  // description
564  $desc = new ilTextAreaInputGUI($this->lng->txt("desc"), "description");
565  $this->form->addItem($desc);
566 
567  $this->lng->loadLanguageModule("rep");
569  $section->setTitle($this->lng->txt('rep_activation_availability'));
570  $this->form->addItem($section);
571 
572  // online
573  $online = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
574  $online->setValue("y");
575  $online->setInfo($this->lng->txt("glo_online_info"));
576  $this->form->addItem($online);
577 
579  $section->setTitle($this->lng->txt('glo_content_settings'));
580  $this->form->addItem($section);
581 
582  // glossary mode
583  $glo_mode = new ilRadioGroupInputGUI($this->lng->txt("glo_mode"), "glo_mode");
584  //$glo_mode->setInfo($this->lng->txt("glo_mode_desc"));
585  $op1 = new ilRadioOption($this->lng->txt("glo_mode_normal"), "none", $this->lng->txt("glo_mode_normal_info"));
586  $glo_mode->addOption($op1);
587  $op2 = new ilRadioOption($this->lng->txt("glo_mode_level"), "level", $this->lng->txt("glo_mode_level_info"));
588  $glo_mode->addOption($op2);
589  $op3 = new ilRadioOption($this->lng->txt("glo_mode_subtree"), "subtree", $this->lng->txt("glo_mode_subtree_info"));
590  $glo_mode->addOption($op3);
591  $this->form->addItem($glo_mode);
592 
593  // glossary mode
594  /*$options = array(
595  "none"=>$this->lng->txt("glo_mode_normal"),
596  "level"=>$this->lng->txt("glo_mode_level"),
597  "subtree"=>$this->lng->txt("glo_mode_subtree")
598  );
599  $glo_mode = new ilSelectInputGUI($this->lng->txt("glo_mode"), "glo_mode");
600  $glo_mode->setOptions($options);
601  $glo_mode->setInfo($this->lng->txt("glo_mode_desc"));
602  $this->form->addItem($glo_mode);*/
603 
604 
606  $section->setTitle($this->lng->txt('cont_presentation'));
607  $this->form->addItem($section);
608 
609  // presentation mode
610  $pres_mode = new ilRadioGroupInputGUI($this->lng->txt("glo_presentation_mode"), "pres_mode");
611  $pres_mode->setValue("table");
612  $op1 = new ilRadioOption($this->lng->txt("glo_table_form"), "table", $this->lng->txt("glo_table_form_info"));
613 
614  // short text length
615  $snl = new ilNumberInputGUI($this->lng->txt("glo_text_snippet_length"), "snippet_length");
616  $snl->setMaxValue(3000);
617  $snl->setMinValue(100);
618  $snl->setMaxLength(4);
619  $snl->setSize(4);
620  $snl->setInfo($this->lng->txt("glo_text_snippet_length_info"));
621  $snl->setValue(200);
622  $op1->addSubItem($snl);
623 
624  $pres_mode->addOption($op1);
625  $op2 = new ilRadioOption($this->lng->txt("glo_full_definitions"), "full_def", $this->lng->txt("glo_full_definitions_info"));
626  $pres_mode->addOption($op2);
627  $this->form->addItem($pres_mode);
628 
629  // show taxonomy
630  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
631  $tax_ids = ilObjTaxonomy::getUsageOfObject($this->object->getId());
632  if (count($tax_ids) > 0) {
633  $show_tax = new ilCheckboxInputGUI($this->lng->txt("glo_show_taxonomy"), "show_tax");
634  $show_tax->setInfo($this->lng->txt("glo_show_taxonomy_info"));
635  $this->form->addItem($show_tax);
636  }
637 
638  // downloads
639  $down = new ilCheckboxInputGUI($this->lng->txt("cont_downloads"), "glo_act_downloads");
640  $down->setValue("y");
641  $down->setInfo($this->lng->txt("cont_downloads_desc"));
642  $this->form->addItem($down);
643 
644  if ($a_mode == "edit") {
645  $title->setValue($this->object->getTitle());
646  $desc->setValue($this->object->getDescription());
647  $online->setChecked($this->object->getOnline());
648  $glo_mode->setValue($this->object->getVirtualMode());
649  $pres_mode->setValue($this->object->getPresentationMode());
650  $snl->setValue($this->object->getSnippetLength());
651  if (count($tax_ids) > 0) {
652  $show_tax->setChecked($this->object->getShowTaxonomy());
653  }
654 
655  $down->setChecked($this->object->isActiveDownloads());
656 
657  // additional features
658  $feat = new ilFormSectionHeaderGUI();
659  $feat->setTitle($this->lng->txt('obj_features'));
660  $this->form->addItem($feat);
661 
662  include_once './Services/Container/classes/class.ilContainer.php';
663  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
665  $this->object->getId(),
666  $this->form,
667  array(
669  )
670  );
671  }
672 
673  // sort columns, if adv fields are given
674  include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
675  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->object->getRefId());
676  $cols = $adv_ap->getColumnOrder();
677  if (count($cols) > 1) {
678  include_once './Modules/Glossary/classes/class.ilGloAdvColSortInputGUI.php';
679  $ti = new ilGloAdvColSortInputGUI($this->lng->txt("cont_col_ordering"), "field_order");
680  $this->form->addItem($ti);
681  $ti->setValue($cols);
682  }
683 
684  // save and cancel commands
685  $this->form->addCommandButton("saveProperties", $this->lng->txt("save"));
686 
687  $this->form->setTitle($this->lng->txt("cont_glo_properties"));
688  $this->form->setFormAction($this->ctrl->getFormAction($this));
689  }
690 
691 
695  public function saveProperties()
696  {
697  $this->initSettingsForm();
698  if ($this->form->checkInput()) {
699  $this->object->setTitle($_POST['title']);
700  $this->object->setDescription($_POST['description']);
701  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
702  $this->object->setVirtualMode($_POST["glo_mode"]);
703  // $this->object->setActiveGlossaryMenu(ilUtil::yn2tf($_POST["glo_act_menu"]));
704  $this->object->setActiveDownloads(ilUtil::yn2tf($_POST["glo_act_downloads"]));
705  $this->object->setPresentationMode($_POST["pres_mode"]);
706  $this->object->setSnippetLength($_POST["snippet_length"]);
707  $this->object->setShowTaxonomy($_POST["show_tax"]);
708  $this->object->update();
709 
710  // field order of advanced metadata
711  include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
712  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->object->getRefId());
713  $cols = $adv_ap->getColumnOrder();
714  if (count($cols) > 1) {
715  $adv_ap->saveColumnOrder($_POST["field_order"]);
716  }
717 
718  // set definition short texts dirty
719  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
721 
722  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
724  $this->object->getId(),
725  $this->form,
726  array(
728  )
729  );
730 
731  // Update ecs export settings
732  include_once 'Modules/Glossary/classes/class.ilECSGlossarySettings.php';
733  $ecs = new ilECSGlossarySettings($this->object);
734  if ($ecs->handleSettingsUpdate()) {
735  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
736  $this->ctrl->redirect($this, "properties");
737  }
738  }
739  $this->form->setValuesByPost();
740  $this->tpl->setContent($this->form->getHTML());
741  }
742 
743 
747  public function listTerms()
748  {
749  if ($_GET["show_tax"]) {
750  $this->showTaxonomy();
751  }
752 
753  // term
754  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
755  $ti = new ilTextInputGUI($this->lng->txt("cont_new_term"), "new_term");
756  $ti->setMaxLength(80);
757  $ti->setSize(20);
758  $this->toolbar->addInputItem($ti, true);
759 
760  // language
761  $this->lng->loadLanguageModule("meta");
763  if ($_SESSION["il_text_lang_" . $_GET["ref_id"]] != "") {
764  $s_lang = $_SESSION["il_text_lang_" . $_GET["ref_id"]];
765  } else {
766  $s_lang = $this->user->getLanguage();
767  }
768  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
769  $si = new ilSelectInputGUI($this->lng->txt("language"), "term_language");
770  $si->setOptions($lang);
771  $si->setValue($s_lang);
772  $this->toolbar->addInputItem($si, true);
773 
774  $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
775  $this->toolbar->addFormButton($this->lng->txt("glo_add_new_term"), "addTerm");
776 
777  $this->toolbar->addSeparator();
778 
779  //ilEditClipboard::getAction() == "copy"
780  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
781  if ($this->user->clipboardHasObjectsOfType("term")) {
782  $this->toolbar->addButton(
783  $this->lng->txt("paste"),
784  $this->ctrl->getLinkTarget($this, "pasteTerms")
785  );
786  $this->toolbar->addButton(
787  $this->lng->txt("clear_clipboard"),
788  $this->ctrl->getLinkTarget($this, "clearClipboard")
789  );
790  } else {
791  $this->toolbar->addButton(
792  $this->lng->txt("glo_add_from_other"),
793  $this->ctrl->getLinkTargetByClass("ilglossaryforeigntermcollectorgui", "")
794  );
795  }
796 
797  if (is_object($this->tax)) {
798  $this->toolbar->addSeparator();
799  if ($_GET["show_tax"]) {
800  $this->toolbar->addButton(
801  $this->lng->txt("glo_hide_taxonomy"),
802  $this->ctrl->getLinkTarget($this, "deactTaxonomy")
803  );
804  } else {
805  $this->toolbar->addButton(
806  $this->lng->txt("glo_show_taxonomy"),
807  $this->ctrl->getLinkTarget($this, "actTaxonomy")
808  );
809  }
810  }
811 
812  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
813  $tab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
814  $this->tpl->setContent($tab->getHTML());
815  }
816 
823  public function actTaxonomy()
824  {
825  $this->ctrl->setParameter($this, "show_tax", 1);
826  $this->ctrl->redirect($this, "listTerms");
827  }
828 
835  public function deactTaxonomy()
836  {
837  $this->ctrl->setParameter($this, "show_tax", "");
838  $this->ctrl->redirect($this, "listTerms");
839  }
840 
841 
847  public function showActions($a_actions)
848  {
849  foreach ($a_actions as $name => $lng) {
850  $d[$name] = array("name" => $name, "lng" => $lng);
851  }
852 
853  $notoperations = array();
854  $operations = array();
855 
856  $operations = $d;
857 
858  if (count($operations) > 0) {
859  foreach ($operations as $val) {
860  $this->tpl->setCurrentBlock("tbl_action_btn");
861  $this->tpl->setVariable("BTN_NAME", $val["name"]);
862  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
863  $this->tpl->parseCurrentBlock();
864  }
865 
866  $this->tpl->setCurrentBlock("tbl_action_row");
867  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
868  $this->tpl->parseCurrentBlock();
869  }
870  }
871 
875  public function addTerm()
876  {
877  if (trim($_POST["new_term"]) == "") {
878  ilUtil::sendFailure($this->lng->txt("cont_please_enter_a_term"), true);
879  $this->ctrl->redirect($this, "listTerms");
880  }
881 
882  // add term
883  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
884  $term = new ilGlossaryTerm();
885  $term->setGlossary($this->object);
886  $term->setTerm(ilUtil::stripSlashes($_POST["new_term"]));
887  $term->setLanguage($_POST["term_language"]);
888  $_SESSION["il_text_lang_" . $_GET["ref_id"]] = $_POST["term_language"];
889  $term->create();
890 
891  // add first definition
892  $def = new ilGlossaryDefinition();
893  $def->setTermId($term->getId());
894  $def->setTitle(ilUtil::stripSlashes($_POST["new_term"]));
895  $def->create();
896 
897  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
898  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def->getId());
899  $this->ctrl->redirectByClass(array("ilglossarytermgui",
900  "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
901  }
902 
906  public function moveDefinitionUp()
907  {
908  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
909 
910  $definition = new ilGlossaryDefinition($_GET["def"]);
911  $definition->moveUp();
912 
913  $this->ctrl->redirect($this, "listTerms");
914  }
915 
919  public function moveDefinitionDown()
920  {
921  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
922 
923  $definition = new ilGlossaryDefinition($_GET["def"]);
924  $definition->moveDown();
925 
926  $this->ctrl->redirect($this, "listTerms");
927  }
928 
932  public function confirmDefinitionDeletion()
933  {
934  //$this->getTemplate();
935  //$this->displayLocator();
936  //$this->setTabs();
937 
938  $term = new ilGlossaryTerm($this->term_id);
939 
940  $add = "";
941  $nr = ilGlossaryTerm::getNumberOfUsages($this->term_id);
942  if ($nr > 0) {
943  $this->ctrl->setParameterByClass(
944  "ilglossarytermgui",
945  "term_id",
946  $this->term_id
947  );
948  $link = "[<a href='" .
949  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") .
950  "'>" . $this->lng->txt("glo_list_usages") . "</a>]";
951  $add = "<br/>" . sprintf($this->lng->txt("glo_term_is_used_n_times"), $nr) . " " . $link;
952  }
953 
954  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
955  $cgui = new ilConfirmationGUI();
956  $cgui->setHeaderText($this->lng->txt("info_delete_sure") . $add);
957 
958  $cgui->setFormAction($this->ctrl->getFormAction($this));
959  $cgui->setCancel($this->lng->txt("cancel"), "cancelDefinitionDeletion");
960  $cgui->setConfirm($this->lng->txt("confirm"), "deleteDefinition");
961 
962  // content style
963  $this->setContentStyleSheet($this->tpl);
964 
965  // syntax style
966  $this->tpl->setCurrentBlock("SyntaxStyle");
967  $this->tpl->setVariable(
968  "LOCATION_SYNTAX_STYLESHEET",
970  );
971  $this->tpl->parseCurrentBlock();
972 
973  $definition = new ilGlossaryDefinition($_GET["def"]);
974  $page_gui = new ilGlossaryDefPageGUI($definition->getId());
975  $page_gui->setTemplateOutput(false);
976  $page_gui->setStyleId($this->object->getStyleSheetId());
977  $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $_GET["ref_id"]);
978  $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $_GET["ref_id"]);
979  $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $_GET["ref_id"]);
980  $output = $page_gui->preview();
981 
982  $cgui->addItem("def", $_GET["def"], $term->getTerm() . $output);
983 
984  $this->tpl->setContent($cgui->getHTML());
985  }
986 
987  public function cancelDefinitionDeletion()
988  {
989  $this->ctrl->redirect($this, "listTerms");
990  }
991 
992 
993  public function deleteDefinition()
994  {
995  $definition = new ilGlossaryDefinition($_REQUEST["def"]);
996  $definition->delete();
997  $this->ctrl->redirect($this, "listTerms");
998  }
999 
1003  public function editTerm()
1004  {
1005  // deprecated
1006  }
1007 
1008 
1012  public function updateTerm()
1013  {
1014  $term = new ilGlossaryTerm($this->term_id);
1015 
1016  $term->setTerm(ilUtil::stripSlashes($_POST["term"]));
1017  $term->setLanguage($_POST["term_language"]);
1018  $term->update();
1019  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1020  $this->ctrl->redirect($this, "listTerms");
1021  }
1022 
1023 
1024 
1028  public function export()
1029  {
1030  $this->checkPermission("write");
1031 
1032  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1033  $glo_exp = new ilGlossaryExport($this->object);
1034  $glo_exp->buildExportFile();
1035  $this->ctrl->redirectByClass("ilexportgui", "");
1036  }
1037 
1041  public function exportHTML()
1042  {
1043  require_once("./Modules/Glossary/classes/class.ilGlossaryExport.php");
1044  $glo_exp = new ilGlossaryExport($this->object, "html");
1045  $glo_exp->buildExportFile();
1046  //echo $this->tpl->get();
1047  $this->ctrl->redirectByClass("ilexportgui", "");
1048  }
1049 
1053  public function publishExportFile()
1054  {
1055  $ilErr = $this->error;
1056 
1057  if (!isset($_POST["file"])) {
1058  $ilErr->raiseError($this->lng->txt("no_checkbox"), $ilErr->MESSAGE);
1059  }
1060  if (count($_POST["file"]) > 1) {
1061  $ilErr->raiseError($this->lng->txt("cont_select_max_one_item"), $ilErr->MESSAGE);
1062  }
1063 
1064  $file = explode(":", $_POST["file"][0]);
1065  $export_dir = $this->object->getExportDirectory($file[0]);
1066 
1067  if ($this->object->getPublicExportFile($file[0]) ==
1068  $file[1]) {
1069  $this->object->setPublicExportFile($file[0], "");
1070  } else {
1071  $this->object->setPublicExportFile($file[0], $file[1]);
1072  }
1073  $this->object->update();
1074  $this->ctrl->redirectByClass("ilexportgui", "");
1075  }
1076 
1077  /*
1078  * list all export files
1079  */
1080  public function viewExportLog()
1081  {
1082  }
1083 
1087  public function confirmTermDeletion()
1088  {
1089  //$this->prepareOutput();
1090  if (!isset($_POST["id"])) {
1091  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1092  $this->ctrl->redirect($this, "listTerms");
1093  }
1094 
1095  // check ids
1096  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1097  include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
1098  foreach ($_POST["id"] as $term_id) {
1099  $term_glo_id = ilGlossaryTerm::_lookGlossaryID((int) $term_id);
1100  if ($term_glo_id != $this->object->getId() && !ilGlossaryTermReferences::isReferenced($this->object->getId(), $term_id)) {
1101  ilUtil::sendFailure($this->lng->txt("glo_term_must_belong_to_glo"), true);
1102  $this->ctrl->redirect($this, "listTerms");
1103  }
1104  }
1105 
1106  // display confirmation message
1107  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1108  $cgui = new ilConfirmationGUI();
1109  $cgui->setFormAction($this->ctrl->getFormAction($this));
1110  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1111  $cgui->setCancel($this->lng->txt("cancel"), "cancelTermDeletion");
1112  $cgui->setConfirm($this->lng->txt("confirm"), "deleteTerms");
1113 
1114  include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
1115 
1116  foreach ($_POST["id"] as $id) {
1117  $term = new ilGlossaryTerm($id);
1118 
1119  $add = "";
1121  if ($nr > 0) {
1122  $this->ctrl->setParameterByClass(
1123  "ilglossarytermgui",
1124  "term_id",
1125  $id
1126  );
1127 
1128  if (ilGlossaryTermReferences::isReferenced($this->object->getId(), $id)) {
1129  $add = " (" . $this->lng->txt("glo_term_reference") . ")";
1130  } else {
1131  $link = "[<a href='" .
1132  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") .
1133  "'>" . $this->lng->txt("glo_list_usages") . "</a>]";
1134  $add = "<div class='small'>" .
1135  sprintf($this->lng->txt("glo_term_is_used_n_times"), $nr) . " " . $link . "</div>";
1136  }
1137  }
1138 
1139  $cgui->addItem("id[]", $id, $term->getTerm() . $add);
1140  }
1141 
1142  $this->tpl->setContent($cgui->getHTML());
1143  }
1144 
1150  public function cancelTermDeletion()
1151  {
1152  $this->ctrl->redirect($this, "listTerms");
1153  }
1154 
1158  public function deleteTerms()
1159  {
1160  include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
1161  foreach ($_POST["id"] as $id) {
1162  if (ilGlossaryTermReferences::isReferenced($this->object->getId(), $id)) {
1163  $refs = new ilGlossaryTermReferences($this->object->getId());
1164  $refs->deleteTerm($id);
1165  $refs->update();
1166  } else {
1167  $term = new ilGlossaryTerm($id);
1168  $term->delete();
1169  }
1170  }
1171  $this->ctrl->redirect($this, "listTerms");
1172  }
1173 
1181  public function setLocator($a_tree = "", $a_id = "")
1182  {
1183  if (strtolower($_GET["baseClass"]) != "ilglossaryeditorgui") {
1184  parent::setLocator($a_tree, $a_id);
1185  } else {
1186  if (is_object($this->object)) {
1187  require_once("./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php");
1188  $gloss_loc = new ilGlossaryLocatorGUI();
1189  if (is_object($this->term)) {
1190  $gloss_loc->setTerm($this->term);
1191  }
1192  $gloss_loc->setGlossary($this->object);
1193  //$gloss_loc->setDefinition($this->definition);
1194  $gloss_loc->display();
1195  }
1196  }
1197  }
1198 
1202  public function view()
1203  {
1204  //$this->prepareOutput();
1205  $this->viewObject();
1206  }
1207 
1211  public function create()
1212  {
1213  switch ($_POST["new_type"]) {
1214  case "term":
1215  $term_gui = new ilGlossaryTermGUI();
1216  $term_gui->create();
1217  break;
1218  }
1219  }
1220 
1221  public function saveTerm()
1222  {
1223  $term_gui = new ilGlossaryTermGUI();
1224  $term_gui->setGlossary($this->object);
1225  $term_gui->save();
1226 
1227  ilUtil::sendSuccess($this->lng->txt("cont_added_term"), true);
1228 
1229  //ilUtil::redirect("glossary_edit.php?ref_id=".$_GET["ref_id"]."&cmd=listTerms");
1230  $this->ctrl->redirect($this, "listTerms");
1231  }
1232 
1233 
1237  public function addDefinition()
1238  {
1239  $term_id = (int) $_GET["term_id"];
1240 
1241  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1242  $term_glo_id = ilGlossaryTerm::_lookGlossaryID((int) $term_id);
1243  if ($term_glo_id != $this->object->getId()) {
1244  ilUtil::sendFailure($this->lng->txt("glo_term_must_belong_to_glo"), true);
1245  $this->ctrl->redirect($this, "listTerms");
1246  }
1247 
1248  // add term
1249  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1250  $term = new ilGlossaryTerm($term_id);
1251 
1252  // add first definition
1253  $def = new ilGlossaryDefinition();
1254  $def->setTermId($term->getId());
1255  $def->setTitle(ilUtil::stripSlashes($term->getTerm()));
1256  $def->create();
1257 
1258  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
1259  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def->getId());
1260  $this->ctrl->redirectByClass(array("ilglossarytermgui",
1261  "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
1262  }
1263 
1264  public function getTemplate()
1265  {
1266  $this->tpl->getStandardTemplate();
1267 
1268  $title = $this->object->getTitle();
1269 
1270 
1271  if ($this->term_id > 0) {
1272  $this->tpl->setTitle($this->lng->txt("term") . ": " .
1273  ilGlossaryTerm::_lookGlossaryTerm($this->term_id));
1274  } else {
1275  parent::setTitleAndDescription();
1276  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
1277  $this->tpl->setTitle($this->lng->txt("glo") . ": " . $title);
1278  }
1279  }
1280 
1284  public function setTabs()
1285  {
1286  $this->getTabs();
1287  }
1288 
1292  public function getTabs()
1293  {
1294  $this->help->setScreenIdComponent("glo");
1295 
1296  // list terms
1297  $force_active = ($_GET["cmd"] == "" || $_GET["cmd"] == "listTerms")
1298  ? true
1299  : false;
1300  $this->tabs_gui->addTarget(
1301  "cont_terms",
1302  $this->ctrl->getLinkTarget($this, "listTerms"),
1303  array("listTerms", ""),
1304  get_class($this),
1305  "",
1306  $force_active
1307  );
1308 
1309  $force_active = false;
1310  if ($this->ctrl->getCmd() == "showSummary" ||
1311  strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui") {
1312  $force_active = true;
1313  }
1314  $this->tabs_gui->addTarget(
1315  "info_short",
1316  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"),
1317  "",
1318  "ilInfoScreenGUI",
1319  "",
1320  $force_active
1321  );
1322 
1323  // properties
1324  if ($this->rbacsystem->checkAccess('write', $this->object->getRefId())) {
1325  $this->tabs_gui->addTarget(
1326  "settings",
1327  $this->ctrl->getLinkTarget($this, "properties"),
1328  "properties",
1329  get_class($this)
1330  );
1331 
1332  // meta data
1333  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1334  $mdgui = new ilObjectMetaDataGUI($this->object, "term");
1335  $mdtab = $mdgui->getTab();
1336  if ($mdtab) {
1337  $this->tabs_gui->addTarget(
1338  "meta_data",
1339  $mdtab,
1340  "",
1341  "ilobjectmetadatagui"
1342  );
1343  }
1344 
1345  // export
1346  /*$tabs_gui->addTarget("export",
1347  $this->ctrl->getLinkTarget($this, "exportList"),
1348  array("exportList", "viewExportLog"), get_class($this));*/
1349 
1350  // export
1351  $this->tabs_gui->addTarget(
1352  "export",
1353  $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1354  "",
1355  "ilexportgui"
1356  );
1357  }
1358 
1359  // permissions
1360  if ($this->rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
1361  /*$tabs_gui->addTarget("permission_settings",
1362  $this->ctrl->getLinkTarget($this, "perm"),
1363  array("perm", "info"),
1364  get_class($this));
1365  */
1366  $this->tabs_gui->addTarget(
1367  "perm_settings",
1368  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1369  array("perm","info","owner"),
1370  'ilpermissiongui'
1371  );
1372  }
1373 
1374  $this->tabs_gui->addNonTabbedLink(
1375  "presentation_view",
1376  $this->lng->txt("glo_presentation_view"),
1377  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $this->object->getRefID(),
1378  "_top"
1379  );
1380  }
1381 
1385  public function setSettingsSubTabs($a_active)
1386  {
1387  if (in_array(
1388  $a_active,
1389  array("general_settings", "style", "taxonomy", "glossaries")
1390  )) {
1391  // general properties
1392  $this->tabs->addSubTab(
1393  "general_settings",
1394  $this->lng->txt("settings"),
1395  $this->ctrl->getLinkTarget($this, 'properties')
1396  );
1397 
1398  // style properties
1399  $this->tabs->addSubTab(
1400  "style",
1401  $this->lng->txt("obj_sty"),
1402  $this->ctrl->getLinkTarget($this, 'editStyleProperties')
1403  );
1404 
1405  // taxonomy
1406  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1408  $this->tabs->addSubTab(
1409  "taxonomy",
1410  $this->lng->txt("tax_taxonomy"),
1411  $this->ctrl->getLinkTargetByClass("ilobjtaxonomygui", '')
1412  );
1413 
1414  // style properties
1415  $this->tabs->addSubTab(
1416  "glossaries",
1417  $this->lng->txt("cont_auto_glossaries"),
1418  $this->ctrl->getLinkTarget($this, 'editGlossaries')
1419  );
1420 
1421  $this->tabs->activateSubTab($a_active);
1422  }
1423  }
1424 
1425 
1431  public static function _goto($a_target)
1432  {
1433  global $DIC;
1434 
1435  $lng = $DIC->language();
1436  $ilAccess = $DIC->access();
1437  $ilErr = $DIC["ilErr"];
1438 
1439  if ($ilAccess->checkAccess("read", "", $a_target)) {
1440  $_GET["ref_id"] = $a_target;
1441  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1442  include("ilias.php");
1443  exit;
1444  } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
1445  $_GET["ref_id"] = $a_target;
1446  $_GET["cmd"] = "infoScreen";
1447  $_GET["baseClass"] = "ilGlossaryPresentationGUI";
1448  include("ilias.php");
1449  exit;
1450  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1451  ilUtil::sendFailure(sprintf(
1452  $lng->txt("msg_no_perm_read_item"),
1454  ), true);
1456  }
1457 
1458  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
1459  }
1460 
1464  public function applyFilter()
1465  {
1466  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
1467  $prtab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
1468  $prtab->resetOffset();
1469  $prtab->writeFilterToSession();
1470  $this->listTerms();
1471  }
1472 
1477  public function resetFilter()
1478  {
1479  include_once("./Modules/Glossary/classes/class.ilTermListTableGUI.php");
1480  $prtab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
1481  $prtab->resetOffset();
1482  $prtab->resetFilter();
1483  $this->listTerms();
1484  }
1485 
1486 
1490 
1494  public function setContentStyleSheet($a_tpl = null)
1495  {
1496  if ($a_tpl != null) {
1497  $ctpl = $a_tpl;
1498  } else {
1499  $ctpl = $this->tpl;
1500  }
1501 
1502  $ctpl->setCurrentBlock("ContentStyle");
1503  $ctpl->setVariable(
1504  "LOCATION_CONTENT_STYLESHEET",
1505  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
1506  );
1507  $ctpl->parseCurrentBlock();
1508  }
1509 
1510 
1514  public function editStyleProperties()
1515  {
1516  $this->checkPermission("write");
1517 
1518  $this->initStylePropertiesForm();
1519  $this->tpl->setContent($this->form->getHTML());
1520 
1521  $this->tabs->activateTab("settings");
1522  $this->setSettingsSubTabs("style");
1523  }
1524 
1528  public function initStylePropertiesForm()
1529  {
1530  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1531  $this->lng->loadLanguageModule("style");
1532 
1533  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1534  $this->form = new ilPropertyFormGUI();
1535 
1536  $fixed_style = $this->setting->get("fixed_content_style_id");
1537  $style_id = $this->object->getStyleSheetId();
1538 
1539  if ($fixed_style > 0) {
1540  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
1541  $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
1542  $this->lng->txt("global_fixed") . ")");
1543  $this->form->addItem($st);
1544  } else {
1546  true,
1547  false,
1548  $_GET["ref_id"]
1549  );
1550 
1551  $st_styles[0] = $this->lng->txt("default");
1552  ksort($st_styles);
1553 
1554  if ($style_id > 0) {
1555  // individual style
1556  if (!ilObjStyleSheet::_lookupStandard($style_id)) {
1557  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
1558  $st->setValue(ilObject::_lookupTitle($style_id));
1559  $this->form->addItem($st);
1560 
1561  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
1562 
1563  // delete command
1564  $this->form->addCommandButton(
1565  "editStyle",
1566  $this->lng->txt("style_edit_style")
1567  );
1568  $this->form->addCommandButton(
1569  "deleteStyle",
1570  $this->lng->txt("style_delete_style")
1571  );
1572  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
1573  }
1574  }
1575 
1576  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
1577  $style_sel = ilUtil::formSelect(
1578  $style_id,
1579  "style_id",
1580  $st_styles,
1581  false,
1582  true
1583  );
1584  $style_sel = new ilSelectInputGUI($this->lng->txt("style_current_style"), "style_id");
1585  $style_sel->setOptions($st_styles);
1586  $style_sel->setValue($style_id);
1587  $this->form->addItem($style_sel);
1588  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
1589  $this->form->addCommandButton(
1590  "saveStyleSettings",
1591  $this->lng->txt("save")
1592  );
1593  $this->form->addCommandButton(
1594  "createStyle",
1595  $this->lng->txt("sty_create_ind_style")
1596  );
1597  }
1598  }
1599  $this->form->setTitle($this->lng->txt("glo_style"));
1600  $this->form->setFormAction($this->ctrl->getFormAction($this));
1601  }
1602 
1606  public function createStyle()
1607  {
1608  $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
1609  }
1610 
1614  public function editStyle()
1615  {
1616  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
1617  }
1618 
1622  public function deleteStyle()
1623  {
1624  $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
1625  }
1626 
1630  public function saveStyleSettings()
1631  {
1632  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1633  if ($this->setting->get("fixed_content_style_id") <= 0 &&
1634  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1635  || $this->object->getStyleSheetId() == 0)) {
1636  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1637  $this->object->update();
1638  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1639  }
1640  $this->ctrl->redirect($this, "editStyleProperties");
1641  }
1642 
1646  public function getPublicAccessColValue($a_type, $a_file)
1647  {
1648  if ($this->object->getPublicExportFile($a_type) == $a_file) {
1649  return $this->lng->txt("yes");
1650  }
1651 
1652  return " ";
1653  }
1654 
1661  public function showTaxonomy()
1662  {
1663  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
1664  $tax_ids = ilObjTaxonomy::getUsageOfObject($this->object->getId());
1665  if (count($tax_ids) > 0) {
1666  include_once("./Services/Taxonomy/classes/class.ilTaxonomyExplorerGUI.php");
1667  $tax_exp = new ilTaxonomyExplorerGUI(
1668  $this,
1669  "showTaxonomy",
1670  $tax_ids[0],
1671  "ilobjglossarygui",
1672  "listTerms"
1673  );
1674  if (!$tax_exp->handleCommand()) {
1675  //$this->tpl->setLeftNavContent($tax_exp->getHTML());
1676  $this->tpl->setLeftNavContent($tax_exp->getHTML() . "&nbsp;");
1677  }
1678  }
1679  }
1680 
1681  //
1682  // Auto glossaries
1683  //
1684 
1691  public function editGlossaries()
1692  {
1693  $this->tabs->setTabActive("settings");
1694  $this->setSettingsSubTabs("glossaries");
1695 
1696  $this->toolbar->addButton(
1697  $this->lng->txt("add"),
1698  $this->ctrl->getLinkTarget($this, "showGlossarySelector")
1699  );
1700 
1701  include_once("./Modules/Glossary/classes/class.ilGlossaryAutoLinkTableGUI.php");
1702  $tab = new ilGlossaryAutoLinkTableGUI($this->object, $this, "editGlossaries");
1703 
1704  $this->tpl->setContent($tab->getHTML());
1705  }
1706 
1713  public function showGlossarySelector()
1714  {
1715  $this->tabs->setTabActive("settings");
1716  $this->setSettingsSubTabs("glossaries");
1717 
1718  include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
1719 
1720  $exp = new ilSearchRootSelector($this->ctrl->getLinkTarget($this, 'showGlossarySelector'));
1721  $exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $this->tree->readRootId());
1722  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showGlossarySelector'));
1723  $exp->setTargetClass(get_class($this));
1724  $exp->setCmd('confirmGlossarySelection');
1725  $exp->setClickableTypes(array("glo"));
1726  $exp->addFilter("glo");
1727 
1728  // build html-output
1729  $exp->setOutput(0);
1730  $this->tpl->setContent($exp->getOutput());
1731  }
1732 
1736  public function confirmGlossarySelection()
1737  {
1738  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1739  $cgui = new ilConfirmationGUI();
1740  $this->ctrl->setParameter($this, "glo_ref_id", $_GET["root_id"]);
1741  $cgui->setFormAction($this->ctrl->getFormAction($this));
1742  $cgui->setHeaderText($this->lng->txt("glo_link_glo_in_glo"));
1743  $cgui->setCancel($this->lng->txt("no"), "selectGlossary");
1744  $cgui->setConfirm($this->lng->txt("yes"), "selectGlossaryLink");
1745  $this->tpl->setContent($cgui->getHTML());
1746  }
1747 
1754  public function selectGlossaryLink()
1755  {
1756  $glo_ref_id = (int) $_GET["glo_ref_id"];
1757  $glo_id = ilObject::_lookupObjId($glo_ref_id);
1758  $this->object->autoLinkGlossaryTerms($glo_ref_id);
1759  $this->selectGlossary();
1760  }
1761 
1762 
1769  public function selectGlossary()
1770  {
1771  $glos = $this->object->getAutoGlossaries();
1772  $glo_ref_id = (int) $_GET["glo_ref_id"];
1773  $glo_id = ilObject::_lookupObjId($glo_ref_id);
1774  if (!in_array($glo_id, $glos)) {
1775  $glos[] = $glo_id;
1776  }
1777  $this->object->setAutoGlossaries($glos);
1778  $this->object->update();
1779 
1780  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1781  $this->ctrl->redirect($this, "editGlossaries");
1782  }
1783 
1790  public function removeGlossary()
1791  {
1792  $this->object->removeAutoGlossary((int) $_GET["glo_id"]);
1793  $this->object->update();
1794 
1795  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1796  $this->ctrl->redirect($this, "editGlossaries");
1797  }
1798 
1805  public function copyTerms()
1806  {
1807  $items = ilUtil::stripSlashesArray($_POST["id"]);
1808  if (!is_array($items)) {
1809  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1810  $this->ctrl->redirect($this, "listTerms");
1811  }
1812 
1813  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
1814  $this->user->clipboardDeleteObjectsOfType("term");
1815 
1816  // put them into the clipboard
1817  $time = date("Y-m-d H:i:s", time());
1818  $order = 0;
1819  foreach ($items as $id) {
1820  $this->user->addObjectToClipboard(
1821  $id,
1822  "term",
1824  0,
1825  $time,
1826  $order
1827  );
1828  }
1829 
1831  ilUtil::sendInfo($this->lng->txt("glo_selected_terms_have_been_copied"), true);
1832  $this->ctrl->redirect($this, "listTerms");
1833  }
1834 
1841  public function referenceTerms()
1842  {
1843  $items = ilUtil::stripSlashesArray($_POST["id"]);
1844  if (!is_array($items)) {
1845  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1846  $this->ctrl->redirect($this, "listTerms");
1847  }
1848 
1849  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
1850  $this->user->clipboardDeleteObjectsOfType("term");
1851 
1852  // put them into the clipboard
1853  $time = date("Y-m-d H:i:s", time());
1854  $order = 0;
1855  foreach ($items as $id) {
1856  $this->user->addObjectToClipboard(
1857  $id,
1858  "term",
1860  0,
1861  $time,
1862  $order
1863  );
1864  }
1865 
1867  ilUtil::sendInfo($this->lng->txt("glo_selected_terms_have_been_copied"), true);
1868  $this->ctrl->redirect($this, "listTerms");
1869  }
1870 
1871 
1878  public function clearClipboard()
1879  {
1880  $this->user->clipboardDeleteObjectsOfType("term");
1881  $this->ctrl->redirect($this, "listTerms");
1882  }
1883 
1887  public function pasteTerms()
1888  {
1889  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
1890  if (ilEditClipboard::getAction() == "copy") {
1891  foreach ($this->user->getClipboardObjects("term") as $item) {
1892  ilGlossaryTerm::_copyTerm($item["id"], $this->object->getId());
1893  }
1894  }
1895  if (ilEditClipboard::getAction() == "link") {
1896  include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
1897  $refs = new ilGlossaryTermReferences($this->object->getId());
1898  foreach ($this->user->getClipboardObjects("term") as $item) {
1899  $refs->addTerm($item["id"]);
1900  }
1901  $refs->update();
1902  }
1903  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1904  $this->ctrl->redirect($this, "listTerms");
1905  }
1906 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
__construct($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor public.
static getInstance(ilObjGlossaryGUI $a_glossary_gui)
Get instance.
Class ilGlossaryGUI.
This class represents an option in a radio group.
Class ilObjectMetaDataGUI.
showInfoScreen()
Show info screen.
saveObject()
save new content object to db
Class ilInfoScreenGUI.
static isReferenced($a_glo_id, $a_term_id)
Is a term referenced by one or multiple glossaries.
setSettingsSubTabs($a_active)
Set sub tabs.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
setTemplateOutput($a_output=true)
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
cancelTermDeletion()
cancel deletion of object
This class represents a property form user interface.
GUI class for the workflow of copying objects.
global $DIC
Definition: saml.php:7
const TITLE_LENGTH
max length of object title
deleteTerms()
delete selected terms
$_GET["client_id"]
editGlossaries()
Edit automatically linked glossaries.
static getNumberOfUsages($a_term_id)
Get number of usages.
Class ilGlossaryTerm.
This class represents a section header in a property form.
moveDefinitionUp()
move a definiton up
Class ilObjGlossary.
initSettingsForm($a_mode="edit")
Init settings form.
Taxonomy explorer GUI class.
if(!array_key_exists('StateId', $_REQUEST)) $id
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
executeCommand()
execute command
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
removeGlossary()
Remove lm glossary.
exportHTML()
create html package
createObject()
create new object form
export()
export content object
showActions($a_actions)
show possible action (form buttons)
resetFilter()
Reset filter (note: this function existed before data table filter has been introduced.
setInfo($a_info)
Set Info.
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
editStyleProperties()
Edit style properties.
showTaxonomy()
Show taxonomy.
static _lookupStandard($a_id)
Lookup standard flag.
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$section
Definition: Utf8Test.php:83
$time
Definition: cron.php:21
$a_type
Definition: workflow.php:92
Export User Interface Class.
moveDefinitionDown()
move a definiton down
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
prepareOutput($a_show_subobjects=true)
prepare output
if($format !==null) $name
Definition: metadata.php:146
This class represents a property in a property form.
TableGUI class for auto link glossaries.
setValue($a_value)
Set Value.
deactTaxonomy()
Hide Taxonomy.
if(isset($_POST['submit'])) $form
Taxonomy GUI class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
confirmGlossarySelection()
Confirm glossary selection.
actTaxonomy()
Show Taxonomy.
selectGlossaryLink()
Select a glossary and link all its terms.
create()
create new (subobject) in glossary
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
saveProperties()
save properties
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
setValue($a_value)
Set Value.
omitLocator($a_omit=true)
setSize($a_size)
Set Size.
static addUsagesToInfo($info, $glo_id)
Add usages to info.
This class represents a text property in a property form.
GUI class for glossary terms.
setMaxLength($a_maxlength)
Set Max Length.
confirmTermDeletion()
confirm term deletion
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
setOptions($a_options)
Set Options.
static updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Update service settings.
Create styles array
The data for the language used.
addDefinition()
add definition
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setLocator($a_tree="", $a_id="")
set Locator
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
static _lookGlossaryID($term_id)
get glossary id form term id
Class ilGlossaryDefinition.
static _copyTerm($a_term_id, $a_glossary_id)
Copy a term to a glossary.
setContentStyleSheet($a_tpl=null)
Set content style sheet.
static getScormModulesForGlossary($a_glo_id)
Get SCORM modules that assign a certain glossary.
properties()
edit properties of object (admin form)
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
This class represents a non editable value in a property form.
Create new PHPExcel object
obj_idprivate
Class ilObjStyleSheetGUI.
static _goto($a_target)
redirect script
This class represents a text area property in a property form.
Glossary definition page GUI class.
$ret
Definition: parser.php:6
static initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Init service settings form.
selectGlossary()
Select lm glossary.
getCreationMode()
get creation mode
referenceTerms()
Reference terms.
$def
Definition: croninfo.php:21
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
confirmDefinitionDeletion()
deletion confirmation screen
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static getLogger($a_component_id)
Get component logger.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Export class for content objects.
getPublicAccessColValue($a_type, $a_file)
Get public access value for export table.
static yn2tf($a_yn)
convert "y"/"n" to true/false
showGlossarySelector()
Select LM Glossary.
$info
Definition: index.php:5
static setAction($a_action)
publishExportFile()
download export file
static redirect($a_script)
addHeaderAction()
Add header action menu.
saveStyleSettings()
Save style settings.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
$cols
Definition: xhr_table.php:11
static _lookGlossaryTerm($term_id)
get glossary term
$_POST["username"]
Input for adv meta data column sorting in glossaries.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static setShortTextsDirty($a_glo_id)
Set short texts dirty.
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view...
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
Class ilECSGlossarySettings.
setLocator()
set Locator
initStylePropertiesForm()
Init style properties form.
Confirmation screen class.
clearClipboard()
Clear clipboard.
static loadLanguageModule()
Load language module.