Render item.
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
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
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"));
116 if (
117 $this->news_item->getUpdateUserId() > 0 &&
118 ($this->news_item->getUpdateUserId() !== $this->news_item->getUserId())
119 ) {
121 $this->news_item->getUpdateUserId(),
122 false,
123 true,
124 $this->ctrl->getLinkTargetByClass(ilNewsTimelineGUI::class)
125 ) . " - ");
126 }
128 $tpl->parseCurrentBlock();
129 }
130
131
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();
138 }
139
140
141 if ($this->news_item->getMobId() > 0 &&
ilObject::_exists($this->news_item->getMobId())) {
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
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
171
172
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
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)
getDateTime()
Get datetime.
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: