ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilNewsTimelineItemGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $lng;
18
22 protected $news_item;
23
27 protected $obj_def;
28
32 protected $user;
33
37 protected $user_edit_all;
38
45
50 protected $ref_id;
51
55 protected $ctrl;
56
62 protected function __construct(ilNewsItem $a_news_item, $a_news_ref_id)
63 {
64 global $DIC;
65
66 $this->lng = $DIC->language();
67 $this->ctrl = $DIC->ctrl();
68 $this->setNewsItem($a_news_item);
69 $this->user = $DIC->user();
70 $this->obj_def = $DIC["objDefinition"];
71 $this->news_item_ref_id = $a_news_ref_id;
72
73 $this->ref_id = (int) $_GET["ref_id"];
74 }
75
82 static function getInstance(ilNewsItem $a_news_item, $a_news_ref_id)
83 {
84 return new self($a_news_item, $a_news_ref_id);
85 }
86
87
93 function setNewsItem(ilNewsItem $a_val)
94 {
95 $this->news_item = $a_val;
96 }
97
103 function getNewsItem()
104 {
105 return $this->news_item;
106 }
107
113 function setUserEditAll($a_val)
114 {
115 $this->user_edit_all = $a_val;
116 }
117
123 function getUserEditAll()
124 {
126 }
127
131 function getDateTime()
132 {
133 $i = $this->getNewsItem();
134 return new ilDateTime($i->getCreationDate(), IL_CAL_DATETIME);
135 }
136
137
141 function render()
142 {
143 $i = $this->getNewsItem();
144 $tpl = new ilTemplate("tpl.timeline_item.html", true, true, "Services/News");
145
146 include_once("./Services/News/classes/class.ilNewsRendererFactory.php");
147 $news_renderer = ilNewsRendererFactory::getRenderer($i->getContextObjType());
148 $news_renderer->setLanguage($this->lng->getLangKey());
149 $news_renderer->setNewsItem($i, $this->news_item_ref_id);
150
151 $obj_id = $i->getContextObjId();
152
153 // edited?
154 if ($i->getCreationDate() != $i->getUpdateDate())
155 {
156 $tpl->setCurrentBlock("edited");
157 $update_date = new ilDateTime($i->getUpdateDate(), IL_CAL_DATETIME);
158 $tpl->setVariable("TXT_EDITED", $this->lng->txt("cont_news_edited"));
159 if ($i->getUpdateUserId() > 0 && ($i->getUpdateUserId() != $i->getUserId()))
160 {
161 include_once("./Services/User/classes/class.ilUserUtil.php");
162 $tpl->setVariable("TXT_USR_EDITED", ilUserUtil::getNamePresentation($i->getUpdateUserId(), false, true,
163 $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")) . " - ");
164 }
165 include_once("./Services/Calendar/classes/class.ilDatePresentation.php");
166 $tpl->setVariable("TIME_EDITED", ilDatePresentation::formatDate($update_date));
167 $tpl->parseCurrentBlock();
168 }
169
170
171 // context object link
172 include_once("./Services/Link/classes/class.ilLink.php");
173 if ($this->news_item_ref_id > 0 && $this->ref_id != $this->news_item_ref_id)
174 {
175 $tpl->setCurrentBlock("object");
176 $tpl->setVariable("OBJ_TITLE", ilObject::_lookupTitle($obj_id));
177 $tpl->setVariable("OBJ_IMG", ilObject::_getIcon($obj_id));
178 $tpl->setVariable("OBJ_HREF", $news_renderer->getObjectLink());
179 $tpl->parseCurrentBlock();
180 }
181
182 // media
183 if ($i->getContentType() == NEWS_AUDIO &&
184 $i->getMobId() > 0 && ilObject::_exists($i->getMobId()))
185 {
186 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
187 include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
188 $mob = new ilObjMediaObject($i->getMobId());
189 $med = $mob->getMediaItem("Standard");
190 $mpl = new ilMediaPlayerGUI("news_pl_".$i->getMobId());
191 if (strcasecmp("Reference", $med->getLocationType()) == 0)
192 $mpl->setFile($med->getLocation());
193 else
194 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId())."/".$med->getLocation());
195 $mpl->setDisplayHeight($med->getHeight());
196 //$mpl->setDisplayWidth("100%");
197 //$mpl->setDisplayHeight("320");
198 $tpl->setCurrentBlock("player");
199 $tpl->setVariable("PLAYER",
200 $mpl->getMp3PlayerHtml());
201 $tpl->parseCurrentBlock();
202 }
203
204
205 $tpl->setVariable("USER_IMAGE", ilObjUser::_getPersonalPicturePath($i->getUserId(), "xsmall"));
206 if (!$i->getContentIsLangVar())
207 {
208 $tpl->setVariable("TITLE", $i->getTitle());
209 }
210 else
211 {
212 $tpl->setVariable("TITLE", $this->lng->txt($i->getTitle()));
213 }
214
215 // content
216 $tpl->setVariable("CONTENT", $news_renderer->getTimelineContent());
217
218 include_once("./Services/User/classes/class.ilUserUtil.php");
219 $tpl->setVariable("TXT_USR", ilUserUtil::getNamePresentation($i->getUserId(), false, true,
220 $this->ctrl->getLinkTargetByClass("ilnewstimelinegui")));
221
222 include_once("./Services/Calendar/classes/class.ilDatePresentation.php");
223 $tpl->setVariable("TIME", ilDatePresentation::formatDate($this->getDateTime()));
224
225 // actions
226 include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
227 $list = new ilAdvancedSelectionListGUI();
228 $list->setListTitle("");
229 $list->setId("news_tl_act_".$i->getId());
230 //$list->setSelectionHeaderClass("small");
231 //$list->setItemLinkClass("xsmall");
232 //$list->setLinksMode("il_ContainerItemCommand2");
234 $list->setUseImages(false);
235
236 if ($i->getPriority() == 1 && ($i->getUserId() == $this->user->getId() || $this->getUserEditAll()))
237 {
238 $list->addItem($this->lng->txt("edit"), "", "", "", "", "",
239 "", false, "il.News.edit(" . $i->getId() . ");");
240 $list->addItem($this->lng->txt("delete"), "", "", "", "", "",
241 "", false, "il.News.delete(" . $i->getId() . ");");
242 }
243
244 $news_renderer->addTimelineActions($list);
245
246 $tpl->setVariable("ACTIONS", $list->getHTML());
247
248
249 return $tpl->get();
250 }
251
252}
253
254?>
user()
Definition: user.php:4
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
const NEWS_AUDIO
User interface class for advanced drop-down selection lists.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
User interface for media player.
static getRenderer($a_context_obj_type)
Get renderer.
Single news timeline item.
__construct(ilNewsItem $a_news_item, $a_news_ref_id)
Constructor.
getDateTime()
Get datetime.ilDateTime timestamp
render()
Render item.string html
setNewsItem(ilNewsItem $a_val)
Set news item.
static getInstance(ilNewsItem $a_news_item, $a_news_ref_id)
Get instance.
getUserEditAll()
Get user can edit other users postings.
setUserEditAll($a_val)
Set user can edit other users postings.
Class ilObjMediaObject.
static _getURL($a_mob_id)
get directory for files of media object (static)
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
static _lookupTitle($a_id)
lookup object title
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
special template class to simplify handling of ITX/PEAR
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
Interface for timeline items.
global $DIC