ILIAS  release_8 Revision v8.24
class.ilWikiFunctionsBlockGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 public static $block_type = "wikiside";
27 public static $st_data;
28 protected int $ref_id;
30 protected ilObjWiki $wiki;
31
32 public function __construct()
33 {
34 global $DIC;
35
37 ->wiki()
38 ->internal()
39 ->gui()
40 ->editing()
41 ->request();
42
43 $this->ctrl = $DIC->ctrl();
44 $this->lng = $DIC->language();
45 $this->user = $DIC->user();
46 $this->access = $DIC->access();
47 $lng = $DIC->language();
48
50
51 $lng->loadLanguageModule("wiki");
52 $this->setEnableNumInfo(false);
53
54 $this->setTitle($lng->txt("wiki_functions"));
55 $this->allow_moving = false;
56
57 $this->ref_id = $request->getRefId();
58
59 $this->wiki = new ilObjWiki($this->ref_id);
60
61 $this->setPresentation(self::PRES_SEC_LEG);
62 }
63
64 public function getBlockType(): string
65 {
66 return self::$block_type;
67 }
68
69 protected function isRepositoryObject(): bool
70 {
71 return false;
72 }
73
77 public function executeCommand()
78 {
79 $ilCtrl = $this->ctrl;
80
81 $next_class = $ilCtrl->getNextClass();
82 $cmd = $ilCtrl->getCmd("getHTML");
83
84 switch ($next_class) {
85 default:
86 return $this->$cmd();
87 }
88 }
89
90 public function setPageObject(ilWikiPage $a_pageob): void
91 {
92 $this->pageob = $a_pageob;
93 }
94
95 public function getPageObject(): ilWikiPage
96 {
97 return $this->pageob;
98 }
99
100 public function fillDataSection(): void
101 {
102 $this->setDataSection($this->getLegacyContent());
103 }
104
105 //
106 // New rendering
107 //
108
109 protected bool $new_rendering = true;
110
111
112 protected function getLegacyContent(): string
113 {
114 $ilCtrl = $this->ctrl;
116 $ilAccess = $this->access;
117
118 $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki");
119
120 $wp = $this->getPageObject();
121
122 // info
123 $actions[] = array(
124 "txt" => $lng->txt("info_short"),
125 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")
126 );
127
128 // recent changes
129 $actions[] = array(
130 "txt" => $lng->txt("wiki_recent_changes"),
131 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")
132 );
133
134 foreach ($actions as $a) {
135 $tpl->setCurrentBlock("action");
136 $tpl->setVariable("HREF", $a["href"]);
137 $tpl->setVariable("TXT", $a["txt"]);
139
140 $tpl->touchBlock("item");
141 }
142
143
144 $actions = array();
145
146 // all pages
147 $actions[] = array(
148 "txt" => $lng->txt("wiki_all_pages"),
149 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")
150 );
151
152 // new pages
153 $actions[] = array(
154 "txt" => $lng->txt("wiki_new_pages"),
155 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")
156 );
157
158 // popular pages
159 $actions[] = array(
160 "txt" => $lng->txt("wiki_popular_pages"),
161 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")
162 );
163
164 // orphaned pages
165 $actions[] = array(
166 "txt" => $lng->txt("wiki_orphaned_pages"),
167 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")
168 );
169
170
171 // page lists
172 $list = new ilAdvancedSelectionListGUI();
173 $list->setListTitle($lng->txt("wiki_page_lists"));
175 $list->setId("wiki_pglists");
176
177 foreach ($actions as $a) {
178 $list->addItem(
179 $a["txt"],
180 "",
181 $a["href"]
182 );
183 }
184 $tpl->setCurrentBlock("plain");
185 $tpl->setVariable("PLAIN", $list->getHTML());
187 $tpl->touchBlock("item");
188
189
190 // page actions
191 $list = new ilAdvancedSelectionListGUI();
193 $list->setListTitle($lng->txt("wiki_page_actions"));
194 $list->setId("wiki_pgactions");
195
196 if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
197 // rating
198 if (ilObjWiki::_lookupRating($this->getPageObject()->getWikiId())) {
199 if (!$this->getPageObject()->getRating()) {
200 $list->addItem(
201 $lng->txt("wiki_activate_page_rating"),
202 "",
203 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating")
204 );
205 } else {
206 $list->addItem(
207 $lng->txt("wiki_deactivate_page_rating"),
208 "",
209 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating")
210 );
211 }
212 }
213 }
214
215 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
216 $ilAccess->checkAccess("edit_page_meta", "", $this->ref_id)) {
217 // unhide advmd?
218 if (count(ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->ref_id, "wpg")) &&
220 $list->addItem(
221 $lng->txt("wiki_unhide_meta_adv_records"),
222 "",
223 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData")
224 );
225 }
226 }
227
228 if (($ilAccess->checkAccess("edit_content", "", $this->ref_id) && !$this->getPageObject()->getBlocked())
229 || $ilAccess->checkAccess("write", "", $this->ref_id)) {
230 // rename
231 $list->addItem(
232 $lng->txt("wiki_rename_page"),
233 "",
234 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage")
235 );
236 }
237
238 if (ilWikiPerm::check("activate_wiki_protection", $this->ref_id)) {
239 // block/unblock
240 if ($this->getPageObject()->getBlocked()) {
241 $list->addItem(
242 $lng->txt("wiki_unblock_page"),
243 "",
244 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage")
245 );
246 } else {
247 $list->addItem(
248 $lng->txt("wiki_block_page"),
249 "",
250 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage")
251 );
252 }
253 }
254
255 if (ilWikiPerm::check("delete_wiki_pages", $this->ref_id)) {
256 // delete page
257 $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
258 if ($st_page !== $this->getPageObject()->getTitle()) {
259 $list->addItem(
260 $lng->txt("wiki_delete_page"),
261 "",
262 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen")
263 );
264 }
265 }
266
267 if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
268 $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId());
269 if (!$wpt->isPageTemplate($this->getPageObject()->getId())) {
270 $list->addItem(
271 $lng->txt("wiki_add_template"),
272 "",
273 $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction")
274 );
275 } else {
276 $list->addItem(
277 $lng->txt("wiki_remove_template_status"),
278 "",
279 $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction")
280 );
281 }
282 }
283
284 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
285 $ilAccess->checkAccess("read", "", $this->ref_id)) {
286 $tpl->setCurrentBlock("plain");
287 $tpl->setVariable("PLAIN", $list->getHTML());
289 $tpl->touchBlock("item");
290 }
291
292 // permissions
293 // if ($ilAccess->checkAccess('edit_permission', "", $this->ref_id))
294 // {
295 // $actions[] = array(
296 // "txt" => $lng->txt("perm_settings"),
297 // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
298 // );
299 // }
300
301 $actions = array();
302
303 // settings
304 if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
305 $actions[] = array(
306 "txt" => $lng->txt("wiki_contributors"),
307 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
308 );
309 }
310
311 // manage
312 if (ilWikiPerm::check("wiki_html_export", $this->ref_id)) {
313 if (!$this->wiki->isCommentsExportPossible()) {
314 $actions[] = array(
315 "txt" => $lng->txt("wiki_html_export"),
316 "id" => "il_wiki_user_export",
317 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "initUserHTMLExport")
318 );
319 } else {
320 $this->lng->loadLanguageModule("note");
321 $comments_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
322 $comments_modal = $comments_helper->getCommentIncludeModalDialog(
323 $this->lng->txt("wiki_html_export"),
324 $this->lng->txt("note_html_export_include_comments"),
325 "il.Wiki.Pres.performHTMLExport();",
326 "il.Wiki.Pres.performHTMLExportWithComments();",
327 true
328 );
329 $actions[] = array(
330 "txt" => $lng->txt("wiki_html_export"),
331 "modal" => $comments_modal
332 );
333 }
334 }
335
336 // manage
337 if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
338 $actions[] = array(
339 "txt" => $lng->txt("settings"),
340 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
341 );
342 } elseif ($ilAccess->checkAccess('statistics_read', "", $this->ref_id)) {
343 $actions[] = array(
344 "txt" => $lng->txt("statistics"),
345 "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial")
346 );
347 }
348
349 $modal_html = "";
350 foreach ($actions as $a) {
351 $tpl->setCurrentBlock("action");
352 if (($a["modal"] ?? "") != "") {
353 $signal = $a["modal"]->getShowSignal();
354 $onclick = "$(document).trigger('" . $signal . "', {'id': '" . $signal . "','triggerer':$(this), 'options': JSON.parse('[]')}); return false;";
355 $tpl->setVariable("ONCLICK", ' onclick="' . $onclick . '" ');
356 $tpl->setVariable("HREF", "#");
357 $modal_html .= $this->ui->renderer()->render($a["modal"]);
358 } else {
359 $tpl->setVariable("HREF", $a["href"]);
360 }
361 $tpl->setVariable("TXT", $a["txt"]);
362 if (($a["id"] ?? "") != "") {
363 $tpl->setVariable("ACT_ID", "id='" . $a["id"] . "'");
364 }
366
367 $tpl->touchBlock("item");
368 }
369
370 return $tpl->get() . $modal_html;
371 }
372}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a block method of a block.
ilAccessHandler $access
ilLanguage $lng
setDataSection(string $a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
setTitle(string $a_title)
setPresentation(int $type)
ilTemplate $tpl
ILIAS Block StandardGUIRequest $request
setEnableNumInfo(bool $a_enablenuminfo)
getNextClass($a_gui_class=null)
@inheritDoc
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupRating(int $a_wiki_id)
Lookup whether rating is activated.
static _lookupStartPage(int $a_wiki_id)
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
get(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Returns a block with all replacements done.
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
touchBlock(string $block)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isRepositoryObject()
Returns whether block has a corresponding repository object.
fillDataSection()
Standard implementation for row based data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupAdvancedMetadataHidden(int $a_page_id)
static check(string $a_perm, int $a_ref_id, string $a_cmd="")
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples