ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilNoteGUI.php
Go to the documentation of this file.
1 <?php
2 
22 
26 class ilNoteGUI
27 {
31  protected ?array $notes = null;
32  protected \ILIAS\Notes\InternalGUIService $gui;
33  protected string $search_text;
34  protected \ILIAS\Notes\AccessManager $notes_access;
35  protected \ILIAS\Notes\InternalDataService $data;
38  protected bool $public_enabled;
41  protected bool $targets_enabled = false;
42  protected bool $export_html = false;
43  protected bool $print = false;
44  protected bool $comments_settings = false;
45  protected string $obj_type;
46  protected bool $private_enabled;
47  protected bool $edit_note_form;
48  protected bool $add_note_form;
49  protected bool $ajax;
50  protected bool $inc_sub;
51  protected int $obj_id;
55  protected $rep_obj_id;
56  protected ilCtrl $ctrl;
57  protected ilLanguage $lng;
58  protected ilObjUser $user;
59  protected ilSetting $settings;
61  protected ilTree $tree;
63  public bool $public_deletion_enabled = false;
64  public bool $repository_mode = false;
65  public bool $old = false;
66  protected string $default_command = "getListHTML";
67  protected array $observer = [];
68  protected \ILIAS\DI\UIServices $ui;
69  protected int $news_id = 0;
70  protected bool $hide_new_form = false;
71  protected bool $only_latest = false; // Show only latest note/comment
72  protected string $widget_header = "";
73  protected bool $no_actions = false; // Do not show edit/delete actions
74  protected bool $enable_sorting = true;
75  protected bool $user_img_export_html = false;
76  protected ilLogger $log;
77  protected ilTemplate $form_tpl;
78  protected int $note_type = Note::PRIVATE;
79  protected int $requested_note_id = 0;
80  protected string $requested_note_mess = "";
81  protected int $requested_news_id = 0;
82  protected bool $delete_note = false;
83  protected string $note_mess = "";
84  protected array $item_list_gui = [];
85  protected bool $use_obj_title_header = true;
86  protected bool $show_empty_list_message = true;
87  protected bool $show_header = true;
88  protected int $recipient = 0;
89 
99  public function __construct(
100  $a_rep_obj_id = 0,
101  int $a_obj_id = 0,
102  string $a_obj_type = "",
103  bool $a_include_subobjects = false,
104  int $a_news_id = 0,
105  bool $ajax = true,
106  string $search_text = ""
107  ) {
108  global $DIC;
109  $this->user = $DIC->user();
110  $this->settings = $DIC->settings();
111  $this->obj_definition = $DIC["objDefinition"];
112  $this->tree = $DIC->repositoryTree();
113  $this->access = $DIC->access();
114  $this->ui = $DIC->ui();
115  $ilCtrl = $DIC->ctrl();
116  $this->lng = $DIC->language();
117  $this->log = ilLoggerFactory::getLogger('note');
118  $this->search_text = $search_text;
119 
120  $ns = $DIC->notes()->internal();
121  $this->manager = $ns
122  ->domain()
123  ->notes();
124  $this->request = $ns
125  ->gui()
126  ->standardRequest();
127  $this->data = $ns->data();
128  $this->gui = $ns->gui();
129  $this->notes_access = $ns->domain()->noteAccess();
130 
131  $this->lng->loadLanguageModule("notes");
132 
133  $ilCtrl->saveParameter($this, "notes_only");
134 
135  $this->rep_obj_id = $a_rep_obj_id;
136  $this->obj_id = $a_obj_id;
137  $this->obj_type = $a_obj_type;
138  $this->inc_sub = $a_include_subobjects;
139  $this->news_id = $a_news_id;
140 
141  // auto-detect object type
142  if (!is_array($a_rep_obj_id) && !$this->obj_type && $a_rep_obj_id) {
143  $this->obj_type = ilObject::_lookupType($a_rep_obj_id);
144  }
145 
146  $this->ajax = $ajax;
147 
148  $this->ctrl = $ilCtrl;
149 
150  $this->add_note_form = false;
151  $this->edit_note_form = false;
152  $this->private_enabled = false;
153 
154  if (!is_array($this->rep_obj_id)) {
155  if ($this->manager->commentsActive($this->rep_obj_id)) {
156  $this->public_enabled = true;
157  } else {
158  $this->public_enabled = false;
159  }
160  }
161  $this->targets_enabled = false;
162  $this->export_html = false;
163  $this->print = false;
164  $this->comments_settings = false;
165 
166  // default: notes for repository objects
167  $this->setRepositoryMode(true);
168 
169  $this->ctrl->saveParameter($this, "note_type");
170  $this->requested_note_id = $this->request->getNoteId();
171  $this->requested_note_mess = $this->request->getNoteMess();
172  $this->requested_news_id = $this->request->getNewsId();
173  }
174 
175  public function setShowEmptyListMessage(bool $a_val): void
176  {
177  $this->show_empty_list_message = $a_val;
178  }
179 
180  public function getShowEmptyListMessage(): bool
181  {
183  }
184 
185  public function setShowHeader(bool $a_val): void
186  {
187  $this->show_header = $a_val;
188  }
189 
190  public function getShowHeader(): bool
191  {
192  return $this->show_header;
193  }
194 
195 
196  public function setUseObjectTitleHeader(bool $a_val): void
197  {
198  $this->use_obj_title_header = $a_val;
199  }
200 
201  public function getUseObjectTitleHeader(): bool
202  {
204  }
205 
206  public function setDefaultCommand(string $a_val): void
207  {
208  $this->default_command = $a_val;
209  }
210 
211  public function setHideNewForm(bool $a_val): void
212  {
213  $this->hide_new_form = $a_val;
214  }
215 
216  public function getDefaultCommand(): string
217  {
218  return $this->default_command;
219  }
220 
221  public function executeCommand()
222  {
223  $cmd = $this->ctrl->getCmd($this->getDefaultCommand());
224  $next_class = $this->ctrl->getNextClass($this);
225  switch ($next_class) {
226  case strtolower(ilCommentGUI::class):
227  $gui = $this->gui->getCommentsGUI(
228  $this->rep_obj_id,
229  $this->obj_id,
230  $this->obj_type,
231  $this->news_id,
232  $this->inc_sub,
233  $this->ajax,
234  $this->search_text
235  );
236  $gui->enableCommentsSettings($this->comments_settings);
237  $this->ctrl->forwardCommand($gui);
238  break;
239 
240  default:
241  return $this->$cmd();
242  }
243  }
244 
245  public function enablePrivateNotes(bool $a_enable = true): void
246  {
247  $this->private_enabled = $a_enable;
248  }
249 
250  public function enablePublicNotes(bool $a_enable = true): void
251  {
252  $this->public_enabled = $a_enable;
253  }
254 
255  public function enableCommentsSettings(bool $a_enable = true): void
256  {
257  $this->comments_settings = $a_enable;
258  }
259 
260  public function enablePublicNotesDeletion(bool $a_enable = true): void
261  {
262  $this->public_deletion_enabled = $a_enable;
263  }
264 
265  // enable target objects
266  public function enableTargets(bool $a_enable = true): void
267  {
268  $this->targets_enabled = $a_enable;
269  }
270 
271  public function setRepositoryMode(bool $a_value): void
272  {
273  $this->repository_mode = $a_value;
274  }
275 
276  public function getNotesHTML(): string
277  {
278  $ilCtrl = $this->ctrl;
279  $ilCtrl->setParameter($this, "notes_type", Note::PRIVATE);
280  return $this->getListHTML($a_init_form = true);
281  }
282 
283  public function getListHTML(bool $a_init_form = true): string
284  {
285  $ilUser = $this->user;
286  $lng = $this->lng;
287  $ilCtrl = $this->ctrl;
289 
290  $content = $this->getNoteListHTML($a_init_form);
291  return $this->renderContent($content);
292  }
293 
294  protected function renderComponents(array $components): string
295  {
296  if ($this->ctrl->isAsynch()) {
297  return $this->ui->renderer()->renderAsync($components);
298  }
299  return $this->ui->renderer()->render($components);
300  }
301 
302  // temporary forward to commentGUI
303  protected function getCommentsHTML(): string
304  {
305  $this->ctrl->redirectByClass(ilCommentGUI::class, "getListHTML", "", $this->ajax);
306  return "";
307  }
308 
309  public function activateComments(): void
310  {
311  $ilCtrl = $this->ctrl;
312 
313  if ($this->comments_settings) {
314  $this->manager->activateComments($this->rep_obj_id, true);
315  }
316 
317  $ilCtrl->redirectByClass(static::class, "getListHTML", "", $this->ajax);
318  }
319 
320  public function deactivateComments(): void
321  {
322  $ilCtrl = $this->ctrl;
323 
324  if ($this->comments_settings) {
325  $this->manager->activateComments($this->rep_obj_id, false);
326  }
327 
328  $ilCtrl->redirectByClass(static::class, "getListHTML", "", $this->ajax);
329  }
330 
334  protected function getNotes(): array
335  {
336  if ($this->notes === null) {
337  $ilUser = $this->user;
338  $filter = null;
339  if ($this->export_html || $this->print) {
340  if ($this->requested_note_id > 0) {
341  $filter = $this->requested_note_id;
342  } else {
343  $filter = $this->request->getNoteText();
344  }
345  }
346 
347  $ascending = $this->manager->getSortAscending();
348  if ($this->only_latest) {
349  $order = false;
350  }
351  $author_id = ($this->note_type === Note::PRIVATE)
352  ? $ilUser->getId()
353  : 0;
354 
355  if (!is_array($this->rep_obj_id)) {
356  $notes = $this->manager->getNotesForContext(
357  $this->data->context(
358  $this->rep_obj_id,
359  $this->obj_id,
360  $this->obj_type,
361  $this->news_id,
362  $this->repository_mode
363  ),
366  $author_id,
367  $ascending,
368  "",
370  );
371  } else {
372  $notes = $this->manager->getNotesForRepositoryObjIds(
373  $this->rep_obj_id,
374  $this->note_type,
375  $this->inc_sub,
376  $author_id,
377  $ascending,
378  "",
379  $this->search_text
380  );
381  }
382  $this->notes = $notes;
383  }
384  return $this->notes;
385  }
386 
387  public function getNoteListHTML(
388  bool $a_init_form = true
389  ): string {
390  $lng = $this->lng;
391  $ilCtrl = $this->ctrl;
392  $f = $this->ui->factory();
393  $ilUser = $this->user;
394 
395  $mtype = "";
396 
397  $notes = $this->getNotes();
398 
399  $tpl = new ilTemplate("tpl.notes_list.html", true, true, "components/ILIAS/Notes");
400 
401  // show counter if notes are hidden
402  $cnt_str = (count($notes) > 0)
403  ? " (" . count($notes) . ")"
404  : "";
405 
406  // origin header
407  $origin_header = $this->getOriginHeader();
408  if ($origin_header != "") {
409  $tpl->setCurrentBlock("title");
410  $tpl->setVariable("TITLE", $origin_header);
411  $tpl->parseCurrentBlock();
412  }
413 
414  $tpl->setVariable("TXT_NOTES", $this->getListTitle() . $cnt_str);
415  $anch = "";
416 
417  // show add new note text area
418  if (!$this->edit_note_form && !is_array($this->rep_obj_id) &&
419  !$this->hide_new_form && $ilUser->getId() !== ANONYMOUS_USER_ID) {
420  $tpl->setCurrentBlock("edit_note_form");
421  $b_caption = $this->getAddText();
422  $b = $this->ui->factory()->button()->standard(
423  $b_caption,
424  "#"
425  );
426  $tpl->setVariable("EDIT_STYLE", "display:none;");
427  $tpl->setVariable(
428  "EDIT_FORM_ACTION",
429  $ilCtrl->getFormActionByClass(static::class, "addNote", "", true)
430  );
431  $tpl->setVariable(
432  "TXT_CANCEL",
433  $this->lng->txt("cancel")
434  );
435  $tpl->setVariable(
436  "EDIT_FORM_BUTTON",
437  $this->renderComponents([$b])
438  );
439  $tpl->setVariable(
440  "EDIT_FORM",
441  $this->getNoteForm("create", $this->note_type)->render()
442  );
443  $tpl->parseCurrentBlock();
444  }
445 
446  // list all notes
449 
450  $notes_given = false;
451 
452  // edit form
453  if ($this->edit_note_form) {
454  $note = $this->manager->getById($this->requested_note_id);
455  $ilCtrl->setParameterByClass(static::class, "note_id", $this->requested_note_id);
456  $tpl->setVariable(
457  "EDIT_FORM_ACTION",
458  $ilCtrl->getFormActionByClass(static::class, "updateNote", "", true)
459  );
460  $tpl->setVariable(
461  "CANCEL_FORM_ACTION",
462  $ilCtrl->getFormActionByClass(static::class, "cancelUpdateNote", "", true)
463  );
464  $tpl->setVariable("NOTE_FOCUS", "1");
465  $tpl->setVariable(
466  "TXT_CANCEL",
467  $this->lng->txt("cancel")
468  );
469  $tpl->setVariable(
470  "EDIT_FORM",
471  $this->getNoteForm("edit", $this->note_type, $note)->render()
472  );
473  $tpl->parseCurrentBlock();
474  }
475 
476  $items = [];
477  $item_groups = [];
478  $text_placeholders = [];
479  $texts = [];
480  $last_obj_id = null;
481  foreach ($notes as $note) {
482  if ($this->only_latest && $notes_given) {
483  continue;
484  }
485 
486  $current_obj_id = $note->getContext()->getObjId();
487  if ($last_obj_id !== null && $current_obj_id !== $last_obj_id) {
488  $it_group_title = $this->getItemGroupTitle($last_obj_id);
489  $item_groups[] = $f->item()->group($it_group_title, $items);
490  $items = [];
491  }
492  $last_obj_id = $current_obj_id;
493 
494  $items[] = $this->getItemForNote($note);
495  $notes_given = true;
496 
497  $text_placeholders[] = $this->getNoteTextPlaceholder($note);
498  $texts[] = $this->getNoteText($note);
499  }
500 
501  $it_group_title = $this->getItemGroupTitle((int) $last_obj_id);
502  $item_groups[] = $f->item()->group($it_group_title, $items);
503 
504  if ($notes_given) {
505  if (!is_array($this->rep_obj_id)) {
506  $title = $item_groups[0]->getTitle();
507  $item_groups[0] = $f->item()->group("", $item_groups[0]->getItems());
508  } else {
509  $title = "";
510  }
511  $panel = $f->panel()->listing()->standard($title, $item_groups);
512  if (!is_array($this->rep_obj_id) && !$this->no_actions) {
513  $panel = $panel->withActions($this->getSortationControl());
514  }
515  $html = $this->renderComponents([$panel]);
516  $html = str_replace($text_placeholders, $texts, $html);
517  $tpl->setVariable("NOTES_LIST", $html);
518  } elseif (!is_array($this->rep_obj_id)) {
519  $it_group_title = $this->getItemGroupTitle($this->rep_obj_id);
520  $item_groups = [$f->item()->group($it_group_title, [])];
521  $panel = $f->panel()->listing()->standard("", $item_groups);
522  $mess_txt = "";
523  if ($this->show_empty_list_message) {
524  $mess_txt = $this->getNoEntriesText($this->search_text !== "");
525  $mess = $f->messageBox()->info($mess_txt);
526  //$html = $this->renderComponents([$panel, $mess]);
527  $html = $this->renderComponents([$mess]);
528  $tpl->setVariable("NOTES_LIST", $html);
529  }
530  } elseif ($this->search_text !== "") {
531  $mess_txt = $this->getNoEntriesText(true);
532  $mess = $f->messageBox()->info($mess_txt);
533  $tpl->setVariable("NOTES_LIST", $this->renderComponents([$mess]));
534  }
535 
537 
538  // message
539  $mtxt = "";
540  switch ($this->requested_note_mess !== "" ? $this->requested_note_mess : $this->note_mess) {
541  case "mod":
542  $mtype = "success";
543  $mtxt = $lng->txt("msg_obj_modified");
544  break;
545 
546  case "ntsdel":
547  $mtype = "success";
548  $mtxt = $this->getDeletedMultipleText();
549  break;
550 
551  case "ntdel":
552  $mtype = "success";
553  $mtxt = $this->getDeletedSingleText();
554  break;
555 
556  case "frmfld":
557  $mtype = "failure";
558  $mtxt = $lng->txt("form_input_not_valid");
559  break;
560 
561  case "qdel":
562  $mtype = "question";
563  $mtxt = $lng->txt("info_delete_sure");
564  break;
565 
566  case "noc":
567  $mtype = "failure";
568  $mtxt = $lng->txt("no_checkbox");
569  break;
570  }
571  if ($mtxt !== "") {
572  $tpl->setVariable("MESS", ilUtil::getSystemMessageHTML($mtxt, $mtype));
573  } else {
574  $tpl->setVariable("MESS", "");
575  }
576 
577  if ($this->widget_header !== "") {
578  $tpl->setVariable("WIDGET_HEADER", $this->widget_header);
579  }
580 
581  return $tpl->get();
582  }
583 
584  protected function getListTitle(): string
585  {
586  return $this->lng->txt("private_notes");
587  }
588 
589  protected function getAddText(): string
590  {
591  return $this->lng->txt("note_add_note");
592  }
593 
594  protected function getDeletedMultipleText(): string
595  {
596  return $this->lng->txt("notes_notes_deleted");
597  }
598 
599  protected function getDeletedSingleText(): string
600  {
601  return $this->lng->txt("notes_note_deleted");
602  }
603 
604  protected function getLatestItemText(): string
605  {
606  return "";
607  }
608 
609  protected function getAddEditItemText(): string
610  {
611  return $this->lng->txt("notes_add_edit_note");
612  }
613 
614  protected function getNoEntriesText(bool $search): string
615  {
616  if (!$search) {
617  $mess_txt = $this->lng->txt("notes_no_notes");
618  } else {
619  $mess_txt = $this->lng->txt("notes_no_notes_found");
620  }
621  return $mess_txt;
622  }
623 
627  //protected function getSortationControl() : \ILIAS\UI\Component\ViewControl\Sortation
628  protected function getSortationControl(): \ILIAS\UI\Component\Dropdown\Standard
629  {
630  /*
631  $c = $this->lng->txt("create_date") . ", ";
632  $options = [
633  'desc' => $c . $this->lng->txt("sorting_desc"),
634  'asc' => $c . $this->lng->txt("sorting_asc")
635  ];
636  $select_option = (true)
637  ? 'asc'
638  : 'desc';
639  $s = $this->ui->factory()->viewControl()->sortation($options, $select_option)
640  ->withTargetURL($this->ctrl->getLinkTarget($this, "setSortation"), 'sortation');
641  */
642  $dd_buttons = [];
643  if ($this->manager->getSortAscending()) {
644  $dd_buttons[] = $this->getShyButton(
645  "sort",
646  $this->lng->txt("notes_sort_desc"),
647  "listSortDesc",
648  "",
649  0
650  );
651  } else {
652  $dd_buttons[] = $this->getShyButton(
653  "sort",
654  $this->lng->txt("notes_sort_asc"),
655  "listSortAsc",
656  "",
657  0
658  );
659  }
660 
661  $s = $this->ui->factory()->dropdown()->standard(
662  $dd_buttons
663  );
664 
665  return $s;
666  }
667 
668  protected function getItemGroupTitle(int $obj_id = 0): string
669  {
670  if (!$this->show_header) {
671  return "";
672  }
673  if (!is_array($this->rep_obj_id) && !$this->getUseObjectTitleHeader()) {
674  $it_group_title = $this->lng->txt("notes");
675  } else {
676  $it_group_title = ($obj_id)
677  ? ilObject::_lookupTitle($obj_id)
678  : $this->lng->txt("note_without_object");
679  }
680  return $it_group_title;
681  }
682 
688  protected function getItemForNote(
689  Note $note,
690  bool $actions = true
691  ): \ILIAS\UI\Component\Item\Item {
692  $f = $this->ui->factory();
693  $ctrl = $this->ctrl;
694  //return $f->item()->standard("");
695 
696  $dd_buttons = [];
697 
698  // edit note stuff for all private notes
699  if ($actions && $this->notes_access->canEdit($note)) {
700  if (!$this->export_html && !$this->print
701  && !$this->edit_note_form && !$this->add_note_form && !$this->no_actions) {
702  $ctrl->setParameterByClass(static::class, "note_id", $note->getId());
703  $dd_buttons[] = $this->getShyButton(
704  "edit_note",
705  $this->lng->txt("edit"),
706  "editNoteForm",
707  "note_" . $note->getId(),
708  $note->getId()
709  );
710  }
711  }
712 
713  // delete note stuff for all private notes
714  if ($actions && !$this->export_html && !$this->print
715  && !$this->no_actions
716  && $this->notes_access->canDelete($note)) {
717  $ctrl->setParameterByClass(static::class, "note_id", $note->getId());
718  $dd_buttons[] = $this->getShyButton(
719  "delete_note",
720  $this->lng->txt("delete"),
721  "deleteNote",
722  "note_" . $note->getId(),
723  $note->getId()
724  );
725  }
726 
727 
728  $creation_date = ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME));
729 
730  $properties = [];
731 
732  // origin
733  if ($this->targets_enabled) {
734  $target = $this->getTarget($note);
735  if ($target["title"] !== "") {
736  if ($target["link"] === "") {
737  $properties[$this->lng->txt("notes_origin")] = $target["title"];
738  } else {
739  $properties[$this->lng->txt("notes_origin")] = $f
740  ->button()
741  ->shy(
742  $target["title"],
743  $target["link"]
744  );
745  }
746  }
747  }
748 
749  // output author account and creation date
750  $img_path = "";
751  $img_alt = "";
752  $avatar = null;
753  $title = $this->getItemTitle($note);
754  if ($note->getType() === Note::PUBLIC) {
755  $avatar = $this->gui->profile()->getAvatar($note->getAuthor());
756  }
757  $this->addItemProperties($note, $properties);
758 
759  // last edited
760  if ($note->getUpdateDate() !== null) {
761  $properties[$this->lng->txt("last_edited_on")] = ilDatePresentation::formatDate(
762  new ilDate(
763  $note->getUpdateDate(),
765  )
766  );
767  }
768 
769  $item = $f->item()->standard($title)
770  ->withDescription($this->getNoteTextPlaceholder($note))
771  ->withProperties($properties);
772  if (!is_null($avatar)) {
773  $item = $item->withLeadAvatar($avatar);
774  }
775  if (count($dd_buttons) > 0) {
776  $item = $item->withActions(
777  $f->dropdown()->standard($dd_buttons)
778  );
779  }
780  return $item;
781  }
782 
783  protected function getItemTitle(Note $note): string
784  {
785  $creation_date = ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME));
786  if ($note->getType() === Note::PUBLIC) {
787  $title = ilUserUtil::getNamePresentation($note->getAuthor(), false, false);
788  } else {
789  $title = $creation_date;
790  }
791  return $title;
792  }
793 
794  protected function addItemProperties(Note $note, array &$properties): void
795  {
796  $creation_date = ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME));
797  if ($note->getType() === Note::PUBLIC) {
798  $properties[$this->lng->txt("create_date")] = $creation_date;
799  }
800  }
801 
802  protected function getNoteTextPlaceholder(Note $note): string
803  {
804  return "##note-text-" . $note->getId() . "##";
805  }
806 
807  protected function getNoteText(Note $note): string
808  {
809  return (trim($note->getText()) !== "")
810  ? nl2br(htmlentities($note->getText()))
811  : $this->lng->txt("note_content_removed");
812  }
813 
817  protected function getSubObjectTitle(
818  int $parent_obj_id,
819  int $sub_obj_id
820  ): string {
821  $objDefinition = $this->obj_definition;
822  $parent_type = ilObject::_lookupType($parent_obj_id);
823  if ($parent_type === "") {
824  return "";
825  }
826  $parent_class = "ilObj" . $objDefinition->getClassName($parent_type) . "GUI";
827  if (method_exists($parent_class, "lookupSubObjectTitle")) {
828  return call_user_func_array(array($parent_class, "lookupSubObjectTitle"), array($parent_obj_id, $sub_obj_id));
829  }
830  return "";
831  }
832 
833  protected function getNoteForm(
834  string $mode,
835  int $type,
836  ?Note $note = null
837  ): \ILIAS\Repository\Form\FormAdapterGUI {
838  global $DIC;
839 
840  $label_key = "note";
841  $label_key .= ($mode === "create")
842  ? "_add"
843  : "_update";
844  $label_key .= "_" . $this->getFormLabelKey($type);
845  $cmd = ($mode === "create")
846  ? "addNote"
847  : "updateNote";
848 
849  $value = ($note)
850  ? $note->getText()
851  : "";
852  if ($cmd === "updateNote") {
853  $this->ctrl->setParameter($this, "note_id", $this->requested_note_id);
854  }
855  $action = $this->ctrl->getFormActionByClass(static::class, $cmd, "");
856  $form = $this->gui->form(static::class, $action)
857  ->section("props", $this->lng->txt($label_key))
858  ->textarea("note", $this->lng->txt("note_text"), "", $value);
859  return $form;
860  }
861 
862  protected function getFormLabelKey(): string
863  {
864  return "note";
865  }
866 
870  public function getTarget(
871  Note $note
872  ): array {
873  $tree = $this->tree;
874  $ilAccess = $this->access;
875  $objDefinition = $this->obj_definition;
876  $ilUser = $this->user;
877 
878  $title = "";
879  $link = "";
880 
881  $a_note_id = $note->getId();
882  $context = $note->getContext();
883  $a_obj_type = $context->getType();
884  $a_obj_id = $context->getSubObjId();
885 
886  if ($context->getObjId() > 0) {
887  // get first visible reference
888  $vis_ref_id = 0;
889  $ref_ids = ilObject::_getAllReferences($context->getObjId());
890  foreach ($ref_ids as $ref_id) {
891  if ($vis_ref_id > 0) {
892  break;
893  }
894  if ($ilAccess->checkAccess("visible", "", $ref_id)) {
895  $vis_ref_id = $ref_id;
896  }
897  }
898 
899  // if we got the reference id
900  if ($vis_ref_id > 0) {
901  $type = ilObject::_lookupType($vis_ref_id, true);
902  $title = ilObject::_lookupTitle($context->getObjId());
903 
904  if ($type === "poll") {
905  $link = ilLink::_getLink($vis_ref_id, "poll");
906  } elseif ($a_obj_type !== "pg") {
907  if (!isset($this->item_list_gui[$type])) {
908  $class = $objDefinition->getClassName($type);
909  $full_class = "ilObj" . $class . "ListGUI";
910  $this->item_list_gui[$type] = new $full_class();
911  }
912 
913  // for references, get original title
914  // (link will lead to orignal, which basically is wrong though)
915  if ($a_obj_type === "crsr" || $a_obj_type === "catr" || $a_obj_type === "grpr") {
916  $tgt_obj_id = ilContainerReference::_lookupTargetId($context->getObjId());
917  $title = ilObject::_lookupTitle($tgt_obj_id);
918  }
919  $this->item_list_gui[$type]->initItem($vis_ref_id, $context->getObjId(), $title, $a_obj_type);
920  $link = $this->item_list_gui[$type]->getCommandLink("infoScreen");
921  $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link) . "#note_" . $a_note_id;
922  } else {
923  $title = ilObject::_lookupTitle($context->getObjId());
924  $link = "goto.php?target=pg_" . $a_obj_id . "_" . $vis_ref_id;
925  }
926  } else { // personal workspace
927  // we only need 1 instance
928  if (!isset($this->wsp_tree)) {
929  $this->wsp_tree = new ilWorkspaceTree($ilUser->getId());
930  $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
931  }
932  $node_id = $this->wsp_tree->lookupNodeId($context->getObjId());
933  if ($this->wsp_access_handler->checkAccess("visible", "", $node_id)) {
934  $path = $this->wsp_tree->getPathFull($node_id);
935  if ($path) {
936  $item = array_pop($path);
937  $title = $item["title"];
938  $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $context->getObjId());
939  }
940  // shared resource
941  else {
942  $owner = ilObject::_lookupOwner($context->getObjId());
943  $title = ilObject::_lookupTitle($context->getObjId()) .
944  " (" . ilObject::_lookupOwnerName($owner) . ")";
945  $link = "ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&dsh=" .
946  $owner;
947  }
948  }
949  }
950  }
951  return [
952  "title" => $title,
953  "link" => $link,
954  ];
955  }
956 
960  public function addNoteForm(
961  bool $a_init_form = true
962  ): string {
963  $this->add_note_form = true;
964  return $this->getListHTML($a_init_form);
965  }
966 
970  public function cancelAddNote(): string
971  {
972  return $this->getListHTML();
973  }
974 
978  public function cancelUpdateNote(): string
979  {
980  return $this->getListHTML();
981  }
982 
986  public function addNote(): void
987  {
988  $ilUser = $this->user;
989  $ilCtrl = $this->ctrl;
990 
991  $text = $this->getNoteForm(
992  "create",
993  $this->note_type
994  )->getData("note") ?? "";
995 
996  //if ($this->form->checkInput())
997  if ($text !== "" && !is_array($this->rep_obj_id)) {
998  $context = $this->data->context(
999  $this->rep_obj_id,
1000  $this->obj_id,
1001  $this->obj_type,
1002  $this->news_id,
1003  $this->repository_mode
1004  );
1005  $note = $this->data->note(
1006  0,
1007  $context,
1008  $text,
1009  $ilUser->getId(),
1011  0,
1012  0,
1014  );
1015  $this->manager->createNote(
1016  $note,
1017  $this->observer
1018  );
1019 
1020  $ilCtrl->setParameter($this, "note_mess", "mod");
1021  }
1022  $ilCtrl->redirect($this, "getListHTML", "", $this->ctrl->isAsynch());
1023  }
1024 
1025  public function updateNote(): void
1026  {
1027  $ilCtrl = $this->ctrl;
1028 
1029  $note = $this->manager->getById($this->requested_note_id);
1030  $text = $this->getNoteForm(
1031  "edit",
1032  $this->note_type
1033  )->getData("note") ?? "";
1034 
1035  if ($this->notes_access->canEdit($note)) {
1036  $this->manager->updateNoteText(
1037  $this->requested_note_id,
1038  $text,
1039  $this->observer
1040  );
1041  $ilCtrl->setParameter($this, "note_mess", "mod");
1042  }
1043  $ilCtrl->redirect($this, "getListHTML", "", $this->ctrl->isAsynch());
1044  }
1045 
1049  public function editNoteForm(
1050  bool $a_init_form = true
1051  ): string {
1052  $this->edit_note_form = true;
1053 
1054  return $this->getListHTML($a_init_form);
1055  }
1056 
1060  public function renderContent(string $content): string
1061  {
1062  $lng = $this->lng;
1063  $ctrl = $this->ctrl;
1064 
1065  $ntpl = new ilTemplate(
1066  "tpl.notes_and_comments.html",
1067  true,
1068  true,
1069  "components/ILIAS/Notes"
1070  );
1071 
1072  if (!$ctrl->isAsynch()) {
1073  $ntpl->setVariable("OUTER_ID", " id='notes_embedded_outer' ");
1074  }
1075 
1076  $ntpl->setVariable("CONTENT", $content);
1077 
1078  if ($ctrl->isAsynch() && !$this->request->isFilterCommand()) {
1079  echo $ntpl->get();
1080  exit;
1081  }
1082 
1083  return $ntpl->get();
1084  }
1085 
1086  protected function deleteNote(): string
1087  {
1090 
1091  $f = $this->ui->factory();
1092  $ctrl = $this->ctrl;
1093  $ctrl->setParameter($this, "note_id", $this->requested_note_id);
1094  $note = $this->manager->getById($this->requested_note_id);
1095 
1096  $text = $this->getDeleteText();
1097 
1098  $mess = $f->messageBox()->confirmation($text);
1099  $item = $this->getItemForNote($note, false);
1100 
1101  $b1 = $this->getButton(
1102  "",
1103  $this->lng->txt("cancel"),
1104  "cancelDelete"
1105  );
1106  $b2 = $this->getButton(
1107  "",
1108  $this->lng->txt("delete"),
1109  "confirmDelete"
1110  );
1111 
1112  $it_group_title = $this->getItemGroupTitle($note->getContext()->getObjId());
1113  $item_groups = [$f->item()->group($it_group_title, [$item])];
1114  $panel = $f->panel()->listing()->standard("", $item_groups);
1115 
1116  $html = $this->renderComponents([$mess, $panel, $b2, $b1]);
1117  $html = str_replace($this->getNoteTextPlaceholder($note), $this->getNoteText($note), $html);
1118 
1119  return $this->renderContent($html);
1120  }
1121 
1122  protected function getDeleteText(): string
1123  {
1124  return $this->lng->txt("notes_delete_note");
1125  }
1126 
1127  public function cancelDelete(): string
1128  {
1129  return $this->getListHTML();
1130  }
1131 
1132  public function confirmDelete(): void
1133  {
1134  $ilCtrl = $this->ctrl;
1135 
1136  $cnt = 0;
1137  $ids = [$this->request->getNoteId()];
1138  foreach ($ids as $id) {
1139  $note = $this->manager->getById($id);
1140  if ($this->notes_access->canDelete($note, $this->user->getId(), $this->public_deletion_enabled)) {
1141  $this->manager->deleteNote($note, $this->user->getId(), $this->public_deletion_enabled);
1142  $cnt++;
1143  }
1144  }
1145  if ($cnt > 1) {
1146  $ilCtrl->setParameter($this, "note_mess", "ntsdel");
1147  } else {
1148  $ilCtrl->setParameter($this, "note_mess", "ntdel");
1149  }
1150  $ilCtrl->redirect($this, "getListHTML", "", $this->ajax);
1151  }
1152 
1156  public function exportNotesHTML(): void
1157  {
1158  $tpl = new ilGlobalTemplate("tpl.main.html", true, true);
1159 
1160  $this->export_html = true;
1161  //$tpl->setVariable("CONTENT", $this->getListHTML());
1162  //ilUtil::deliverData($tpl->get(), "notes.html");
1163 
1164  $authors = array_unique(array_map(function (Note $note) {
1165  return $note->getAuthor();
1166  }, $this->getNotes()));
1167  $export = new \ILIAS\Notes\Export\NotesHtmlExport(
1168  $this->note_type,
1169  $this->user->getId(),
1170  $authors
1171  );
1172  $export->exportHTML($this->getListHTML());
1173  }
1174 
1178  public static function getListNotesJSCall(
1179  string $a_hash,
1180  ?string $a_update_code = null
1181  ): string {
1182  if ($a_update_code === null) {
1183  $a_update_code = "null";
1184  } else {
1185  $a_update_code = "'" . $a_update_code . "'";
1186  }
1187 
1188  return "ilNotes.listNotes(event, '" . $a_hash . "', " . $a_update_code . ");";
1189  }
1190 
1194  public static function getListCommentsJSCall(
1195  string $a_hash,
1196  ?string $a_update_code = null
1197  ): string {
1198  if ($a_update_code === null) {
1199  $a_update_code = "null";
1200  } else {
1201  $a_update_code = "'" . $a_update_code . "'";
1202  }
1203 
1204  return "ilNotes.listComments(event, '" . $a_hash . "', " . $a_update_code . ");";
1205  }
1206 
1210  public function getShyButton(
1211  string $a_var,
1212  string $a_txt,
1213  string $a_cmd,
1214  string $a_anchor = "",
1215  int $note_id = 0
1216  ): \ILIAS\UI\Component\Button\Shy {
1217  $ctrl = $this->ctrl;
1218  $f = $this->ui->factory();
1219 
1220  $class = static::class;
1221  if ($this->ajax) {
1222  $button = $f->button()->shy(
1223  $a_txt,
1224  "#"
1225  )->withOnLoadCode(function ($id) use ($ctrl, $a_cmd, $note_id, $class) {
1226  $ctrl->setParameterByClass($class, "note_id", $note_id);
1227  return
1228  "document.querySelector('#$id').addEventListener('click', () => { ilNotes.cmdAjaxLink(event, '" .
1229  $ctrl->getLinkTargetByClass($class, $a_cmd, "", true) .
1230  "');});";
1231  });
1232  } else {
1233  $button = $f->button()->shy(
1234  $a_txt,
1235  $ctrl->getLinkTargetByClass($class, $a_cmd, $a_anchor)
1236  );
1237  }
1238  return $button;
1239  }
1240 
1244  public function getButton(
1245  string $a_var,
1246  string $a_txt,
1247  string $a_cmd,
1248  string $a_anchor = ""
1249  ): \ILIAS\UI\Component\Button\Standard {
1250  $ctrl = $this->ctrl;
1251  $f = $this->ui->factory();
1252 
1253  if ($this->ajax) {
1254  $button = $f->button()->standard(
1255  $a_txt,
1256  "#"
1257  )->withOnLoadCode(function ($id) use ($ctrl, $a_cmd) {
1258  return
1259  "document.querySelector('#$id').addEventListener('click', () => { ilNotes.cmdAjaxLink(event, '" .
1260  $ctrl->getLinkTargetByClass(static::class, $a_cmd, "", true) .
1261  "');});";
1262  });
1263  } else {
1264  $button = $f->button()->standard(
1265  $a_txt,
1266  $ctrl->getLinkTargetByClass(static::class, $a_cmd, $a_anchor)
1267  );
1268  }
1269  return $button;
1270  }
1271 
1275  public function addObserver(
1276  callable $a_callback
1277  ): void {
1278  $this->observer[] = $a_callback;
1279  }
1280 
1281  protected function listSortAsc(): string
1282  {
1283  $this->manager->setSortAscending(true);
1284  return $this->getListHTML();
1285  }
1286 
1287  protected function listSortDesc(): string
1288  {
1289  $this->manager->setSortAscending(false);
1290  return $this->getListHTML();
1291  }
1292 
1293 
1294  public function setExportMode(): void
1295  {
1296  $this->hide_new_form = true;
1297  $this->no_actions = true;
1298  $this->enable_sorting = false;
1299  $this->user_img_export_html = true;
1300  }
1301 
1302  protected function getOriginHeader(): string
1303  {
1304  if (!is_array($this->rep_obj_id) && !$this->only_latest && $this->ctrl->isAsynch()) {
1305  switch ($this->obj_type) {
1306  case "grpr":
1307  case "catr":
1308  case "crsr":
1309  $title = ilContainerReference::_lookupTitle($this->rep_obj_id);
1310  break;
1311 
1312  default:
1313  $title = ilObject::_lookupTitle($this->rep_obj_id);
1314  break;
1315  }
1316 
1317  $img = ilUtil::img(ilObject::_getIcon($this->rep_obj_id, "tiny"));
1318 
1319  // add sub-object if given
1320  if ($this->obj_id) {
1321  $sub_title = $this->getSubObjectTitle($this->rep_obj_id, $this->obj_id);
1322  if ($sub_title) {
1323  $title .= " - " . $sub_title;
1324  }
1325  }
1326 
1327  return $img . " " . $title;
1328  }
1329  return "";
1330  }
1331 
1332  public function getGlyph(): string
1333  {
1334  $f = $this->ui->factory();
1335  $r = $this->ui->renderer();
1336  $lng = $this->lng;
1337  $ctrl = $this->ctrl;
1338  $ctrl->setParameter($this, "news_id", $this->news_id);
1341  null,
1342  ilObject::_lookupType($this->rep_obj_id),
1343  $this->rep_obj_id,
1344  $this->obj_type,
1345  $this->obj_id,
1346  $this->news_id
1347  );
1348 
1349  $context = $this->data->context(
1350  $this->rep_obj_id,
1351  $this->obj_id,
1352  $this->obj_type,
1353  $this->news_id
1354  );
1355 
1356  $cnt[$this->rep_obj_id][$this->note_type] = $this->manager->getNrOfNotesForContext($context, $this->note_type);
1357  $cnt = $cnt[$this->rep_obj_id][$this->note_type] ?? 0;
1358 
1359  $widget_el_id = "notew_" . str_replace(";", "_", $hash);
1360  $ctrl->setParameter($this, "hash", $hash);
1361  $update_url = $ctrl->getLinkTarget($this, "updateGlyph", "", true, false);
1362  $query_url = $ctrl->getLinkTarget($this, "getListHtml", "", true, false);
1363  $comps = array();
1364  $c = $f->counter()->status((int) $cnt);
1365  $comps[] = $f->symbol()->glyph()->comment()->withCounter($c)->withAdditionalOnLoadCode(function ($id) use ($hash, $query_url) {
1366  $code = "$('#$id').attr('data-note-key','$hash');\n";
1367  $code .= "$('#$id').attr('data-note-ui-type','trigger');\n";
1368  $code .= "$('#$id').attr('data-note-query-url','" . $query_url . "');\n";
1369  $code .= "$(\"#$id\").click(function(event) { ilNotes.clickTrigger(event)});";
1370  return $code;
1371  });
1372  if ($this->ctrl->isAsynch()) {
1373  $html = $r->renderAsync($comps);
1374  } else {
1375  $html = $r->render($comps);
1376  }
1377  $html = "<span id='" . $widget_el_id . "' data-note-key='$hash' data-note-ui-type='widget' data-note-update-url='$update_url'>" . $html . "</span>";
1378  $ctrl->setParameter($this, "news_id", $this->requested_news_id);
1379  return $html;
1380  }
1381 
1382  public function getNumber(): string
1383  {
1384  $f = $this->ui->factory();
1385  $r = $this->ui->renderer();
1386  $lng = $this->lng;
1387  $ctrl = $this->ctrl;
1388  $ctrl->setParameter($this, "news_id", $this->news_id);
1391  null,
1392  ilObject::_lookupType($this->rep_obj_id),
1393  $this->rep_obj_id,
1394  $this->obj_type,
1395  $this->obj_id,
1396  $this->news_id
1397  );
1398 
1399  $context = $this->data->context(
1400  $this->rep_obj_id,
1401  $this->obj_id,
1402  $this->obj_type,
1403  $this->news_id
1404  );
1405 
1406  $cnt[$this->rep_obj_id][$this->note_type] = $this->manager->getNrOfNotesForContext($context, $this->note_type);
1407  $cnt = $cnt[$this->rep_obj_id][$this->note_type] ?? 0;
1408 
1409  $widget_el_id = "notew_" . str_replace(";", "_", $hash);
1410  $ctrl->setParameter($this, "hash", $hash);
1411  $update_url = $ctrl->getLinkTarget($this, "updateNumber", "", true, false);
1412  $query_url = $ctrl->getLinkTarget($this, "getListHtml", "", true, false);
1413  $comps = array();
1414  $comps[] = $f->button()->shy($cnt, "#")->withAdditionalOnLoadCode(function ($id) use ($hash, $query_url) {
1415  $code = "$('#$id').attr('data-note-key','$hash');\n";
1416  $code .= "$('#$id').attr('data-note-ui-type','trigger');\n";
1417  $code .= "$('#$id').attr('data-note-query-url','" . $query_url . "');\n";
1418  $code .= "$(\"#$id\").click(function(event) { ilNotes.clickTrigger(event)});";
1419  return $code;
1420  });
1421  if ($this->ctrl->isAsynch()) {
1422  $html = $r->renderAsync($comps);
1423  } else {
1424  $html = $r->render($comps);
1425  }
1426  //echo "<br>" . $widget_el_id . ":" . $update_url . "<br>";
1427  $html = "<span id='" . $widget_el_id . "' data-note-key='$hash' data-note-ui-type='widget' data-note-update-url='$update_url'>" . $html . "</span>";
1428  $ctrl->setParameter($this, "news_id", $this->requested_news_id);
1429  return $html;
1430  }
1431 
1432  public function getTriggerShyButton(): \ILIAS\UI\Component\Button\Shy
1433  {
1434  $f = $this->ui->factory();
1435  $r = $this->ui->renderer();
1436  $lng = $this->lng;
1437  $ctrl = $this->ctrl;
1438  $ctrl->setParameter($this, "news_id", $this->news_id);
1441  null,
1442  ilObject::_lookupType($this->rep_obj_id),
1443  $this->rep_obj_id,
1444  $this->obj_type,
1445  $this->obj_id,
1446  $this->news_id
1447  );
1448 
1449  $context = $this->data->context(
1450  $this->rep_obj_id,
1451  $this->obj_id,
1452  $this->obj_type,
1453  $this->news_id
1454  );
1455 
1456  $widget_el_id = "notew_" . str_replace(";", "_", $hash);
1457  $ctrl->setParameter($this, "hash", $hash);
1458  $update_url = $ctrl->getLinkTarget($this, "updateNumber", "", true, false);
1459  $query_url = $ctrl->getLinkTarget($this, "getListHtml", "", true, false);
1460  $but = $f->button()->shy($this->lng->txt("comments"), "#")->withAdditionalOnLoadCode(function ($id) use ($hash, $query_url) {
1461  $code = "$('#$id').attr('data-note-key','$hash');\n";
1462  $code .= "$('#$id').attr('data-note-ui-type','trigger');\n";
1463  $code .= "$('#$id').attr('data-note-query-url','" . $query_url . "');\n";
1464  $code .= "$(\"#$id\").click(function(event) { ilNotes.clickTrigger(event)});";
1465  return $code;
1466  });
1467  return $but;
1468  }
1469 
1470  public function getWidget(): string
1471  {
1472  $f = $this->ui->factory();
1473  $r = $this->ui->renderer();
1474  $lng = $this->lng;
1475  $ctrl = $this->ctrl;
1476  $ctrl->setParameter($this, "news_id", $this->news_id);
1479  null,
1480  ilObject::_lookupType($this->rep_obj_id),
1481  $this->rep_obj_id,
1482  $this->obj_type,
1483  $this->obj_id,
1484  $this->news_id
1485  );
1486 
1487  $context = $this->data->context(
1488  $this->rep_obj_id,
1489  $this->obj_id,
1490  $this->obj_type,
1491  $this->news_id
1492  );
1493 
1494  $cnt[$this->rep_obj_id][$this->note_type] = $this->manager->getNrOfNotesForContext($context, $this->note_type);
1495  $cnt = $cnt[$this->rep_obj_id][$this->note_type] ?? 0;
1496 
1497  $tpl = new ilTemplate("tpl.note_widget_header.html", true, true, "components/ILIAS/Notes");
1498  $widget_el_id = "notew_" . str_replace(";", "_", $hash);
1499  $ctrl->setParameter($this, "hash", $hash);
1500  $update_url = $ctrl->getLinkTarget($this, "updateWidget", "", true, false);
1501  $query_url = $ctrl->getLinkTarget($this, "getListHtml", "", true, false);
1502  $comps = array();
1503  if ($cnt > 0) {
1504  $c = $f->counter()->status((int) $cnt);
1505  $comps[] = $f->symbol()->glyph()->comment()->withCounter($c)->withAdditionalOnLoadCode(function ($id) use ($hash, $query_url) {
1506  $code = "$('#$id').attr('data-note-key','$hash');\n";
1507  $code .= "$('#$id').attr('data-note-ui-type','trigger');\n";
1508  $code .= "$('#$id').attr('data-note-query-url','" . $query_url . "');\n";
1509  $code .= "$(\"#$id\").click(function(event) { ilNotes.clickTrigger(event)});";
1510  return $code;
1511  });
1512  $comps[] = $f->divider()->vertical();
1513  $tpl->setVariable("GLYPH", $r->render($comps));
1514  $tpl->setVariable("TXT_LATEST", $this->getLatestItemText());
1515  }
1516 
1517  $b = $f->button()->shy($this->getAddEditItemText(), "#")->withAdditionalOnLoadCode(function ($id) use ($hash, $query_url) {
1518  $code = "$('#$id').attr('data-note-key','$hash');\n";
1519  $code .= "$('#$id').attr('data-note-ui-type','trigger');\n";
1520  $code .= "$('#$id').attr('data-note-query-url','" . $query_url . "');\n";
1521  $code .= "$(\"#$id\").click(function(event) { ilNotes.clickTrigger(event)});";
1522  return $code;
1523  });
1524  if ($ctrl->isAsynch()) {
1525  $tpl->setVariable("SHY_BUTTON", $r->renderAsync($b));
1526  } else {
1527  $tpl->setVariable("SHY_BUTTON", $r->render($b));
1528  }
1529 
1530  $this->widget_header = $tpl->get();
1531 
1532  $this->hide_new_form = true;
1533  $this->only_latest = true;
1534  $this->no_actions = true;
1535  $html = "<div id='" . $widget_el_id . "' data-note-key='$hash' data-note-ui-type='widget' data-note-update-url='$update_url'>" . $this->getNoteListHTML() . "</div>";
1536  $ctrl->setParameter($this, "news_id", $this->requested_news_id);
1537  return $html;
1538  }
1539 
1540  protected function updateWidget(): void
1541  {
1542  echo $this->getWidget();
1543  exit;
1544  }
1545 
1546  protected function updateGlyph(): void
1547  {
1548  echo $this->getGlyph();
1549  exit;
1550  }
1551 
1552  protected function updateNumber(): void
1553  {
1554  echo $this->getNumber();
1555  exit;
1556  }
1557 
1558 }
getItemTitle(Note $note)
static array static setUseRelativeDates(bool $a_status)
set use relative dates
getButton(string $a_var, string $a_txt, string $a_cmd, string $a_anchor="")
bool $enable_sorting
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getSystemMessageHTML(string $a_txt, string $a_type="info")
Get HTML for a system message.
enableCommentsSettings(bool $a_enable=true)
StandardGUIRequest $request
static _lookupTitle(int $obj_id)
$context
Definition: webdav.php:31
const IL_CAL_DATETIME
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
ILIAS Notes AccessManager $notes_access
const ANONYMOUS_USER_ID
Definition: constants.php:27
static getLogger(string $a_component_id)
Get component logger.
bool $edit_note_form
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
bool $show_empty_list_message
special template class to simplify handling of ITX/PEAR
getItemGroupTitle(int $obj_id=0)
bool $comments_settings
string $obj_type
array $item_list_gui
ILIAS DI UIServices $ui
getNoteListHTML(bool $a_init_form=true)
Interface Observer Contains several chained tasks and infos about them.
static _getAllReferences(int $id)
get all reference ids for object ID
NotesManager $manager
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
static getGotoLink(int $a_node_id, int $a_obj_id, string $a_additional="")
addNoteForm(bool $a_init_form=true)
get notes list including add note area
ilWorkspaceAccessHandler $wsp_access_handler
setDefaultCommand(string $a_val)
enablePrivateNotes(bool $a_enable=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParameterByClass(string $a_class, string $a_parameter, $a_value)
__construct( $a_rep_obj_id=0, int $a_obj_id=0, string $a_obj_type="", bool $a_include_subobjects=false, int $a_news_id=0, bool $ajax=true, string $search_text="")
int $requested_news_id
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
ilObjectDefinition $obj_definition
$c
Definition: deliver.php:25
ilSetting $settings
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
string $requested_note_mess
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:29
bool $repository_mode
$components
getItemForNote(Note $note, bool $actions=true)
ilWorkspaceTree $wsp_tree
ilNoteGUI: ilCommentGUI
ILIAS Notes InternalGUIService $gui
static buildAjaxHash(int $node_type, ?int $node_id, string $obj_type, int $obj_id, ?string $sub_type=null, ?int $sub_id=null, int $news_id=0)
Build ajax hash.
bool $user_img_export_html
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
enableTargets(bool $a_enable=true)
bool $add_note_form
getNoteTextPlaceholder(Note $note)
exportNotesHTML()
export selected notes to html
bool $public_deletion_enabled
setUseObjectTitleHeader(bool $a_val)
getSubObjectTitle(int $parent_obj_id, int $sub_obj_id)
Get sub object title if available with callback.
$ref_id
Definition: ltiauth.php:65
setHideNewForm(bool $a_val)
ilLanguage $lng
ilAccessHandler $access
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
getListHTML(bool $a_init_form=true)
static _lookupTitle(int $obj_id)
string $note_mess
addNote()
add note
getNoteForm(string $mode, int $type, ?Note $note=null)
bool $private_enabled
ilObjUser $user
setRepositoryMode(bool $a_value)
getNoteText(Note $note)
setShowEmptyListMessage(bool $a_val)
setShowHeader(bool $a_val)
global $DIC
Definition: shib_login.php:26
string $default_command
cancelUpdateNote()
cancel edit note
ilTemplate $form_tpl
string $widget_header
string $search_text
bool $targets_enabled
bool $hide_new_form
enablePublicNotesDeletion(bool $a_enable=true)
int $requested_note_id
exit
getShyButton(string $a_var, string $a_txt, string $a_cmd, string $a_anchor="", int $note_id=0)
bool $use_obj_title_header
addObserver(callable $a_callback)
Add observer.
static getListCommentsJSCall(string $a_hash, ?string $a_update_code=null)
Get list comments js call.
bool $public_enabled
renderContent(string $content)
Render content into notes wrapper.
addItemProperties(Note $note, array &$properties)
global $ilSetting
Definition: privfeed.php:31
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static _lookupTargetId(int $a_obj_id)
enablePublicNotes(bool $a_enable=true)
getNoEntriesText(bool $search)
static _lookupOwnerName(int $owner_id)
Lookup owner name for owner id.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
static _lookupType(int $id, bool $reference=false)
cancelAddNote()
cancel add note
ilLogger $log
getTarget(Note $note)
show related objects as links
static getListNotesJSCall(string $a_hash, ?string $a_update_code=null)
Get list notes js call.
editNoteForm(bool $a_init_form=true)
get notes list including add note area
ILIAS Notes InternalDataService $data
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
$r
renderComponents(array $components)