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