ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
21 {
26  function ilObjWikiGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
27  {
28  global $ilCtrl, $lng;
29 
30  $this->type = "wiki";
31 
32  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
33  $lng->loadLanguageModule("wiki");
34 
35  if ($_GET["page"] != "")
36  {
37  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
38  }
39  }
40 
41  function executeCommand()
42  {
43  global $ilUser, $ilCtrl, $tpl, $ilTabs, $ilAccess;
44 
45  $next_class = $this->ctrl->getNextClass($this);
46  $cmd = $this->ctrl->getCmd();
47 
48  $this->prepareOutput();
49 
50  // see ilWikiPageGUI::printViewOrderList()
51  // printView() and pdfExport() cannot be in ilWikiPageGUI because of stylesheet confusion
52  if($cmd == "printView" || $cmd == "pdfExport")
53  {
54  $next_class = null;
55  }
56 
57  switch($next_class)
58  {
59  case "ilinfoscreengui":
60  $this->checkPermission("visible");
61  $this->addHeaderAction();
62  $this->infoScreen(); // forwards command
63  break;
64 
65  case 'ilpermissiongui':
66  $this->addHeaderAction();
67  $ilTabs->activateTab("perm_settings");
68  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
69  $perm_gui =& new ilPermissionGUI($this);
70  $ret =& $this->ctrl->forwardCommand($perm_gui);
71  break;
72 
73  case 'ilwikipagegui':
74  $this->checkPermission("read");
75  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
76  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
77  ilWikiUtil::makeDbTitle($_GET["page"]), $_GET["old_nr"], $this->object->getRefId());
78  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
79  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
80  $this->object->getStyleSheetId(), "wiki"));
81  $this->setContentStyleSheet();
82  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
83  (!$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()) ||
84  $wpage_gui->getPageObject()->getBlocked()
85  ))
86  {
87  $wpage_gui->setEnableEditing(false);
88  }
89 
90  // alter title and description
91 // $tpl->setTitle($wpage_gui->getPageObject()->getTitle());
92 // $tpl->setDescription($this->object->getTitle());
93 
94  $ret = $this->ctrl->forwardCommand($wpage_gui);
95  if ($ret != "")
96  {
97  $tpl->setContent($ret);
98  }
99  break;
100 
101  case 'ilpublicuserprofilegui':
102  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
103  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
104  $ret = $this->ctrl->forwardCommand($profile_gui);
105  $tpl->setContent($ret);
106  break;
107 
108  case "ilobjstylesheetgui":
109  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
110  $this->ctrl->setReturn($this, "editStyleProperties");
111  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
112  $style_gui->omitLocator();
113  if ($cmd == "create" || $_GET["new_type"]=="sty")
114  {
115  $style_gui->setCreationMode(true);
116  }
117 
118  if ($cmd == "confirmedDelete")
119  {
120  $this->object->setStyleSheetId(0);
121  $this->object->update();
122  }
123 
124  $ret = $this->ctrl->forwardCommand($style_gui);
125 
126  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
127  {
128  $style_id = $ret;
129  $this->object->setStyleSheetId($style_id);
130  $this->object->update();
131  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
132  }
133  break;
134 
135  case "ilexportgui":
136 // $this->prepareOutput();
137  $this->addHeaderAction();
138  $ilTabs->activateTab("export");
139  include_once("./Services/Export/classes/class.ilExportGUI.php");
140  $exp_gui = new ilExportGUI($this);
141  $exp_gui->addFormat("xml");
142  $exp_gui->addFormat("html", "", $this, "exportHTML");
143  $ret = $this->ctrl->forwardCommand($exp_gui);
144 // $this->tpl->show();
145  break;
146 
147  case "ilcommonactiondispatchergui":
148  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
150  $this->ctrl->forwardCommand($gui);
151  break;
152 
153  case "ilratinggui":
154  // for rating category editing
155  $this->checkPermission("write");
156  $this->addHeaderAction();
157  $ilTabs->activateTab("settings");
158  $this->setSettingsSubTabs("rating_categories");
159  include_once("Services/Rating/classes/class.ilRatingGUI.php");
160  $gui = new ilRatingGUI();
161  $gui->setObject($this->object->getId(), $this->object->getType());
162  $gui->setExportCallback(array($this, "getSubObjectTitle"), $this->lng->txt("page"));
163  $this->ctrl->forwardCommand($gui);
164  break;
165 
166  case "ilwikistatgui":
167  $this->checkPermission("statistics_read");
168 
169  $this->addHeaderAction();
170  $ilTabs->activateTab("statistics");
171 
172  include_once "Modules/Wiki/classes/class.ilWikiStatGUI.php";
173  $gui = new ilWikiStatGUI($this->object->getId());
174  $this->ctrl->forwardCommand($gui);
175  break;
176 
177  case "ilwikipagetemplategui":
178  $this->addHeaderAction();
179  $ilTabs->activateTab("settings");
180  $this->setSettingsSubTabs("page_templates");
181  include_once("./Modules/Wiki/classes/class.ilWikiPageTemplateGUI.php");
182  $wptgui = new ilWikiPageTemplateGUI($this);
183  $this->ctrl->forwardCommand($wptgui);
184  break;
185 
186  default:
187  $this->addHeaderAction();
188  if(!$cmd)
189  {
190  $cmd = "infoScreen";
191  }
192  $cmd .= "Object";
193  if ($cmd != "infoScreenObject")
194  {
195  $this->checkPermission("read");
196  }
197  else
198  {
199  $this->checkPermission("visible");
200  }
201  $this->$cmd();
202  break;
203  }
204 
205  return $ret;
206  }
207 
213  function isOnlineHelpWiki()
214  {
215  if (is_object($this->object))
216  {
217  return ilObjWiki::isOnlineHelpWiki($this->object->getRefId());
218  }
219  return false;
220  }
221 
225  function viewObject()
226  {
227  $this->checkPermission("read");
228  $this->gotoStartPageObject();
229  }
230 
231  protected function initCreationForms($a_new_type)
232  {
233  $this->initSettingsForm("create");
234  $this->getSettingsFormValues("create");
235 
236  $forms = array(self::CFORM_NEW => $this->form_gui,
237  self::CFORM_IMPORT => $this->initImportForm($a_new_type));
238 
239  return $forms;
240  }
241 
246  function saveObject()
247  {
248  global $tpl, $lng, $rbacsystem;
249 
250  if (!$this->checkPermissionBool("create", "", "wiki", $_GET["ref_id"]))
251  {
252  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
253  }
254 
255  $this->initSettingsForm("create");
256  if ($this->form_gui->checkInput())
257  {
258  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")))
259  {
260  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
261  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
262  }
263  else
264  {
265  // create and insert forum in objecttree
266  $_POST["title"] = $this->form_gui->getInput("title");
267  $_POST["desc"] = $this->form_gui->getInput("description");
268  return parent::saveObject();
269  }
270  }
271 
272  $this->form_gui->setValuesByPost();
273  $tpl->setContent($this->form_gui->getHtml());
274  }
275 
280  function afterSave($newObj)
281  {
282  global $ilSetting;
283 
284  $newObj->setTitle($this->form_gui->getInput("title"));
285  $newObj->setDescription($this->form_gui->getInput("description"));
286  $newObj->setIntroduction($this->form_gui->getInput("intro"));
287  $newObj->setStartPage($this->form_gui->getInput("startpage"));
288  $newObj->setShortTitle($this->form_gui->getInput("shorttitle"));
289  $newObj->setRating($this->form_gui->getInput("rating"));
290  // $newObj->setRatingAsBlock($this->form_gui->getInput("rating_side"));
291  $newObj->setRatingForNewPages($this->form_gui->getInput("rating_new"));
292  $newObj->setRatingCategories($this->form_gui->getInput("rating_ext"));
293 
294  $newObj->setRatingOverall($this->form_gui->getInput("rating_overall"));
295  $newObj->setPageToc($this->form_gui->getInput("page_toc"));
296 
297 
298 
299  if (!$ilSetting->get("disable_comments"))
300  {
301  $newObj->setPublicNotes($this->form_gui->getInput("public_notes"));
302  }
303  $newObj->setOnline($this->form_gui->getInput("online"));
304  $newObj->update();
305 
306  // always send a message
307  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
308  ilUtil::redirect(ilObjWikiGUI::getGotoLink($newObj->getRefId()));
309  }
310 
316  function infoScreenObject()
317  {
318  $this->checkPermission("visible");
319  $this->ctrl->setCmd("showSummary");
320  $this->ctrl->setCmdClass("ilinfoscreengui");
321  $this->infoScreen();
322  }
323 
327  function infoScreen()
328  {
329  global $ilAccess, $ilUser, $ilTabs, $lng;
330 
331  $ilTabs->activateTab("info_short");
332 
333  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId()))
334  {
335  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
336  }
337 
338  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
339  $info = new ilInfoScreenGUI($this);
340  $info->enablePrivateNotes();
341  if (trim($this->object->getIntroduction()) != "")
342  {
343  $info->addSection($lng->txt("wiki_introduction"));
344  $info->addProperty("", nl2br($this->object->getIntroduction()));
345  }
346 
347  // feedback from tutor; mark, status, comment
348  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
349  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
350  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
351  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
352  $status = ilWikiContributor::_lookupStatus($this->object->getId(), $ilUser->getId());
353  if ($lpcomment != "" || $mark != "" || $status != ilWikiContributor::STATUS_NOT_GRADED)
354  {
355  $info->addSection($this->lng->txt("wiki_feedback_from_tutor"));
356  if ($lpcomment != "")
357  {
358  $info->addProperty($this->lng->txt("wiki_comment"),
359  $lpcomment);
360  }
361  if ($mark != "")
362  {
363  $info->addProperty($this->lng->txt("wiki_mark"),
364  $mark);
365  }
366 
367  if ($status == ilWikiContributor::STATUS_PASSED)
368  {
369  $info->addProperty($this->lng->txt("status"),
370  $this->lng->txt("wiki_passed"));
371  }
372  if ($status == ilWikiContributor::STATUS_FAILED)
373  {
374  $info->addProperty($this->lng->txt("status"),
375  $this->lng->txt("wiki_failed"));
376  }
377  }
378 
379  /*
380  $info->enableNews();
381  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
382  {
383  //$info->enableNewsEditing();
384  $info->setBlockProperty("news", "settings", true);
385  }*/
386 
387  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
388  {
389  $info->addButton($lng->txt("wiki_start_page"), ilObjWikiGUI::getGotoLink($this->object->getRefId()));
390  }
391 
392  // general information
393  $this->lng->loadLanguageModule("meta");
394  $this->lng->loadLanguageModule("wiki");
395 
396  //$info->addSection($this->lng->txt("meta_general"));
397  //$info->addProperty($this->lng->txt("mcst_nr_items"),
398  // (int) count($med_items));
399 
400  // forward the command
401  $this->ctrl->forwardCommand($info);
402 
403  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
404  {
405 // $this->setSideBlock();
406  }
407  }
408 
413  {
414  global $ilCtrl;
415 
416  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId()));
417  }
418 
422  function addPageTabs()
423  {
424  global $ilTabs, $ilCtrl;
425 
426  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
427  $ilCtrl->setParameter($this, "wpg_id",
428  ilWikiPage::getPageIdForTitle($this->object->getId(), ilWikiUtil::makeDbTitle($_GET["page"])));
429  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
430  $ilTabs->addTarget("wiki_what_links_here",
431  $this->ctrl->getLinkTargetByClass("ilwikipagegui",
432  "whatLinksHere"), "whatLinksHere");
433  $ilTabs->addTarget("wiki_print_view",
434  $this->ctrl->getLinkTargetByClass("ilwikipagegui",
435  "printViewSelection"), "printViewSelection");
436  }
437 
441  function addPagesSubTabs()
442  {
443  global $ilTabs, $ilCtrl;
444 
445  $ilTabs->activateTab("wiki_pages");
446 
447  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
448  $ilCtrl->setParameter($this, "wpg_id",
449  ilWikiPage::getPageIdForTitle($this->object->getId(),
450  ilWikiUtil::makeDbTitle($_GET["page"])));
451  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
452  $ilTabs->addSubTabTarget("wiki_all_pages",
453  $this->ctrl->getLinkTarget($this, "allPages"), "allPages");
454  $ilTabs->addSubTabTarget("wiki_recent_changes",
455  $this->ctrl->getLinkTarget($this, "recentChanges"), "recentChanges");
456  $ilTabs->addSubTabTarget("wiki_new_pages",
457  $this->ctrl->getLinkTarget($this, "newPages"), "newPages");
458  $ilTabs->addSubTabTarget("wiki_popular_pages",
459  $this->ctrl->getLinkTarget($this, "popularPages"), "popularPages");
460  $ilTabs->addSubTabTarget("wiki_orphaned_pages",
461  $this->ctrl->getLinkTarget($this, "orphanedPages"), "orphanedPages");
462  }
463 
469  function getTabs($tabs_gui)
470  {
471  global $ilCtrl, $ilAccess, $ilTabs, $lng, $ilHelp;
472 
473  $ilHelp->setScreenIdComponent("wiki");
474 
475 
476  // wiki tabs
477  if (in_array($ilCtrl->getCmdClass(), array("", "ilobjwikigui",
478  "ilinfoscreengui", "ilpermissiongui", "ilexportgui", "ilratingcategorygui",
479  "ilwikistatgui", "ilwikipagetemplategui"
480  )))
481  {
482  if ($_GET["page"] != "")
483  {
484  $tabs_gui->setBackTarget($lng->txt("wiki_last_visited_page"),
485  $this->getGotoLink($_GET["ref_id"],
486  ilWikiUtil::makeDbTitle($_GET["page"])));
487  }
488 
489  // pages
490  if ($ilAccess->checkAccess('read', "", $this->object->getRefId()))
491  {
492  $ilTabs->addTab("wiki_pages",
493  $lng->txt("wiki_pages"),
494  $this->ctrl->getLinkTarget($this, "allPages"));
495  }
496 
497  // info screen
498  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
499  {
500  $ilTabs->addTab("info_short",
501  $lng->txt("info_short"),
502  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
503  }
504 
505  // settings
506  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
507  {
508  $ilTabs->addTab("settings",
509  $lng->txt("settings"),
510  $this->ctrl->getLinkTarget($this, "editSettings"));
511  }
512 
513  // contributors
514  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
515  {
516  $ilTabs->addTab("wiki_contributors",
517  $lng->txt("wiki_contributors"),
518  $this->ctrl->getLinkTarget($this, "listContributors"));
519  }
520 
521  // statistics
522  if ($ilAccess->checkAccess('statistics_read', "", $this->object->getRefId()))
523  {
524  $ilTabs->addTab("statistics",
525  $lng->txt("statistics"),
526  $this->ctrl->getLinkTargetByClass("ilWikiStatGUI", "initial"));
527  }
528 
529  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
530  {
531  $ilTabs->addTab("export",
532  $lng->txt("export"),
533  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
534  }
535 
536  // edit permissions
537  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
538  {
539  $ilTabs->addTab("perm_settings",
540  $lng->txt("perm_settings"),
541  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
542  }
543  }
544  }
545 
549  function setSettingsSubTabs($a_active)
550  {
551  global $ilTabs, $ilCtrl, $lng;
552 
553  if (in_array($a_active,
554  array("general_settings", "style", "imp_pages", "rating_categories",
555  "page_templates")))
556  {
557  // general properties
558  $ilTabs->addSubTab("general_settings",
559  $lng->txt("wiki_general_settings"),
560  $ilCtrl->getLinkTarget($this, 'editSettings'));
561 
562  // style properties
563  $ilTabs->addSubTab("style",
564  $lng->txt("wiki_style"),
565  $ilCtrl->getLinkTarget($this, 'editStyleProperties'));
566 
567  // important pages
568  $ilTabs->addSubTab("imp_pages",
569  $lng->txt("wiki_navigation"),
570  $ilCtrl->getLinkTarget($this, 'editImportantPages'));
571 
572  // page templates
573  $ilTabs->addSubTab("page_templates",
574  $lng->txt("wiki_page_templates"),
575  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", ""));
576 
577  // rating categories
578  if($this->object->getRating() && $this->object->getRatingCategories())
579  {
580  $lng->loadLanguageModule("rating");
581  $ilTabs->addSubTab("rating_categories",
582  $lng->txt("rating_categories"),
583  $ilCtrl->getLinkTargetByClass(array('ilratinggui', 'ilratingcategorygui'), ''));
584  }
585 
586  $ilTabs->activateSubTab($a_active);
587  }
588  }
589 
594  {
595  global $tpl;
596 
597  $this->checkPermission("write");
598 
599  $this->setSettingsSubTabs("general_settings");
600 
601  $this->initSettingsForm();
602  $this->getSettingsFormValues();
603 
604  // Edit ecs export settings
605  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
606  $ecs = new ilECSWikiSettings($this->object);
607  $ecs->addSettingsToForm($this->form_gui, 'wiki');
608 
609  $tpl->setContent($this->form_gui->getHtml());
610  $this->setSideBlock();
611  }
612 
616  function initSettingsForm($a_mode = "edit")
617  {
618  global $lng, $ilCtrl, $ilTabs, $ilSetting;
619 
620  $lng->loadLanguageModule("wiki");
621  $ilTabs->activateTab("settings");
622 
623  include("Services/Form/classes/class.ilPropertyFormGUI.php");
624  $this->form_gui = new ilPropertyFormGUI();
625 
626  // Title
627  $tit = new ilTextInputGUI($lng->txt("title"), "title");
628  $tit->setRequired(true);
629  $this->form_gui->addItem($tit);
630 
631  // Short Title
632  // The problem with the short title is, that it is per object
633  // and can't be a substitute for a ref id in the permanent link
634 /*
635  $stit = new ilRegExpInputGUI($lng->txt("wiki_short_title"), "shorttitle");
636  $stit->setPattern("/^[^0-9][^ _\&]+$/");
637  $stit->setRequired(false);
638  $stit->setNoMatchMessage($lng->txt("wiki_msg_short_name_regexp")." &amp; _");
639  $stit->setSize(20);
640  $stit->setMaxLength(20);
641  $stit->setInfo($lng->txt("wiki_short_title_desc2"));
642  $this->form_gui->addItem($stit);
643 */
644 
645  // Description
646  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
647  $this->form_gui->addItem($des);
648 
649  // Introduction
650  $intro = new ilTextAreaInputGUI($lng->txt("wiki_introduction"), "intro");
651  $intro->setCols(40);
652  $intro->setRows(4);
653  $this->form_gui->addItem($intro);
654 
655  // Start Page
656  if ($a_mode == "edit")
657  {
658  $pages = ilWikiPage::getAllPages($this->object->getId());
659  foreach ($pages as $p)
660  {
661  $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
662  }
663  $si = new ilSelectInputGUI($lng->txt("wiki_start_page"), "startpage_id");
664  $si->setOptions($options);
665  $this->form_gui->addItem($si);
666  }
667  else
668  {
669  $sp = new ilTextInputGUI($lng->txt("wiki_start_page"), "startpage");
670  if ($a_mode == "edit")
671  {
672  $sp->setInfo($lng->txt("wiki_start_page_info"));
673  }
674  $sp->setMaxLength(200);
675  $sp->setRequired(true);
676  $this->form_gui->addItem($sp);
677  }
678 
679  // Online
680  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
681  $this->form_gui->addItem($online);
682 
683 
684  // rating
685 
686  $lng->loadLanguageModule('rating');
687  $rate = new ilCheckboxInputGUI($lng->txt('rating_activate_rating'), 'rating_overall');
688  $rate->setInfo($lng->txt('rating_activate_rating_info'));
689  $this->form_gui->addItem($rate);
690 
691  $rating = new ilCheckboxInputGUI($lng->txt("wiki_activate_rating"), "rating");
692  $this->form_gui->addItem($rating);
693 
694  /* always active
695  $side = new ilCheckboxInputGUI($lng->txt("wiki_activate_sideblock_rating"), "rating_side");
696  $rating->addSubItem($side);
697  */
698 
699  $new = new ilCheckboxInputGUI($lng->txt("wiki_activate_new_page_rating"), "rating_new");
700  $rating->addSubItem($new);
701 
702  $extended = new ilCheckboxInputGUI($lng->txt("wiki_activate_extended_rating"), "rating_ext");
703  $rating->addSubItem($extended);
704 
705 
706  // public comments
707  if (!$ilSetting->get("disable_comments"))
708  {
709  $comments = new ilCheckboxInputGUI($lng->txt("wiki_public_comments"), "public_notes");
710  $this->form_gui->addItem($comments);
711  }
712 
713  // important pages
714 // $imp_pages = new ilCheckboxInputGUI($lng->txt("wiki_important_pages"), "imp_pages");
715 // $this->form_gui->addItem($imp_pages);
716 
717  // page toc
718  $page_toc = new ilCheckboxInputGUI($lng->txt("wiki_page_toc"), "page_toc");
719  $page_toc->setInfo($lng->txt("wiki_page_toc_info"));
720  $this->form_gui->addItem($page_toc);
721 
722  if($a_mode == "edit")
723  {
724  // advanced metadata
725  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
726  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_REC_SELECTION,'wiki',$this->object->getId(), "wpg");
727  $record_gui->setPropertyForm($this->form_gui);
728  $record_gui->parseRecordSelection($this->lng->txt("wiki_add_page_properties"));
729  }
730 
731  // :TODO: sorting
732 
733  // Form action and save button
734  $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_wiki.svg"));
735  if ($a_mode != "create")
736  {
737  $this->form_gui->setTitle($lng->txt("wiki_settings"));
738  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
739  }
740  else
741  {
742  $this->form_gui->setTitle($lng->txt("wiki_new"));
743  $this->form_gui->addCommandButton("save", $lng->txt("wiki_add"));
744  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
745  }
746 
747  // set values
748  if ($a_mode == "create")
749  {
750  $ilCtrl->setParameter($this, "new_type", "wiki");
751  }
752 
753  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
754  }
755 
756  function getSettingsFormValues($a_mode = "edit")
757  {
758  global $lng, $ilUser;
759 
760  // set values
761  if ($a_mode == "create")
762  {
763  //$values["startpage"] = $lng->txt("wiki_main_page");
764  $values["rating_new"] = true;
765 
766  $values["rating_overall"] = ilObject::hasAutoRating("wiki", $_GET["ref_id"]);
767 
768  $this->form_gui->setValuesByArray($values);
769  }
770  else
771  {
772  $values["online"] = $this->object->getOnline();
773  $values["title"] = $this->object->getTitle();
774  //$values["startpage"] = $this->object->getStartPage();
775  $values["startpage_id"] = ilWikiPage::_getPageIdForWikiTitle($this->object->getId(), $this->object->getStartPage());
776  $values["shorttitle"] = $this->object->getShortTitle();
777  $values["description"] = $this->object->getLongDescription();
778  $values["rating_overall"] = $this->object->getRatingOverall();
779  $values["rating"] = $this->object->getRating();
780  // $values["rating_side"] = $this->object->getRatingAsBlock();
781  $values["rating_new"] = $this->object->getRatingForNewPages();
782  $values["rating_ext"] = $this->object->getRatingCategories();
783  $values["public_notes"] = $this->object->getPublicNotes();
784  $values["intro"] = $this->object->getIntroduction();
785 // $values["imp_pages"] = $this->object->getImportantPages();
786  $values["page_toc"] = $this->object->getPageToc();
787 
788  // only set given values (because of adv. metadata)
789  $this->form_gui->setValuesByArray($values, true);
790  }
791  }
792 
793 
798  {
799  global $ilCtrl, $lng, $ilUser, $ilSetting;
800 
801  $this->checkPermission("write");
802 
803  $this->initSettingsForm();
804 
805  if ($this->form_gui->checkInput())
806  {
807  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")) &&
808  $this->form_gui->getInput("shorttitle") != $this->object->getShortTitle())
809  {
810  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
811  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
812  }
813  else
814  {
815  $this->object->setTitle($this->form_gui->getInput("title"));
816  $this->object->setDescription($this->form_gui->getInput("description"));
817  $this->object->setOnline($this->form_gui->getInput("online"));
818  $this->object->setStartPage(ilWikiPage::lookupTitle($this->form_gui->getInput("startpage_id")));
819  $this->object->setShortTitle($this->form_gui->getInput("shorttitle"));
820  $this->object->setRatingOverall($this->form_gui->getInput("rating_overall"));
821  $this->object->setRating($this->form_gui->getInput("rating"));
822  // $this->object->setRatingAsBlock($this->form_gui->getInput("rating_side"));
823  $this->object->setRatingForNewPages($this->form_gui->getInput("rating_new"));
824  $this->object->setRatingCategories($this->form_gui->getInput("rating_ext"));
825 
826  if (!$ilSetting->get("disable_comments"))
827  {
828  $this->object->setPublicNotes($this->form_gui->getInput("public_notes"));
829  }
830  $this->object->setIntroduction($this->form_gui->getInput("intro"));
831 // $this->object->setImportantPages($this->form_gui->getInput("imp_pages"));
832  $this->object->setPageToc($this->form_gui->getInput("page_toc"));
833  $this->object->update();
834 
835  // update metadata record selection
836  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
837  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_REC_SELECTION,'wiki',$this->object->getId(), "wpg");
838  $record_gui->saveSelection();
839 
840  // Update ecs export settings
841  include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
842  $ecs = new ilECSWikiSettings($this->object);
843  if($ecs->handleSettingsUpdate())
844  {
845  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
846  $ilCtrl->redirect($this, "editSettings");
847  }
848  }
849  }
850 
851  $this->form_gui->setValuesByPost();
852  $this->tpl->setContent($this->form_gui->getHTML());
853  }
854 
859  {
860  global $tpl, $ilTabs;
861 
862  $this->checkPermission("write");
863  $ilTabs->activateTab("wiki_contributors");
864 
865  include_once("./Modules/Wiki/classes/class.ilWikiContributorsTableGUI.php");
866 
867  $table_gui = new ilWikiContributorsTableGUI($this, "listContributors",
868  $this->object->getId());
869 
870  $tpl->setContent($table_gui->getHTML());
871 
872  $this->setSideBlock();
873  }
874 
878  function saveGradingObject()
879  {
880  global $ilCtrl, $lng;
881 
882  $this->checkPermission("write");
883 
884  $users = (is_array($_POST["user_id"])
885  ? $_POST["user_id"]
886  : array());
887 
888  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
889  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
890  $saved = false;
891  foreach($users as $user_id)
892  {
893  if ($user_id != "")
894  {
895  $marks_obj = new ilLPMarks($this->object->getId(),$user_id);
896  $new_mark = ilUtil::stripSlashes($_POST['mark'][$user_id]);
897  $new_comment = ilUtil::stripSlashes($_POST['lcomment'][$user_id]);
898  $new_status = ilUtil::stripSlashes($_POST["status"][$user_id]);
899 
900  if ($marks_obj->getMark() != $new_mark ||
901  $marks_obj->getComment() != $new_comment ||
902  ilWikiContributor::_lookupStatus($this->object->getId(), $user_id) != $new_status)
903  {
904  ilWikiContributor::_writeStatus($this->object->getId(), $user_id, $new_status);
905  $marks_obj->setMark($new_mark);
906  $marks_obj->setComment($new_comment);
907  $marks_obj->update();
908  $saved = true;
909  }
910  }
911  }
912  if ($saved)
913  {
914  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
915  }
916 
917  $ilCtrl->redirect($this, "listContributors");
918  }
919 
920  // add wiki to locator
921  function addLocatorItems()
922  {
923  global $ilLocator;
924 
925  if (is_object($this->object))
926  {
927  $ilLocator->addItem($this->object->getTitle(),
928  $this->getGotoLink($this->object->getRefId()), "", $_GET["ref_id"]);
929  }
930  }
931 
932  public static function _goto($a_target)
933  {
934  global $ilAccess, $ilErr, $lng, $ilNavigationHistory;
935 
936  $i = strpos($a_target, "_");
937  if ($i > 0)
938  {
939  $a_page = substr($a_target, $i+1);
940  $a_target = substr($a_target, 0, $i);
941  }
942 
943  if ($a_target == "wpage")
944  {
945  $a_page_arr = explode("_", $a_page);
946  $wpg_id = (int) $a_page_arr[0];
947  $ref_id = (int) $a_page_arr[1];
948  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
949  $w_id = ilWikiPage::lookupWikiId($wpg_id);
950  if ($ref_id > 0)
951  {
952  $refs = array($ref_id);
953  }
954  else
955  {
956  $refs = ilObject::_getAllReferences($w_id);
957  }
958  foreach ($refs as $r)
959  {
960  if ($ilAccess->checkAccess("read", "", $r))
961  {
962  $a_target = $r;
963  $a_page = ilWikiPage::lookupTitle($wpg_id);
964  }
965  }
966  }
967 
968  if ($ilAccess->checkAccess("read", "", $a_target))
969  {
970  $_GET["cmd"] = "viewPage";
971  $_GET["ref_id"] = $a_target;
972  $_GET["page"] = $a_page;
973  $_GET["baseClass"] = "ilwikihandlergui";
974  $_GET["cmdClass"] = "ilobjwikigui";
975 /* if ($a_page != "")
976  {
977  $add = "&amp;page=".rawurlencode($_GET["page"]);
978  $ilNavigationHistory->addItem($_GET["ref_id"],
979  "./goto.php?target=wiki_".$_GET["ref_id"].$add, "wiki");
980  }*/
981  include("ilias.php");
982  exit;
983  }
984  else if ($ilAccess->checkAccess("visible", "", $a_target))
985  {
986  ilObjectGUI::_gotoRepositoryNode($tarr[0], "infoScreen");
987  }
988  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
989  {
990  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
993  }
994 
995  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
996  }
997 
1001  static function getGotoLink($a_ref_id, $a_page = "")
1002  {
1003  if ($a_page == "")
1004  {
1006  }
1007 
1008  $goto = "goto.php?target=wiki_".$a_ref_id."_".
1009  ilWikiUtil::makeUrlTitle($a_page);
1010 
1011  return $goto;
1012  }
1013 
1017  function viewPageObject()
1018  {
1019  global $lng, $ilCtrl, $tpl, $ilTabs, $ilAccess;
1020 
1021  $this->checkPermission("read");
1022 
1023  $ilTabs->clearTargets();
1024  $tpl->setHeaderActionMenu(null);
1025 
1026  $page = ($_GET["page"] != "")
1027  ? $_GET["page"]
1028  : $this->object->getStartPage();
1029  $_GET["page"] = $page;
1030 
1031  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1032  if (!ilWikiPage::exists($this->object->getId(), $page))
1033  {
1034  $page = $this->object->getStartPage();
1035  }
1036 
1037  if (!ilWikiPage::exists($this->object->getId(), $page))
1038  {
1039  ilUtil::sendInfo($lng->txt("wiki_no_start_page"), true);
1040  $ilCtrl->redirect($this, "infoScreen");
1041  return;
1042  }
1043 
1044  // page exists, show it !
1045  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($page));
1046 
1047  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
1048  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
1049  ilWikiUtil::makeDbTitle($page), 0, $this->object->getRefId());
1050  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1051  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
1052  $this->object->getStyleSheetId(), "wiki"));
1053 
1054  $this->setContentStyleSheet();
1055  //$wpage_gui->setOutputMode(IL_PAGE_PREVIEW);
1056 
1057  //$wpage_gui->setSideBlock();
1058  $ilCtrl->setCmdClass("ilwikipagegui");
1059  $ilCtrl->setCmd("preview");
1060  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
1061  (!$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()) ||
1062  $wpage_gui->getPageObject()->getBlocked()
1063  ))
1064  {
1065  $wpage_gui->setEnableEditing(false);
1066  }
1067 
1068  // alter title and description
1069  //$tpl->setTitle($wpage_gui->getPageObject()->getTitle());
1070  //$tpl->setDescription($this->object->getTitle());
1071 
1072 
1073  $html = $ilCtrl->forwardCommand($wpage_gui);
1074  //$this->addPageTabs();
1075 
1076  $tpl->setContent($html);
1077  }
1078 
1082  function allPagesObject()
1083  {
1084  global $tpl;
1085 
1086  $this->checkPermission("read");
1087 
1088  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1089 
1090  $this->addPagesSubTabs();
1091 
1092  $table_gui = new ilWikiPagesTableGUI($this, "allPages",
1093  $this->object->getId(), IL_WIKI_ALL_PAGES);
1094 
1095  $this->setSideBlock();
1096  $tpl->setContent($table_gui->getHTML());
1097  }
1098 
1103  {
1104  global $tpl;
1105 
1106  $this->checkPermission("read");
1107 
1108  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1109 
1110  $this->addPagesSubTabs();
1111 
1112  $table_gui = new ilWikiPagesTableGUI($this, "popularPages",
1113  $this->object->getId(), IL_WIKI_POPULAR_PAGES);
1114 
1115  $this->setSideBlock();
1116  $tpl->setContent($table_gui->getHTML());
1117  }
1118 
1123  {
1124  global $tpl;
1125 
1126  $this->checkPermission("read");
1127 
1128  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1129 
1130  $this->addPagesSubTabs();
1131 
1132  $table_gui = new ilWikiPagesTableGUI($this, "orphanedPages",
1133  $this->object->getId(), IL_WIKI_ORPHANED_PAGES);
1134 
1135  $this->setSideBlock();
1136  $tpl->setContent($table_gui->getHTML());
1137  }
1138 
1144  function gotoPageObject($a_page = "")
1145  {
1146  global $ilCtrl;
1147 
1148  if ($a_page == "")
1149  {
1150  $a_page = $_GET["page"];
1151  }
1152 
1153  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1154  if (ilWikiPage::_wikiPageExists($this->object->getId(),
1155  ilWikiUtil::makeDbTitle($a_page)))
1156  {
1157  // to do: get rid of this redirect
1158  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $a_page));
1159  }
1160  else
1161  {
1162  if (!$this->object->getTemplateSelectionOnCreation())
1163  {
1164  $this->object->createWikiPage($a_page);
1165 
1166  // redirect to newly created page
1167  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1168  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1169  }
1170  else
1171  {
1172  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
1173  $ilCtrl->setParameter($this, "from_page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
1174  $ilCtrl->redirect($this, "showTemplateSelection");
1175  }
1176  }
1177  }
1178 
1184  function randomPageObject()
1185  {
1186  $this->checkPermission("read");
1187 
1188  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1189  $page = ilWikiPage::getRandomPage($this->object->getId());
1190  $this->gotoPageObject($page);
1191  }
1192 
1197  {
1198  global $tpl;
1199 
1200  $this->checkPermission("read");
1201 
1202  include_once("./Modules/Wiki/classes/class.ilWikiRecentChangesTableGUI.php");
1203 
1204  $this->addPagesSubTabs();
1205 
1206  $table_gui = new ilWikiRecentChangesTableGUI($this, "recentChanges",
1207  $this->object->getId());
1208 
1209  $this->setSideBlock();
1210  $tpl->setContent($table_gui->getHTML());
1211  }
1212 
1216  function setSideBlock($a_wpg_id = 0)
1217  {
1218  ilObjWikiGUI::renderSideBlock($a_wpg_id, $this->object->getRefId());
1219  }
1220 
1221 
1225  static function renderSideBlock($a_wpg_id, $a_wiki_ref_id, $a_wp = null)
1226  {
1227  global $tpl, $lng;
1228 
1229  if ($a_wpg_id > 0 && !$a_wp)
1230  {
1231  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1232  $a_wp = ilWikiPage($a_wpg_id);
1233  }
1234 
1235  // search block
1236  include_once("./Modules/Wiki/classes/class.ilWikiSearchBlockGUI.php");
1237  $wiki_search_block = new ilWikiSearchBlockGUI();
1238  $rcontent = $wiki_search_block->getHTML();
1239 
1240  // quick navigation
1241  if ($a_wpg_id > 0)
1242  {
1243 // include_once("./Modules/Wiki/classes/class.ilWikiSideBlockGUI.php");
1244 // $wiki_side_block = new ilWikiSideBlockGUI();
1245 // $wiki_side_block->setPageObject($a_wp);
1246 // $rcontent.= $wiki_side_block->getHTML();
1247 
1248  // rating
1249  $wiki_id =ilObject::_lookupObjId($a_wiki_ref_id);
1250  if(ilObjWiki::_lookupRating($wiki_id) &&
1251  // ilObjWiki::_lookupRatingAsBlock($wiki_id) &&
1252  $a_wp->getRating())
1253  {
1254  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
1255  $rgui = new ilRatingGUI();
1256  $rgui->setObject($wiki_id, "wiki", $a_wpg_id, "wpg");
1257  $rgui->enableCategories(ilObjWiki::_lookupRatingCategories($wiki_id));
1258  $rgui->setYourRatingText("#");
1259  $rcontent .= $rgui->getBlockHTML($lng->txt("wiki_rate_page"));
1260  }
1261 
1262  // advanced metadata
1263  include_once("./Modules/Wiki/classes/class.ilWikiAdvMetaDataBlockGUI.php");
1265  {
1266  $rec_ids = ilWikiAdvMetaDataBlockGUI::getRecords($wiki_id);
1267  foreach($rec_ids as $record)
1268  {
1269  $advmd_pages_block = new ilWikiAdvMetaDataBlockGUI($record);
1270  $advmd_pages_block->setObject($a_wiki_ref_id, $wiki_id, $a_wpg_id);
1271  $rcontent.= $advmd_pages_block->getHTML();
1272  }
1273  }
1274  }
1275 
1276  // important pages
1277 // if (ilObjWiki::_lookupImportantPages(ilObject::_lookupObjId($a_wiki_ref_id)))
1278 // {
1279  include_once("./Modules/Wiki/classes/class.ilWikiImportantPagesBlockGUI.php");
1280  $imp_pages_block = new ilWikiImportantPagesBlockGUI();
1281  $rcontent.= $imp_pages_block->getHTML();
1282 // }
1283 
1284  // wiki functions block
1285  if ($a_wpg_id > 0)
1286  {
1287  include_once("./Modules/Wiki/classes/class.ilWikiFunctionsBlockGUI.php");
1288  $wiki_functions_block = new ilWikiFunctionsBlockGUI();
1289  $wiki_functions_block->setPageObject($a_wp);
1290  $rcontent .= $wiki_functions_block->getHTML();
1291  }
1292 
1293  $tpl->setRightContent($rcontent);
1294  }
1295 
1299  function newPagesObject()
1300  {
1301  global $tpl;
1302 
1303  $this->checkPermission("read");
1304 
1305  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1306 
1307  $this->addPagesSubTabs();
1308 
1309  $table_gui = new ilWikiPagesTableGUI($this, "newPages",
1310  $this->object->getId(), IL_WIKI_NEW_PAGES);
1311 
1312  $this->setSideBlock();
1313  $tpl->setContent($table_gui->getHTML());
1314  }
1315 
1316  protected function getPrintPageIds()
1317  {
1318  // multiple ordered page ids
1319  if(is_array($_POST["wordr"]))
1320  {
1321  asort($_POST["wordr"]);
1322  $page_ids = array_keys($_POST["wordr"]);
1323  }
1324  // single page
1325  else if((int)$_GET["wpg_id"])
1326  {
1327  $page_ids = array((int)$_GET["wpg_id"]);
1328  }
1329 
1330  return $page_ids;
1331  }
1332 
1333  public function printViewObject($a_pdf_export = false)
1334  {
1335  global $tpl;
1336 
1337  $page_ids = $this->getPrintPageIds();
1338  if(!$page_ids)
1339  {
1340  $this->ctrl->redirect($this, "");
1341  }
1342 
1343  $tpl = new ilTemplate("tpl.main.html", true, true);
1344  $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
1345  $this->setContentStyleSheet($tpl);
1346 
1347  // syntax style
1348  $tpl->setCurrentBlock("SyntaxStyle");
1349  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1351  $tpl->parseCurrentBlock();
1352 
1353 
1354  // determine target frames for internal links
1355 
1356  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
1357 
1358  $page_content = "";
1359 
1360  foreach ($page_ids as $p_id)
1361  {
1362  $page_gui = new ilWikiPageGUI($p_id);
1363  $page_gui->setOutputMode("print");
1364  $page_content.= $page_gui->showPage();
1365 
1366  if($a_pdf_export)
1367  {
1368  $page_content .= '<p style="page-break-after:always;"></p>';
1369  }
1370  }
1371 
1372  $page_content = '<div class="ilInvisibleBorder">'.$page_content.'</div>';
1373 
1374  if(!$a_pdf_export)
1375  {
1376  $page_content .= '<script type="text/javascript" language="javascript1.2">
1377  <!--
1378  il.Util.addOnLoad(function () {
1379  il.Util.print();
1380  });
1381  //-->
1382  </script>';
1383  }
1384 
1385  $tpl->setVariable("CONTENT", $page_content);
1386 
1387  if(!$a_pdf_export)
1388  {
1389  $tpl->show(false);
1390  exit;
1391  }
1392  else
1393  {
1394  return $tpl->get("DEFAULT", false, false, false, true, false, false);
1395  }
1396  }
1397 
1398  public function pdfExportObject()
1399  {
1400  $html = $this->printViewObject(true);
1401 
1402  // :TODO: fixing css dummy parameters
1403  $html = preg_replace("/\?dummy\=[0-9]+/", "", $html);
1404  $html = preg_replace("/\?vers\=[0-9A-Za-z\-]+/", "", $html);
1405 
1406  include_once "Services/PDFGeneration/classes/class.ilPDFGeneration.php";
1407  include_once "Services/PDFGeneration/classes/class.ilPDFGenerationJob.php";
1408 
1409  $job = new ilPDFGenerationJob();
1410  $job->setAutoPageBreak(true)
1411  ->setMarginLeft("10")
1412  ->setMarginRight("10")
1413  ->setMarginTop("10")
1414  ->setMarginBottom("10")
1415  ->setOutputMode("D") // download
1416  ->setFilename("wiki.pdf") // :TODO:
1417  ->setCreator("ILIAS Wiki") // :TODO:
1418  ->setImageScale(1.25) // complete content scaling ?!
1419  ->addPage($html);
1420 
1421  ilPDFGeneration::doJob($job);
1422  }
1423 
1428  {
1429  global $tpl, $ilTabs, $ilCtrl, $lng;
1430 
1431  $this->checkPermission("read");
1432 
1433  include_once("./Modules/Wiki/classes/class.ilWikiSearchResultsTableGUI.php");
1434 
1435  $ilTabs->setTabActive("wiki_search_results");
1436 
1437  if (trim($_POST["search_term"]) == "")
1438  {
1439  ilUtil::sendFailure($lng->txt("wiki_please_enter_search_term"), true);
1440  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1441  }
1442 
1443  $search_results = ilObjWiki::_performSearch($this->object->getId(),
1444  ilUtil::stripSlashes($_POST["search_term"]));
1445  $table_gui = new ilWikiSearchResultsTableGUI($this, "performSearch",
1446  $this->object->getId(), $search_results, $_POST["search_term"]);
1447 
1448  $this->setSideBlock();
1449  $tpl->setContent($table_gui->getHTML());
1450  }
1451 
1455  function setContentStyleSheet($a_tpl = null)
1456  {
1457  global $tpl;
1458 
1459  if ($a_tpl != null)
1460  {
1461  $ctpl = $a_tpl;
1462  }
1463  else
1464  {
1465  $ctpl = $tpl;
1466  }
1467 
1468  $ctpl->setCurrentBlock("ContentStyle");
1469  $ctpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1470  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
1471  $ctpl->parseCurrentBlock();
1472 
1473  }
1474 
1475 
1480  {
1481  global $ilTabs, $tpl;
1482 
1483  $this->checkPermission("write");
1484 
1485  $this->initStylePropertiesForm();
1486  $tpl->setContent($this->form->getHTML());
1487 
1488  $ilTabs->activateTab("settings");
1489  $this->setSettingsSubTabs("style");
1490 
1491  $this->setSideBlock();
1492  }
1493 
1498  {
1499  global $ilCtrl, $lng, $ilTabs, $ilSetting;
1500 
1501  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1502  $lng->loadLanguageModule("style");
1503 
1504  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1505  $this->form = new ilPropertyFormGUI();
1506 
1507  $fixed_style = $ilSetting->get("fixed_content_style_id");
1508  $style_id = $this->object->getStyleSheetId();
1509 
1510  if ($fixed_style > 0)
1511  {
1512  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1513  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
1514  $this->lng->txt("global_fixed").")");
1515  $this->form->addItem($st);
1516  }
1517  else
1518  {
1519  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
1520  $_GET["ref_id"]);
1521 
1522  $st_styles[0] = $this->lng->txt("default");
1523  ksort($st_styles);
1524 
1525  if ($style_id > 0)
1526  {
1527  // individual style
1528  if (!ilObjStyleSheet::_lookupStandard($style_id))
1529  {
1530  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1531  $st->setValue(ilObject::_lookupTitle($style_id));
1532  $this->form->addItem($st);
1533 
1534 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
1535 
1536  // delete command
1537  $this->form->addCommandButton("editStyle",
1538  $lng->txt("style_edit_style"));
1539  $this->form->addCommandButton("deleteStyle",
1540  $lng->txt("style_delete_style"));
1541 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
1542  }
1543  }
1544 
1545  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
1546  {
1547  $style_sel = ilUtil::formSelect ($style_id, "style_id",
1548  $st_styles, false, true);
1549  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
1550  $style_sel->setOptions($st_styles);
1551  $style_sel->setValue($style_id);
1552  $this->form->addItem($style_sel);
1553 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
1554  $this->form->addCommandButton("saveStyleSettings",
1555  $lng->txt("save"));
1556  $this->form->addCommandButton("createStyle",
1557  $lng->txt("sty_create_ind_style"));
1558  }
1559  }
1560  $this->form->setTitle($lng->txt("wiki_style"));
1561  $this->form->setFormAction($ilCtrl->getFormAction($this));
1562  }
1563 
1568  {
1569  global $ilCtrl;
1570 
1571  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
1572  }
1573 
1577  function editStyleObject()
1578  {
1579  global $ilCtrl;
1580 
1581  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
1582  }
1583 
1588  {
1589  global $ilCtrl;
1590 
1591  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
1592  }
1593 
1598  {
1599  global $ilSetting;
1600 
1601  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1602  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1603  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1604  || $this->object->getStyleSheetId() == 0))
1605  {
1606  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1607  $this->object->update();
1608  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1609  }
1610  $this->ctrl->redirect($this, "editStyleProperties");
1611  }
1612 
1613  //
1614  // Important pages
1615  //
1616 
1621  {
1622  global $tpl, $ilToolbar, $ilTabs, $lng, $ilCtrl;
1623 
1624  $this->checkPermission("write");
1625 
1626  ilUtil::sendInfo($lng->txt("wiki_navigation_info"));
1627 
1628  $ipages = ilObjWiki::_lookupImportantPagesList($this->object->getId());
1629  $ipages_ids = array();
1630  foreach ($ipages as $i)
1631  {
1632  $ipages_ids[] = $i["page_id"];
1633  }
1634 
1635  // list pages
1636  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1637  $pages = ilWikiPage::getAllPages($this->object->getId());
1638  $options = array("" => $lng->txt("please_select"));
1639  foreach ($pages as $p)
1640  {
1641  if (!in_array($p["id"], $ipages_ids))
1642  {
1643  $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
1644  }
1645  }
1646  if (count($options) > 0)
1647  {
1648  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1649  $si = new ilSelectInputGUI($lng->txt("wiki_pages"), "imp_page_id");
1650  $si->setOptions($options);
1651  $si->setInfo($lng->txt(""));
1652  $ilToolbar->addInputItem($si);
1653  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1654  $ilToolbar->addFormButton($lng->txt("add"), "addImportantPage");
1655  }
1656 
1657 
1658  $ilTabs->activateTab("settings");
1659  $this->setSettingsSubTabs("imp_pages");
1660 
1661  include_once("./Modules/Wiki/classes/class.ilImportantPagesTableGUI.php");
1662  $imp_table = new ilImportantPagesTableGUI($this, "editImportantPages");
1663 
1664  $tpl->setContent($imp_table->getHTML());
1665  }
1666 
1674  {
1675  global $ilCtrl, $lng;
1676 
1677  $this->checkPermission("write");
1678 
1679  if ($_POST["imp_page_id"] > 0)
1680  {
1681  $this->object->addImportantPage((int) $_POST["imp_page_id"]);
1682  ilUtil::sendSuccess($lng->txt("wiki_imp_page_added"), true);
1683  }
1684  $ilCtrl->redirect($this, "editImportantPages");
1685  }
1686 
1691  {
1692  global $ilCtrl, $tpl, $lng;
1693 
1694  if (!is_array($_POST["imp_page_id"]) || count($_POST["imp_page_id"]) == 0)
1695  {
1696  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
1697  $ilCtrl->redirect($this, "editImportantPages");
1698  }
1699  else
1700  {
1701  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1702  $cgui = new ilConfirmationGUI();
1703  $cgui->setFormAction($ilCtrl->getFormAction($this));
1704  $cgui->setHeaderText($lng->txt("wiki_sure_remove_imp_pages"));
1705  $cgui->setCancel($lng->txt("cancel"), "editImportantPages");
1706  $cgui->setConfirm($lng->txt("remove"), "removeImportantPages");
1707 
1708  foreach ($_POST["imp_page_id"] as $i)
1709  {
1710  $cgui->addItem("imp_page_id[]", $i, ilWikiPage::lookupTitle((int) $i));
1711  }
1712 
1713  $tpl->setContent($cgui->getHTML());
1714  }
1715  }
1716 
1724  {
1725  global $ilCtrl, $lng;
1726 
1727  $this->checkPermission("write");
1728 
1729  if (is_array($_POST["imp_page_id"]))
1730  {
1731  foreach ($_POST["imp_page_id"] as $i)
1732  {
1733  $this->object->removeImportantPage((int) $i);
1734  }
1735  }
1736  ilUtil::sendSuccess($lng->txt("wiki_removed_imp_pages"), true);
1737  $ilCtrl->redirect($this, "editImportantPages");
1738  }
1739 
1744  {
1745  global $ilCtrl, $lng;
1746 
1747  $this->checkPermission("write");
1748 
1749  $this->object->saveOrderingAndIndentation($_POST["ord"], $_POST["indent"]);
1750  ilUtil::sendSuccess($lng->txt("wiki_ordering_and_indent_saved"), true);
1751  $ilCtrl->redirect($this, "editImportantPages");
1752  }
1753 
1758  {
1759  global $ilCtrl, $lng;
1760 
1761  $this->checkPermission("write");
1762 
1763  if (!is_array($_POST["imp_page_id"]) || count($_POST["imp_page_id"]) != 1)
1764  {
1765  ilUtil::sendInfo($lng->txt("wiki_select_one_item"), true);
1766  }
1767  else
1768  {
1769  $this->object->removeImportantPage((int) $_POST["imp_page_id"][0]);
1770  $this->object->setStartPage(ilWikiPage::lookupTitle((int) $_POST["imp_page_id"][0]));
1771  $this->object->update();
1772  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1773  }
1774  $ilCtrl->redirect($this, "editImportantPages");
1775  }
1776 
1777 
1781  function exportHTML()
1782  {
1783  require_once("./Modules/Wiki/classes/class.ilWikiHTMLExport.php");
1784  $cont_exp = new ilWikiHTMLExport($this);
1785  $cont_exp->buildExportFile();
1786  }
1787 
1795  static function lookupSubObjectTitle($a_wiki_id, $a_page_id)
1796  {
1797  include_once "Modules/Wiki/classes/class.ilWikiPage.php";
1798  $page = new ilWikiPage($a_page_id);
1799  if($page->getWikiId() == $a_wiki_id)
1800  {
1801  return $page->getTitle();
1802  }
1803  }
1804 
1812  function getSubObjectTitle($a_id, $a_type)
1813  {
1814  include_once "Modules/Wiki/classes/class.ilWikiPage.php";
1815  return ilWikiPage::lookupTitle($a_id);
1816  }
1817 
1822  {
1823  global $lng, $tpl, $ilTabs, $ilCtrl;
1824 
1825 
1826  $ilCtrl->setParameterByClass("ilobjwikigui", "from_page", ilWikiUtil::makeUrlTitle($_GET["from_page"]));
1827  $ilTabs->clearTargets();
1828  ilUtil::sendInfo($lng->txt("wiki_page_not_exist_select_templ"));
1829 
1830  $form = $this->initTemplateSelectionForm();
1831  $tpl->setContent($form->getHTML());
1832  }
1833 
1837  public function initTemplateSelectionForm()
1838  {
1839  global $lng, $ilCtrl;
1840 
1841  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1842  $form = new ilPropertyFormGUI();
1843 
1844  // page name
1845  $hi = new ilHiddenInputGUI("page");
1846  $hi->setValue($_GET["page"]);
1847  $form->addItem($hi);
1848 
1849  // page template
1850  $radg = new ilRadioGroupInputGUI($lng->txt("wiki_page_template"), "page_templ");
1851  $radg->setRequired(true);
1852 
1853  if ($this->object->getEmptyPageTemplate())
1854  {
1855  $op1 = new ilRadioOption($lng->txt("wiki_empty_page"), 0);
1856  $radg->addOption($op1);
1857  }
1858 
1859  include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
1860  $wt = new ilWikiPageTemplate($this->object->getId());
1862  foreach ($ts as $t)
1863  {
1864  $op = new ilRadioOption($t["title"], $t["wpage_id"]);
1865  $radg->addOption($op);
1866  }
1867 
1868  $form->addItem($radg);
1869 
1870  // save and cancel commands
1871  $form->addCommandButton("createPageUsingTemplate", $lng->txt("wiki_create_page"));
1872  $form->addCommandButton("cancelCreationPageUsingTemplate", $lng->txt("cancel"));
1873 
1874  $form->setTitle($lng->txt("wiki_new_page").": ".$_GET["page"]);
1875  $form->setFormAction($ilCtrl->getFormAction($this));
1876 
1877  return $form;
1878  }
1879 
1884  {
1885  global $tpl, $lng, $ilCtrl;
1886 
1887  $form = $this->initTemplateSelectionForm();
1888  if ($form->checkInput())
1889  {
1890  $a_page = $_POST["page"];
1891  $this->object->createWikiPage($a_page, (int) $_POST["page_templ"]);
1892 
1893  // redirect to newly created page
1894  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1895  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1896 
1897  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1898  $ilCtrl->redirect($this, "");
1899  }
1900  else
1901  {
1902  $form->setValuesByPost();
1903  $tpl->setContent($form->getHtml());
1904  }
1905  }
1906 
1911  {
1912  global $ilCtrl;
1913 
1914  // redirect to newly created page
1915  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($_GET["from_page"])));
1916  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1917  }
1918 
1919 
1920 }
1921 
1922 ?>