ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCommentGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
28 protected int $note_type = Note::PUBLIC;
29
30 public function __construct(
31 $rep_obj_id = 0,
32 int $obj_id = 0,
33 string $obj_type = "",
34 bool $include_subobjects = false,
35 int $news_id = 0,
36 bool $ajax = true,
37 string $search_text = ""
38 ) {
41 $obj_id,
43 $include_subobjects,
45 $ajax,
47 );
48 $this->enablePrivateNotes(false);
49 $this->enablePublicNotes(true);
50 }
51
52 public function getNotesHTML(): string
53 {
54 throw new ilException("Call to getNotesHTML is deprecated");
55 }
56
57 public function getCommentsHTML(): string
58 {
59 throw new ilException("Call to getCommentsHTML is deprecated");
60 }
61
62 protected function getNoEntriesText(bool $search): string
63 {
64 if (!$search) {
65 $mess_txt = $this->lng->txt("notes_no_comments");
66 } else {
67 $mess_txt = $this->lng->txt("notes_no_comments_found");
68 }
69 return $mess_txt;
70 }
71
72 protected function getItemGroupTitle(int $obj_id = 0): string
73 {
74 if (!$this->show_header) {
75 return "";
76 }
77 return $this->lng->txt("notes_comments");
78 }
79
80 protected function getItemTitle(Note $note): string
81 {
82 return $this->gui->profile()->getNamePresentation($note->getAuthor());
83 }
84
85 protected function addItemProperties(Note $note, array &$properties): void
86 {
88 $properties[$this->lng->txt("create_date")] = $creation_date;
89 }
90
91 protected function getFormLabelKey(): string
92 {
93 return "comment";
94 }
95
96 protected function getDeleteText(): string
97 {
98 return $this->lng->txt("notes_delete_comment");
99 }
100
101 protected function getLatestItemText(): string
102 {
103 return $this->lng->txt("notes_latest_comment");
104 }
105
106 protected function getAddEditItemText(): string
107 {
108 return $this->lng->txt("notes_add_edit_comment");
109 }
110
111
112 /*
113 public function getHTML(): string
114 {
115 $this->gui->initJavascript();
116 return $this->getCommentsWidget();
117 }*/
118
119 public function getListHTML(bool $a_init_form = true): string
120 {
121 $ilUser = $this->user;
123 $ilCtrl = $this->ctrl;
125
126 if ($this->ajax) {
127 $this->gui->initJavascript();
128 }
129 $ilCtrl = $this->ctrl;
130 $ilCtrl->setParameter($this, "notes_type", $this->note_type);
131
132 $content = "";
133 // #15948 - public enabled vs. comments_settings
134 $active = true;
135 // news items (in timeline) do not check, if the object has news activated!
136 if (!is_array($this->rep_obj_id) && $this->news_id === 0) {
137
138 // if common object settings are used, we check for activation
139 // 37713, 37701
140 // removed setting check due to 41511
141 //if ($this->comments_settings) {
142 $active = $this->manager->commentsActive($this->rep_obj_id);
143 //}
144 }
145 if ($active) {
146 $content = $this->getNoteListHTML($a_init_form);
147 }
148
149 // Comments Settings
150 if (!is_array($this->rep_obj_id) && $this->comments_settings && $ilUser->getId() !== ANONYMOUS_USER_ID) {
151 $active = $this->manager->commentsActive($this->rep_obj_id);
152 if ($active) {
153 if ($this->news_id === 0) {
154 $content .= $this->renderComponents([$this->getShyButton(
155 "comments_settings",
156 $lng->txt("notes_deactivate_comments"),
157 "deactivateComments",
158 ""
159 )
160 ]);
161 }
162 } else {
163 $content .= $this->renderComponents([$this->getShyButton(
164 "comments_settings",
165 $lng->txt("notes_activate_comments"),
166 "activateComments",
167 ""
168 )
169 ]);
170 /*
171 if ($this->ajax && !$comments_col) {
172 $ntpl->setVariable(
173 "COMMENTS_MESS",
174 ilUtil::getSystemMessageHTML($lng->txt("comments_feature_currently_not_activated_for_object"), "info")
175 );
176 }*/
177 }
178 }
179 return $this->renderContent($content);
180 }
181
182
183
184 protected function getListTitle(): string
185 {
186 return $this->lng->txt("notes_public_comments");
187 }
188
189 protected function getAddText(): string
190 {
191 return $this->lng->txt("note_add_comment");
192 }
193
194 protected function getDeletedMultipleText(): string
195 {
196 return $this->lng->txt("notes_comments_deleted");
197 }
198
199 protected function getDeletedSingleText(): string
200 {
201 return $this->lng->txt("notes_comment_deleted");
202 }
203
204}
const IL_CAL_DATETIME
__construct( $rep_obj_id=0, int $obj_id=0, string $obj_type="", bool $include_subobjects=false, int $news_id=0, bool $ajax=true, string $search_text="")
getNoEntriesText(bool $search)
getItemGroupTitle(int $obj_id=0)
addItemProperties(Note $note, array &$properties)
getItemTitle(Note $note)
getListHTML(bool $a_init_form=true)
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
Base class for ILIAS Exception handling.
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...
@ilCtrl_Calls ilNoteGUI: ilCommentGUI
renderComponents(array $components)
ilSetting $settings
getShyButton(string $a_var, string $a_txt, string $a_cmd, string $a_anchor="", int $note_id=0)
getNoteListHTML(bool $a_init_form=true)
renderContent(string $content)
Render content into notes wrapper.
ilObjUser $user
enablePrivateNotes(bool $a_enable=true)
string $obj_type
string $search_text
ilLanguage $lng
enablePublicNotes(bool $a_enable=true)
const ANONYMOUS_USER_ID
Definition: constants.php:27
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:31