ILIAS  release_7 Revision v7.30-3-g800a261c036
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 
4 include_once("Services/Block/classes/class.ilBlockGUI.php");
5 
15 {
16  public static $block_type = "wikiside";
17  public static $st_data;
18 
22  protected $wiki;
23 
27  public function __construct()
28  {
29  global $DIC;
30 
31  $this->ctrl = $DIC->ctrl();
32  $this->lng = $DIC->language();
33  $this->user = $DIC->user();
34  $this->access = $DIC->access();
35  $lng = $DIC->language();
36 
38 
39  $lng->loadLanguageModule("wiki");
40  $this->setEnableNumInfo(false);
41 
42  $this->setTitle($lng->txt("wiki_functions"));
43  $this->allow_moving = false;
44 
45  $this->ref_id = (int) $_GET["ref_id"];
46 
47  $this->wiki = new ilObjWiki($this->ref_id);
48 
49  $this->setPresentation(self::PRES_SEC_LEG);
50  }
51 
55  public function getBlockType() : string
56  {
57  return self::$block_type;
58  }
59 
63  protected function isRepositoryObject() : bool
64  {
65  return false;
66  }
67 
71  public static function getScreenMode()
72  {
73  return IL_SCREEN_SIDE;
74  }
75 
79  public function executeCommand()
80  {
81  $ilCtrl = $this->ctrl;
82 
83  $next_class = $ilCtrl->getNextClass();
84  $cmd = $ilCtrl->getCmd("getHTML");
85 
86  switch ($next_class) {
87  default:
88  return $this->$cmd();
89  }
90  }
91 
97  public function setPageObject($a_pageob)
98  {
99  $this->pageob = $a_pageob;
100  }
101 
107  public function getPageObject()
108  {
109  return $this->pageob;
110  }
111 
115  public function getHTML()
116  {
117  $ilCtrl = $this->ctrl;
118  $lng = $this->lng;
120 
121  return parent::getHTML();
122  }
123 
127  public function fillDataSection()
128  {
129  $this->setDataSection($this->getLegacyContent());
130  }
131 
132  //
133  // New rendering
134  //
135 
136  protected $new_rendering = true;
137 
138 
142  protected function getLegacyContent() : string
143  {
144  $ilCtrl = $this->ctrl;
145  $lng = $this->lng;
146  $ilAccess = $this->access;
147 
148  $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki");
149 
150  $wp = $this->getPageObject();
151 
152  // info
153  $actions[] = array(
154  "txt" => $lng->txt("info_short"),
155  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")
156  );
157 
158  // recent changes
159  $actions[] = array(
160  "txt" => $lng->txt("wiki_recent_changes"),
161  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")
162  );
163 
164  foreach ($actions as $a) {
165  $tpl->setCurrentBlock("action");
166  $tpl->setVariable("HREF", $a["href"]);
167  $tpl->setVariable("TXT", $a["txt"]);
168  $tpl->parseCurrentBlock();
169 
170  $tpl->touchBlock("item");
171  }
172 
173 
174  $actions = array();
175 
176  // all pages
177  $actions[] = array(
178  "txt" => $lng->txt("wiki_all_pages"),
179  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")
180  );
181 
182  // new pages
183  $actions[] = array(
184  "txt" => $lng->txt("wiki_new_pages"),
185  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")
186  );
187 
188  // popular pages
189  $actions[] = array(
190  "txt" => $lng->txt("wiki_popular_pages"),
191  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")
192  );
193 
194  // orphaned pages
195  $actions[] = array(
196  "txt" => $lng->txt("wiki_orphaned_pages"),
197  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")
198  );
199 
200 
201  // page lists
202  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
203  $list = new ilAdvancedSelectionListGUI();
204  $list->setListTitle($lng->txt("wiki_page_lists"));
206  $list->setId("wiki_pglists");
207 
208  foreach ($actions as $a) {
209  $list->addItem(
210  $a["txt"],
211  "",
212  $a["href"]
213  );
214  }
215  $tpl->setCurrentBlock("plain");
216  $tpl->setVariable("PLAIN", $list->getHTML());
217  $tpl->parseCurrentBlock();
218  $tpl->touchBlock("item");
219 
220 
221  // page actions
222  $list = new ilAdvancedSelectionListGUI();
224  $list->setListTitle($lng->txt("wiki_page_actions"));
225  $list->setId("wiki_pgactions");
226 
227  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
228  // rating
229  if (ilObjWiki::_lookupRating($this->getPageObject()->getWikiId())) {
230  if (!$this->getPageObject()->getRating()) {
231  $list->addItem(
232  $lng->txt("wiki_activate_page_rating"),
233  "",
234  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating")
235  );
236  } else {
237  $list->addItem(
238  $lng->txt("wiki_deactivate_page_rating"),
239  "",
240  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating")
241  );
242  }
243  }
244  }
245 
246  if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
247  $ilAccess->checkAccess("edit_page_meta", "", $this->ref_id)) {
248  // unhide advmd?
249  include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
250  if ((bool) sizeof(ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->ref_id, "wpg")) &&
252  $list->addItem(
253  $lng->txt("wiki_unhide_meta_adv_records"),
254  "",
255  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData")
256  );
257  }
258  }
259 
260  if (($ilAccess->checkAccess("edit_content", "", $this->ref_id) && !$this->getPageObject()->getBlocked())
261  || $ilAccess->checkAccess("write", "", $this->ref_id)) {
262  // rename
263  $list->addItem(
264  $lng->txt("wiki_rename_page"),
265  "",
266  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage")
267  );
268  }
269 
270  include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
271  if (ilWikiPerm::check("activate_wiki_protection", $this->ref_id)) {
272  // block/unblock
273  if ($this->getPageObject()->getBlocked()) {
274  $list->addItem(
275  $lng->txt("wiki_unblock_page"),
276  "",
277  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage")
278  );
279  } else {
280  $list->addItem(
281  $lng->txt("wiki_block_page"),
282  "",
283  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage")
284  );
285  }
286  }
287 
288  include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
289  if (ilWikiPerm::check("delete_wiki_pages", $this->ref_id)) {
290  // delete page
291  $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
292  if ($st_page != $this->getPageObject()->getTitle()) {
293  $list->addItem(
294  $lng->txt("wiki_delete_page"),
295  "",
296  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen")
297  );
298  }
299  }
300 
301  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
302  include_once "Modules/Wiki/classes/class.ilWikiPageTemplate.php";
303  $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId());
304  if (!$wpt->isPageTemplate($this->getPageObject()->getId())) {
305  $list->addItem(
306  $lng->txt("wiki_add_template"),
307  "",
308  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction")
309  );
310  } else {
311  $list->addItem(
312  $lng->txt("wiki_remove_template_status"),
313  "",
314  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction")
315  );
316  }
317  }
318 
319  if ($ilAccess->checkAccess("write", "", $this->ref_id) ||
320  $ilAccess->checkAccess("read", "", $this->ref_id)) {
321  $tpl->setCurrentBlock("plain");
322  $tpl->setVariable("PLAIN", $list->getHTML());
323  $tpl->parseCurrentBlock();
324  $tpl->touchBlock("item");
325  }
326 
327  // permissions
328  // if ($ilAccess->checkAccess('edit_permission', "", $this->ref_id))
329  // {
330  // $actions[] = array(
331  // "txt" => $lng->txt("perm_settings"),
332  // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
333  // );
334  // }
335 
336  $actions = array();
337 
338  // settings
339  if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
340  $actions[] = array(
341  "txt" => $lng->txt("wiki_contributors"),
342  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
343  );
344  }
345 
346  // manage
347  if (ilWikiPerm::check("wiki_html_export", $this->ref_id)) {
348  if (!$this->wiki->isCommentsExportPossible()) {
349  $actions[] = array(
350  "txt" => $lng->txt("wiki_html_export"),
351  "id" => "il_wiki_user_export",
352  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "initUserHTMLExport")
353  );
354  } else {
355  $this->lng->loadLanguageModule("note");
356  $comments_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
357  $comments_modal = $comments_helper->getCommentIncludeModalDialog(
358  $this->lng->txt("wiki_html_export"),
359  $this->lng->txt("note_html_export_include_comments"),
360  "il.Wiki.Pres.performHTMLExport();",
361  "il.Wiki.Pres.performHTMLExportWithComments();",
362  true
363  );
364  $actions[] = array(
365  "txt" => $lng->txt("wiki_html_export"),
366  "modal" => $comments_modal
367  );
368  }
369  }
370 
371  // manage
372  if ($ilAccess->checkAccess('write', "", $this->ref_id)) {
373  $actions[] = array(
374  "txt" => $lng->txt("settings"),
375  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
376  );
377  } elseif ($ilAccess->checkAccess('statistics_read', "", $this->ref_id)) {
378  $actions[] = array(
379  "txt" => $lng->txt("statistics"),
380  "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial")
381  );
382  }
383 
384  $modal_html = "";
385  foreach ($actions as $a) {
386  $tpl->setCurrentBlock("action");
387  if ($a["modal"] != "") {
388  $signal = $a["modal"]->getShowSignal();
389  $onclick = "$(document).trigger('" . $signal . "', {'id': '" . $signal . "','triggerer':$(this), 'options': JSON.parse('[]')}); return false;";
390  $tpl->setVariable("ONCLICK", ' onclick="' . $onclick . '" ');
391  $tpl->setVariable("HREF", "#");
392  $modal_html .= $this->ui->renderer()->render($a["modal"]);
393  } else {
394  $tpl->setVariable("HREF", $a["href"]);
395  }
396  $tpl->setVariable("TXT", $a["txt"]);
397  if ($a["id"] != "") {
398  $tpl->setVariable("ACT_ID", "id='" . $a["id"] . "'");
399  }
400  $tpl->parseCurrentBlock();
401 
402  $tpl->touchBlock("item");
403  }
404 
405  return $tpl->get() . $modal_html;
406  }
407 }
static check($a_perm, $a_ref_id, $a_cmd="")
Check permission.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
static _lookupStartPage($a_wiki_id)
Lookup start page.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static lookupAdvancedMetadataHidden($a_page_id)
user()
Definition: user.php:4
static _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type="")
Get selected records by object.
BlockGUI class for wiki functions block.
static _lookupRating($a_wiki_id)
Lookup whether rating is activated.
setTitle($a_title)
Set Title.
Class ilObjWiki.
global $DIC
Definition: goto.php:24
ui()
Definition: ui.php:5
static getScreenMode()
Get Screen Mode for current command.
__construct(Container $dic, ilPlugin $plugin)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
This class represents a block method of a block.
$ilUser
Definition: imgupload.php:18
const IL_SCREEN_SIDE
setPageObject($a_pageob)
Set Page Object.
getTitle()
Get Title.
setPresentation(int $type)
Set presentation.