ILIAS  release_8 Revision v8.24
class.ilNewsDefaultRendererGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected \ILIAS\Refinery\Factory $refinery;
27 protected string $lng_key;
28 protected ilCtrl$ctrl;
29 protected ilLanguage $lng;
31 protected int $news_ref_id;
32
33 public function __construct()
34 {
35 global $DIC;
36
37 $this->ctrl = $DIC->ctrl();
38 $this->lng = $DIC->language();
39 $this->refinery = $DIC->refinery();
40 }
41
42 public function setNewsItem(
43 ilNewsItem $a_news_item,
44 int $a_news_ref_id
45 ): void {
46 $this->news_item = $a_news_item;
47 $this->news_ref_id = $a_news_ref_id;
48 }
49
50 public function getNewsItem(): ilNewsItem
51 {
52 return $this->news_item;
53 }
54
55 public function getNewsRefId(): int
56 {
57 return $this->news_ref_id;
58 }
59
60 public function setLanguage(string $lang_key): void
61 {
62 $this->lng_key = $lang_key;
63 }
64
65 public function getTimelineContent(): string
66 {
67 return $this->getDetailContent();
68 }
69
70 public function getDetailContent(): string
71 {
72 if ($this->news_item->getContentTextIsLangVar()) {
73 $this->lng->loadLanguageModule($this->news_item->getContextObjType());
75 $this->news_item->getContextObjType(),
76 $this->news_item->getContent(),
77 $this->news_item->getContentTextIsLangVar()
78 );
79 }
80
81 $content = $this->makeClickable($this->news_item->getContent());
82 if (!$this->news_item->getContentHtml()) {
83 $content = "<p>" . nl2br($content) . "</p>";
84 }
85 $content .= $this->news_item->getContentLong();
86
87 return $content;
88 }
89
90 public function makeClickable(string $a_str): string
91 {
92 // this fixes bug 8744.
93 // If the string already contains a tags our makeClickable does not work
94 if (is_int(strpos($a_str, "</a>")) && is_int(strpos($a_str, "<a"))) {
95 return $a_str;
96 }
97
98 return $this->refinery->string()->makeClickable()->transform($a_str);
99 }
100
102 {
103 }
104
105 public function getObjectLink(): string
106 {
107 return ilLink::_getLink($this->getNewsRefId());
108 }
109
110 public function preventEditing(): bool
111 {
112 return false;
113 }
114}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setNewsItem(ilNewsItem $a_news_item, int $a_news_ref_id)
getTimelineContent()
Render content for timeline.
getObjectLink()
Get link href for object link.
getDetailContent()
Render content for detail view.
addTimelineActions(ilAdvancedSelectionListGUI $list)
A news item can be created by different sources.
static determineNewsContent(string $a_context_obj_type, string $a_content, bool $a_is_lang_var)
Determine new content.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...