ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
SideBarGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Blog\Navigation;
22
25use ilTemplate;
33
35{
38
39 public function __construct(
42 protected ?PermissionManager $perm,
43 protected LinkBuilder $link_builder,
44 protected Settings $settings,
45 protected ?int $node_id = null,
46 protected int $id_type = \ilObjBlogGUI::REPOSITORY_NODE_ID
47 ) {
48 $this->domain = $domain;
49 $this->gui = $gui;
50 }
51
52 protected function mayEditPosting(int $blpg): bool
53 {
54 if ($this->link_builder instanceof EditingLinkBuilder &&
55 !is_null($this->perm) &&
56 $this->perm->mayEditPosting($blpg)) {
57 return true;
58 }
59 return false;
60 }
61
62 protected function isExport(): bool
63 {
64 return $this->link_builder instanceof ExportLinkBuilder;
65 }
66
67 protected function isPresentation(): bool
68 {
69 return $this->link_builder instanceof PresentationLinkBuilder;
70 }
71
75 public function render(
76 array $items,
77 bool $show_inactive = false,
78 int $blpg = 0
79 ): string {
80 $lng = $this->domain->lng();
81 $ui = $this->gui->ui();
82 if ($this->settings->getOrder()) {
83 $order = array_flip($this->settings->getOrder());
84 } else {
85 $order = array(
86 "navigation" => 0,
87 "keywords" => 2,
88 "authors" => 1
89 );
90 }
91
92 $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true, "components/ILIAS/Blog");
93
94 $blocks = array();
95
96 // by date
97 if (count($items)) {
98 $blocks[$order["navigation"] ?? 0] = array(
99 $lng->txt("blog_navigation"),
100 $this->gui->navigation()->monthBlock(
101 $this->link_builder,
102 $this->id_type === \ilObjBlogGUI::REPOSITORY_NODE_ID
103 )->render(
104 $items,
105 $show_inactive,
106 $blpg
107 )
108 );
109 }
110
111 if ($this->settings->getKeywords()) {
112 // keywords
113 $may_edit_keywords = ($blpg > 0 &&
114 $this->mayEditPosting($blpg));
115
116 $keywords = $this->gui->navigation()->keywordBlock(
117 $this->link_builder,
118 $this->id_type === \ilObjBlogGUI::REPOSITORY_NODE_ID
119 )->render(
120 $show_inactive,
121 $blpg
122 );
123 if ($keywords || $may_edit_keywords) {
124 if (!$keywords) {
125 $keywords = $lng->txt("blog_no_keywords");
126 }
127 $cmd = null;
128 $blocks[$order["keywords"] ?? 2] = array(
129 $lng->txt("blog_keywords"),
130 $keywords,
131 $cmd
132 ? array($cmd, $lng->txt("blog_edit_keywords"))
133 : null
134 );
135 }
136 }
137
138 // is not part of (html) export
139 if (!$this->isExport()) {
140 // authors
141 if ($this->id_type === \ilObjBlogGUI::REPOSITORY_NODE_ID &&
142 $this->settings->getAuthors()) {
143 $authors = $this->gui->navigation()->authorBlock($this->link_builder)->render(
144 $show_inactive
145 );
146 if ($authors) {
147 $blocks[$order["authors"] ?? 1] = array($lng->txt("blog_authors"), $authors);
148 }
149 }
150
151 // rss
152 if ($this->settings->getRSS() &&
153 $this->domain->settings()->get('enable_global_profiles') &&
154 $this->isPresentation()) {
155 // #10827
156 $blog_id = (string) $this->node_id;
157 if ($this->id_type !== \ilObjBlogGUI::WORKSPACE_NODE_ID) {
158 $blog_id .= "_cll";
159 }
160 $url = ILIAS_HTTP_PATH . "/feed.php?blog_id=" . $blog_id .
161 "&client_id=" . rawurlencode(CLIENT_ID);
162
163 $wtpl->setVariable("RSS_BUTTON", ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_RSS, $url));
164 }
165 }
166
167 if (count($blocks)) {
168 $ui_factory = $ui->factory();
169 $ui_renderer = $ui->renderer();
170
171 ksort($blocks);
172 foreach ($blocks as $block) {
173 $title = $block[0];
174 $content = $block[1];
175
176 $secondary_panel = $ui_factory->panel()->secondary()->legacy($title, $ui_factory->legacy()->content($content));
177
178 if (isset($block[2]) && is_array($block[2])) {
179 $link = $ui_factory->button()->shy($block[2][1], $block[2][0]);
180 $secondary_panel = $secondary_panel->withFooter($link);
181 }
182
183 $wtpl->setCurrentBlock("block_bl");
184 $wtpl->setVariable("BLOCK", $ui_renderer->render($secondary_panel));
185 $wtpl->parseCurrentBlock();
186 }
187 }
188
189 return $wtpl->get();
190 }
191}
$settings
Definition: index.php:44
InternalDomainService $domain
Definition: SideBarGUI.php:36
render(array $items, bool $show_inactive=false, int $blpg=0)
Build navigation blocks.
Definition: SideBarGUI.php:75
__construct(InternalDomainService $domain, InternalGUIService $gui, protected ?PermissionManager $perm, protected LinkBuilder $link_builder, protected Settings $settings, protected ?int $node_id=null, protected int $id_type=\ilObjBlogGUI::REPOSITORY_NODE_ID)
Definition: SideBarGUI.php:39
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static get(string $a_type, string $a_href="")
Get icon html.
special template class to simplify handling of ITX/PEAR
const CLIENT_ID
Definition: constants.php:41
global $lng
Definition: privfeed.php:26