ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilWikiFunctionsBlockGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("Services/Block/classes/class.ilBlockGUI.php");
5
15{
16 public static $block_type = "wikiside";
17 public static $st_data;
18
22 public function __construct()
23 {
24 global $DIC;
25
26 $this->ctrl = $DIC->ctrl();
27 $this->lng = $DIC->language();
28 $this->user = $DIC->user();
29 $this->access = $DIC->access();
30 $lng = $DIC->language();
31
33
34 $lng->loadLanguageModule("wiki");
35 $this->setEnableNumInfo(false);
36
37 $this->setTitle($lng->txt("wiki_functions"));
38 $this->allow_moving = false;
39
40 $this->ref_id = (int) $_GET["ref_id"];
41
42 $this->setPresentation(self::PRES_SEC_LEG);
43 }
44
48 public function getBlockType() : string
49 {
50 return self::$block_type;
51 }
52
56 protected function isRepositoryObject() : bool
57 {
58 return false;
59 }
60
64 public static function getScreenMode()
65 {
66 return IL_SCREEN_SIDE;
67 }
68
72 public function executeCommand()
73 {
75
76 $next_class = $ilCtrl->getNextClass();
77 $cmd = $ilCtrl->getCmd("getHTML");
78
79 switch ($next_class) {
80 default:
81 return $this->$cmd();
82 }
83 }
84
90 public function setPageObject($a_pageob)
91 {
92 $this->pageob = $a_pageob;
93 }
94
100 public function getPageObject()
101 {
102 return $this->pageob;
103 }
104
108 public function getHTML()
109 {
113
114 return parent::getHTML();
115 }
116
120 public function fillDataSection()
121 {
122 $this->setDataSection($this->getLegacyContent());
123 }
124
125 //
126 // New rendering
127 //
128
129 protected $new_rendering = true;
130
131
135 protected function getLegacyContent() : string
136 {
139 $ilAccess = $this->access;
140
141 $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki");
142
143 $wp = $this->getPageObject();
144
145 // info
146 $actions[] = array(
147 "txt" => $lng->txt("info_short"),
148 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")
149 );
150
151 // recent changes
152 $actions[] = array(
153 "txt" => $lng->txt("wiki_recent_changes"),
154 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")
155 );
156
157 foreach ($actions as $a) {
158 $tpl->setCurrentBlock("action");
159 $tpl->setVariable("HREF", $a["href"]);
160 $tpl->setVariable("TXT", $a["txt"]);
161 $tpl->parseCurrentBlock();
162
163 $tpl->touchBlock("item");
164 }
165
166
167 $actions = array();
168
169 // all pages
170 $actions[] = array(
171 "txt" => $lng->txt("wiki_all_pages"),
172 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")
173 );
174
175 // new pages
176 $actions[] = array(
177 "txt" => $lng->txt("wiki_new_pages"),
178 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")
179 );
180
181 // popular pages
182 $actions[] = array(
183 "txt" => $lng->txt("wiki_popular_pages"),
184 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")
185 );
186
187 // orphaned pages
188 $actions[] = array(
189 "txt" => $lng->txt("wiki_orphaned_pages"),
190 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")
191 );
192
193
194 // page lists
195 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
196 $list = new ilAdvancedSelectionListGUI();
197 $list->setListTitle($lng->txt("wiki_page_lists"));
199 $list->setId("wiki_pglists");
200
201 foreach ($actions as $a) {
202 $list->addItem(
203 $a["txt"],
204 "",
205 $a["href"]
206 );
207 }
208 $tpl->setCurrentBlock("plain");
209 $tpl->setVariable("PLAIN", $list->getHTML());
210 $tpl->parseCurrentBlock();
211 $tpl->touchBlock("item");
212
213
214 // page actions
215 $list = new ilAdvancedSelectionListGUI();
217 $list->setListTitle($lng->txt("wiki_page_actions"));
218 $list->setId("wiki_pgactions");
219
220 if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
221 // rating
222 if (ilObjWiki::_lookupRating($this->getPageObject()->getWikiId())) {
223 if (!$this->getPageObject()->getRating()) {
224 $list->addItem(
225 $lng->txt("wiki_activate_page_rating"),
226 "",
227 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating")
228 );
229 } else {
230 $list->addItem(
231 $lng->txt("wiki_deactivate_page_rating"),
232 "",
233 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating")
234 );
235 }
236 }
237 }
238
239 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
240 $ilAccess->checkAccess("edit_page_meta", "", $this->ref_id)) {
241 // unhide advmd?
242 include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
243 if ((bool) sizeof(ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->ref_id, "wpg")) &&
245 $list->addItem(
246 $lng->txt("wiki_unhide_meta_adv_records"),
247 "",
248 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData")
249 );
250 }
251 }
252
253 if (($ilAccess->checkAccess("edit_content", "", $this->ref_id) && !$this->getPageObject()->getBlocked())
254 || $ilAccess->checkAccess("write", "", $this->ref_id)) {
255 // rename
256 $list->addItem(
257 $lng->txt("wiki_rename_page"),
258 "",
259 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage")
260 );
261 }
262
263 include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
264 if (ilWikiPerm::check("activate_wiki_protection", $this->ref_id)) {
265 // block/unblock
266 if ($this->getPageObject()->getBlocked()) {
267 $list->addItem(
268 $lng->txt("wiki_unblock_page"),
269 "",
270 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage")
271 );
272 } else {
273 $list->addItem(
274 $lng->txt("wiki_block_page"),
275 "",
276 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage")
277 );
278 }
279 }
280
281 include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
282 if (ilWikiPerm::check("delete_wiki_pages", $this->ref_id)) {
283 // delete page
284 $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
285 if ($st_page != $this->getPageObject()->getTitle()) {
286 $list->addItem(
287 $lng->txt("wiki_delete_page"),
288 "",
289 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen")
290 );
291 }
292 }
293
294 if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
295 include_once "Modules/Wiki/classes/class.ilWikiPageTemplate.php";
296 $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId());
297 if (!$wpt->isPageTemplate($this->getPageObject()->getId())) {
298 $list->addItem(
299 $lng->txt("wiki_add_template"),
300 "",
301 $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction")
302 );
303 } else {
304 $list->addItem(
305 $lng->txt("wiki_remove_template_status"),
306 "",
307 $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction")
308 );
309 }
310 }
311
312 if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
313 $ilAccess->checkAccess("read", "", $this->ref_id)) {
314 $tpl->setCurrentBlock("plain");
315 $tpl->setVariable("PLAIN", $list->getHTML());
316 $tpl->parseCurrentBlock();
317 $tpl->touchBlock("item");
318 }
319
320 // permissions
321 // if ($ilAccess->checkAccess('edit_permission', "", $this->ref_id))
322 // {
323 // $actions[] = array(
324 // "txt" => $lng->txt("perm_settings"),
325 // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
326 // );
327 // }
328
329 $actions = array();
330
331 // settings
332 if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
333 $actions[] = array(
334 "txt" => $lng->txt("wiki_contributors"),
335 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
336 );
337 }
338
339 // manage
340 if (ilWikiPerm::check("wiki_html_export", $this->ref_id)) {
341 $actions[] = array(
342 "txt" => $lng->txt("wiki_html_export"),
343 "id" => "il_wiki_user_export",
344 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "initUserHTMLExport")
345 );
346 }
347
348 // manage
349 if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
350 $actions[] = array(
351 "txt" => $lng->txt("settings"),
352 "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
353 );
354 } elseif ($ilAccess->checkAccess('statistics_read', "", $this->ref_id)) {
355 $actions[] = array(
356 "txt" => $lng->txt("statistics"),
357 "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial")
358 );
359 }
360
361 foreach ($actions as $a) {
362 $tpl->setCurrentBlock("action");
363 $tpl->setVariable("HREF", $a["href"]);
364 $tpl->setVariable("TXT", $a["txt"]);
365 if ($a["id"] != "") {
366 $tpl->setVariable("ACT_ID", "id='" . $a["id"] . "'");
367 }
368 $tpl->parseCurrentBlock();
369
370 $tpl->touchBlock("item");
371 }
372
373 return $tpl->get();
374 }
375}
user()
Definition: user.php:4
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
static _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type="")
Get selected records by object.
User interface class for advanced drop-down selection lists.
This class represents a block method of a block.
setPresentation(int $type)
Set presentation.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
getTitle()
Get Title.
setTitle($a_title)
Set Title.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static _lookupStartPage($a_wiki_id)
Lookup start page.
static _lookupRating($a_wiki_id)
Lookup whether rating is activated.
special template class to simplify handling of ITX/PEAR
BlockGUI class for wiki functions block.
static getScreenMode()
Get Screen Mode for current command.
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
getLegacyContent()
Get legacy content.string
setPageObject($a_pageob)
Set Page Object.
static lookupAdvancedMetadataHidden($a_page_id)
static check($a_perm, $a_ref_id, $a_cmd="")
Check permission.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46