ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 \ILIAS\Wiki\InternalGUIService $gui;
29 protected int $wpg_id;
30 protected int $ref_id;
32 protected ilObjWiki $wiki;
33
34 public function __construct()
35 {
36 global $DIC;
37
39 ->wiki()
40 ->internal()
41 ->gui()
42 ->request();
43
44 $this->gui = $DIC->wiki()
45 ->internal()
46 ->gui();
47
48 $this->ctrl = $DIC->ctrl();
49 $this->lng = $DIC->language();
50 $this->user = $DIC->user();
51 $this->access = $DIC->access();
52 $lng = $DIC->language();
53
55
56 $lng->loadLanguageModule("wiki");
57 $this->setEnableNumInfo(false);
58
59 $this->setTitle($lng->txt("wiki_functions"));
60 $this->allow_moving = false;
61
62 $this->ref_id = $request->getRefId();
63 $this->wpg_id = $request->getWikiPageId();
64
65 $this->wiki = new ilObjWiki($this->ref_id);
66
67 $this->setPresentation(self::PRES_SEC_LEG);
68 }
69
70 public function getBlockType(): string
71 {
72 return self::$block_type;
73 }
74
75 protected function isRepositoryObject(): bool
76 {
77 return false;
78 }
79
83 public function executeCommand()
84 {
85 $ilCtrl = $this->ctrl;
86
87 $next_class = $ilCtrl->getNextClass();
88 $cmd = $ilCtrl->getCmd("getHTML");
89
90 switch ($next_class) {
91 default:
92 return $this->$cmd();
93 }
94 }
95
96 public function setPageObject(ilWikiPage $a_pageob): void
97 {
98 $this->pageob = $a_pageob;
99 }
100
101 public function getPageObject(): ilWikiPage
102 {
103 return $this->pageob;
104 }
105 protected function getLegacyContent(): string
106 {
107 $ilCtrl = $this->ctrl;
109 $ilAccess = $this->access;
110 $ui_factory = $this->gui->ui()->factory();
111 $ui_renderer = $this->gui->ui()->renderer();
112
113 $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "components/ILIAS/Wiki");
114
115 $wp = $this->getPageObject();
116 $ilCtrl->setParameterByClass(ilWikiPageGUI::class, "wpg_id", $this->wpg_id);
117
118 // info
119 $actions[] = array(
120 "txt" => $lng->txt("info_short"),
121 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")
122 );
123
124 // recent changes
125 $actions[] = array(
126 "txt" => $lng->txt("wiki_recent_changes"),
127 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")
128 );
129
130 foreach ($actions as $a) {
131 $tpl->setCurrentBlock("action");
132 $tpl->setVariable("HREF", $a["href"]);
133 $tpl->setVariable("TXT", $a["txt"]);
135
136 $tpl->touchBlock("item");
137 }
138
139
140 $actions = array();
141
142 // all pages
143 $actions[] = array(
144 "txt" => $lng->txt("wiki_all_pages"),
145 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")
146 );
147
148 // new pages
149 $actions[] = array(
150 "txt" => $lng->txt("wiki_new_pages"),
151 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")
152 );
153
154 // popular pages
155 $actions[] = array(
156 "txt" => $lng->txt("wiki_popular_pages"),
157 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")
158 );
159
160 // orphaned pages
161 $actions[] = array(
162 "txt" => $lng->txt("wiki_orphaned_pages"),
163 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")
164 );
165
166
167 // page lists
168 $dd_actions = [];
169 foreach ($actions as $a) {
170 $dd_actions[] = $ui_factory->link()->standard(
171 $a["txt"],
172 $a["href"]
173 );
174 }
175 $dd = $ui_factory->dropdown()->standard($dd_actions)->withLabel($lng->txt("wiki_page_lists"));
176 $tpl->setCurrentBlock("plain");
177 $tpl->setVariable("PLAIN", $ui_renderer->render($dd));
179 $tpl->touchBlock("item");
180
181
182 // page actions
183 $dd_actions = [];
184
185 if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
186 // rating
187 if (ilObjWiki::_lookupRating($this->getPageObject()->getWikiId())) {
188 if (!$this->getPageObject()->getRating()) {
189 $dd_actions[] = $ui_factory->link()->standard(
190 $lng->txt("wiki_activate_page_rating"),
191 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating")
192 );
193 } else {
194 $dd_actions[] = $ui_factory->link()->standard(
195 $lng->txt("wiki_deactivate_page_rating"),
196 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating")
197 );
198 }
199 }
200 }
201
202 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
203 $ilAccess->checkAccess("edit_page_meta", "", $this->ref_id)) {
204 // unhide advmd?
205 if (count(ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->ref_id, "wpg")) &&
207 $dd_actions[] = $ui_factory->link()->standard(
208 $lng->txt("wiki_unhide_meta_adv_records"),
209 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData")
210 );
211 }
212 }
213
214 if (($ilAccess->checkAccess("edit_content", "", $this->ref_id) && !$this->getPageObject()->getBlocked())
215 || $ilAccess->checkAccess("write", "", $this->ref_id)) {
216 // rename
217 $dd_actions[] = $ui_factory->link()->standard(
218 $lng->txt("wiki_rename_page"),
219 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage")
220 );
221 }
222
223 if (ilWikiPerm::check("activate_wiki_protection", $this->ref_id)) {
224 // block/unblock
225 if ($this->getPageObject()->getBlocked()) {
226 $dd_actions[] = $ui_factory->link()->standard(
227 $lng->txt("wiki_unblock_page"),
228 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage")
229 );
230 } else {
231 $dd_actions[] = $ui_factory->link()->standard(
232 $lng->txt("wiki_block_page"),
233 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage")
234 );
235 }
236 }
237
238 if (ilWikiPerm::check("delete_wiki_pages", $this->ref_id)) {
239 // delete page
240 $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
241 if ($st_page !== $this->getPageObject()->getTitle()) {
242 $dd_actions[] = $ui_factory->link()->standard(
243 $lng->txt("wiki_delete_page"),
244 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen")
245 );
246 }
247 }
248
249 if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
250 $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId());
251 $ilCtrl->setParameterByClass(ilWikiPageTemplateGUI::class, "wpg_id", $this->getPageObject()->getId());
252 if (!$wpt->isPageTemplate($this->getPageObject()->getId())) {
253 $dd_actions[] = $ui_factory->link()->standard(
254 $lng->txt("wiki_add_template"),
255 $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction")
256 );
257 } else {
258 $dd_actions[] = $ui_factory->link()->standard(
259 $lng->txt("wiki_remove_template_status"),
260 $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction")
261 );
262 }
263 }
264
265 $dd = $ui_factory->dropdown()->standard($dd_actions)->withLabel($lng->txt("wiki_page_actions"));
266
267 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
268 $ilAccess->checkAccess("read", "", $this->ref_id)) {
269 $tpl->setCurrentBlock("plain");
270 $tpl->setVariable("PLAIN", $ui_renderer->render($dd));
272 $tpl->touchBlock("item");
273 }
274
275 // permissions
276 // if ($ilAccess->checkAccess('edit_permission', "", $this->ref_id))
277 // {
278 // $actions[] = array(
279 // "txt" => $lng->txt("perm_settings"),
280 // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
281 // );
282 // }
283
284 $actions = array();
285
286 // settings
287 if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
288 $actions[] = array(
289 "txt" => $lng->txt("wiki_contributors"),
290 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
291 );
292 }
293
294 // manage
295 if (ilWikiPerm::check("wiki_html_export", $this->ref_id)) {
296 if (!$this->wiki->isCommentsExportPossible()) {
297 $actions[] = array(
298 "txt" => $lng->txt("wiki_html_export"),
299 "id" => "il_wiki_user_export",
300 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "initUserHTMLExport")
301 );
302 } else {
303 $this->lng->loadLanguageModule("note");
304 $comments_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
305 $comments_modal = $comments_helper->getCommentIncludeModalDialog(
306 $this->lng->txt("wiki_html_export"),
307 $this->lng->txt("note_html_export_include_comments"),
308 "il.Wiki.Pres.performHTMLExport();",
309 "il.Wiki.Pres.performHTMLExportWithComments();",
310 true
311 );
312 $actions[] = array(
313 "txt" => $lng->txt("wiki_html_export"),
314 "modal" => $comments_modal,
315 "id" => "il_wiki_user_export2",
316 );
317 }
318 }
319
320 // manage
321 if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
322 $actions[] = array(
323 "txt" => $lng->txt("settings"),
324 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
325 );
326 } elseif ($ilAccess->checkAccess('statistics_read', "", $this->ref_id)) {
327 $actions[] = array(
328 "txt" => $lng->txt("statistics"),
329 "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial")
330 );
331 }
332
333 $modal_html = "";
334 foreach ($actions as $a) {
335 $tpl->setCurrentBlock("action");
336 if (($a["modal"] ?? "") != "") {
337 $signal = $a["modal"]->getShowSignal();
338 $onclick = "$(document).trigger('" . $signal . "', {'id': '" . $signal . "','triggerer':$(this), 'options': JSON.parse('[]')}); return false;";
339 $tpl->setVariable("ONCLICK", ' onclick="' . $onclick . '" ');
340 $tpl->setVariable("HREF", "#");
341 $modal_html .= $this->ui->renderer()->render($a["modal"]);
342 } else {
343 $tpl->setVariable("HREF", $a["href"]);
344 }
345 $tpl->setVariable("TXT", $a["txt"]);
346 if (($a["id"] ?? "") != "") {
347 $tpl->setVariable("ACT_ID", "id='" . $a["id"] . "'");
348 }
350
351 $tpl->touchBlock("item");
352 }
353
354 return $tpl->get() . $modal_html;
355 }
356}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
This class represents a block method of a block.
ilAccessHandler $access
ilLanguage $lng
setTitle(string $a_title)
setPresentation(int $type)
ilTemplate $tpl
ILIAS Container 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.
ILIAS Wiki InternalGUIService $gui
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="")
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
global $DIC
Definition: shib_login.php:26