ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilNewsTimelineItemGUI Class Reference

Single news timeline item. More...

+ Inheritance diagram for ilNewsTimelineItemGUI:
+ Collaboration diagram for ilNewsTimelineItemGUI:

Public Member Functions

 setUserEditAll (bool $a_val)
 Set user can edit other users postings. More...
 
 getUserEditAll ()
 Get user can edit other users postings. More...
 
 getDateTime ()
 Get datetime. More...
 
 render ()
 Render item. More...
 
 renderFooter ()
 
 render ()
 Render item. More...
 
 getDateTime ()
 Get datetime. More...
 

Static Public Member Functions

static getInstance (NewsItem $news_item, ilLikeGUI $like_gui)
 

Protected Member Functions

 __construct (protected readonly NewsItem $news_item, protected readonly ilLikeGUI $like_gui)
 
 renderMedia ()
 
 renderMediaModal ()
 
 getMediaPath ()
 

Protected Attributes

ILIAS News InternalGUIService $gui
 
ILIAS Notes Service $notes
 
ilLanguage $lng
 
ilObjectDefinition $obj_def
 
ilObjUser $user
 
bool $user_edit_all
 
int $ref_id
 
ilCtrl $ctrl
 
StandardGUIRequest $std_request
 
array $item_image = []
 
array $item_modal = []
 
readonly ilObjMediaObject $media_object
 

Detailed Description

Single news timeline item.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file class.ilNewsTimelineItemGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilNewsTimelineItemGUI::__construct ( protected readonly NewsItem  $news_item,
protected readonly ilLikeGUI  $like_gui 
)
protected

Definition at line 48 of file class.ilNewsTimelineItemGUI.php.

51 {
52 global $DIC;
53
54 $this->lng = $DIC->language();
55 $this->ctrl = $DIC->ctrl();
56 $this->user = $DIC->user();
57 $this->obj_def = $DIC["objDefinition"];
58
59 $this->std_request = $DIC->news()
60 ->internal()
61 ->gui()
62 ->standardRequest();
63 $this->ref_id = $this->std_request->getRefId();
64 $this->gui = $DIC->news()
65 ->internal()
66 ->gui();
67 $this->notes = $DIC->notes();
68 $this->media_object = new ilObjMediaObject($this->news_item->getMobId());
69 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDateTime()

ilNewsTimelineItemGUI::getDateTime ( )

Get datetime.

Returns
ilDateTime timestamp

Implements ilTimelineItemInt.

Definition at line 94 of file class.ilNewsTimelineItemGUI.php.

95 {
96 return new ilDateTime($this->news_item->getCreationDate()->format('c'), IL_CAL_DATETIME);
97 }
const IL_CAL_DATETIME
@classDescription Date and time handling

References IL_CAL_DATETIME.

◆ getInstance()

static ilNewsTimelineItemGUI::getInstance ( NewsItem  $news_item,
ilLikeGUI  $like_gui 
)
static

Definition at line 71 of file class.ilNewsTimelineItemGUI.php.

74 : self {
75 return new self($news_item, $like_gui);
76 }

◆ getMediaPath()

ilNewsTimelineItemGUI::getMediaPath ( )
protected

Definition at line 307 of file class.ilNewsTimelineItemGUI.php.

307 : string
308 {
309 return $this->news_item->getMobId() > 0 ? $this->media_object->getStandardSrc() : "";
310 }

◆ getUserEditAll()

ilNewsTimelineItemGUI::getUserEditAll ( )

Get user can edit other users postings.

Definition at line 89 of file class.ilNewsTimelineItemGUI.php.

89 : bool
90 {
92 }

◆ render()

ilNewsTimelineItemGUI::render ( )

Render item.

Returns
string html

Implements ilTimelineItemInt.

Definition at line 99 of file class.ilNewsTimelineItemGUI.php.

99 : string
100 {
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();
104
105 $news_renderer = ilNewsRendererFactory::getRenderer($this->news_item->getContextObjType());
106 $news_renderer->setLanguage($this->lng->getLangKey());
107 $news_renderer->setNewsItem($this->news_item->toLegacy(), $this->news_item->getContextRefId());
108
109 $obj_id = $this->news_item->getContextObjId();
110
111 // edited?
112 if ($this->news_item->getCreationDate() !== $this->news_item->getUpdateDate()) {
113 $tpl->setCurrentBlock("edited");
114 $update_date = new ilDateTime($this->news_item->getUpdateDate()->format('c'), IL_CAL_DATETIME);
115 $tpl->setVariable("TXT_EDITED", $this->lng->txt("cont_news_edited"));
116 if (
117 $this->news_item->getUpdateUserId() > 0 &&
118 ($this->news_item->getUpdateUserId() !== $this->news_item->getUserId())
119 ) {
120 $tpl->setVariable("TXT_USR_EDITED", ilUserUtil::getNamePresentation(
121 $this->news_item->getUpdateUserId(),
122 false,
123 true,
124 $this->ctrl->getLinkTargetByClass(ilNewsTimelineGUI::class)
125 ) . " - ");
126 }
127 $tpl->setVariable("TIME_EDITED", ilDatePresentation::formatDate($update_date));
128 $tpl->parseCurrentBlock();
129 }
130
131 // context object link
132 if ($this->news_item->getContextRefId() > 0 && $this->ref_id !== $this->news_item->getContextRefId()) {
133 $tpl->setCurrentBlock("object");
134 $tpl->setVariable("OBJ_TITLE", ilObject::_lookupTitle($obj_id));
135 $tpl->setVariable("OBJ_IMG", ilObject::_getIcon($obj_id));
136 $tpl->setVariable("OBJ_HREF", $news_renderer->getObjectLink());
137 $tpl->parseCurrentBlock();
138 }
139
140 // media
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();
146 }
147
148 $p = $this->gui->profile();
149 $tpl->setVariable("USER_AVATAR", $this->gui->ui()->renderer()->render(
150 $p->getAvatar($this->news_item->getUserId())
151 ));
152 $tpl->setVariable(
153 "TITLE",
155 $this->news_item->getContextObjType(),
156 $this->news_item->getTitle(),
157 $this->news_item->isContentIsLangVar()
158 )
159 );
160
161 // content
162 $tpl->setVariable("CONTENT", $news_renderer->getTimelineContent());
163
164 $tpl->setVariable("TXT_USR", $p->getNamePresentation(
165 $this->news_item->getUserId(),
166 true,
167 $this->ctrl->getLinkTargetByClass(ilNewsTimelineGUI::class)
168 ));
169
170 $tpl->setVariable("TIME", ilDatePresentation::formatDate($this->getDateTime()));
171
172 // actions
173 $actions = [];
174
175 if (
176 $this->news_item->getPriority() === 1 &&
177 ($this->news_item->getUserId() === $this->user->getId() || $this->getUserEditAll())
178 ) {
179 if (!$news_renderer->preventEditing()) {
180 $i = $this->news_item;
181 $actions[] = $ui_factory->button()->shy(
182 $this->lng->txt("edit"),
183 ""
184 )->withOnLoadCode(static function ($id) use ($i) {
185 return "document.getElementById('$id').addEventListener('click', () => {il.News.edit(" . $i->getId() . ");});";
186 });
187 $actions[] = $ui_factory->button()->shy(
188 $this->lng->txt("delete"),
189 ""
190 )->withOnLoadCode(static function ($id) use ($i) {
191 return "document.getElementById('$id').addEventListener('click', () => {il.News.delete(" . $i->getId() . ");});";
192 });
193 }
194 }
195 foreach ($news_renderer->getTimelineActions() as $action) {
196 $actions[] = $action;
197 }
198 $dd = $ui_factory->dropdown()->standard($actions);
199 $tpl->setVariable("ACTIONS", $ui_renderer->render($dd));
200
201 return $tpl->get();
202 }
$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 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)
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:

References $id, ilObject\_exists(), ilObject\_getIcon(), ilObject\_lookupTitle(), ilNewsItem\determineNewsTitle(), ilDatePresentation\formatDate(), ilUserUtil\getNamePresentation(), ilNewsRendererFactory\getRenderer(), IL_CAL_DATETIME, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ renderFooter()

ilNewsTimelineItemGUI::renderFooter ( )

Definition at line 273 of file class.ilNewsTimelineItemGUI.php.

273 : string
274 {
275 // like
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()
283 );
284 $html = $this->ctrl->getHTML($this->like_gui);
285
286 // comments
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(),
293 $notes_obj_type,
294 $this->news_item->getId()
295 );
296 $comments_gui->setDefaultCommand("getWidget");
297 $comments_gui->setShowEmptyListMessage(false);
298 $comments_gui->setShowHeader(false);
299 $html .= $comments_gui->getWidget();
300 //$html .= $this->ctrl->getHTML($comments_gui);
301
302 $this->ctrl->setParameterByClass(ilNewsTimelineGUI::class, "news_id", $this->std_request->getNewsId());
303
304 return $html . $this->renderMediaModal($this->news_item);
305 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ renderMedia()

ilNewsTimelineItemGUI::renderMedia ( )
protected

Definition at line 204 of file class.ilNewsTimelineItemGUI.php.

204 : string
205 {
206 $media_path = $this->getMediaPath();
207 $mime = ilObjMediaObject::getMimeType($media_path);
208
209 $ui_factory = $this->gui->ui()->factory();
210 $ui_renderer = $this->gui->ui()->renderer();
211
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()];
215 } else {
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;
223 }
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")
236 );
237 $html = $ui_renderer->render($link);
238 $this->ctrl->setParameterByClass(ilNewsTimelineGUI::class, "news_id", null);
239 } else {
240 $html = "";
241 }
242 return $html;
243 }
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file

References ILIAS\Repository\ctrl(), and ilObjMediaObject\getMimeType().

+ Here is the call graph for this function:

◆ renderMediaModal()

ilNewsTimelineItemGUI::renderMediaModal ( )
protected

Definition at line 245 of file class.ilNewsTimelineItemGUI.php.

245 : string
246 {
247 $ui_factory = $this->gui->ui()->factory();
248 $ui_renderer = $this->gui->ui()->renderer();
249
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);
253 }
254
255 $media_path = $this->getMediaPath();
256 $mime = ilObjMediaObject::getMimeType($media_path);
257
258 $modal_html = "";
259
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);
269 }
270 return $modal_html;
271 }

References ilObjMediaObject\getMimeType().

+ Here is the call graph for this function:

◆ setUserEditAll()

ilNewsTimelineItemGUI::setUserEditAll ( bool  $a_val)

Set user can edit other users postings.

Definition at line 81 of file class.ilNewsTimelineItemGUI.php.

81 : void
82 {
83 $this->user_edit_all = $a_val;
84 }

Field Documentation

◆ $ctrl

ilCtrl ilNewsTimelineItemGUI::$ctrl
protected

Definition at line 35 of file class.ilNewsTimelineItemGUI.php.

◆ $gui

ILIAS News InternalGUIService ilNewsTimelineItemGUI::$gui
protected

Definition at line 28 of file class.ilNewsTimelineItemGUI.php.

◆ $item_image

array ilNewsTimelineItemGUI::$item_image = []
protected

Definition at line 40 of file class.ilNewsTimelineItemGUI.php.

◆ $item_modal

array ilNewsTimelineItemGUI::$item_modal = []
protected

Definition at line 44 of file class.ilNewsTimelineItemGUI.php.

◆ $lng

ilLanguage ilNewsTimelineItemGUI::$lng
protected

Definition at line 30 of file class.ilNewsTimelineItemGUI.php.

◆ $media_object

readonly ilObjMediaObject ilNewsTimelineItemGUI::$media_object
protected

Definition at line 46 of file class.ilNewsTimelineItemGUI.php.

◆ $notes

ILIAS Notes Service ilNewsTimelineItemGUI::$notes
protected

Definition at line 29 of file class.ilNewsTimelineItemGUI.php.

◆ $obj_def

ilObjectDefinition ilNewsTimelineItemGUI::$obj_def
protected

Definition at line 31 of file class.ilNewsTimelineItemGUI.php.

◆ $ref_id

int ilNewsTimelineItemGUI::$ref_id
protected

Definition at line 34 of file class.ilNewsTimelineItemGUI.php.

◆ $std_request

StandardGUIRequest ilNewsTimelineItemGUI::$std_request
protected

Definition at line 36 of file class.ilNewsTimelineItemGUI.php.

◆ $user

ilObjUser ilNewsTimelineItemGUI::$user
protected

Definition at line 32 of file class.ilNewsTimelineItemGUI.php.

◆ $user_edit_all

bool ilNewsTimelineItemGUI::$user_edit_all
protected

Definition at line 33 of file class.ilNewsTimelineItemGUI.php.


The documentation for this class was generated from the following file: