ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjWikiGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./Services/Object/classes/class.ilObjectGUI.php";
5 require_once "./Modules/Wiki/classes/class.ilObjWiki.php";
6 
7 
24 {
28  protected $tabs;
29 
33  protected $error;
34 
38  protected $help;
39 
40 
44  protected $log;
45 
50  public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
51  {
52  global $DIC;
53 
54  $this->ctrl = $DIC->ctrl();
55  $this->lng = $DIC->language();
56  $this->user = $DIC->user();
57  $this->tpl = $DIC["tpl"];
58  $this->tabs = $DIC->tabs();
59  $this->access = $DIC->access();
60  $this->error = $DIC["ilErr"];
61  $this->settings = $DIC->settings();
62  $this->help = $DIC["ilHelp"];
63  $this->locator = $DIC["ilLocator"];
64  $this->toolbar = $DIC->toolbar();
65  $ilCtrl = $DIC->ctrl();
66  $lng = $DIC->language();
67 
68  $this->type = "wiki";
69 
70  $this->log = ilLoggerFactory::getLogger('wiki');
71 
72  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
73  $lng->loadLanguageModule("obj");
74  $lng->loadLanguageModule("wiki");
75 
76  if ($_GET["page"] != "") {
77  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
78  }
79  }
80 
81  public function executeCommand()
82  {
85  $tpl = $this->tpl;
86  $ilTabs = $this->tabs;
87  $ilAccess = $this->access;
88 
89  $next_class = $this->ctrl->getNextClass($this);
90  $cmd = $this->ctrl->getCmd();
91 
92  $this->prepareOutput();
93 
94  // see ilWikiPageGUI::printViewOrderList()
95  // printView() and pdfExport() cannot be in ilWikiPageGUI because of stylesheet confusion
96  if ($cmd == "printView" || $cmd == "pdfExport") {
97  $next_class = null;
98  }
99 
100  switch ($next_class) {
101  case "ilinfoscreengui":
102  $this->checkPermission("visible");
103  $this->addHeaderAction();
104  $this->infoScreen(); // forwards command
105  break;
106 
107  case 'ilpermissiongui':
108  $this->addHeaderAction();
109  $ilTabs->activateTab("perm_settings");
110  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
111  $perm_gui = new ilPermissionGUI($this);
112  $ret = $this->ctrl->forwardCommand($perm_gui);
113  break;
114 
115  case 'ilsettingspermissiongui':
116  $this->checkPermission("write");
117  $this->addHeaderAction();
118  $ilTabs->activateTab("settings");
119  $this->setSettingsSubTabs("permission_settings");
120  include_once("Services/AccessControl/classes/class.ilSettingsPermissionGUI.php");
121  $perm_gui = new ilSettingsPermissionGUI($this);
122  $perm_gui->setPermissions(array("edit_wiki_navigation", "delete_wiki_pages", "activate_wiki_protection",
123  "wiki_html_export"));
124  $perm_gui->setRoleRequiredPermissions(array("edit_content"));
125  $perm_gui->setRoleProhibitedPermissions(array("write"));
126  $ret = $this->ctrl->forwardCommand($perm_gui);
127  break;
128 
129  case 'ilwikipagegui':
130  $this->checkPermission("read");
131  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
132  $wpage_gui = ilWikiPageGUI::getGUIForTitle(
133  $this->object->getId(),
135  $_GET["old_nr"],
136  $this->object->getRefId()
137  );
138  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
139  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
140  $this->object->getStyleSheetId(),
141  "wiki"
142  ));
143  $this->setContentStyleSheet();
144  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
145  (
146  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()) ||
147  $wpage_gui->getPageObject()->getBlocked()
148  )) {
149  $wpage_gui->setEnableEditing(false);
150  }
151 
152  // alter title and description
153 // $tpl->setTitle($wpage_gui->getPageObject()->getTitle());
154 // $tpl->setDescription($this->object->getTitle());
155  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
156  $wpage_gui->activateMetaDataEditor($this->object, "wpg", $wpage_gui->getId());
157  }
158 
159  $ret = $this->ctrl->forwardCommand($wpage_gui);
160  if ($ret != "") {
161  $tpl->setContent($ret);
162  }
163  break;
164 
165  case 'ilobjectcopygui':
166  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
167  $cp = new ilObjectCopyGUI($this);
168  $cp->setType('wiki');
169  $this->ctrl->forwardCommand($cp);
170  break;
171 
172  case 'ilpublicuserprofilegui':
173  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
174  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
175  $ret = $this->ctrl->forwardCommand($profile_gui);
176  $tpl->setContent($ret);
177  break;
178 
179  case "ilobjstylesheetgui":
180  include_once("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
181  $this->ctrl->setReturn($this, "editStyleProperties");
182  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
183  $style_gui->omitLocator();
184  if ($cmd == "create" || $_GET["new_type"]=="sty") {
185  $style_gui->setCreationMode(true);
186  }
187 
188  if ($cmd == "confirmedDelete") {
189  $this->object->setStyleSheetId(0);
190  $this->object->update();
191  }
192 
193  $ret = $this->ctrl->forwardCommand($style_gui);
194 
195  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
196  $style_id = $ret;
197  $this->object->setStyleSheetId($style_id);
198  $this->object->update();
199  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
200  }
201  break;
202 
203  case "ilexportgui":
204 // $this->prepareOutput();
205  $this->addHeaderAction();
206  $ilTabs->activateTab("export");
207  include_once("./Services/Export/classes/class.ilExportGUI.php");
208  $exp_gui = new ilExportGUI($this);
209  $exp_gui->addFormat("xml");
210  $exp_gui->addFormat("html", "", $this, "exportHTML");
211  $ret = $this->ctrl->forwardCommand($exp_gui);
212 // $this->tpl->show();
213  break;
214 
215  case "ilcommonactiondispatchergui":
216  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
218  $this->ctrl->forwardCommand($gui);
219  break;
220 
221  case "ilratinggui":
222  // for rating category editing
223  $this->checkPermission("write");
224  $this->addHeaderAction();
225  $ilTabs->activateTab("settings");
226  $this->setSettingsSubTabs("rating_categories");
227  include_once("Services/Rating/classes/class.ilRatingGUI.php");
228  $gui = new ilRatingGUI();
229  $gui->setObject($this->object->getId(), $this->object->getType());
230  $gui->setExportCallback(array($this, "getSubObjectTitle"), $this->lng->txt("page"));
231  $this->ctrl->forwardCommand($gui);
232  break;
233 
234  case "ilwikistatgui":
235  $this->checkPermission("statistics_read");
236 
237  $this->addHeaderAction();
238  $ilTabs->activateTab("statistics");
239 
240  include_once "Modules/Wiki/classes/class.ilWikiStatGUI.php";
241  $gui = new ilWikiStatGUI($this->object->getId());
242  $this->ctrl->forwardCommand($gui);
243  break;
244 
245  case "ilwikipagetemplategui":
246  $this->checkPermission("write");
247  $this->addHeaderAction();
248  $ilTabs->activateTab("settings");
249  $this->setSettingsSubTabs("page_templates");
250  include_once("./Modules/Wiki/classes/class.ilWikiPageTemplateGUI.php");
251  $wptgui = new ilWikiPageTemplateGUI($this);
252  $this->ctrl->forwardCommand($wptgui);
253  break;
254 
255  case 'ilobjectmetadatagui':
256  $this->checkPermission("write");
257  $this->addHeaderAction();
258  $ilTabs->activateTab("advmd");
259  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
260  $md_gui = new ilObjectMetaDataGUI($this->object, "wpg");
261  $this->ctrl->forwardCommand($md_gui);
262  break;
263 
264  case 'ilrepositoryobjectsearchgui':
265  $this->addHeaderAction();
266  $this->setSideBlock();
267  $ilTabs->setTabActive("wiki_search_results");
268  $ilCtrl->setReturn($this, 'view');
269  include_once './Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
270  $search_gui = new ilRepositoryObjectSearchGUI(
271  $this->object->getRefId(),
272  $this,
273  'view'
274  );
275  $ilCtrl->forwardCommand($search_gui);
276  break;
277 
278  case 'ilobjnotificationsettingsgui':
279  $this->addHeaderAction();
280  $ilTabs->activateTab("settings");
281  $this->setSettingsSubTabs("notifications");
282  include_once("./Services/Notification/classes/class.ilObjNotificationSettingsGUI.php");
283  $gui = new ilObjNotificationSettingsGUI($this->object->getRefId());
284  $this->ctrl->forwardCommand($gui);
285  break;
286 
287  default:
288  $this->addHeaderAction();
289  if (!$cmd) {
290  $cmd = "infoScreen";
291  }
292  $cmd .= "Object";
293  if ($cmd != "cancelObject") {
294  if ($cmd != "infoScreenObject") {
295  if (!in_array($cmd, array("createObject", "saveObject", "importFileObject"))) {
296  $this->checkPermission("read");
297  }
298  } else {
299  $this->checkPermission("visible");
300  }
301  }
302  $this->$cmd();
303  break;
304  }
305 
306  return $ret;
307  }
308 
314  public function isOnlineHelpWiki()
315  {
316  if (is_object($this->object)) {
317  return ilObjWiki::isOnlineHelpWiki($this->object->getRefId());
318  }
319  return false;
320  }
321 
325  public function viewObject()
326  {
327  $this->checkPermission("read");
328  $this->gotoStartPageObject();
329  }
330 
331  protected function initCreationForms($a_new_type)
332  {
333  $this->initSettingsForm("create");
334  $this->getSettingsFormValues("create");
335 
336  $forms = array(self::CFORM_NEW => $this->form_gui,
337  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
338  self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type));
339 
340  return $forms;
341  }
342 
347  public function saveObject()
348  {
349  $tpl = $this->tpl;
350  $lng = $this->lng;
352 
353  if (!$this->checkPermissionBool("create", "", "wiki", $_GET["ref_id"])) {
354  $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
355  }
356 
357  $this->initSettingsForm("create");
358  if ($this->form_gui->checkInput()) {
359  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle"))) {
360  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
361  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
362  } else {
363  // create and insert forum in objecttree
364  $_POST["title"] = $this->form_gui->getInput("title");
365  $_POST["desc"] = $this->form_gui->getInput("description");
366  return parent::saveObject();
367  }
368  }
369 
370  $this->form_gui->setValuesByPost();
371  $tpl->setContent($this->form_gui->getHtml());
372  }
373 
378  public function afterSave(ilObject $newObj)
379  {
381 
382  $newObj->setTitle($this->form_gui->getInput("title"));
383  $newObj->setDescription($this->form_gui->getInput("description"));
384  $newObj->setIntroduction($this->form_gui->getInput("intro"));
385  $newObj->setStartPage($this->form_gui->getInput("startpage"));
386  $newObj->setShortTitle($this->form_gui->getInput("shorttitle"));
387  $newObj->setRating($this->form_gui->getInput("rating"));
388  // $newObj->setRatingAsBlock($this->form_gui->getInput("rating_side"));
389  $newObj->setRatingForNewPages($this->form_gui->getInput("rating_new"));
390  $newObj->setRatingCategories($this->form_gui->getInput("rating_ext"));
391 
392  $newObj->setRatingOverall($this->form_gui->getInput("rating_overall"));
393  $newObj->setPageToc($this->form_gui->getInput("page_toc"));
394 
395 
396 
397  if (!$ilSetting->get("disable_comments")) {
398  $newObj->setPublicNotes($this->form_gui->getInput("public_notes"));
399  }
400  $newObj->setOnline($this->form_gui->getInput("online"));
401  $newObj->update();
402 
403  // always send a message
404  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
406  }
407 
413  public function infoScreenObject()
414  {
415  $this->checkPermission("visible");
416  $this->ctrl->setCmd("showSummary");
417  $this->ctrl->setCmdClass("ilinfoscreengui");
418  $this->infoScreen();
419  }
420 
424  public function infoScreen()
425  {
426  $ilAccess = $this->access;
428  $ilTabs = $this->tabs;
429  $lng = $this->lng;
431 
432  $ilTabs->activateTab("info_short");
433 
434  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId())) {
435  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
436  }
437 
438  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
439  $info = new ilInfoScreenGUI($this);
440  $info->enablePrivateNotes();
441  if (trim($this->object->getIntroduction()) != "") {
442  $info->addSection($lng->txt("wiki_introduction"));
443  $info->addProperty("", nl2br($this->object->getIntroduction()));
444  }
445 
446  // feedback from tutor; mark, status, comment
447  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
448  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
449  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
450  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
451  $status = ilWikiContributor::_lookupStatus($this->object->getId(), $ilUser->getId());
452  if ($lpcomment != "" || $mark != "" || $status != ilWikiContributor::STATUS_NOT_GRADED) {
453  $info->addSection($this->lng->txt("wiki_feedback_from_tutor"));
454  if ($lpcomment != "") {
455  $info->addProperty(
456  $this->lng->txt("wiki_comment"),
457  $lpcomment
458  );
459  }
460  if ($mark != "") {
461  $info->addProperty(
462  $this->lng->txt("wiki_mark"),
463  $mark
464  );
465  }
466 
467  if ($status == ilWikiContributor::STATUS_PASSED) {
468  $info->addProperty(
469  $this->lng->txt("status"),
470  $this->lng->txt("wiki_passed")
471  );
472  }
473  if ($status == ilWikiContributor::STATUS_FAILED) {
474  $info->addProperty(
475  $this->lng->txt("status"),
476  $this->lng->txt("wiki_failed")
477  );
478  }
479  }
480 
481  /*
482  $info->enableNews();
483  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
484  {
485  //$info->enableNewsEditing();
486  $info->setBlockProperty("news", "settings", true);
487  }*/
488 
489  if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
490  $info->addButton($lng->txt("wiki_start_page"), ilObjWikiGUI::getGotoLink($this->object->getRefId()));
491  }
492 
493  // general information
494  $this->lng->loadLanguageModule("meta");
495  $this->lng->loadLanguageModule("wiki");
496 
497  //$info->addSection($this->lng->txt("meta_general"));
498  //$info->addProperty($this->lng->txt("mcst_nr_items"),
499  // (int) count($med_items));
500 
501  // forward the command
502  $this->ctrl->forwardCommand($info);
503 
504  if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
505  // $this->setSideBlock();
506  }
507  }
508 
512  public function gotoStartPageObject()
513  {
515 
517  }
518 
522  public function addPageTabs()
523  {
524  $ilTabs = $this->tabs;
526 
527  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
528  $ilCtrl->setParameter(
529  $this,
530  "wpg_id",
532  );
533  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
534  $ilTabs->addTarget(
535  "wiki_what_links_here",
536  $this->ctrl->getLinkTargetByClass(
537  "ilwikipagegui",
538  "whatLinksHere"
539  ),
540  "whatLinksHere"
541  );
542  $ilTabs->addTarget(
543  "wiki_print_view",
544  $this->ctrl->getLinkTargetByClass(
545  "ilwikipagegui",
546  "printViewSelection"
547  ),
548  "printViewSelection"
549  );
550  }
551 
555  public function addPagesSubTabs()
556  {
557  $ilTabs = $this->tabs;
559 
560  $ilTabs->activateTab("wiki_pages");
561 
562  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
563  $ilCtrl->setParameter(
564  $this,
565  "wpg_id",
567  $this->object->getId(),
569  )
570  );
571  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
572  $ilTabs->addSubTabTarget(
573  "wiki_all_pages",
574  $this->ctrl->getLinkTarget($this, "allPages"),
575  "allPages"
576  );
577  $ilTabs->addSubTabTarget(
578  "wiki_recent_changes",
579  $this->ctrl->getLinkTarget($this, "recentChanges"),
580  "recentChanges"
581  );
582  $ilTabs->addSubTabTarget(
583  "wiki_new_pages",
584  $this->ctrl->getLinkTarget($this, "newPages"),
585  "newPages"
586  );
587  $ilTabs->addSubTabTarget(
588  "wiki_popular_pages",
589  $this->ctrl->getLinkTarget($this, "popularPages"),
590  "popularPages"
591  );
592  $ilTabs->addSubTabTarget(
593  "wiki_orphaned_pages",
594  $this->ctrl->getLinkTarget($this, "orphanedPages"),
595  "orphanedPages"
596  );
597  }
598 
604  public function getTabs()
605  {
607  $ilAccess = $this->access;
608  $lng = $this->lng;
609  $ilHelp = $this->help;
610 
611  $ilHelp->setScreenIdComponent("wiki");
612 
613  // wiki tabs
614  if (in_array($ilCtrl->getCmdClass(), array("", "ilobjwikigui",
615  "ilinfoscreengui", "ilpermissiongui", "ilexportgui", "ilratingcategorygui", "ilobjnotificationsettingsgui", "iltaxmdgui",
616  "ilwikistatgui", "ilwikipagetemplategui", "iladvancedmdsettingsgui", "ilsettingspermissiongui", 'ilrepositoryobjectsearchgui'
617  )) || (in_array($ilCtrl->getNextClass(), array("ilpermissiongui")))) {
618  if ($_GET["page"] != "") {
619  $this->tabs_gui->setBackTarget(
620  $lng->txt("wiki_last_visited_page"),
621  $this->getGotoLink(
622  $_GET["ref_id"],
624  )
625  );
626  }
627 
628  // pages
629  if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
630  $this->tabs_gui->addTab(
631  "wiki_pages",
632  $lng->txt("wiki_pages"),
633  $this->ctrl->getLinkTarget($this, "allPages")
634  );
635  }
636 
637  // info screen
638  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId())) {
639  $this->tabs_gui->addTab(
640  "info_short",
641  $lng->txt("info_short"),
642  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
643  );
644  }
645 
646  // settings
647  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
648  $this->tabs_gui->addTab(
649  "settings",
650  $lng->txt("settings"),
651  $this->ctrl->getLinkTarget($this, "editSettings")
652  );
653 
654  // metadata
655  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
656  $mdgui = new ilObjectMetaDataGUI($this->object, "wpg");
657  $mdtab = $mdgui->getTab();
658  if ($mdtab) {
659  $this->tabs_gui->addTab(
660  "advmd",
661  $this->lng->txt("meta_data"),
662  $mdtab
663  );
664  }
665  }
666 
667  // contributors
668  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
669  $this->tabs_gui->addTab(
670  "wiki_contributors",
671  $lng->txt("wiki_contributors"),
672  $this->ctrl->getLinkTarget($this, "listContributors")
673  );
674  }
675 
676  // statistics
677  if ($ilAccess->checkAccess('statistics_read', "", $this->object->getRefId())) {
678  $this->tabs_gui->addTab(
679  "statistics",
680  $lng->txt("statistics"),
681  $this->ctrl->getLinkTargetByClass("ilWikiStatGUI", "initial")
682  );
683  }
684 
685  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
686  $this->tabs_gui->addTab(
687  "export",
688  $lng->txt("export"),
689  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
690  );
691  }
692 
693  // edit permissions
694  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
695  $this->tabs_gui->addTab(
696  "perm_settings",
697  $lng->txt("perm_settings"),
698  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
699  );
700  }
701  }
702  }
703 
707  public function setSettingsSubTabs($a_active)
708  {
709  $ilTabs = $this->tabs;
711  $lng = $this->lng;
712  $ilAccess = $this->access;
713 
714  if (in_array(
715  $a_active,
716  array("general_settings", "style", "imp_pages", "rating_categories",
717  "page_templates", "advmd", "permission_settings", "notifications")
718  )) {
719  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
720  // general properties
721  $ilTabs->addSubTab(
722  "general_settings",
723  $lng->txt("wiki_general_settings"),
724  $ilCtrl->getLinkTarget($this, 'editSettings')
725  );
726 
727  // permission settings
728  $ilTabs->addSubTab(
729  "permission_settings",
730  $lng->txt("obj_permission_settings"),
731  $this->ctrl->getLinkTargetByClass("ilsettingspermissiongui", "")
732  );
733 
734  // style properties
735  $ilTabs->addSubTab(
736  "style",
737  $lng->txt("wiki_style"),
738  $ilCtrl->getLinkTarget($this, 'editStyleProperties')
739  );
740  }
741 
742  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
743  // important pages
744  $ilTabs->addSubTab(
745  "imp_pages",
746  $lng->txt("wiki_navigation"),
747  $ilCtrl->getLinkTarget($this, 'editImportantPages')
748  );
749  }
750 
751  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
752  // page templates
753  $ilTabs->addSubTab(
754  "page_templates",
755  $lng->txt("wiki_page_templates"),
756  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "")
757  );
758 
759  // rating categories
760  if ($this->object->getRating() && $this->object->getRatingCategories()) {
761  $lng->loadLanguageModule("rating");
762  $ilTabs->addSubTab(
763  "rating_categories",
764  $lng->txt("rating_categories"),
765  $ilCtrl->getLinkTargetByClass(array('ilratinggui', 'ilratingcategorygui'), '')
766  );
767  }
768 
769  $ilTabs->addSubTab(
770  'notifications',
771  $lng->txt("notifications"),
772  $ilCtrl->getLinkTargetByClass("ilobjnotificationsettingsgui", '')
773  );
774  }
775 
776  $ilTabs->activateSubTab($a_active);
777  }
778  }
779 
783  public function editSettingsObject()
784  {
785  $tpl = $this->tpl;
786 
787  $this->checkPermission("write");
788 
789  $this->setSettingsSubTabs("general_settings");
790 
791  $this->initSettingsForm();
792  $this->getSettingsFormValues();
793 
794  // Edit ecs export settings
795  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
796  $ecs = new ilECSWikiSettings($this->object);
797  $ecs->addSettingsToForm($this->form_gui, 'wiki');
798 
799  $tpl->setContent($this->form_gui->getHtml());
800  $this->setSideBlock();
801  }
802 
806  public function initSettingsForm($a_mode = "edit")
807  {
808  $lng = $this->lng;
810  $ilTabs = $this->tabs;
812 
813  $lng->loadLanguageModule("wiki");
814  $ilTabs->activateTab("settings");
815 
816  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
817  $this->form_gui = new ilPropertyFormGUI();
818 
819  // Title
820  $tit = new ilTextInputGUI($lng->txt("title"), "title");
821  $tit->setRequired(true);
822  $this->form_gui->addItem($tit);
823 
824  // Short Title
825  // The problem with the short title is, that it is per object
826  // and can't be a substitute for a ref id in the permanent link
827  /*
828  $stit = new ilRegExpInputGUI($lng->txt("wiki_short_title"), "shorttitle");
829  $stit->setPattern("/^[^0-9][^ _\&]+$/");
830  $stit->setRequired(false);
831  $stit->setNoMatchMessage($lng->txt("wiki_msg_short_name_regexp")." &amp; _");
832  $stit->setSize(20);
833  $stit->setMaxLength(20);
834  $stit->setInfo($lng->txt("wiki_short_title_desc2"));
835  $this->form_gui->addItem($stit);
836  */
837 
838  // Description
839  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
840  $this->form_gui->addItem($des);
841 
842  // Introduction
843  $intro = new ilTextAreaInputGUI($lng->txt("wiki_introduction"), "intro");
844  $intro->setCols(40);
845  $intro->setRows(4);
846  $this->form_gui->addItem($intro);
847 
848  // Start Page
849  if ($a_mode == "edit") {
850  $pages = ilWikiPage::getAllWikiPages($this->object->getId());
851  foreach ($pages as $p) {
852  $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
853  }
854  $si = new ilSelectInputGUI($lng->txt("wiki_start_page"), "startpage_id");
855  $si->setOptions($options);
856  $this->form_gui->addItem($si);
857  } else {
858  $sp = new ilTextInputGUI($lng->txt("wiki_start_page"), "startpage");
859  if ($a_mode == "edit") {
860  $sp->setInfo($lng->txt("wiki_start_page_info"));
861  }
862  $sp->setMaxLength(200);
863  $sp->setRequired(true);
864  $this->form_gui->addItem($sp);
865  }
866 
867  // Online
868  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
869  $this->form_gui->addItem($online);
870 
871 
872  // rating
873 
874  $lng->loadLanguageModule('rating');
875  $rate = new ilCheckboxInputGUI($lng->txt('rating_activate_rating'), 'rating_overall');
876  $rate->setInfo($lng->txt('rating_activate_rating_info'));
877  $this->form_gui->addItem($rate);
878 
879  $rating = new ilCheckboxInputGUI($lng->txt("wiki_activate_rating"), "rating");
880  $this->form_gui->addItem($rating);
881 
882  /* always active
883  $side = new ilCheckboxInputGUI($lng->txt("wiki_activate_sideblock_rating"), "rating_side");
884  $rating->addSubItem($side);
885  */
886 
887  $new = new ilCheckboxInputGUI($lng->txt("wiki_activate_new_page_rating"), "rating_new");
888  $rating->addSubItem($new);
889 
890  $extended = new ilCheckboxInputGUI($lng->txt("wiki_activate_extended_rating"), "rating_ext");
891  $rating->addSubItem($extended);
892 
893 
894  // public comments
895  if (!$ilSetting->get("disable_comments")) {
896  $comments = new ilCheckboxInputGUI($lng->txt("wiki_public_comments"), "public_notes");
897  $this->form_gui->addItem($comments);
898  }
899 
900  // important pages
901  // $imp_pages = new ilCheckboxInputGUI($lng->txt("wiki_important_pages"), "imp_pages");
902  // $this->form_gui->addItem($imp_pages);
903 
904  // page toc
905  $page_toc = new ilCheckboxInputGUI($lng->txt("wiki_page_toc"), "page_toc");
906  $page_toc->setInfo($lng->txt("wiki_page_toc_info"));
907  $this->form_gui->addItem($page_toc);
908 
909  if ($a_mode == "edit") {
910  // advanced metadata auto-linking
911  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
912  if (count(ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->object->getRefId(), "wpg")) > 0) {
913  $link_md = new ilCheckboxInputGUI($lng->txt("wiki_link_md_values"), "link_md_values");
914  $link_md->setInfo($lng->txt("wiki_link_md_values_info"));
915  $this->form_gui->addItem($link_md);
916  }
917 
918  // additional features
919  $feat = new ilFormSectionHeaderGUI();
920  $feat->setTitle($this->lng->txt('obj_features'));
921  $this->form_gui->addItem($feat);
922 
923  include_once './Services/Container/classes/class.ilContainer.php';
924  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
926  $this->object->getId(),
927  $this->form_gui,
928  array(
930  )
931  );
932  }
933 
934  // :TODO: sorting
935 
936  // Form action and save button
937  $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_wiki.svg"));
938  if ($a_mode != "create") {
939  $this->form_gui->setTitle($lng->txt("wiki_settings"));
940  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
941  } else {
942  $this->form_gui->setTitle($lng->txt("wiki_new"));
943  $this->form_gui->addCommandButton("save", $lng->txt("wiki_add"));
944  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
945  }
946 
947  // set values
948  if ($a_mode == "create") {
949  $ilCtrl->setParameter($this, "new_type", "wiki");
950  }
951 
952  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
953  }
954 
955  public function getSettingsFormValues($a_mode = "edit")
956  {
957  $lng = $this->lng;
959 
960  // set values
961  if ($a_mode == "create") {
962  //$values["startpage"] = $lng->txt("wiki_main_page");
963  $values["rating_new"] = true;
964 
965  $values["rating_overall"] = ilObject::hasAutoRating("wiki", $_GET["ref_id"]);
966 
967  $this->form_gui->setValuesByArray($values);
968  } else {
969  $values["online"] = $this->object->getOnline();
970  $values["title"] = $this->object->getTitle();
971  //$values["startpage"] = $this->object->getStartPage();
972  $values["startpage_id"] = ilWikiPage::_getPageIdForWikiTitle($this->object->getId(), $this->object->getStartPage());
973  $values["shorttitle"] = $this->object->getShortTitle();
974  $values["description"] = $this->object->getLongDescription();
975  $values["rating_overall"] = $this->object->getRatingOverall();
976  $values["rating"] = $this->object->getRating();
977  // $values["rating_side"] = $this->object->getRatingAsBlock();
978  $values["rating_new"] = $this->object->getRatingForNewPages();
979  $values["rating_ext"] = $this->object->getRatingCategories();
980  $values["public_notes"] = $this->object->getPublicNotes();
981  $values["intro"] = $this->object->getIntroduction();
982  // $values["imp_pages"] = $this->object->getImportantPages();
983  $values["page_toc"] = $this->object->getPageToc();
984  $values["link_md_values"] = $this->object->getLinkMetadataValues();
985 
986  // only set given values (because of adv. metadata)
987  $this->form_gui->setValuesByArray($values, true);
988  }
989  }
990 
991 
995  public function saveSettingsObject()
996  {
998  $lng = $this->lng;
1001 
1002  $this->checkPermission("write");
1003 
1004  $this->initSettingsForm();
1005 
1006  if ($this->form_gui->checkInput()) {
1007  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")) &&
1008  $this->form_gui->getInput("shorttitle") != $this->object->getShortTitle()) {
1009  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
1010  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
1011  } else {
1012  $this->object->setTitle($this->form_gui->getInput("title"));
1013  $this->object->setDescription($this->form_gui->getInput("description"));
1014  $this->object->setOnline($this->form_gui->getInput("online"));
1015  $this->object->setStartPage(ilWikiPage::lookupTitle($this->form_gui->getInput("startpage_id")));
1016  $this->object->setShortTitle($this->form_gui->getInput("shorttitle"));
1017  $this->object->setRatingOverall($this->form_gui->getInput("rating_overall"));
1018  $this->object->setRating($this->form_gui->getInput("rating"));
1019  // $this->object->setRatingAsBlock($this->form_gui->getInput("rating_side"));
1020  $this->object->setRatingForNewPages($this->form_gui->getInput("rating_new"));
1021  $this->object->setRatingCategories($this->form_gui->getInput("rating_ext"));
1022 
1023  if (!$ilSetting->get("disable_comments")) {
1024  $this->object->setPublicNotes($this->form_gui->getInput("public_notes"));
1025  }
1026  $this->object->setIntroduction($this->form_gui->getInput("intro"));
1027  // $this->object->setImportantPages($this->form_gui->getInput("imp_pages"));
1028  $this->object->setPageToc($this->form_gui->getInput("page_toc"));
1029  $this->object->setLinkMetadataValues($this->form_gui->getInput("link_md_values"));
1030  $this->object->update();
1031 
1032  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
1034  $this->object->getId(),
1035  $this->form_gui,
1036  array(
1038  )
1039  );
1040 
1041  // Update ecs export settings
1042  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
1043  $ecs = new ilECSWikiSettings($this->object);
1044  if ($ecs->handleSettingsUpdate()) {
1045  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1046  $ilCtrl->redirect($this, "editSettings");
1047  }
1048  }
1049  }
1050 
1051  $this->form_gui->setValuesByPost();
1052  $this->tpl->setContent($this->form_gui->getHTML());
1053  }
1054 
1058  public function listContributorsObject()
1059  {
1060  $tpl = $this->tpl;
1061  $ilTabs = $this->tabs;
1062 
1063  $this->checkPermission("write");
1064  $ilTabs->activateTab("wiki_contributors");
1065 
1066  include_once("./Modules/Wiki/classes/class.ilWikiContributorsTableGUI.php");
1067 
1068  $table_gui = new ilWikiContributorsTableGUI(
1069  $this,
1070  "listContributors",
1071  $this->object->getId()
1072  );
1073 
1074  $tpl->setContent($table_gui->getHTML());
1075 
1076  $this->setSideBlock();
1077  }
1078 
1082  public function saveGradingObject()
1083  {
1084  $ilCtrl = $this->ctrl;
1085  $lng = $this->lng;
1086 
1087  $this->checkPermission("write");
1088 
1089  $users = (is_array($_POST["user_id"])
1090  ? $_POST["user_id"]
1091  : array());
1092 
1093  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
1094  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
1095  $saved = false;
1096  foreach ($users as $user_id) {
1097  if ($user_id != "") {
1098  $marks_obj = new ilLPMarks($this->object->getId(), $user_id);
1099  $new_mark = ilUtil::stripSlashes($_POST['mark'][$user_id]);
1100  $new_comment = ilUtil::stripSlashes($_POST['lcomment'][$user_id]);
1101  $new_status = ilUtil::stripSlashes($_POST["status"][$user_id]);
1102 
1103  if ($marks_obj->getMark() != $new_mark ||
1104  $marks_obj->getComment() != $new_comment ||
1105  ilWikiContributor::_lookupStatus($this->object->getId(), $user_id) != $new_status) {
1106  ilWikiContributor::_writeStatus($this->object->getId(), $user_id, $new_status);
1107  $marks_obj->setMark($new_mark);
1108  $marks_obj->setComment($new_comment);
1109  $marks_obj->update();
1110  $saved = true;
1111  }
1112  }
1113  }
1114  if ($saved) {
1115  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1116  }
1117 
1118  $ilCtrl->redirect($this, "listContributors");
1119  }
1120 
1121  // add wiki to locator
1122  public function addLocatorItems()
1123  {
1124  $ilLocator = $this->locator;
1125 
1126  if (is_object($this->object)) {
1127  $ilLocator->addItem(
1128  $this->object->getTitle(),
1129  $this->getGotoLink($this->object->getRefId()),
1130  "",
1131  $_GET["ref_id"]
1132  );
1133  }
1134  }
1135 
1136  public static function _goto($a_target)
1137  {
1138  global $DIC;
1139 
1140  $ilAccess = $DIC->access();
1141  $ilErr = $DIC["ilErr"];
1142  $lng = $DIC->language();
1143  $ilNavigationHistory = $DIC["ilNavigationHistory"];
1144 
1145  $i = strpos($a_target, "_");
1146  if ($i > 0) {
1147  $a_page = substr($a_target, $i+1);
1148  $a_target = substr($a_target, 0, $i);
1149  }
1150 
1151  if ($a_target == "wpage") {
1152  $a_page_arr = explode("_", $a_page);
1153  $wpg_id = (int) $a_page_arr[0];
1154  $ref_id = (int) $a_page_arr[1];
1155  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1156  $w_id = ilWikiPage::lookupWikiId($wpg_id);
1157  if ($ref_id > 0) {
1158  $refs = array($ref_id);
1159  } else {
1160  $refs = ilObject::_getAllReferences($w_id);
1161  }
1162  foreach ($refs as $r) {
1163  if ($ilAccess->checkAccess("read", "", $r)) {
1164  $a_target = $r;
1165  $a_page = ilWikiPage::lookupTitle($wpg_id);
1166  }
1167  }
1168  }
1169 
1170  if ($ilAccess->checkAccess("read", "", $a_target)) {
1171  $_GET["cmd"] = "viewPage";
1172  $_GET["ref_id"] = $a_target;
1173  $_GET["page"] = $a_page;
1174  $_GET["baseClass"] = "ilwikihandlergui";
1175  $_GET["cmdClass"] = "ilobjwikigui";
1176  /* if ($a_page != "")
1177  {
1178  $add = "&amp;page=".rawurlencode($_GET["page"]);
1179  $ilNavigationHistory->addItem($_GET["ref_id"],
1180  "./goto.php?target=wiki_".$_GET["ref_id"].$add, "wiki");
1181  }*/
1182  include("ilias.php");
1183  exit;
1184  } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
1185  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
1186  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1187  ilUtil::sendFailure(sprintf(
1188  $lng->txt("msg_no_perm_read_item"),
1190  ), true);
1192  }
1193 
1194  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1195  }
1196 
1200  public static function getGotoLink($a_ref_id, $a_page = "")
1201  {
1202  if ($a_page == "") {
1204  }
1205 
1206  $goto = "goto.php?target=wiki_" . $a_ref_id . "_" .
1207  ilWikiUtil::makeUrlTitle($a_page);
1208 
1209  return $goto;
1210  }
1211 
1215  public function viewPageObject()
1216  {
1217  $lng = $this->lng;
1218  $ilCtrl = $this->ctrl;
1219  $tpl = $this->tpl;
1220  $ilTabs = $this->tabs;
1221  $ilAccess = $this->access;
1222 
1223  $this->checkPermission("read");
1224 
1225  $ilTabs->clearTargets();
1226  $tpl->setHeaderActionMenu(null);
1227 
1228  $page = ($_GET["page"] != "")
1229  ? $_GET["page"]
1230  : $this->object->getStartPage();
1231  $_GET["page"] = $page;
1232 
1233  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1234  if (!ilWikiPage::exists($this->object->getId(), $page)) {
1235  $page = $this->object->getStartPage();
1236  }
1237 
1238  if (!ilWikiPage::exists($this->object->getId(), $page)) {
1239  ilUtil::sendInfo($lng->txt("wiki_no_start_page"), true);
1240  $ilCtrl->redirect($this, "infoScreen");
1241  return;
1242  }
1243 
1244  // page exists, show it !
1245  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($page));
1246 
1247  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
1248  $wpage_gui = ilWikiPageGUI::getGUIForTitle(
1249  $this->object->getId(),
1250  ilWikiUtil::makeDbTitle($page),
1251  0,
1252  $this->object->getRefId()
1253  );
1254  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1255  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
1256  $this->object->getStyleSheetId(),
1257  "wiki"
1258  ));
1259 
1260  $this->setContentStyleSheet();
1261  //$wpage_gui->setOutputMode(IL_PAGE_PREVIEW);
1262 
1263  //$wpage_gui->setSideBlock();
1264  $ilCtrl->setCmdClass("ilwikipagegui");
1265  $ilCtrl->setCmd("preview");
1266  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
1267  (
1268  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()) ||
1269  $wpage_gui->getPageObject()->getBlocked()
1270  )) {
1271  $wpage_gui->setEnableEditing(false);
1272  }
1273 
1274  // alter title and description
1275  //$tpl->setTitle($wpage_gui->getPageObject()->getTitle());
1276  //$tpl->setDescription($this->object->getTitle());
1277  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1278  $wpage_gui->activateMetaDataEditor($this->object, "wpg", $wpage_gui->getId());
1279  }
1280 
1281 
1282  $html = $ilCtrl->forwardCommand($wpage_gui);
1283  //$this->addPageTabs();
1284 
1285  $tpl->setContent($html);
1286  }
1287 
1291  public function allPagesObject()
1292  {
1293  $tpl = $this->tpl;
1294 
1295  $this->checkPermission("read");
1296 
1297  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1298 
1299  $this->addPagesSubTabs();
1300 
1301  $table_gui = new ilWikiPagesTableGUI(
1302  $this,
1303  "allPages",
1304  $this->object->getId(),
1306  );
1307 
1308  $this->setSideBlock();
1309  $tpl->setContent($table_gui->getHTML());
1310  }
1311 
1315  public function popularPagesObject()
1316  {
1317  $tpl = $this->tpl;
1318 
1319  $this->checkPermission("read");
1320 
1321  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1322 
1323  $this->addPagesSubTabs();
1324 
1325  $table_gui = new ilWikiPagesTableGUI(
1326  $this,
1327  "popularPages",
1328  $this->object->getId(),
1330  );
1331 
1332  $this->setSideBlock();
1333  $tpl->setContent($table_gui->getHTML());
1334  }
1335 
1339  public function orphanedPagesObject()
1340  {
1341  $tpl = $this->tpl;
1342 
1343  $this->checkPermission("read");
1344 
1345  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1346 
1347  $this->addPagesSubTabs();
1348 
1349  $table_gui = new ilWikiPagesTableGUI(
1350  $this,
1351  "orphanedPages",
1352  $this->object->getId(),
1354  );
1355 
1356  $this->setSideBlock();
1357  $tpl->setContent($table_gui->getHTML());
1358  }
1359 
1365  public function gotoPageObject($a_page = "")
1366  {
1367  $ilCtrl = $this->ctrl;
1368 
1369  if ($a_page == "") {
1370  $a_page = $_GET["page"];
1371  }
1372 
1373  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1375  $this->object->getId(),
1376  ilWikiUtil::makeDbTitle($a_page)
1377  )) {
1378  // to do: get rid of this redirect
1379  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $a_page));
1380  } else {
1381  if (!$this->object->getTemplateSelectionOnCreation()) {
1382  // check length
1383  include_once("./Services/Utilities/classes/class.ilStr.php");
1384  if (ilStr::strLen(ilWikiUtil::makeDbTitle($a_page)) > 200) {
1385  ilUtil::sendFailure($this->lng->txt("wiki_page_title_too_long") . " (" . $a_page . ")", true);
1386  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
1387  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1388  }
1389  $this->object->createWikiPage($a_page);
1390 
1391  // redirect to newly created page
1392  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1393  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1394  } else {
1395  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
1396  $ilCtrl->setParameter($this, "from_page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
1397  $ilCtrl->redirect($this, "showTemplateSelection");
1398  }
1399  }
1400  }
1401 
1407  public function randomPageObject()
1408  {
1409  $this->checkPermission("read");
1410 
1411  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1412  $page = ilWikiPage::getRandomPage($this->object->getId());
1413  $this->gotoPageObject($page);
1414  }
1415 
1419  public function recentChangesObject()
1420  {
1421  $tpl = $this->tpl;
1422 
1423  $this->checkPermission("read");
1424 
1425  include_once("./Modules/Wiki/classes/class.ilWikiRecentChangesTableGUI.php");
1426 
1427  $this->addPagesSubTabs();
1428 
1429  $table_gui = new ilWikiRecentChangesTableGUI(
1430  $this,
1431  "recentChanges",
1432  $this->object->getId()
1433  );
1434 
1435  $this->setSideBlock();
1436  $tpl->setContent($table_gui->getHTML());
1437  }
1438 
1442  public function setSideBlock($a_wpg_id = 0)
1443  {
1444  ilObjWikiGUI::renderSideBlock($a_wpg_id, $this->object->getRefId());
1445  }
1446 
1447 
1451  public static function renderSideBlock($a_wpg_id, $a_wiki_ref_id, $a_wp = null)
1452  {
1453  global $DIC;
1454 
1455  $tpl = $DIC["tpl"];
1456  $lng = $DIC->language();
1457  $ilAccess = $DIC->access();
1458  $ilCtrl = $DIC->ctrl();
1459 
1460  $tpl->addJavaScript("./Modules/Wiki/js/WikiPres.js");
1461 
1462  // setting asynch to false fixes #0019457, since otherwise ilBlockGUI would act on asynch and output html when side blocks
1463  // being processed during the export. This is a flaw in ilCtrl and/or ilBlockGUI.
1464  $tpl->addOnLoadCode("il.Wiki.Pres.init('" . $ilCtrl->getLinkTargetByClass("ilobjwikigui", "", "", false, false) . "');");
1465 
1466  if ($a_wpg_id > 0 && !$a_wp) {
1467  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1468  $a_wp = ilWikiPage($a_wpg_id);
1469  }
1470 
1471  // search block
1472  include_once './Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
1473  $rcontent = ilRepositoryObjectSearchGUI::getSearchBlockHTML($lng->txt('wiki_search'));
1474 
1475  #include_once("./Modules/Wiki/classes/class.ilWikiSearchBlockGUI.php");
1476  #$wiki_search_block = new ilWikiSearchBlockGUI();
1477  #$rcontent = $wiki_search_block->getHTML();
1478 
1479  // quick navigation
1480  if ($a_wpg_id > 0) {
1481  // include_once("./Modules/Wiki/classes/class.ilWikiSideBlockGUI.php");
1482  // $wiki_side_block = new ilWikiSideBlockGUI();
1483  // $wiki_side_block->setPageObject($a_wp);
1484  // $rcontent.= $wiki_side_block->getHTML();
1485 
1486  // rating
1487  $wiki_id =ilObject::_lookupObjId($a_wiki_ref_id);
1488  if (ilObjWiki::_lookupRating($wiki_id) &&
1489  // ilObjWiki::_lookupRatingAsBlock($wiki_id) &&
1490  $a_wp->getRating()) {
1491  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
1492  $rgui = new ilRatingGUI();
1493  $rgui->setObject($wiki_id, "wiki", $a_wpg_id, "wpg");
1494  $rgui->enableCategories(ilObjWiki::_lookupRatingCategories($wiki_id));
1495  $rgui->setYourRatingText("#");
1496  $rcontent .= $rgui->getBlockHTML($lng->txt("wiki_rate_page"));
1497  }
1498 
1499  // advanced metadata
1500  if (!ilWikiPage::lookupAdvancedMetadataHidden($a_wpg_id)) {
1501  $cmd = null;
1502  if ($ilAccess->checkAccess("write", "", $a_wiki_ref_id) ||
1503  $ilAccess->checkAccess("edit_page_meta", "", $a_wiki_ref_id)) {
1504  $cmd = array(
1505  "edit" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "editAdvancedMetaData"),
1506  "hide" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "hideAdvancedMetaData")
1507  );
1508  }
1509  include_once("./Services/Object/classes/class.ilObjectMetaDataGUI.php");
1510  $wiki = new ilObjWiki($a_wiki_ref_id);
1511  $callback = $wiki->getLinkMetadataValues()
1512  ? array($wiki, "decorateAdvMDValue")
1513  : null;
1514  $mdgui = new ilObjectMetaDataGUI($wiki, "wpg", $a_wpg_id);
1515  $rcontent .= $mdgui->getBlockHTML($cmd, $callback); // #17291
1516  }
1517  }
1518 
1519  // important pages
1520  // if (ilObjWiki::_lookupImportantPages(ilObject::_lookupObjId($a_wiki_ref_id)))
1521  // {
1522  include_once("./Modules/Wiki/classes/class.ilWikiImportantPagesBlockGUI.php");
1523  $imp_pages_block = new ilWikiImportantPagesBlockGUI();
1524  $rcontent.= $imp_pages_block->getHTML();
1525  // }
1526 
1527  // wiki functions block
1528  if ($a_wpg_id > 0) {
1529  include_once("./Modules/Wiki/classes/class.ilWikiFunctionsBlockGUI.php");
1530  $wiki_functions_block = new ilWikiFunctionsBlockGUI();
1531  $wiki_functions_block->setPageObject($a_wp);
1532  $rcontent .= $wiki_functions_block->getHTML();
1533  }
1534 
1535  $tpl->setRightContent($rcontent);
1536  }
1537 
1541  public function newPagesObject()
1542  {
1543  $tpl = $this->tpl;
1544 
1545  $this->checkPermission("read");
1546 
1547  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1548 
1549  $this->addPagesSubTabs();
1550 
1551  $table_gui = new ilWikiPagesTableGUI(
1552  $this,
1553  "newPages",
1554  $this->object->getId(),
1556  );
1557 
1558  $this->setSideBlock();
1559  $tpl->setContent($table_gui->getHTML());
1560  }
1561 
1562  protected function getPrintPageIds()
1563  {
1564  // multiple ordered page ids
1565  if (is_array($_POST["wordr"])) {
1566  asort($_POST["wordr"]);
1567  $page_ids = array_keys($_POST["wordr"]);
1568  }
1569  // single page
1570  elseif ((int) $_GET["wpg_id"]) {
1571  $page_ids = array((int) $_GET["wpg_id"]);
1572  }
1573 
1574  return $page_ids;
1575  }
1576 
1577  public function printViewObject($a_pdf_export = false)
1578  {
1579  $tpl = $this->tpl;
1580 
1581  $page_ids = $this->getPrintPageIds();
1582  if (!$page_ids) {
1583  $this->ctrl->redirect($this, "");
1584  }
1585 
1586  $tpl = new ilTemplate("tpl.main.html", true, true);
1587  $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
1588  $this->setContentStyleSheet($tpl);
1589 
1590  // syntax style
1591  $tpl->setCurrentBlock("SyntaxStyle");
1592  $tpl->setVariable(
1593  "LOCATION_SYNTAX_STYLESHEET",
1595  );
1596  $tpl->parseCurrentBlock();
1597 
1598 
1599  // determine target frames for internal links
1600 
1601  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
1602 
1603  $page_content = "";
1604 
1605  foreach ($page_ids as $p_id) {
1606  $page_gui = new ilWikiPageGUI($p_id);
1607  $page_gui->setWiki($this->object);
1608  $page_gui->setOutputMode("print");
1609  $page_content.= $page_gui->showPage();
1610 
1611  if ($a_pdf_export) {
1612  $page_content .= '<p style="page-break-after:always;"></p>';
1613  }
1614  }
1615 
1616  $page_content = '<div class="ilInvisibleBorder">' . $page_content . '</div>';
1617 
1618  if (!$a_pdf_export) {
1619  $page_content .= '<script type="text/javascript" language="javascript1.2">
1620  <!--
1621  il.Util.addOnLoad(function () {
1622  il.Util.print();
1623  });
1624  //-->
1625  </script>';
1626  }
1627 
1628  $tpl->setVariable("CONTENT", $page_content);
1629 
1630  if (!$a_pdf_export) {
1631  $tpl->show(false);
1632  exit;
1633  } else {
1634  return $tpl->get("DEFAULT", false, false, false, true, false, false);
1635  }
1636  }
1637 
1638  public function pdfExportObject()
1639  {
1640 
1641  // prepare generation before contents are processed (for mathjax)
1642  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
1644 
1645  $html = $this->printViewObject(true);
1646 
1647  // :TODO: fixing css dummy parameters
1648  $html = preg_replace("/\?dummy\=[0-9]+/", "", $html);
1649  $html = preg_replace("/\?vers\=[0-9A-Za-z\-]+/", "", $html);
1650 
1651  if (false) {
1652  include_once "Services/PDFGeneration/classes/class.ilPDFGeneration.php";
1653  include_once "Services/PDFGeneration/classes/class.ilPDFGenerationJob.php";
1654 
1655  $job = new ilPDFGenerationJob();
1656  $job->setAutoPageBreak(true)
1657  ->setMarginLeft("10")
1658  ->setMarginRight("10")
1659  ->setMarginTop("10")
1660  ->setMarginBottom("10")
1661  ->setOutputMode("D")// download
1662  ->setFilename("wiki.pdf")// :TODO:
1663  ->setCreator("ILIAS Wiki")// :TODO:
1664  ->setImageScale(1.25)// complete content scaling ?!
1665  ->addPage($html);
1666 
1667  ilPDFGeneration::doJob($job);
1668  } else {
1669  $html = preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $html);
1670  $html = preg_replace("/href=\"\\.\\//ims", "href=\"" . ILIAS_HTTP_PATH . "/", $html);
1671  $pdf_factory = new ilHtmlToPdfTransformerFactory();
1672  $pdf_factory->deliverPDFFromHTMLString($html, "wiki.pdf", ilHtmlToPdfTransformerFactory::PDF_OUTPUT_DOWNLOAD, "Wiki", "ContentExport");
1673  }
1674  }
1675 
1679  public function performSearchObject()
1680  {
1681  $tpl = $this->tpl;
1682  $ilTabs = $this->tabs;
1683  $ilCtrl = $this->ctrl;
1684  $lng = $this->lng;
1685 
1686  $this->checkPermission("read");
1687 
1688  include_once("./Modules/Wiki/classes/class.ilWikiSearchResultsTableGUI.php");
1689 
1690  $ilTabs->setTabActive("wiki_search_results");
1691 
1692  if (trim($_POST["search_term"]) == "") {
1693  ilUtil::sendFailure($lng->txt("wiki_please_enter_search_term"), true);
1694  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1695  }
1696 
1697  $search_results = ilObjWiki::_performSearch(
1698  $this->object->getId(),
1699  ilUtil::stripSlashes($_POST["search_term"])
1700  );
1701  $table_gui = new ilWikiSearchResultsTableGUI(
1702  $this,
1703  "performSearch",
1704  $this->object->getId(),
1705  $search_results,
1706  $_POST["search_term"]
1707  );
1708 
1709  $this->setSideBlock();
1710  $tpl->setContent($table_gui->getHTML());
1711  }
1712 
1716  public function setContentStyleSheet($a_tpl = null)
1717  {
1718  $tpl = $this->tpl;
1719 
1720  if ($a_tpl != null) {
1721  $ctpl = $a_tpl;
1722  } else {
1723  $ctpl = $tpl;
1724  }
1725 
1726  $ctpl->setCurrentBlock("ContentStyle");
1727  $ctpl->setVariable(
1728  "LOCATION_CONTENT_STYLESHEET",
1729  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
1730  );
1731  $ctpl->parseCurrentBlock();
1732  }
1733 
1734 
1738  public function editStylePropertiesObject()
1739  {
1740  $ilTabs = $this->tabs;
1741  $tpl = $this->tpl;
1742 
1743  $this->checkPermission("write");
1744 
1745  $this->initStylePropertiesForm();
1746  $tpl->setContent($this->form->getHTML());
1747 
1748  $ilTabs->activateTab("settings");
1749  $this->setSettingsSubTabs("style");
1750 
1751  $this->setSideBlock();
1752  }
1753 
1757  public function initStylePropertiesForm()
1758  {
1759  $ilCtrl = $this->ctrl;
1760  $lng = $this->lng;
1761  $ilTabs = $this->tabs;
1763 
1764  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1765  $lng->loadLanguageModule("style");
1766 
1767  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1768  $this->form = new ilPropertyFormGUI();
1769 
1770  $fixed_style = $ilSetting->get("fixed_content_style_id");
1771  $style_id = $this->object->getStyleSheetId();
1772 
1773  if ($fixed_style > 0) {
1774  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1775  $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
1776  $this->lng->txt("global_fixed") . ")");
1777  $this->form->addItem($st);
1778  } else {
1780  true,
1781  false,
1782  $_GET["ref_id"]
1783  );
1784 
1785  $st_styles[0] = $this->lng->txt("default");
1786  ksort($st_styles);
1787 
1788  if ($style_id > 0) {
1789  // individual style
1790  if (!ilObjStyleSheet::_lookupStandard($style_id)) {
1791  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1792  $st->setValue(ilObject::_lookupTitle($style_id));
1793  $this->form->addItem($st);
1794 
1795  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
1796 
1797  // delete command
1798  $this->form->addCommandButton(
1799  "editStyle",
1800  $lng->txt("style_edit_style")
1801  );
1802  $this->form->addCommandButton(
1803  "deleteStyle",
1804  $lng->txt("style_delete_style")
1805  );
1806  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
1807  }
1808  }
1809 
1810  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
1811  $style_sel = ilUtil::formSelect(
1812  $style_id,
1813  "style_id",
1814  $st_styles,
1815  false,
1816  true
1817  );
1818  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
1819  $style_sel->setOptions($st_styles);
1820  $style_sel->setValue($style_id);
1821  $this->form->addItem($style_sel);
1822  //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
1823  $this->form->addCommandButton(
1824  "saveStyleSettings",
1825  $lng->txt("save")
1826  );
1827  $this->form->addCommandButton(
1828  "createStyle",
1829  $lng->txt("sty_create_ind_style")
1830  );
1831  }
1832  }
1833  $this->form->setTitle($lng->txt("wiki_style"));
1834  $this->form->setFormAction($ilCtrl->getFormAction($this));
1835  }
1836 
1840  public function createStyleObject()
1841  {
1842  $ilCtrl = $this->ctrl;
1843 
1844  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
1845  }
1846 
1850  public function editStyleObject()
1851  {
1852  $ilCtrl = $this->ctrl;
1853 
1854  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
1855  }
1856 
1860  public function deleteStyleObject()
1861  {
1862  $ilCtrl = $this->ctrl;
1863 
1864  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
1865  }
1866 
1870  public function saveStyleSettingsObject()
1871  {
1873 
1874  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1875  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1876  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1877  || $this->object->getStyleSheetId() == 0)) {
1878  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1879  $this->object->update();
1880  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1881  }
1882  $this->ctrl->redirect($this, "editStyleProperties");
1883  }
1884 
1885  //
1886  // Important pages
1887  //
1888 
1892  public function editImportantPagesObject()
1893  {
1894  $tpl = $this->tpl;
1895  $ilToolbar = $this->toolbar;
1896  $ilTabs = $this->tabs;
1897  $lng = $this->lng;
1898  $ilCtrl = $this->ctrl;
1899 
1900  $this->checkPermission("edit_wiki_navigation");
1901 
1902  ilUtil::sendInfo($lng->txt("wiki_navigation_info"));
1903 
1904  $ipages = ilObjWiki::_lookupImportantPagesList($this->object->getId());
1905  $ipages_ids = array();
1906  foreach ($ipages as $i) {
1907  $ipages_ids[] = $i["page_id"];
1908  }
1909 
1910  // list pages
1911  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1912  $pages = ilWikiPage::getAllWikiPages($this->object->getId());
1913  $options = array("" => $lng->txt("please_select"));
1914  foreach ($pages as $p) {
1915  if (!in_array($p["id"], $ipages_ids)) {
1916  $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
1917  }
1918  }
1919  if (count($options) > 0) {
1920  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1921  $si = new ilSelectInputGUI($lng->txt("wiki_pages"), "imp_page_id");
1922  $si->setOptions($options);
1923  $si->setInfo($lng->txt(""));
1924  $ilToolbar->addInputItem($si);
1925  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1926  $ilToolbar->addFormButton($lng->txt("add"), "addImportantPage");
1927  }
1928 
1929 
1930  $ilTabs->activateTab("settings");
1931  $this->setSettingsSubTabs("imp_pages");
1932 
1933  include_once("./Modules/Wiki/classes/class.ilImportantPagesTableGUI.php");
1934  $imp_table = new ilImportantPagesTableGUI($this, "editImportantPages");
1935 
1936  $tpl->setContent($imp_table->getHTML());
1937  }
1938 
1945  public function addImportantPageObject()
1946  {
1947  $ilCtrl = $this->ctrl;
1948  $lng = $this->lng;
1949 
1950  $this->checkPermission("edit_wiki_navigation");
1951 
1952  if ($_POST["imp_page_id"] > 0) {
1953  $this->object->addImportantPage((int) $_POST["imp_page_id"]);
1954  ilUtil::sendSuccess($lng->txt("wiki_imp_page_added"), true);
1955  }
1956  $ilCtrl->redirect($this, "editImportantPages");
1957  }
1958 
1963  {
1964  $ilCtrl = $this->ctrl;
1965  $tpl = $this->tpl;
1966  $lng = $this->lng;
1967 
1968  if (!is_array($_POST["imp_page_id"]) || count($_POST["imp_page_id"]) == 0) {
1969  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1970  $ilCtrl->redirect($this, "editImportantPages");
1971  } else {
1972  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1973  $cgui = new ilConfirmationGUI();
1974  $cgui->setFormAction($ilCtrl->getFormAction($this));
1975  $cgui->setHeaderText($lng->txt("wiki_sure_remove_imp_pages"));
1976  $cgui->setCancel($lng->txt("cancel"), "editImportantPages");
1977  $cgui->setConfirm($lng->txt("remove"), "removeImportantPages");
1978 
1979  foreach ($_POST["imp_page_id"] as $i) {
1980  $cgui->addItem("imp_page_id[]", $i, ilWikiPage::lookupTitle((int) $i));
1981  }
1982 
1983  $tpl->setContent($cgui->getHTML());
1984  }
1985  }
1986 
1993  public function removeImportantPagesObject()
1994  {
1995  $ilCtrl = $this->ctrl;
1996  $lng = $this->lng;
1997 
1998  $this->checkPermission("edit_wiki_navigation");
1999 
2000  if (is_array($_POST["imp_page_id"])) {
2001  foreach ($_POST["imp_page_id"] as $i) {
2002  $this->object->removeImportantPage((int) $i);
2003  }
2004  }
2005  ilUtil::sendSuccess($lng->txt("wiki_removed_imp_pages"), true);
2006  $ilCtrl->redirect($this, "editImportantPages");
2007  }
2008 
2013  {
2014  $ilCtrl = $this->ctrl;
2015  $lng = $this->lng;
2016 
2017  $this->checkPermission("edit_wiki_navigation");
2018 
2019  $this->object->saveOrderingAndIndentation($_POST["ord"], $_POST["indent"]);
2020  ilUtil::sendSuccess($lng->txt("wiki_ordering_and_indent_saved"), true);
2021  $ilCtrl->redirect($this, "editImportantPages");
2022  }
2023 
2027  public function setAsStartPageObject()
2028  {
2029  $ilCtrl = $this->ctrl;
2030  $lng = $this->lng;
2031 
2032  $this->checkPermission("edit_wiki_navigation");
2033 
2034  if (!is_array($_POST["imp_page_id"]) || count($_POST["imp_page_id"]) != 1) {
2035  ilUtil::sendInfo($lng->txt("wiki_select_one_item"), true);
2036  } else {
2037  $this->object->removeImportantPage((int) $_POST["imp_page_id"][0]);
2038  $this->object->setStartPage(ilWikiPage::lookupTitle((int) $_POST["imp_page_id"][0]));
2039  $this->object->update();
2040  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2041  }
2042  $ilCtrl->redirect($this, "editImportantPages");
2043  }
2044 
2045 
2049  public function exportHTML()
2050  {
2051  require_once("./Modules/Wiki/classes/class.ilWikiHTMLExport.php");
2052  $cont_exp = new ilWikiHTMLExport($this->object);
2053  $cont_exp->buildExportFile();
2054  }
2055 
2063  public static function lookupSubObjectTitle($a_wiki_id, $a_page_id)
2064  {
2065  include_once "Modules/Wiki/classes/class.ilWikiPage.php";
2066  $page = new ilWikiPage($a_page_id);
2067  if ($page->getWikiId() == $a_wiki_id) {
2068  return $page->getTitle();
2069  }
2070  }
2071 
2079  public function getSubObjectTitle($a_id, $a_type)
2080  {
2081  include_once "Modules/Wiki/classes/class.ilWikiPage.php";
2082  return ilWikiPage::lookupTitle($a_id);
2083  }
2084 
2089  {
2090  $lng = $this->lng;
2091  $tpl = $this->tpl;
2092  $ilTabs = $this->tabs;
2093  $ilCtrl = $this->ctrl;
2094 
2095 
2096  $ilCtrl->setParameterByClass("ilobjwikigui", "from_page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
2097  $ilTabs->clearTargets();
2098  ilUtil::sendInfo($lng->txt("wiki_page_not_exist_select_templ"));
2099 
2100  $form = $this->initTemplateSelectionForm();
2101  $tpl->setContent($form->getHTML());
2102  }
2103 
2107  public function initTemplateSelectionForm()
2108  {
2109  $lng = $this->lng;
2110  $ilCtrl = $this->ctrl;
2111 
2112  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2113  $form = new ilPropertyFormGUI();
2114 
2115  // page name
2116  $hi = new ilHiddenInputGUI("page");
2117  $hi->setValue($_GET["page"]);
2118  $form->addItem($hi);
2119 
2120  // page template
2121  $radg = new ilRadioGroupInputGUI($lng->txt("wiki_page_template"), "page_templ");
2122  $radg->setRequired(true);
2123 
2124  if ($this->object->getEmptyPageTemplate()) {
2125  $op1 = new ilRadioOption($lng->txt("wiki_empty_page"), 0);
2126  $radg->addOption($op1);
2127  }
2128 
2129  include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
2130  $wt = new ilWikiPageTemplate($this->object->getId());
2132  foreach ($ts as $t) {
2133  $op = new ilRadioOption($t["title"], $t["wpage_id"]);
2134  $radg->addOption($op);
2135  }
2136 
2137  $form->addItem($radg);
2138 
2139  // save and cancel commands
2140  $form->addCommandButton("createPageUsingTemplate", $lng->txt("wiki_create_page"));
2141  $form->addCommandButton("cancelCreationPageUsingTemplate", $lng->txt("cancel"));
2142 
2143  $form->setTitle($lng->txt("wiki_new_page") . ": " . $_GET["page"]);
2144  $form->setFormAction($ilCtrl->getFormAction($this));
2145 
2146  return $form;
2147  }
2148 
2153  {
2154  $tpl = $this->tpl;
2155  $lng = $this->lng;
2156  $ilCtrl = $this->ctrl;
2157 
2158  $form = $this->initTemplateSelectionForm();
2159  if ($form->checkInput()) {
2160  $a_page = $_POST["page"];
2161  $this->object->createWikiPage($a_page, (int) $_POST["page_templ"]);
2162 
2163  // redirect to newly created page
2164  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
2165  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
2166 
2167  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2168  $ilCtrl->redirect($this, "");
2169  } else {
2170  $form->setValuesByPost();
2171  $tpl->setContent($form->getHtml());
2172  }
2173  }
2174 
2179  {
2180  $ilCtrl = $this->ctrl;
2181 
2182  // redirect to newly created page
2183  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($_GET["from_page"])));
2184  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
2185  }
2186 
2196  protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_ref_id = null)
2197  {
2198  if ($a_perm == "create") {
2199  return parent::checkPermissionBool($a_perm, $a_cmd, $a_type, $a_ref_id);
2200  } else {
2201  if (!$a_ref_id) {
2202  $a_ref_id = $this->object->getRefId();
2203  }
2204  include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
2205  return ilWikiPerm::check($a_perm, $a_ref_id, $a_cmd);
2206  }
2207  }
2208 
2209 
2210  //
2211  // User HTML Export
2212  //
2213 
2217  public function initUserHTMLExportObject()
2218  {
2219  $this->log->debug("init");
2220  $this->checkPermission("wiki_html_export");
2221  $this->object->initUserHTMLExport();
2222  }
2223 
2227  public function startUserHTMLExportObject()
2228  {
2229  $this->log->debug("start");
2230  $this->checkPermission("wiki_html_export");
2231  $this->object->startUserHTMLExport();
2232  }
2233 
2238  {
2239  $this->log->debug("get progress");
2240  $this->checkPermission("wiki_html_export");
2241  $p = $this->object->getUserHTMLExportProgress();
2242 
2243  include_once("./Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php");
2245  $pb->setCurrent($p["progress"]);
2246 
2247  $r = new stdClass();
2248  $r->progressBar = $pb->render();
2249  $r->status = $p["status"];
2250  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
2251  $this->log->debug("status: " . $r->status);
2252  echo(ilJsonUtil::encode($r));
2253  exit;
2254  }
2255 
2260  {
2261  $this->log->debug("download");
2262  $this->checkPermission("wiki_html_export");
2263  $this->object->deliverUserHTMLExport();
2264  }
2265 }
static renderSideBlock($a_wpg_id, $a_wiki_ref_id, $a_wp=null)
Side column.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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.
static getContentPrintStyle()
get content print style
initStylePropertiesForm()
Init style properties form.
getAllInfo($a_type=self::TYPE_ALL)
Get all info.
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.
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 _lookupImportantPagesList($a_wiki_id)
Get important pages list.
const IL_WIKI_POPULAR_PAGES
This class represents a selection list property in a property form.
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.
global $DIC
Definition: saml.php:7
$_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.
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)
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.
$r
Definition: example_031.php:79
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.
if(isset($_POST['submit'])) $form
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)
special template class to simplify handling of ITX/PEAR
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)
This class represents a text property in a property form.
createPageUsingTemplateObject()
Save creation with template form.
Class ilWikiPage GUI class.
$ilUser
Definition: imgupload.php:18
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
static getContentStylePath($a_style_id, $add_random=true)
get content style path
setOptions($a_options)
Set Options.
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.
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
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.
static prepareGeneration()
Prepare the PDF generation This initializes the purpose for MathJax rendering It has to be called bef...
static getSearchBlockHTML($a_title)
Get standar search block html.
const IL_WIKI_ALL_PAGES
randomPageObject()
Go to random page.
deleteStyleObject()
Delete Style.
settings()
Definition: settings.php:2
initSettingsForm($a_mode="edit")
Init Settings Form.
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.
setContentStyleSheet($a_tpl=null)
Set content style sheet.
Create new PHPExcel object
obj_idprivate
Class ilObjStyleSheetGUI.
global $ilSetting
Definition: privfeed.php:17
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.
$i
Definition: disco.tpl.php:19
getRefId()
get reference id public
Wiki HTML exporter class.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
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.
$info
Definition: index.php:5
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.
$html
Definition: example_001.php:87
recentChangesObject()
Recent Changes.
Class ilObjWikiGUI.
setRequired($a_required)
Set Required.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
viewPageObject()
view wiki page
static _goto($a_target)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Confirmation screen class.
afterSave(ilObject $newObj)
save object public
const IL_WIKI_NEW_PAGES