28 protected \ILIAS\News\InternalGUIService
$gui;
29 protected \ILIAS\Notes\Service
$notes;
49 protected readonly
NewsItem $news_item,
54 $this->
lng = $DIC->language();
55 $this->
ctrl = $DIC->ctrl();
56 $this->
user = $DIC->user();
57 $this->obj_def =
$DIC[
"objDefinition"];
59 $this->std_request =
$DIC->news()
63 $this->ref_id = $this->std_request->getRefId();
64 $this->gui =
$DIC->news()
67 $this->notes =
$DIC->notes();
75 return new self($news_item, $like_gui);
83 $this->user_edit_all = $a_val;
91 return $this->user_edit_all;
101 $tpl =
new ilTemplate(
"tpl.timeline_item.html",
true,
true,
"components/ILIAS/News");
102 $ui_factory = $this->gui->ui()->factory();
103 $ui_renderer = $this->gui->ui()->renderer();
106 $news_renderer->setLanguage($this->
lng->getLangKey());
107 $news_renderer->setNewsItem($this->news_item->toLegacy(), $this->news_item->getContextRefId());
109 $obj_id = $this->news_item->getContextObjId();
112 if ($this->news_item->getCreationDate() !== $this->news_item->getUpdateDate()) {
113 $tpl->setCurrentBlock(
"edited");
115 $tpl->setVariable(
"TXT_EDITED", $this->
lng->txt(
"cont_news_edited"));
117 $this->news_item->getUpdateUserId() > 0 &&
118 ($this->news_item->getUpdateUserId() !== $this->news_item->getUserId())
121 $this->news_item->getUpdateUserId(),
124 $this->ctrl->getLinkTargetByClass(ilNewsTimelineGUI::class)
128 $tpl->parseCurrentBlock();
132 if ($this->news_item->getContextRefId() > 0 && $this->ref_id !== $this->news_item->getContextRefId()) {
133 $tpl->setCurrentBlock(
"object");
136 $tpl->setVariable(
"OBJ_HREF", $news_renderer->getObjectLink());
137 $tpl->parseCurrentBlock();
141 if ($this->news_item->getMobId() > 0 &&
ilObject::_exists($this->news_item->getMobId())) {
142 $media = $this->renderMedia();
143 $tpl->setCurrentBlock(
"player");
144 $tpl->setVariable(
"PLAYER", $media);
145 $tpl->parseCurrentBlock();
148 $p = $this->gui->profile();
149 $tpl->setVariable(
"USER_AVATAR", $this->gui->ui()->renderer()->render(
150 $p->getAvatar($this->news_item->getUserId())
155 $this->news_item->getContextObjType(),
156 $this->news_item->getTitle(),
157 $this->news_item->isContentIsLangVar()
162 $tpl->setVariable(
"CONTENT", $news_renderer->getTimelineContent());
164 $tpl->setVariable(
"TXT_USR", $p->getNamePresentation(
165 $this->news_item->getUserId(),
167 $this->ctrl->getLinkTargetByClass(ilNewsTimelineGUI::class)
176 $this->news_item->getPriority() === 1 &&
177 ($this->news_item->getUserId() === $this->user->getId() || $this->getUserEditAll())
179 if (!$news_renderer->preventEditing()) {
180 $i = $this->news_item;
181 $actions[] = $ui_factory->button()->shy(
182 $this->
lng->txt(
"edit"),
184 )->withOnLoadCode(
static function (
$id) use ($i) {
185 return "document.getElementById('$id').addEventListener('click', () => {il.News.edit(" . $i->getId() .
");});";
187 $actions[] = $ui_factory->button()->shy(
188 $this->
lng->txt(
"delete"),
190 )->withOnLoadCode(
static function (
$id) use ($i) {
191 return "document.getElementById('$id').addEventListener('click', () => {il.News.delete(" . $i->getId() .
");});";
195 foreach ($news_renderer->getTimelineActions() as $action) {
196 $actions[] = $action;
198 $dd = $ui_factory->dropdown()->standard($actions);
199 $tpl->setVariable(
"ACTIONS", $ui_renderer->render($dd));
206 $media_path = $this->getMediaPath();
209 $ui_factory = $this->gui->ui()->factory();
210 $ui_renderer = $this->gui->ui()->renderer();
212 if (in_array($mime, [
"image/jpeg",
"image/svg+xml",
"image/gif",
"image/png"])) {
213 if (isset($this->item_image[$this->news_item->getId()]) && isset($this->item_modal[$this->news_item->getId()])) {
214 $image = $this->item_image[$this->news_item->getId()];
216 $title = $this->media_object->getTitle();
217 $image = $ui_factory->image()->responsive($media_path, $title);
218 $modal_page = $ui_factory->modal()->lightboxImagePage($image, $title);
219 $modal = $ui_factory->modal()->lightbox($modal_page);
220 $image = $image->withAction($modal->getShowSignal());
221 $this->item_image[$this->news_item->getId()] = $image;
222 $this->item_modal[$this->news_item->getId()] = $modal;
224 $html = $ui_renderer->render($image);
225 } elseif (in_array($mime, [
"video/mp4",
"video/youtube",
"video/vimeo"])) {
226 $video = $ui_factory->player()->video($media_path);
227 $html = $ui_renderer->render($video);
228 } elseif (in_array($mime, [
"audio/mpeg"])) {
229 $audio = $ui_factory->player()->audio($media_path);
230 $html = $ui_renderer->render($audio);
231 } elseif (in_array($mime, [
"application/pdf"])) {
232 $this->
ctrl->setParameterByClass(ilNewsTimelineGUI::class,
"news_id", $this->news_item->getId());
233 $link = $ui_factory->link()->standard(
234 basename($media_path),
235 $this->
ctrl->getLinkTargetByClass(ilNewsTimelineGUI::class,
"downloadMob")
237 $html = $ui_renderer->render($link);
238 $this->
ctrl->setParameterByClass(ilNewsTimelineGUI::class,
"news_id",
null);
247 $ui_factory = $this->gui->ui()->factory();
248 $ui_renderer = $this->gui->ui()->renderer();
250 if (isset($this->item_image[$this->news_item->getId()]) && isset($this->item_modal[$this->news_item->getId()])) {
251 $modal = $this->item_modal[$this->news_item->getId()];
252 return $ui_renderer->render($modal);
255 $media_path = $this->getMediaPath();
260 if (in_array($mime, [
"image/jpeg",
"image/svg+xml",
"image/gif",
"image/png"])) {
261 $title = $this->media_object->getTitle();
262 $image = $ui_factory->image()->responsive($media_path, $title);
263 $modal_page = $ui_factory->modal()->lightboxImagePage($image, $title);
264 $modal = $ui_factory->modal()->lightbox($modal_page);
265 $image = $image->withAction($modal->getShowSignal());
266 $this->item_image[$this->news_item->getId()] = $image;
267 $this->item_modal[$this->news_item->getId()] = $modal;
268 $modal_html = $ui_renderer->render($modal);
276 $this->
ctrl->setParameterByClass(ilNewsTimelineGUI::class,
"news_id", $this->news_item->getId());
277 $this->like_gui->setObject(
278 $this->news_item->getContextObjId(),
279 $this->news_item->getContextObjType(),
280 $this->news_item->getContextSubObjId(),
281 (
string) $this->news_item->getContextSubObjType(),
282 $this->news_item->getId()
284 $html = $this->
ctrl->getHTML($this->like_gui);
287 $notes_obj_type = ($this->news_item->getContextSubObjType() ===
null)
288 ? $this->news_item->getContextObjType()
289 : $this->news_item->getContextSubObjType();
290 $comments_gui = $this->notes->gui()->getCommentsGUI(
291 $this->news_item->getContextObjId(),
292 $this->news_item->getContextSubObjId(),
294 $this->news_item->getId()
296 $comments_gui->setDefaultCommand(
"getWidget");
297 $comments_gui->setShowEmptyListMessage(
false);
298 $comments_gui->setShowHeader(
false);
299 $html .= $comments_gui->getWidget();
302 $this->
ctrl->setParameterByClass(ilNewsTimelineGUI::class,
"news_id", $this->std_request->getNewsId());
304 return $html . $this->renderMediaModal($this->news_item);
309 return $this->news_item->getMobId() > 0 ? $this->media_object->getStandardSrc() :
"";
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
News Item DTO for transfer of news items.
Class ilCtrl provides processing control methods.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
User interface for like feature.
static determineNewsTitle(string $a_context_obj_type, string $a_title, bool $a_content_is_lang_var, int $a_agg_ref_id=0, array $a_aggregation=[], ?ilLanguage $lng=null)
Determine title for news item entry.
static getRenderer(string $a_context_obj_type)
Single news timeline item.
setUserEditAll(bool $a_val)
Set user can edit other users postings.
static getInstance(NewsItem $news_item, ilLikeGUI $like_gui)
getDateTime()
Get datetime.
ILIAS Notes Service $notes
StandardGUIRequest $std_request
readonly ilObjMediaObject $media_object
ilObjectDefinition $obj_def
getUserEditAll()
Get user can edit other users postings.
ILIAS News InternalGUIService $gui
__construct(protected readonly NewsItem $news_item, protected readonly ilLikeGUI $like_gui)
parses the objects.xml it handles the xml-description of all ilias objects
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupTitle(int $obj_id)
special template class to simplify handling of ITX/PEAR
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=null)
Default behaviour is:
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...