ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjWikiGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 use \ILIAS\Wiki\Export;
6 
22 {
26  protected $tabs;
27 
31  protected $error;
32 
36  protected $help;
37 
38 
42  protected $log;
43 
47  protected $tool_context;
48 
52  protected $ui;
53 
58  public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
59  {
60  global $DIC;
61 
62  $this->ctrl = $DIC->ctrl();
63  $this->lng = $DIC->language();
64  $this->user = $DIC->user();
65  $this->tpl = $DIC["tpl"];
66  $this->tabs = $DIC->tabs();
67  $this->access = $DIC->access();
68  $this->error = $DIC["ilErr"];
69  $this->settings = $DIC->settings();
70  $this->help = $DIC["ilHelp"];
71  $this->locator = $DIC["ilLocator"];
72  $this->toolbar = $DIC->toolbar();
73  $ilCtrl = $DIC->ctrl();
74  $lng = $DIC->language();
75 
76  $this->type = "wiki";
77 
78  $this->log = ilLoggerFactory::getLogger('wiki');
79 
80  $this->tool_context = $DIC->globalScreen()->tool()->context();
81  $this->ui = $DIC->ui();
82 
83  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
84  $lng->loadLanguageModule("obj");
85  $lng->loadLanguageModule("wiki");
86 
87  if ($_GET["page"] != "") {
88  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
89  }
90  }
91 
92  public function executeCommand()
93  {
96  $tpl = $this->tpl;
97  $ilTabs = $this->tabs;
98  $ilAccess = $this->access;
99 
100  $next_class = $this->ctrl->getNextClass($this);
101  $cmd = $this->ctrl->getCmd();
102 
103  $this->triggerAssignmentTool();
104 
105  $this->prepareOutput();
106 
107  // see ilWikiPageGUI::printViewOrderList()
108  // printView() and pdfExport() cannot be in ilWikiPageGUI because of stylesheet confusion
109  if ($cmd == "printView" || $cmd == "pdfExport") {
110  $next_class = null;
111  }
112 
113  switch ($next_class) {
114  case "ilinfoscreengui":
115  $this->checkPermission("visible");
116  $this->addHeaderAction();
117  $this->infoScreen(); // forwards command
118  break;
119 
120  case 'ilpermissiongui':
121  $this->addHeaderAction();
122  $ilTabs->activateTab("perm_settings");
123  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
124  $perm_gui = new ilPermissionGUI($this);
125  $ret = $this->ctrl->forwardCommand($perm_gui);
126  break;
127 
128  case 'ilsettingspermissiongui':
129  $this->checkPermission("write");
130  $this->addHeaderAction();
131  $ilTabs->activateTab("settings");
132  $this->setSettingsSubTabs("permission_settings");
133  include_once("Services/AccessControl/classes/class.ilSettingsPermissionGUI.php");
134  $perm_gui = new ilSettingsPermissionGUI($this);
135  $perm_gui->setPermissions(array("edit_wiki_navigation", "delete_wiki_pages", "activate_wiki_protection",
136  "wiki_html_export"));
137  $perm_gui->setRoleRequiredPermissions(array("edit_content"));
138  $perm_gui->setRoleProhibitedPermissions(array("write"));
139  $ret = $this->ctrl->forwardCommand($perm_gui);
140  break;
141 
142  case 'ilwikipagegui':
143  $this->checkPermission("read");
144  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
145  $wpage_gui = ilWikiPageGUI::getGUIForTitle(
146  $this->object->getId(),
148  $_GET["old_nr"],
149  $this->object->getRefId()
150  );
151  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
152  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
153  $this->object->getStyleSheetId(),
154  "wiki"
155  ));
156  $this->setContentStyleSheet();
157  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
158  (
159  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()) ||
160  $wpage_gui->getPageObject()->getBlocked()
161  )) {
162  $wpage_gui->setEnableEditing(false);
163  }
164 
165  // alter title and description
166 // $tpl->setTitle($wpage_gui->getPageObject()->getTitle());
167 // $tpl->setDescription($this->object->getTitle());
168  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
169  $wpage_gui->activateMetaDataEditor($this->object, "wpg", $wpage_gui->getId());
170  }
171 
172  $ret = $this->ctrl->forwardCommand($wpage_gui);
173  if ($ret != "") {
174  $tpl->setContent($ret);
175  }
176  break;
177 
178  case 'ilobjectcopygui':
179  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
180  $cp = new ilObjectCopyGUI($this);
181  $cp->setType('wiki');
182  $this->ctrl->forwardCommand($cp);
183  break;
184 
185  case 'ilpublicuserprofilegui':
186  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
187  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
188  $ret = $this->ctrl->forwardCommand($profile_gui);
189  $tpl->setContent($ret);
190  break;
191 
192  case "ilobjstylesheetgui":
193  include_once("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
194  $this->ctrl->setReturn($this, "editStyleProperties");
195  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
196  $style_gui->omitLocator();
197  if ($cmd == "create" || $_GET["new_type"] == "sty") {
198  $style_gui->setCreationMode(true);
199  }
200 
201  if ($cmd == "confirmedDelete") {
202  $this->object->setStyleSheetId(0);
203  $this->object->update();
204  }
205 
206  $ret = $this->ctrl->forwardCommand($style_gui);
207 
208  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
209  $style_id = $ret;
210  $this->object->setStyleSheetId($style_id);
211  $this->object->update();
212  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
213  }
214  break;
215 
216  case "ilexportgui":
217 // $this->prepareOutput();
218  $this->addHeaderAction();
219  $ilTabs->activateTab("export");
220  include_once("./Services/Export/classes/class.ilExportGUI.php");
221  $exp_gui = new ilExportGUI($this);
222  $exp_gui->addFormat("xml");
223  $exp_gui->addFormat("html", "", $this, "exportHTML");
224  $ret = $this->ctrl->forwardCommand($exp_gui);
225 // $this->tpl->show();
226  break;
227 
228  case "ilcommonactiondispatchergui":
229  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
231  $this->ctrl->forwardCommand($gui);
232  break;
233 
234  case "ilratinggui":
235  // for rating category editing
236  $this->checkPermission("write");
237  $this->addHeaderAction();
238  $ilTabs->activateTab("settings");
239  $this->setSettingsSubTabs("rating_categories");
240  include_once("Services/Rating/classes/class.ilRatingGUI.php");
241  $gui = new ilRatingGUI();
242  $gui->setObject($this->object->getId(), $this->object->getType());
243  $gui->setExportCallback(array($this, "getSubObjectTitle"), $this->lng->txt("page"));
244  $this->ctrl->forwardCommand($gui);
245  break;
246 
247  case "ilwikistatgui":
248  $this->checkPermission("statistics_read");
249 
250  $this->addHeaderAction();
251  $ilTabs->activateTab("statistics");
252 
253  include_once "Modules/Wiki/classes/class.ilWikiStatGUI.php";
254  $gui = new ilWikiStatGUI($this->object->getId());
255  $this->ctrl->forwardCommand($gui);
256  break;
257 
258  case "ilwikipagetemplategui":
259  $this->checkPermission("write");
260  $this->addHeaderAction();
261  $ilTabs->activateTab("settings");
262  $this->setSettingsSubTabs("page_templates");
263  include_once("./Modules/Wiki/classes/class.ilWikiPageTemplateGUI.php");
264  $wptgui = new ilWikiPageTemplateGUI($this);
265  $this->ctrl->forwardCommand($wptgui);
266  break;
267 
268  case 'ilobjectmetadatagui':
269  $this->checkPermission("write");
270  $this->addHeaderAction();
271  $ilTabs->activateTab("advmd");
272  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
273  $md_gui = new ilObjectMetaDataGUI($this->object, "wpg");
274  $this->ctrl->forwardCommand($md_gui);
275  break;
276 
277  case 'ilrepositoryobjectsearchgui':
278  $this->addHeaderAction();
279  $this->setSideBlock();
280  $ilTabs->setTabActive("wiki_search_results");
281  $ilCtrl->setReturn($this, 'view');
282  include_once './Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
283  $search_gui = new ilRepositoryObjectSearchGUI(
284  $this->object->getRefId(),
285  $this,
286  'view'
287  );
288  $ilCtrl->forwardCommand($search_gui);
289  break;
290 
291  case 'ilobjnotificationsettingsgui':
292  $this->addHeaderAction();
293  $ilTabs->activateTab("settings");
294  $this->setSettingsSubTabs("notifications");
295  include_once("./Services/Notification/classes/class.ilObjNotificationSettingsGUI.php");
296  $gui = new ilObjNotificationSettingsGUI($this->object->getRefId());
297  $this->ctrl->forwardCommand($gui);
298  break;
299 
300  default:
301  $this->addHeaderAction();
302  if (!$cmd) {
303  $cmd = "infoScreen";
304  }
305  $cmd .= "Object";
306  if ($cmd != "cancelObject") {
307  if ($cmd != "infoScreenObject") {
308  if (!in_array($cmd, array("createObject", "saveObject", "importFileObject"))) {
309  $this->checkPermission("read");
310  }
311  } else {
312  $this->checkPermission("visible");
313  }
314  }
315  $this->$cmd();
316  break;
317  }
318 
319  return $ret;
320  }
321 
327  public function isOnlineHelpWiki()
328  {
329  if (is_object($this->object)) {
330  return ilObjWiki::isOnlineHelpWiki($this->object->getRefId());
331  }
332  return false;
333  }
334 
338  public function viewObject()
339  {
340  $this->checkPermission("read");
341  $this->gotoStartPageObject();
342  }
343 
344  protected function initCreationForms($a_new_type)
345  {
346  $this->initSettingsForm("create");
347  $this->getSettingsFormValues("create");
348 
349  $forms = array(self::CFORM_NEW => $this->form_gui,
350  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
351  self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type));
352 
353  return $forms;
354  }
355 
360  public function saveObject()
361  {
362  $tpl = $this->tpl;
363  $lng = $this->lng;
365 
366  if (!$this->checkPermissionBool("create", "", "wiki", $_GET["ref_id"])) {
367  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
368  }
369 
370  $this->initSettingsForm("create");
371  if ($this->form_gui->checkInput()) {
372  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle"))) {
373  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
374  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
375  } else {
376  // create and insert forum in objecttree
377  $_POST["title"] = $this->form_gui->getInput("title");
378  $_POST["desc"] = $this->form_gui->getInput("description");
379  return parent::saveObject();
380  }
381  }
382 
383  $this->form_gui->setValuesByPost();
384  $tpl->setContent($this->form_gui->getHtml());
385  }
386 
391  public function afterSave(ilObject $newObj)
392  {
394 
395  $newObj->setTitle($this->form_gui->getInput("title"));
396  $newObj->setDescription($this->form_gui->getInput("description"));
397  $newObj->setIntroduction($this->form_gui->getInput("intro"));
398  $newObj->setStartPage($this->form_gui->getInput("startpage"));
399  $newObj->setShortTitle($this->form_gui->getInput("shorttitle"));
400  $newObj->setRating($this->form_gui->getInput("rating"));
401  // $newObj->setRatingAsBlock($this->form_gui->getInput("rating_side"));
402  $newObj->setRatingForNewPages($this->form_gui->getInput("rating_new"));
403  $newObj->setRatingCategories($this->form_gui->getInput("rating_ext"));
404 
405  $newObj->setRatingOverall($this->form_gui->getInput("rating_overall"));
406  $newObj->setPageToc($this->form_gui->getInput("page_toc"));
407 
408 
409 
410  if (!$ilSetting->get("disable_comments")) {
411  $newObj->setPublicNotes($this->form_gui->getInput("public_notes"));
412  }
413  $newObj->setOnline($this->form_gui->getInput("online"));
414  $newObj->update();
415 
416  // always send a message
417  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
419  }
420 
426  public function infoScreenObject()
427  {
428  $this->checkPermission("visible");
429  $this->ctrl->setCmd("showSummary");
430  $this->ctrl->setCmdClass("ilinfoscreengui");
431  $this->infoScreen();
432  }
433 
437  public function infoScreen()
438  {
439  $ilAccess = $this->access;
441  $ilTabs = $this->tabs;
442  $lng = $this->lng;
444 
445  $ilTabs->activateTab("info_short");
446 
447  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId())) {
448  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
449  }
450 
451  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
452  $info = new ilInfoScreenGUI($this);
453  $info->enablePrivateNotes();
454  if (trim($this->object->getIntroduction()) != "") {
455  $info->addSection($lng->txt("wiki_introduction"));
456  $info->addProperty("", nl2br($this->object->getIntroduction()));
457  }
458 
459  // feedback from tutor; mark, status, comment
460  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
461  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
462  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
463  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
464  $status = ilWikiContributor::_lookupStatus($this->object->getId(), $ilUser->getId());
465  if ($lpcomment != "" || $mark != "" || $status != ilWikiContributor::STATUS_NOT_GRADED) {
466  $info->addSection($this->lng->txt("wiki_feedback_from_tutor"));
467  if ($lpcomment != "") {
468  $info->addProperty(
469  $this->lng->txt("wiki_comment"),
470  $lpcomment
471  );
472  }
473  if ($mark != "") {
474  $info->addProperty(
475  $this->lng->txt("wiki_mark"),
476  $mark
477  );
478  }
479 
480  if ($status == ilWikiContributor::STATUS_PASSED) {
481  $info->addProperty(
482  $this->lng->txt("status"),
483  $this->lng->txt("wiki_passed")
484  );
485  }
486  if ($status == ilWikiContributor::STATUS_FAILED) {
487  $info->addProperty(
488  $this->lng->txt("status"),
489  $this->lng->txt("wiki_failed")
490  );
491  }
492  }
493 
494  /*
495  $info->enableNews();
496  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
497  {
498  //$info->enableNewsEditing();
499  $info->setBlockProperty("news", "settings", true);
500  }*/
501 
502  if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
503  $info->addButton($lng->txt("wiki_start_page"), ilObjWikiGUI::getGotoLink($this->object->getRefId()));
504  }
505 
506  // general information
507  $this->lng->loadLanguageModule("meta");
508  $this->lng->loadLanguageModule("wiki");
509 
510  //$info->addSection($this->lng->txt("meta_general"));
511  //$info->addProperty($this->lng->txt("mcst_nr_items"),
512  // (int) count($med_items));
513 
514  // forward the command
515  $this->ctrl->forwardCommand($info);
516 
517  if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
518  // $this->setSideBlock();
519  }
520  }
521 
525  public function gotoStartPageObject()
526  {
528 
529  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId()));
530  }
531 
535  public function addPageTabs()
536  {
537  $ilTabs = $this->tabs;
539 
540  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
541  $ilCtrl->setParameter(
542  $this,
543  "wpg_id",
544  ilWikiPage::getPageIdForTitle($this->object->getId(), ilWikiUtil::makeDbTitle($_GET["page"]))
545  );
546  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
547  $ilTabs->addTarget(
548  "wiki_what_links_here",
549  $this->ctrl->getLinkTargetByClass(
550  "ilwikipagegui",
551  "whatLinksHere"
552  ),
553  "whatLinksHere"
554  );
555  $ilTabs->addTarget(
556  "wiki_print_view",
557  $this->ctrl->getLinkTargetByClass(
558  "ilwikipagegui",
559  "printViewSelection"
560  ),
561  "printViewSelection"
562  );
563  }
564 
568  public function addPagesSubTabs()
569  {
570  $ilTabs = $this->tabs;
572 
573  $ilTabs->activateTab("wiki_pages");
574 
575  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
576  $ilCtrl->setParameter(
577  $this,
578  "wpg_id",
580  $this->object->getId(),
582  )
583  );
584  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
585  $ilTabs->addSubTabTarget(
586  "wiki_all_pages",
587  $this->ctrl->getLinkTarget($this, "allPages"),
588  "allPages"
589  );
590  $ilTabs->addSubTabTarget(
591  "wiki_recent_changes",
592  $this->ctrl->getLinkTarget($this, "recentChanges"),
593  "recentChanges"
594  );
595  $ilTabs->addSubTabTarget(
596  "wiki_new_pages",
597  $this->ctrl->getLinkTarget($this, "newPages"),
598  "newPages"
599  );
600  $ilTabs->addSubTabTarget(
601  "wiki_popular_pages",
602  $this->ctrl->getLinkTarget($this, "popularPages"),
603  "popularPages"
604  );
605  $ilTabs->addSubTabTarget(
606  "wiki_orphaned_pages",
607  $this->ctrl->getLinkTarget($this, "orphanedPages"),
608  "orphanedPages"
609  );
610  }
611 
617  public function getTabs()
618  {
620  $ilAccess = $this->access;
621  $lng = $this->lng;
622  $ilHelp = $this->help;
623 
624  $ilHelp->setScreenIdComponent("wiki");
625 
626  // wiki tabs
627  if (in_array($ilCtrl->getCmdClass(), array("", "ilobjwikigui",
628  "ilinfoscreengui", "ilpermissiongui", "ilexportgui", "ilratingcategorygui", "ilobjnotificationsettingsgui", "iltaxmdgui",
629  "ilwikistatgui", "ilwikipagetemplategui", "iladvancedmdsettingsgui", "ilsettingspermissiongui", 'ilrepositoryobjectsearchgui'
630  )) || (in_array($ilCtrl->getNextClass(), array("ilpermissiongui")))) {
631  if ($_GET["page"] != "") {
632  $this->tabs_gui->setBackTarget(
633  $lng->txt("wiki_last_visited_page"),
634  $this->getGotoLink(
635  $_GET["ref_id"],
637  )
638  );
639  }
640 
641  // pages
642  if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
643  $this->tabs_gui->addTab(
644  "wiki_pages",
645  $lng->txt("wiki_pages"),
646  $this->ctrl->getLinkTarget($this, "allPages")
647  );
648  }
649 
650  // info screen
651  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId())) {
652  $this->tabs_gui->addTab(
653  "info_short",
654  $lng->txt("info_short"),
655  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
656  );
657  }
658 
659  // settings
660  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
661  $this->tabs_gui->addTab(
662  "settings",
663  $lng->txt("settings"),
664  $this->ctrl->getLinkTarget($this, "editSettings")
665  );
666 
667  // metadata
668  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
669  $mdgui = new ilObjectMetaDataGUI($this->object, "wpg");
670  $mdtab = $mdgui->getTab();
671  if ($mdtab) {
672  $this->tabs_gui->addTab(
673  "advmd",
674  $this->lng->txt("meta_data"),
675  $mdtab
676  );
677  }
678  }
679 
680  // contributors
681  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
682  $this->tabs_gui->addTab(
683  "wiki_contributors",
684  $lng->txt("wiki_contributors"),
685  $this->ctrl->getLinkTarget($this, "listContributors")
686  );
687  }
688 
689  // statistics
690  if ($ilAccess->checkAccess('statistics_read', "", $this->object->getRefId())) {
691  $this->tabs_gui->addTab(
692  "statistics",
693  $lng->txt("statistics"),
694  $this->ctrl->getLinkTargetByClass("ilWikiStatGUI", "initial")
695  );
696  }
697 
698  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
699  $this->tabs_gui->addTab(
700  "export",
701  $lng->txt("export"),
702  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
703  );
704  }
705 
706  // edit permissions
707  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
708  $this->tabs_gui->addTab(
709  "perm_settings",
710  $lng->txt("perm_settings"),
711  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
712  );
713  }
714  }
715  }
716 
720  public function setSettingsSubTabs($a_active)
721  {
722  $ilTabs = $this->tabs;
724  $lng = $this->lng;
725  $ilAccess = $this->access;
726 
727  if (in_array(
728  $a_active,
729  array("general_settings", "style", "imp_pages", "rating_categories",
730  "page_templates", "advmd", "permission_settings", "notifications")
731  )) {
732  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
733  // general properties
734  $ilTabs->addSubTab(
735  "general_settings",
736  $lng->txt("wiki_general_settings"),
737  $ilCtrl->getLinkTarget($this, 'editSettings')
738  );
739 
740  // permission settings
741  $ilTabs->addSubTab(
742  "permission_settings",
743  $lng->txt("obj_permission_settings"),
744  $this->ctrl->getLinkTargetByClass("ilsettingspermissiongui", "")
745  );
746 
747  // style properties
748  $ilTabs->addSubTab(
749  "style",
750  $lng->txt("wiki_style"),
751  $ilCtrl->getLinkTarget($this, 'editStyleProperties')
752  );
753  }
754 
755  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
756  // important pages
757  $ilTabs->addSubTab(
758  "imp_pages",
759  $lng->txt("wiki_navigation"),
760  $ilCtrl->getLinkTarget($this, 'editImportantPages')
761  );
762  }
763 
764  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
765  // page templates
766  $ilTabs->addSubTab(
767  "page_templates",
768  $lng->txt("wiki_page_templates"),
769  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "")
770  );
771 
772  // rating categories
773  if ($this->object->getRating() && $this->object->getRatingCategories()) {
774  $lng->loadLanguageModule("rating");
775  $ilTabs->addSubTab(
776  "rating_categories",
777  $lng->txt("rating_categories"),
778  $ilCtrl->getLinkTargetByClass(array('ilratinggui', 'ilratingcategorygui'), '')
779  );
780  }
781 
782  $ilTabs->addSubTab(
783  'notifications',
784  $lng->txt("notifications"),
785  $ilCtrl->getLinkTargetByClass("ilobjnotificationsettingsgui", '')
786  );
787  }
788 
789  $ilTabs->activateSubTab($a_active);
790  }
791  }
792 
796  public function editSettingsObject()
797  {
798  $tpl = $this->tpl;
799 
800  $this->checkPermission("write");
801 
802  $this->setSettingsSubTabs("general_settings");
803 
804  $this->initSettingsForm();
805  $this->getSettingsFormValues();
806 
807  // Edit ecs export settings
808  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
809  $ecs = new ilECSWikiSettings($this->object);
810  $ecs->addSettingsToForm($this->form_gui, 'wiki');
811 
812  $tpl->setContent($this->form_gui->getHtml());
813  $this->setSideBlock();
814  }
815 
819  public function initSettingsForm($a_mode = "edit")
820  {
821  $lng = $this->lng;
823  $ilTabs = $this->tabs;
825  $obj_service = $this->object_service;
826 
827  $lng->loadLanguageModule("wiki");
828  $ilTabs->activateTab("settings");
829 
830  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
831  $this->form_gui = new ilPropertyFormGUI();
832 
833  // Title
834  $tit = new ilTextInputGUI($lng->txt("title"), "title");
835  $tit->setRequired(true);
836  $this->form_gui->addItem($tit);
837 
838  // Short Title
839  // The problem with the short title is, that it is per object
840  // and can't be a substitute for a ref id in the permanent link
841  /*
842  $stit = new ilRegExpInputGUI($lng->txt("wiki_short_title"), "shorttitle");
843  $stit->setPattern("/^[^0-9][^ _\&]+$/");
844  $stit->setRequired(false);
845  $stit->setNoMatchMessage($lng->txt("wiki_msg_short_name_regexp")." &amp; _");
846  $stit->setSize(20);
847  $stit->setMaxLength(20);
848  $stit->setInfo($lng->txt("wiki_short_title_desc2"));
849  $this->form_gui->addItem($stit);
850  */
851 
852  // Description
853  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
854  $this->form_gui->addItem($des);
855 
856  // Introduction
857  $intro = new ilTextAreaInputGUI($lng->txt("wiki_introduction"), "intro");
858  $intro->setCols(40);
859  $intro->setRows(4);
860  $this->form_gui->addItem($intro);
861 
862  // Start Page
863  if ($a_mode == "edit") {
864  $pages = ilWikiPage::getAllWikiPages($this->object->getId());
865  foreach ($pages as $p) {
866  $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
867  }
868  $si = new ilSelectInputGUI($lng->txt("wiki_start_page"), "startpage_id");
869  $si->setOptions($options);
870  $this->form_gui->addItem($si);
871  } else {
872  $sp = new ilTextInputGUI($lng->txt("wiki_start_page"), "startpage");
873  if ($a_mode == "edit") {
874  $sp->setInfo($lng->txt("wiki_start_page_info"));
875  }
876  $sp->setMaxLength(200);
877  $sp->setRequired(true);
878  $this->form_gui->addItem($sp);
879  }
880 
881  // Online
882  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
883  $this->form_gui->addItem($online);
884 
885 
886  // rating
887 
888  $lng->loadLanguageModule('rating');
889  $rate = new ilCheckboxInputGUI($lng->txt('rating_activate_rating'), 'rating_overall');
890  $rate->setInfo($lng->txt('rating_activate_rating_info'));
891  $this->form_gui->addItem($rate);
892 
893  $rating = new ilCheckboxInputGUI($lng->txt("wiki_activate_rating"), "rating");
894  $this->form_gui->addItem($rating);
895 
896  /* always active
897  $side = new ilCheckboxInputGUI($lng->txt("wiki_activate_sideblock_rating"), "rating_side");
898  $rating->addSubItem($side);
899  */
900 
901  $new = new ilCheckboxInputGUI($lng->txt("wiki_activate_new_page_rating"), "rating_new");
902  $rating->addSubItem($new);
903 
904  $extended = new ilCheckboxInputGUI($lng->txt("wiki_activate_extended_rating"), "rating_ext");
905  $rating->addSubItem($extended);
906 
907 
908  // public comments
909  if (!$ilSetting->get("disable_comments")) {
910  $comments = new ilCheckboxInputGUI($lng->txt("wiki_public_comments"), "public_notes");
911  $this->form_gui->addItem($comments);
912  }
913 
914  // important pages
915  // $imp_pages = new ilCheckboxInputGUI($lng->txt("wiki_important_pages"), "imp_pages");
916  // $this->form_gui->addItem($imp_pages);
917 
918  // page toc
919  $page_toc = new ilCheckboxInputGUI($lng->txt("wiki_page_toc"), "page_toc");
920  $page_toc->setInfo($lng->txt("wiki_page_toc_info"));
921  $this->form_gui->addItem($page_toc);
922 
923  if ($a_mode == "edit") {
924  // advanced metadata auto-linking
925  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
926  if (count(ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->object->getRefId(), "wpg")) > 0) {
927  $link_md = new ilCheckboxInputGUI($lng->txt("wiki_link_md_values"), "link_md_values");
928  $link_md->setInfo($lng->txt("wiki_link_md_values_info"));
929  $this->form_gui->addItem($link_md);
930  }
931 
932 
934  $section->setTitle($this->lng->txt('obj_presentation'));
935  $this->form_gui->addItem($section);
936 
937  // tile image
938  $obj_service->commonSettings()->legacyForm($this->form_gui, $this->object)->addTileImage();
939 
940 
941  // additional features
942  $feat = new ilFormSectionHeaderGUI();
943  $feat->setTitle($this->lng->txt('obj_features'));
944  $this->form_gui->addItem($feat);
945 
946  include_once './Services/Container/classes/class.ilContainer.php';
947  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
949  $this->object->getId(),
950  $this->form_gui,
951  array(
953  )
954  );
955  }
956 
957  // :TODO: sorting
958 
959  // Form action and save button
960  $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_wiki.svg"));
961  if ($a_mode != "create") {
962  $this->form_gui->setTitle($lng->txt("wiki_settings"));
963  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
964  } else {
965  $this->form_gui->setTitle($lng->txt("wiki_new"));
966  $this->form_gui->addCommandButton("save", $lng->txt("wiki_add"));
967  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
968  }
969 
970  // set values
971  if ($a_mode == "create") {
972  $ilCtrl->setParameter($this, "new_type", "wiki");
973  }
974 
975  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
976  }
977 
978  public function getSettingsFormValues($a_mode = "edit")
979  {
980  $lng = $this->lng;
982 
983  // set values
984  if ($a_mode == "create") {
985  //$values["startpage"] = $lng->txt("wiki_main_page");
986  $values["rating_new"] = true;
987 
988  $values["rating_overall"] = ilObject::hasAutoRating("wiki", $_GET["ref_id"]);
989 
990  $this->form_gui->setValuesByArray($values);
991  } else {
992  $values["online"] = $this->object->getOnline();
993  $values["title"] = $this->object->getTitle();
994  //$values["startpage"] = $this->object->getStartPage();
995  $values["startpage_id"] = ilWikiPage::_getPageIdForWikiTitle($this->object->getId(), $this->object->getStartPage());
996  $values["shorttitle"] = $this->object->getShortTitle();
997  $values["description"] = $this->object->getLongDescription();
998  $values["rating_overall"] = $this->object->getRatingOverall();
999  $values["rating"] = $this->object->getRating();
1000  // $values["rating_side"] = $this->object->getRatingAsBlock();
1001  $values["rating_new"] = $this->object->getRatingForNewPages();
1002  $values["rating_ext"] = $this->object->getRatingCategories();
1003  $values["public_notes"] = $this->object->getPublicNotes();
1004  $values["intro"] = $this->object->getIntroduction();
1005  // $values["imp_pages"] = $this->object->getImportantPages();
1006  $values["page_toc"] = $this->object->getPageToc();
1007  $values["link_md_values"] = $this->object->getLinkMetadataValues();
1008 
1009  // only set given values (because of adv. metadata)
1010  $this->form_gui->setValuesByArray($values, true);
1011  }
1012  }
1013 
1014 
1018  public function saveSettingsObject()
1019  {
1020  $ilCtrl = $this->ctrl;
1021  $lng = $this->lng;
1022  $ilUser = $this->user;
1024  $obj_service = $this->object_service;
1025 
1026  $this->checkPermission("write");
1027 
1028  $this->initSettingsForm();
1029 
1030  if ($this->form_gui->checkInput()) {
1031  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")) &&
1032  $this->form_gui->getInput("shorttitle") != $this->object->getShortTitle()) {
1033  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
1034  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
1035  } else {
1036  $this->object->setTitle($this->form_gui->getInput("title"));
1037  $this->object->setDescription($this->form_gui->getInput("description"));
1038  $this->object->setOnline($this->form_gui->getInput("online"));
1039  $this->object->setStartPage(ilWikiPage::lookupTitle($this->form_gui->getInput("startpage_id")));
1040  $this->object->setShortTitle($this->form_gui->getInput("shorttitle"));
1041  $this->object->setRatingOverall($this->form_gui->getInput("rating_overall"));
1042  $this->object->setRating($this->form_gui->getInput("rating"));
1043  // $this->object->setRatingAsBlock($this->form_gui->getInput("rating_side"));
1044  $this->object->setRatingForNewPages($this->form_gui->getInput("rating_new"));
1045  $this->object->setRatingCategories($this->form_gui->getInput("rating_ext"));
1046 
1047  if (!$ilSetting->get("disable_comments")) {
1048  $this->object->setPublicNotes($this->form_gui->getInput("public_notes"));
1049  }
1050  $this->object->setIntroduction($this->form_gui->getInput("intro"));
1051  // $this->object->setImportantPages($this->form_gui->getInput("imp_pages"));
1052  $this->object->setPageToc($this->form_gui->getInput("page_toc"));
1053  $this->object->setLinkMetadataValues($this->form_gui->getInput("link_md_values"));
1054  $this->object->update();
1055 
1056  // tile image
1057  $obj_service->commonSettings()->legacyForm($this->form_gui, $this->object)->saveTileImage();
1058 
1059 
1060  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
1062  $this->object->getId(),
1063  $this->form_gui,
1064  array(
1066  )
1067  );
1068 
1069  // Update ecs export settings
1070  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
1071  $ecs = new ilECSWikiSettings($this->object);
1072  if ($ecs->handleSettingsUpdate()) {
1073  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1074  $ilCtrl->redirect($this, "editSettings");
1075  }
1076  }
1077  }
1078 
1079  $this->form_gui->setValuesByPost();
1080  $this->tpl->setContent($this->form_gui->getHTML());
1081  }
1082 
1086  public function listContributorsObject()
1087  {
1088  $tpl = $this->tpl;
1089  $ilTabs = $this->tabs;
1090 
1091  $this->checkPermission("write");
1092  $ilTabs->activateTab("wiki_contributors");
1093 
1094  include_once("./Modules/Wiki/classes/class.ilWikiContributorsTableGUI.php");
1095 
1096  $table_gui = new ilWikiContributorsTableGUI(
1097  $this,
1098  "listContributors",
1099  $this->object->getId()
1100  );
1101 
1102  $tpl->setContent($table_gui->getHTML());
1103 
1104  $this->setSideBlock();
1105  }
1106 
1110  public function saveGradingObject()
1111  {
1112  $ilCtrl = $this->ctrl;
1113  $lng = $this->lng;
1114 
1115  $this->checkPermission("write");
1116 
1117  $users = (is_array($_POST["user_id"])
1118  ? $_POST["user_id"]
1119  : array());
1120 
1121  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
1122  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
1123  $saved = false;
1124  foreach ($users as $user_id) {
1125  if ($user_id != "") {
1126  $marks_obj = new ilLPMarks($this->object->getId(), $user_id);
1127  $new_mark = ilUtil::stripSlashes($_POST['mark'][$user_id]);
1128  $new_comment = ilUtil::stripSlashes($_POST['lcomment'][$user_id]);
1129  $new_status = ilUtil::stripSlashes($_POST["status"][$user_id]);
1130 
1131  if ($marks_obj->getMark() != $new_mark ||
1132  $marks_obj->getComment() != $new_comment ||
1133  ilWikiContributor::_lookupStatus($this->object->getId(), $user_id) != $new_status) {
1134  ilWikiContributor::_writeStatus($this->object->getId(), $user_id, $new_status);
1135  $marks_obj->setMark($new_mark);
1136  $marks_obj->setComment($new_comment);
1137  $marks_obj->update();
1138  $saved = true;
1139  }
1140  }
1141  }
1142  if ($saved) {
1143  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1144  }
1145 
1146  $ilCtrl->redirect($this, "listContributors");
1147  }
1148 
1149  // add wiki to locator
1150  public function addLocatorItems()
1151  {
1152  $ilLocator = $this->locator;
1153 
1154  if (is_object($this->object)) {
1155  $ilLocator->addItem(
1156  $this->object->getTitle(),
1157  $this->getGotoLink($this->object->getRefId()),
1158  "",
1159  $_GET["ref_id"]
1160  );
1161  }
1162  }
1163 
1164  public static function _goto($a_target)
1165  {
1166  global $DIC;
1167 
1168  $ilAccess = $DIC->access();
1169  $ilErr = $DIC["ilErr"];
1170  $lng = $DIC->language();
1171  $ilNavigationHistory = $DIC["ilNavigationHistory"];
1172 
1173  $i = strpos($a_target, "_");
1174  if ($i > 0) {
1175  $a_page = substr($a_target, $i + 1);
1176  $a_target = substr($a_target, 0, $i);
1177  }
1178 
1179  if ($a_target == "wpage") {
1180  $a_page_arr = explode("_", $a_page);
1181  $wpg_id = (int) $a_page_arr[0];
1182  $ref_id = (int) $a_page_arr[1];
1183  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1184  $w_id = ilWikiPage::lookupWikiId($wpg_id);
1185  if ($ref_id > 0) {
1186  $refs = array($ref_id);
1187  } else {
1188  $refs = ilObject::_getAllReferences($w_id);
1189  }
1190  foreach ($refs as $r) {
1191  if ($ilAccess->checkAccess("read", "", $r)) {
1192  $a_target = $r;
1193  $a_page = ilWikiPage::lookupTitle($wpg_id);
1194  }
1195  }
1196  }
1197 
1198  if ($ilAccess->checkAccess("read", "", $a_target)) {
1199  $_GET["cmd"] = "viewPage";
1200  $_GET["ref_id"] = $a_target;
1201  $_GET["page"] = $a_page;
1202  $_GET["baseClass"] = "ilwikihandlergui";
1203  $_GET["cmdClass"] = "ilobjwikigui";
1204  /* if ($a_page != "")
1205  {
1206  $add = "&amp;page=".rawurlencode($_GET["page"]);
1207  $ilNavigationHistory->addItem($_GET["ref_id"],
1208  "./goto.php?target=wiki_".$_GET["ref_id"].$add, "wiki");
1209  }*/
1210  include("ilias.php");
1211  exit;
1212  } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
1213  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
1214  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1215  ilUtil::sendFailure(sprintf(
1216  $lng->txt("msg_no_perm_read_item"),
1218  ), true);
1220  }
1221 
1222  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1223  }
1224 
1228  public static function getGotoLink($a_ref_id, $a_page = "")
1229  {
1230  if ($a_page == "") {
1232  }
1233 
1234  $goto = "goto.php?target=wiki_" . $a_ref_id . "_" .
1235  ilWikiUtil::makeUrlTitle($a_page);
1236 
1237  return $goto;
1238  }
1239 
1243  public function viewPageObject()
1244  {
1245  $lng = $this->lng;
1246  $ilCtrl = $this->ctrl;
1247  $tpl = $this->tpl;
1248  $ilTabs = $this->tabs;
1249  $ilAccess = $this->access;
1250 
1251  $this->checkPermission("read");
1252 
1253  $ilTabs->clearTargets();
1254  $tpl->setHeaderActionMenu(null);
1255 
1256  $page = ($_GET["page"] != "")
1257  ? $_GET["page"]
1258  : $this->object->getStartPage();
1259  $_GET["page"] = $page;
1260 
1261  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1262  if (!ilWikiPage::exists($this->object->getId(), $page)) {
1263  $page = $this->object->getStartPage();
1264  }
1265 
1266  if (!ilWikiPage::exists($this->object->getId(), $page)) {
1267  ilUtil::sendInfo($lng->txt("wiki_no_start_page"), true);
1268  $ilCtrl->redirect($this, "infoScreen");
1269  return;
1270  }
1271 
1272  // page exists, show it !
1273  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($page));
1274 
1275  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
1276  $wpage_gui = ilWikiPageGUI::getGUIForTitle(
1277  $this->object->getId(),
1278  ilWikiUtil::makeDbTitle($page),
1279  0,
1280  $this->object->getRefId()
1281  );
1282  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1283  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
1284  $this->object->getStyleSheetId(),
1285  "wiki"
1286  ));
1287 
1288  $this->setContentStyleSheet();
1289 
1290  //$wpage_gui->setSideBlock();
1291  $ilCtrl->setCmdClass("ilwikipagegui");
1292  $ilCtrl->setCmd("preview");
1293  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
1294  (
1295  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()) ||
1296  $wpage_gui->getPageObject()->getBlocked()
1297  )) {
1298  $wpage_gui->setEnableEditing(false);
1299  }
1300 
1301  // alter title and description
1302  //$tpl->setTitle($wpage_gui->getPageObject()->getTitle());
1303  //$tpl->setDescription($this->object->getTitle());
1304  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1305  $wpage_gui->activateMetaDataEditor($this->object, "wpg", $wpage_gui->getId());
1306  }
1307 
1308 
1309  $html = $ilCtrl->forwardCommand($wpage_gui);
1310  //$this->addPageTabs();
1311 
1312  $tpl->setContent($html);
1313  }
1314 
1318  public function allPagesObject()
1319  {
1320  $tpl = $this->tpl;
1321 
1322  $this->checkPermission("read");
1323 
1324  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1325 
1326  $this->addPagesSubTabs();
1327 
1328  $table_gui = new ilWikiPagesTableGUI(
1329  $this,
1330  "allPages",
1331  $this->object->getId(),
1333  );
1334 
1335  $this->setSideBlock();
1336  $tpl->setContent($table_gui->getHTML());
1337  }
1338 
1342  public function popularPagesObject()
1343  {
1344  $tpl = $this->tpl;
1345 
1346  $this->checkPermission("read");
1347 
1348  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1349 
1350  $this->addPagesSubTabs();
1351 
1352  $table_gui = new ilWikiPagesTableGUI(
1353  $this,
1354  "popularPages",
1355  $this->object->getId(),
1357  );
1358 
1359  $this->setSideBlock();
1360  $tpl->setContent($table_gui->getHTML());
1361  }
1362 
1366  public function orphanedPagesObject()
1367  {
1368  $tpl = $this->tpl;
1369 
1370  $this->checkPermission("read");
1371 
1372  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1373 
1374  $this->addPagesSubTabs();
1375 
1376  $table_gui = new ilWikiPagesTableGUI(
1377  $this,
1378  "orphanedPages",
1379  $this->object->getId(),
1381  );
1382 
1383  $this->setSideBlock();
1384  $tpl->setContent($table_gui->getHTML());
1385  }
1386 
1392  public function gotoPageObject($a_page = "")
1393  {
1394  $ilCtrl = $this->ctrl;
1395 
1396  if ($a_page == "") {
1397  $a_page = $_GET["page"];
1398  }
1399 
1400  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1402  $this->object->getId(),
1403  ilWikiUtil::makeDbTitle($a_page)
1404  )) {
1405  // to do: get rid of this redirect
1406  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $a_page));
1407  } else {
1408  if (!$this->access->checkAccess("edit_content", "", $this->object->getRefId())) {
1409  ilUtil::sendFailure($this->lng->txt("no_permission"), true);
1410  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $_GET["from_page"]));
1411  }
1412  if (!$this->object->getTemplateSelectionOnCreation()) {
1413 
1414  // check length
1415  include_once("./Services/Utilities/classes/class.ilStr.php");
1416  if (ilStr::strLen(ilWikiUtil::makeDbTitle($a_page)) > 200) {
1417  ilUtil::sendFailure($this->lng->txt("wiki_page_title_too_long") . " (" . $a_page . ")", true);
1418  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
1419  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1420  }
1421  $this->object->createWikiPage($a_page);
1422 
1423  // redirect to newly created page
1424  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1425  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1426  } else {
1427  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
1428  $ilCtrl->setParameter($this, "from_page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
1429  $ilCtrl->redirect($this, "showTemplateSelection");
1430  }
1431  }
1432  }
1433 
1439  public function randomPageObject()
1440  {
1441  $this->checkPermission("read");
1442 
1443  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1444  $page = ilWikiPage::getRandomPage($this->object->getId());
1445  $this->gotoPageObject($page);
1446  }
1447 
1451  public function recentChangesObject()
1452  {
1453  $tpl = $this->tpl;
1454 
1455  $this->checkPermission("read");
1456 
1457  include_once("./Modules/Wiki/classes/class.ilWikiRecentChangesTableGUI.php");
1458 
1459  $this->addPagesSubTabs();
1460 
1461  $table_gui = new ilWikiRecentChangesTableGUI(
1462  $this,
1463  "recentChanges",
1464  $this->object->getId()
1465  );
1466 
1467  $this->setSideBlock();
1468  $tpl->setContent($table_gui->getHTML());
1469  }
1470 
1474  public function setSideBlock($a_wpg_id = 0)
1475  {
1476  ilObjWikiGUI::renderSideBlock($a_wpg_id, $this->object->getRefId());
1477  }
1478 
1479 
1483  public static function renderSideBlock($a_wpg_id, $a_wiki_ref_id, $a_wp = null)
1484  {
1485  global $DIC;
1486 
1487  $tpl = $DIC["tpl"];
1488  $lng = $DIC->language();
1489  $ilAccess = $DIC->access();
1490  $ilCtrl = $DIC->ctrl();
1491 
1492  $tpl->addJavaScript("./Modules/Wiki/js/WikiPres.js");
1493 
1494  // setting asynch to false fixes #0019457, since otherwise ilBlockGUI would act on asynch and output html when side blocks
1495  // being processed during the export. This is a flaw in ilCtrl and/or ilBlockGUI.
1496  $tpl->addOnLoadCode("il.Wiki.Pres.init('" . $ilCtrl->getLinkTargetByClass("ilobjwikigui", "", "", false, false) . "');");
1497 
1498  if ($a_wpg_id > 0 && !$a_wp) {
1499  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1500  $a_wp = ilWikiPage($a_wpg_id);
1501  }
1502 
1503  // search block
1504  include_once './Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
1505  $rcontent = ilRepositoryObjectSearchGUI::getSearchBlockHTML($lng->txt('wiki_search'));
1506 
1507 
1508  // quick navigation
1509  if ($a_wpg_id > 0) {
1510  // rating
1511  $wiki_id = ilObject::_lookupObjId($a_wiki_ref_id);
1512  if (ilObjWiki::_lookupRating($wiki_id) &&
1513  // ilObjWiki::_lookupRatingAsBlock($wiki_id) &&
1514  $a_wp->getRating()) {
1515  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
1516  $rgui = new ilRatingGUI();
1517  $rgui->setObject($wiki_id, "wiki", $a_wpg_id, "wpg");
1518  $rgui->enableCategories(ilObjWiki::_lookupRatingCategories($wiki_id));
1519  $rgui->setYourRatingText("#");
1520  $rcontent .= $rgui->getBlockHTML($lng->txt("wiki_rate_page"));
1521  }
1522 
1523  // advanced metadata
1524  if (!ilWikiPage::lookupAdvancedMetadataHidden($a_wpg_id)) {
1525  $cmd = null;
1526  if ($ilAccess->checkAccess("write", "", $a_wiki_ref_id) ||
1527  $ilAccess->checkAccess("edit_page_meta", "", $a_wiki_ref_id)) {
1528  $cmd = array(
1529  "edit" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "editAdvancedMetaData"),
1530  "hide" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "hideAdvancedMetaData")
1531  );
1532  }
1533  include_once("./Services/Object/classes/class.ilObjectMetaDataGUI.php");
1534  $wiki = new ilObjWiki($a_wiki_ref_id);
1535  $callback = $wiki->getLinkMetadataValues()
1536  ? array($wiki, "decorateAdvMDValue")
1537  : null;
1538  $mdgui = new ilObjectMetaDataGUI($wiki, "wpg", $a_wpg_id);
1539  $rcontent .= $mdgui->getBlockHTML($cmd, $callback); // #17291
1540  }
1541  }
1542 
1543  // important pages
1544  include_once("./Modules/Wiki/classes/class.ilWikiImportantPagesBlockGUI.php");
1545  $imp_pages_block = new ilWikiImportantPagesBlockGUI();
1546  $rcontent .= $imp_pages_block->getHTML();
1547 
1548  // wiki functions block
1549  if ($a_wpg_id > 0) {
1550  include_once("./Modules/Wiki/classes/class.ilWikiFunctionsBlockGUI.php");
1551  $wiki_functions_block = new ilWikiFunctionsBlockGUI();
1552  $wiki_functions_block->setPageObject($a_wp);
1553  $rcontent .= $wiki_functions_block->getHTML();
1554  }
1555 
1556  $tpl->setRightContent($rcontent);
1557  }
1558 
1562  public function newPagesObject()
1563  {
1564  $tpl = $this->tpl;
1565 
1566  $this->checkPermission("read");
1567 
1568  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1569 
1570  $this->addPagesSubTabs();
1571 
1572  $table_gui = new ilWikiPagesTableGUI(
1573  $this,
1574  "newPages",
1575  $this->object->getId(),
1577  );
1578 
1579  $this->setSideBlock();
1580  $tpl->setContent($table_gui->getHTML());
1581  }
1582 
1583  protected function getPrintPageIds()
1584  {
1585  // multiple ordered page ids
1586  if (is_array($_POST["wordr"])) {
1587  asort($_POST["wordr"]);
1588  $page_ids = array_keys($_POST["wordr"]);
1589  }
1590  // single page
1591  elseif ((int) $_GET["wpg_id"]) {
1592  $page_ids = array((int) $_GET["wpg_id"]);
1593  }
1594 
1595  return $page_ids;
1596  }
1597 
1598  public function printViewObject($a_pdf_export = false)
1599  {
1600  global $tpl;
1601  $tpl = $this->tpl;
1602 
1604 
1605  $tabs->clearTargets();
1606  $tabs->setBackTarget(
1607  $this->lng->txt("back"),
1608  $this->ctrl->getLinkTargetByClass("ilwikipagegui", "printViewSelection")
1609  );
1610 
1611  $page_ids = $this->getPrintPageIds();
1612  if (!$page_ids) {
1613  $this->ctrl->redirect($this, "");
1614  }
1615 
1616  $this->setContentStyleSheet($tpl);
1617 
1618  $page_content = "";
1619  foreach ($page_ids as $p_id) {
1620  $page_gui = new ilWikiPageGUI($p_id);
1621  $page_gui->setWiki($this->object);
1622  $page_gui->setOutputMode("print");
1623  $page_content .= $page_gui->showPage();
1624 
1625  if ($a_pdf_export) {
1626  $page_content .= '<p style="page-break-after:always;"></p>';
1627  }
1628  }
1629 
1630  //$page_content = '<div class="ilInvisibleBorder">' . $page_content . '</div>';
1631 
1632  if (!$a_pdf_export) {
1633  $tpl->addOnLoadCode("il.Util.print();");
1634  }
1635 
1636  $tpl->setContent($page_content);
1637 
1638  if (!$a_pdf_export) {
1639 // $tpl->printToStdout(false);
1640  } else {
1641  return $tpl->printToString();
1642  }
1643  }
1644 
1645  public function pdfExportObject()
1646  {
1647 
1648  // prepare generation before contents are processed (for mathjax)
1649  ilPDFGeneratorUtils::prepareGenerationRequest("Wiki", "ContentExport");
1650 
1651  $html = $this->printViewObject(true);
1652 
1653  // :TODO: fixing css dummy parameters
1654  $html = preg_replace("/\?dummy\=[0-9]+/", "", $html);
1655  $html = preg_replace("/\?vers\=[0-9A-Za-z\-]+/", "", $html);
1656  $html = str_replace('.css$Id$', ".css", $html);
1657 
1658  if (false) {
1659  include_once "Services/PDFGeneration/classes/class.ilPDFGeneration.php";
1660  include_once "Services/PDFGeneration/classes/class.ilPDFGenerationJob.php";
1661 
1662  $job = new ilPDFGenerationJob();
1663  $job->setAutoPageBreak(true)
1664  ->setMarginLeft("10")
1665  ->setMarginRight("10")
1666  ->setMarginTop("10")
1667  ->setMarginBottom("10")
1668  ->setOutputMode("D")// download
1669  ->setFilename("wiki.pdf")// :TODO:
1670  ->setCreator("ILIAS Wiki")// :TODO:
1671  ->setImageScale(1.25)// complete content scaling ?!
1672  ->addPage($html);
1673 
1674  ilPDFGeneration::doJob($job);
1675  } else {
1676  $html = preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $html);
1677  $html = preg_replace("/href=\"\\.\\//ims", "href=\"" . ILIAS_HTTP_PATH . "/", $html);
1678  $pdf_factory = new ilHtmlToPdfTransformerFactory();
1679  $pdf_factory->deliverPDFFromHTMLString($html, "wiki.pdf", ilHtmlToPdfTransformerFactory::PDF_OUTPUT_DOWNLOAD, "Wiki", "ContentExport");
1680  }
1681  }
1682 
1686  public function performSearchObject()
1687  {
1688  $tpl = $this->tpl;
1689  $ilTabs = $this->tabs;
1690  $ilCtrl = $this->ctrl;
1691  $lng = $this->lng;
1692 
1693  $this->checkPermission("read");
1694 
1695  include_once("./Modules/Wiki/classes/class.ilWikiSearchResultsTableGUI.php");
1696 
1697  $ilTabs->setTabActive("wiki_search_results");
1698 
1699  if (trim($_POST["search_term"]) == "") {
1700  ilUtil::sendFailure($lng->txt("wiki_please_enter_search_term"), true);
1701  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1702  }
1703 
1704  $search_results = ilObjWiki::_performSearch(
1705  $this->object->getId(),
1706  ilUtil::stripSlashes($_POST["search_term"])
1707  );
1708  $table_gui = new ilWikiSearchResultsTableGUI(
1709  $this,
1710  "performSearch",
1711  $this->object->getId(),
1712  $search_results,
1713  $_POST["search_term"]
1714  );
1715 
1716  $this->setSideBlock();
1717  $tpl->setContent($table_gui->getHTML());
1718  }
1719 
1723  public function setContentStyleSheet($tpl = null)
1724  {
1725  $tpl = $this->tpl;
1726 
1727  if ($tpl == null) {
1728  $tpl = $this->tpl;
1729  }
1730 
1733  $this->object->getStyleSheetId(),
1734  "wiki"
1735  )
1736  ));
1738  }
1739 
1740 
1744  public function editStylePropertiesObject()
1745  {
1746  $ilTabs = $this->tabs;
1747  $tpl = $this->tpl;
1748 
1749  $this->checkPermission("write");
1750 
1751  $this->initStylePropertiesForm();
1752  $tpl->setContent($this->form->getHTML());
1753 
1754  $ilTabs->activateTab("settings");
1755  $this->setSettingsSubTabs("style");
1756 
1757  $this->setSideBlock();
1758  }
1759 
1763  public function initStylePropertiesForm()
1764  {
1765  $ilCtrl = $this->ctrl;
1766  $lng = $this->lng;
1767  $ilTabs = $this->tabs;
1769 
1770  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1771  $lng->loadLanguageModule("style");
1772 
1773  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1774  $this->form = new ilPropertyFormGUI();
1775 
1776  $fixed_style = $ilSetting->get("fixed_content_style_id");
1777  $style_id = $this->object->getStyleSheetId();
1778 
1779  if ($fixed_style > 0) {
1780  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1781  $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
1782  $this->lng->txt("global_fixed") . ")");
1783  $this->form->addItem($st);
1784  } else {
1786  true,
1787  false,
1788  $_GET["ref_id"]
1789  );
1790 
1791  $st_styles[0] = $this->lng->txt("default");
1792  ksort($st_styles);
1793 
1794  if ($style_id > 0) {
1795  // individual style
1796  if (!ilObjStyleSheet::_lookupStandard($style_id)) {
1797  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1798  $st->setValue(ilObject::_lookupTitle($style_id));
1799  $this->form->addItem($st);
1800 
1801  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
1802 
1803  // delete command
1804  $this->form->addCommandButton(
1805  "editStyle",
1806  $lng->txt("style_edit_style")
1807  );
1808  $this->form->addCommandButton(
1809  "deleteStyle",
1810  $lng->txt("style_delete_style")
1811  );
1812  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
1813  }
1814  }
1815 
1816  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
1817  $style_sel = ilUtil::formSelect(
1818  $style_id,
1819  "style_id",
1820  $st_styles,
1821  false,
1822  true
1823  );
1824  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
1825  $style_sel->setOptions($st_styles);
1826  $style_sel->setValue($style_id);
1827  $this->form->addItem($style_sel);
1828  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
1829  $this->form->addCommandButton(
1830  "saveStyleSettings",
1831  $lng->txt("save")
1832  );
1833  $this->form->addCommandButton(
1834  "createStyle",
1835  $lng->txt("sty_create_ind_style")
1836  );
1837  }
1838  }
1839  $this->form->setTitle($lng->txt("wiki_style"));
1840  $this->form->setFormAction($ilCtrl->getFormAction($this));
1841  }
1842 
1846  public function createStyleObject()
1847  {
1848  $ilCtrl = $this->ctrl;
1849 
1850  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
1851  }
1852 
1856  public function editStyleObject()
1857  {
1858  $ilCtrl = $this->ctrl;
1859 
1860  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
1861  }
1862 
1866  public function deleteStyleObject()
1867  {
1868  $ilCtrl = $this->ctrl;
1869 
1870  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
1871  }
1872 
1876  public function saveStyleSettingsObject()
1877  {
1879 
1880  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1881  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1882  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1883  || $this->object->getStyleSheetId() == 0)) {
1884  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1885  $this->object->update();
1886  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1887  }
1888  $this->ctrl->redirect($this, "editStyleProperties");
1889  }
1890 
1891  //
1892  // Important pages
1893  //
1894 
1898  public function editImportantPagesObject()
1899  {
1900  $tpl = $this->tpl;
1901  $ilToolbar = $this->toolbar;
1902  $ilTabs = $this->tabs;
1903  $lng = $this->lng;
1904  $ilCtrl = $this->ctrl;
1905 
1906  $this->checkPermission("edit_wiki_navigation");
1907 
1908  ilUtil::sendInfo($lng->txt("wiki_navigation_info"));
1909 
1910  $ipages = ilObjWiki::_lookupImportantPagesList($this->object->getId());
1911  $ipages_ids = array();
1912  foreach ($ipages as $i) {
1913  $ipages_ids[] = $i["page_id"];
1914  }
1915 
1916  // list pages
1917  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1918  $pages = ilWikiPage::getAllWikiPages($this->object->getId());
1919  $options = array("" => $lng->txt("please_select"));
1920  foreach ($pages as $p) {
1921  if (!in_array($p["id"], $ipages_ids)) {
1922  $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
1923  }
1924  }
1925  if (count($options) > 0) {
1926  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1927  $si = new ilSelectInputGUI($lng->txt("wiki_pages"), "imp_page_id");
1928  $si->setOptions($options);
1929  $si->setInfo($lng->txt(""));
1930  $ilToolbar->addInputItem($si);
1931  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1932  $ilToolbar->addFormButton($lng->txt("add"), "addImportantPage");
1933  }
1934 
1935 
1936  $ilTabs->activateTab("settings");
1937  $this->setSettingsSubTabs("imp_pages");
1938 
1939  include_once("./Modules/Wiki/classes/class.ilImportantPagesTableGUI.php");
1940  $imp_table = new ilImportantPagesTableGUI($this, "editImportantPages");
1941 
1942  $tpl->setContent($imp_table->getHTML());
1943  }
1944 
1951  public function addImportantPageObject()
1952  {
1953  $ilCtrl = $this->ctrl;
1954  $lng = $this->lng;
1955 
1956  $this->checkPermission("edit_wiki_navigation");
1957 
1958  if ($_POST["imp_page_id"] > 0) {
1959  $this->object->addImportantPage((int) $_POST["imp_page_id"]);
1960  ilUtil::sendSuccess($lng->txt("wiki_imp_page_added"), true);
1961  }
1962  $ilCtrl->redirect($this, "editImportantPages");
1963  }
1964 
1969  {
1970  $ilCtrl = $this->ctrl;
1971  $tpl = $this->tpl;
1972  $lng = $this->lng;
1973 
1974  if (!is_array($_POST["imp_page_id"]) || count($_POST["imp_page_id"]) == 0) {
1975  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1976  $ilCtrl->redirect($this, "editImportantPages");
1977  } else {
1978  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1979  $cgui = new ilConfirmationGUI();
1980  $cgui->setFormAction($ilCtrl->getFormAction($this));
1981  $cgui->setHeaderText($lng->txt("wiki_sure_remove_imp_pages"));
1982  $cgui->setCancel($lng->txt("cancel"), "editImportantPages");
1983  $cgui->setConfirm($lng->txt("remove"), "removeImportantPages");
1984 
1985  foreach ($_POST["imp_page_id"] as $i) {
1986  $cgui->addItem("imp_page_id[]", $i, ilWikiPage::lookupTitle((int) $i));
1987  }
1988 
1989  $tpl->setContent($cgui->getHTML());
1990  }
1991  }
1992 
1999  public function removeImportantPagesObject()
2000  {
2001  $ilCtrl = $this->ctrl;
2002  $lng = $this->lng;
2003 
2004  $this->checkPermission("edit_wiki_navigation");
2005 
2006  if (is_array($_POST["imp_page_id"])) {
2007  foreach ($_POST["imp_page_id"] as $i) {
2008  $this->object->removeImportantPage((int) $i);
2009  }
2010  }
2011  ilUtil::sendSuccess($lng->txt("wiki_removed_imp_pages"), true);
2012  $ilCtrl->redirect($this, "editImportantPages");
2013  }
2014 
2019  {
2020  $ilCtrl = $this->ctrl;
2021  $lng = $this->lng;
2022 
2023  $this->checkPermission("edit_wiki_navigation");
2024 
2025  $this->object->saveOrderingAndIndentation($_POST["ord"], $_POST["indent"]);
2026  ilUtil::sendSuccess($lng->txt("wiki_ordering_and_indent_saved"), true);
2027  $ilCtrl->redirect($this, "editImportantPages");
2028  }
2029 
2033  public function setAsStartPageObject()
2034  {
2035  $ilCtrl = $this->ctrl;
2036  $lng = $this->lng;
2037 
2038  $this->checkPermission("edit_wiki_navigation");
2039 
2040  if (!is_array($_POST["imp_page_id"]) || count($_POST["imp_page_id"]) != 1) {
2041  ilUtil::sendInfo($lng->txt("wiki_select_one_item"), true);
2042  } else {
2043  $this->object->removeImportantPage((int) $_POST["imp_page_id"][0]);
2044  $this->object->setStartPage(ilWikiPage::lookupTitle((int) $_POST["imp_page_id"][0]));
2045  $this->object->update();
2046  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2047  }
2048  $ilCtrl->redirect($this, "editImportantPages");
2049  }
2050 
2051 
2055  public function exportHTML()
2056  {
2057  $cont_exp = new Export\WikiHtmlExport($this->object);
2058  $cont_exp->buildExportFile();
2059  }
2060 
2068  public static function lookupSubObjectTitle($a_wiki_id, $a_page_id)
2069  {
2070  include_once "Modules/Wiki/classes/class.ilWikiPage.php";
2071  $page = new ilWikiPage($a_page_id);
2072  if ($page->getWikiId() == $a_wiki_id) {
2073  return $page->getTitle();
2074  }
2075  }
2076 
2084  public function getSubObjectTitle($a_id, $a_type)
2085  {
2086  include_once "Modules/Wiki/classes/class.ilWikiPage.php";
2087  return ilWikiPage::lookupTitle($a_id);
2088  }
2089 
2094  {
2095  $lng = $this->lng;
2096  $tpl = $this->tpl;
2097  $ilTabs = $this->tabs;
2098  $ilCtrl = $this->ctrl;
2099 
2100 
2101  $ilCtrl->setParameterByClass("ilobjwikigui", "from_page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
2102  $ilTabs->clearTargets();
2103  ilUtil::sendInfo($lng->txt("wiki_page_not_exist_select_templ"));
2104 
2105  $form = $this->initTemplateSelectionForm();
2106  $tpl->setContent($form->getHTML());
2107  }
2108 
2112  public function initTemplateSelectionForm()
2113  {
2114  $lng = $this->lng;
2115  $ilCtrl = $this->ctrl;
2116 
2117  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2118  $form = new ilPropertyFormGUI();
2119 
2120  // page name
2121  $hi = new ilHiddenInputGUI("page");
2122  $hi->setValue($_GET["page"]);
2123  $form->addItem($hi);
2124 
2125  // page template
2126  $radg = new ilRadioGroupInputGUI($lng->txt("wiki_page_template"), "page_templ");
2127  $radg->setRequired(true);
2128 
2129  if ($this->object->getEmptyPageTemplate()) {
2130  $op1 = new ilRadioOption($lng->txt("wiki_empty_page"), 0);
2131  $radg->addOption($op1);
2132  }
2133 
2134  include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
2135  $wt = new ilWikiPageTemplate($this->object->getId());
2137  foreach ($ts as $t) {
2138  $op = new ilRadioOption($t["title"], $t["wpage_id"]);
2139  $radg->addOption($op);
2140  }
2141 
2142  $form->addItem($radg);
2143 
2144  // save and cancel commands
2145  $form->addCommandButton("createPageUsingTemplate", $lng->txt("wiki_create_page"));
2146  $form->addCommandButton("cancelCreationPageUsingTemplate", $lng->txt("cancel"));
2147 
2148  $form->setTitle($lng->txt("wiki_new_page") . ": " . $_GET["page"]);
2149  $form->setFormAction($ilCtrl->getFormAction($this));
2150 
2151  return $form;
2152  }
2153 
2158  {
2159  $tpl = $this->tpl;
2160  $lng = $this->lng;
2161  $ilCtrl = $this->ctrl;
2162 
2163  $form = $this->initTemplateSelectionForm();
2164  if ($form->checkInput()) {
2165  $a_page = $_POST["page"];
2166  $this->object->createWikiPage($a_page, (int) $_POST["page_templ"]);
2167 
2168  // redirect to newly created page
2169  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
2170  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
2171 
2172  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2173  $ilCtrl->redirect($this, "");
2174  } else {
2175  $form->setValuesByPost();
2176  $tpl->setContent($form->getHtml());
2177  }
2178  }
2179 
2184  {
2185  $ilCtrl = $this->ctrl;
2186 
2187  // redirect to newly created page
2188  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($_GET["from_page"])));
2189  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
2190  }
2191 
2201  protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
2202  {
2203  if ($a_perm == "create") {
2204  return parent::checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id);
2205  } else {
2206  if (!$a_ref_id) {
2207  $a_ref_id = $this->object->getRefId();
2208  }
2209  include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
2210  return ilWikiPerm::check($a_perm, $a_ref_id, $a_cmd);
2211  }
2212  }
2213 
2214 
2215  //
2216  // User HTML Export
2217  //
2218 
2222  public function initUserHTMLExportObject()
2223  {
2224  $this->log->debug("init");
2225  $this->checkPermission("wiki_html_export");
2226  $this->object->initUserHTMLExport();
2227  }
2228 
2232  public function startUserHTMLExportObject()
2233  {
2234  $this->log->debug("start");
2235  $this->checkPermission("wiki_html_export");
2236  $this->object->startUserHTMLExport();
2237  }
2238 
2243  {
2244  $this->log->debug("get progress");
2245  $this->checkPermission("wiki_html_export");
2246  $p = $this->object->getUserHTMLExportProgress();
2247 
2248  include_once("./Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php");
2250  $pb->setCurrent($p["progress"]);
2251 
2252  $r = new stdClass();
2253  $r->progressBar = $pb->render();
2254  $r->status = $p["status"];
2255  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
2256  $this->log->debug("status: " . $r->status);
2257  echo(ilJsonUtil::encode($r));
2258  exit;
2259  }
2260 
2265  {
2266  $this->log->debug("download");
2267  $this->checkPermission("wiki_html_export");
2268  $this->object->deliverUserHTMLExport();
2269  }
2270 
2276  protected function triggerAssignmentTool()
2277  {
2278  if (!is_object($this->object)) {
2279  return;
2280  }
2281  $ass_info = ilExcRepoObjAssignment::getInstance()->getAssignmentInfoOfObj(
2282  $this->object->getRefId(),
2283  $this->user->getId()
2284  );
2285  if (count($ass_info) > 0) {
2286  $ass_ids = array_map(function ($i) {
2287  return $i->getId();
2288  }, $ass_info);
2289  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
2290  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
2291  $this->tool_context->current()->addAdditionalData(
2293  $this->getAssignmentButtons()
2294  );
2295  }
2296  }
2297 
2301  protected function getAssignmentButtons()
2302  {
2303  $ilCtrl = $this->ctrl;
2304  $ui = $this->ui;
2305  $lng = $this->lng;
2306 
2307  $ass_info = ilExcRepoObjAssignment::getInstance()->getAssignmentInfoOfObj(
2308  $this->object->getRefId(),
2309  $this->user->getId()
2310  );
2311  $buttons = [];
2312  foreach ($ass_info as $i) { // should be only one
2313  $ass = new ilExAssignment($i->getId());
2314  $times_up = $ass->afterDeadlineStrict();
2315 
2316  // submit button
2317  if (!$times_up) {
2318  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", $ass->getId());
2319  $submit_link = $ilCtrl->getLinkTargetByClass("ilwikipagegui", "finalizeAssignment");
2320  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", "");
2321 
2322  $buttons[$i->getId()][] = $ui->factory()->button()->primary($lng->txt("wiki_finalize_wiki"), $submit_link);
2323  }
2324 
2325  // submitted files
2326  include_once "Modules/Exercise/classes/class.ilExSubmission.php";
2327  $submission = new ilExSubmission($ass, $this->user->getId());
2328  if ($submission->hasSubmitted()) {
2329  $submitted = $submission->getSelectedObject();
2330  if ($submitted["ts"] != "") {
2331  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", $ass->getId());
2332  }
2333  $dl_link = $ilCtrl->getLinkTargetByClass("ilwikipagegui", "downloadExcSubFile");
2334  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", "");
2335  $buttons[$i->getId()][] = $ui->factory()->button()->standard($lng->txt("wiki_download_submission"), $dl_link);
2336  }
2337  }
2338  return $buttons;
2339  }
2340 }
static renderSideBlock($a_wpg_id, $a_wiki_ref_id, $a_wp=null)
Side column.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
UI class for handling permissions that can be configured having the write permission for an object...
isOnlineHelpWiki()
Is wiki an online help wiki?
setSideBlock($a_wpg_id=0)
Side column.
infoScreen()
show information screen
static getGotoLink($a_ref_id, $a_page="")
Get goto link.
exportHTML()
Create html package.
This class represents an option in a radio group.
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
Class ilObjectMetaDataGUI.
initStylePropertiesForm()
Init style properties form.
exit
Definition: login.php:29
getAllInfo($a_type=self::TYPE_ALL)
Get all info.
settings()
Definition: settings.php:2
Class ilInfoScreenGUI.
editStylePropertiesObject()
Edit style properties.
allPagesObject()
All pages of wiki.
TableGUI class for listing users that contributed to the wiki.
static strLen($a_string)
Definition: class.ilStr.php:78
getUserHTMLExportProgressObject()
Get user html export progress.
Exercise assignment.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static check($a_perm, $a_ref_id, $a_cmd="")
Check permission.
saveStyleSettingsObject()
Save style settings.
static getInstance()
Get instance.
static _lookupImportantPagesList($a_wiki_id)
Get important pages list.
const IL_WIKI_POPULAR_PAGES
Wiki page template gui class.
This class represents a property form user interface.
GUI class for the workflow of copying objects.
TableGUI class for recent changes in wiki.
addImportantPageObject()
Add important pages.
$_GET["client_id"]
orphanedPagesObject()
Orphaned pages.
static checkShortTitleAvailability($a_short_title)
Check availability of short title.
This class represents a section header in a property form.
static lookupSubObjectTitle($a_wiki_id, $a_page_id)
Get title for wiki page (used in ilNotesGUI)
Wiki statistics GUI class.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
saveGradingObject()
Save grading.
static _writeStatus($a_obj_id, $a_user_id, $a_status)
Write success status.
static _lookupStartPage($a_wiki_id)
Lookup start page.
gotoStartPageObject()
Go to start page.
static getGUIForTitle($a_wiki_id, $a_title, $a_old_nr=0, $a_wiki_ref_id=0)
Get wiki page gui for id and title.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
TableGUI class for wiki pages table.
This class represents a checkbox property in a property form.
addPageTabs()
Add Page Tabs.
static _lookupTitle($a_id)
lookup object title
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
downloadUserHTMLExportObject()
Download user html export file.
initCreationForms($a_new_type)
static _lookupRatingCategories($a_wiki_id)
Lookup whether rating categories are activated.
fillCloneTemplate($a_tpl_varname, $a_type)
Fill object clone template This method can be called from any object GUI class that wants to offer ob...
static lookupAdvancedMetadataHidden($a_page_id)
static getPageIdForTitle($a_wiki_id, $a_title)
Get wiki page object for id and title.
user()
Definition: user.php:4
confirmRemoveImportantPagesObject()
Confirm important pages deletion.
static _getAllReferences($a_id)
get all reference ids of object
setTitle($a_title)
set object title
saveObject()
save object public
static _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type="")
Get selected records by object.
popularPagesObject()
Popular pages.
createStyleObject()
Create Style.
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current success status (STATUS_NOT_GRADED|STATUS_PASSED|STATUS_FAILED)
static getRandomPage($a_wiki_id)
Get a random page.
static _lookupStandard($a_id)
Lookup standard flag.
global $ilCtrl
Definition: ilias.php:18
BlockGUI class for wiki functions block.
help()
Definition: help.php:2
setInfo($a_info)
Set Information Text.
static _lookupRating($a_wiki_id)
Lookup whether rating is activated.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
startUserHTMLExportObject()
Export html (as user)
$section
Definition: Utf8Test.php:83
static hasAutoRating($a_type, $a_ref_id)
Check if auto rating is active for parent group/course.
printViewObject($a_pdf_export=false)
$a_type
Definition: workflow.php:92
Export User Interface Class.
static lookupWikiId($a_page_id)
Lookup wiki id.
initImportForm($a_new_type)
Init object import form.
setSettingsSubTabs($a_active)
Set sub tabs.
This class represents a hidden form property in a property form.
prepareOutput($a_show_subobjects=true)
prepare output
Class ilECSWikiSettings.
static _performSearch($a_wiki_id, $a_searchterm)
Search in Wiki.
GUI class for public user profile presentation.
This class represents a property in a property form.
static _getPageIdForWikiTitle($a_wiki_id, $a_title)
Checks whether a page with given title exists.
static encode($mixed, $suppress_native=false)
editImportantPagesObject()
List important pages.
Class ilRatingGUI.
static getInstance()
Factory.
saveSettingsObject()
Save Settings.
Class ilHtmlToPdfTransformerFactory.
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
addPagesSubTabs()
Add Pages SubTabs.
initTemplateSelectionForm()
Init template selection form.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getSubObjectTitle($a_id, $a_type)
Used for rating export.
listContributorsObject()
List all contributors.
Class ilObjWiki.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
omitLocator($a_omit=true)
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
cancelCreationPageUsingTemplateObject()
Cancel page creation using a template.
setAsStartPageObject()
Confirm important pages deletion.
initUserHTMLExportObject()
Export html (as user)
createPageUsingTemplateObject()
Save creation with template form.
getAssignmentButtons()
Get assignment buttons.
Class ilWikiPage GUI class.
$ilUser
Definition: imgupload.php:18
ui()
Definition: ui.php:5
Class ilWikiPage.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getSyntaxStylePath()
get syntax style path
showTemplateSelectionObject()
Show template selection.
getTabs()
get tabs public
static updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Update service settings.
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.
static makeDbTitle($a_par)
Handle page GET parameter.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getSettingsFormValues($a_mode="edit")
static _wikiPageExists($a_wiki_id, $a_title)
Check whether page exists for wiki or not.
afterDeadlineStrict($a_include_personal=true)
static getSearchBlockHTML($a_title)
Get standar search block html.
const IL_WIKI_ALL_PAGES
randomPageObject()
Go to random page.
deleteStyleObject()
Delete Style.
initSettingsForm($a_mode="edit")
Init Settings Form.
triggerAssignmentTool()
Trigger assignment tool.
static exists($a_wiki_id, $a_title)
Checks whether a page with given title exists.
Class ilPDFGenerationJob.
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
editSettingsObject()
Edit settings.
This class represents a non editable value in a property form.
Class ilObjStyleSheetGUI.
global $ilSetting
Definition: privfeed.php:17
__construct(Container $dic, ilPlugin $plugin)
Handles general notification settings, see e.g.
This class represents a text area property in a property form.
const IL_WIKI_ORPHANED_PAGES
gotoPageObject($a_page="")
Go to specific page.
performSearchObject()
Search.
$ret
Definition: parser.php:6
static isOnlineHelpWiki($a_ref_id)
Is wiki an online help wiki?
static initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Init service settings form.
$DIC
Definition: xapitoken.php:46
getRefId()
get reference id public
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
Exercise submission //TODO: This class has to much static methods related to delivered "files"...
setContentStyleSheet($tpl=null)
Set content style sheet.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
setDescription($a_desc)
set object description
static getLogger($a_component_id)
Get component logger.
static _lookupMark($a_usr_id, $a_obj_id)
update()
update object in db
static _lookupComment($a_usr_id, $a_obj_id)
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor public.
newPagesObject()
Latest pages.
TableGUI class for recent changes in wiki.
removeImportantPagesObject()
Remove important pages.
static redirect($a_script)
saveOrderingAndIndentObject()
Save important pages ordering and indentation.
addHeaderAction()
Add header action menu.
viewObject()
Start page.
static doJob(ilPDFGenerationJob $job)
$_POST["username"]
editStyleObject()
Edit Style.
recentChangesObject()
Recent Changes.
Class ilObjWikiGUI.
setRequired($a_required)
Set Required.
static prepareGenerationRequest($service, $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
viewPageObject()
view wiki page
static _goto($a_target)
$i
Definition: metadata.php:24
Confirmation screen class.
afterSave(ilObject $newObj)
save object public
const IL_WIKI_NEW_PAGES