ILIAS  Release_4_1_x_branch Revision 61804
 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 "./classes/class.ilObjectGUI.php";
5 require_once "./Modules/Wiki/classes/class.ilObjWiki.php";
6 
7 
20 {
25  function ilObjWikiGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
26  {
27  global $ilCtrl, $lng;
28 
29  $this->type = "wiki";
30  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
31  $lng->loadLanguageModule("wiki");
32 
33  if ($_GET["page"] != "")
34  {
35  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
36  }
37  }
38 
39  function executeCommand()
40  {
41  global $ilUser, $ilCtrl, $tpl, $ilTabs, $ilAccess;
42 
43  $next_class = $this->ctrl->getNextClass($this);
44  $cmd = $this->ctrl->getCmd();
45 
46  $this->prepareOutput();
47 
48  switch($next_class)
49  {
50  case "ilinfoscreengui":
51  $this->checkPermission("visible");
52  $this->infoScreen(); // forwards command
53  break;
54 
55  case 'ilpermissiongui':
56  $ilTabs->activateTab("perm_settings");
57  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
58  $perm_gui =& new ilPermissionGUI($this);
59  $ret =& $this->ctrl->forwardCommand($perm_gui);
60  break;
61 
62  case 'ilwikipagegui':
63  $this->checkPermission("read");
64  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
65  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
66  ilWikiUtil::makeDbTitle($_GET["page"]), $_GET["old_nr"], $this->object->getRefId());
67  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
68  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
69  $this->object->getStyleSheetId(), "wiki"));
70  $this->setContentStyleSheet();
71 
72  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
73  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()))
74  {
75  $wpage_gui->setEnableEditing(false);
76  }
77  $ret = $this->ctrl->forwardCommand($wpage_gui);
78  if ($ret != "")
79  {
80  $tpl->setContent($ret);
81  }
82  break;
83 
84  case 'ilpublicuserprofilegui':
85  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
86  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
87  $ret = $this->ctrl->forwardCommand($profile_gui);
88  $tpl->setContent($ret);
89  break;
90 
91  case "ilobjstylesheetgui":
92  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
93  $this->ctrl->setReturn($this, "editStyleProperties");
94  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
95  $style_gui->omitLocator();
96  if ($cmd == "create" || $_GET["new_type"]=="sty")
97  {
98  $style_gui->setCreationMode(true);
99  }
100 
101  if ($cmd == "confirmedDelete")
102  {
103  $this->object->setStyleSheetId(0);
104  $this->object->update();
105  }
106 
107  $ret = $this->ctrl->forwardCommand($style_gui);
108 
109  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
110  {
111  $style_id = $ret;
112  $this->object->setStyleSheetId($style_id);
113  $this->object->update();
114  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
115  }
116  break;
117 
118  case "ilexportgui":
119 // $this->prepareOutput();
120  $ilTabs->activateTab("export");
121  include_once("./Services/Export/classes/class.ilExportGUI.php");
122  $exp_gui = new ilExportGUI($this);
123  $exp_gui->addFormat("xml");
124  $ret = $this->ctrl->forwardCommand($exp_gui);
125 // $this->tpl->show();
126  break;
127 
128 
129  default:
130  if(!$cmd)
131  {
132  $cmd = "infoScreen";
133  }
134  $cmd .= "Object";
135  if ($cmd != "infoScreenObject")
136  {
137  $this->checkPermission("read");
138  }
139  else
140  {
141  $this->checkPermission("visible");
142  }
143  $this->$cmd();
144  break;
145  }
146 
147  return $ret;
148  }
149 
153  function viewObject()
154  {
155  $this->checkPermission("read");
156  $this->gotoStartPageObject();
157  }
158 
164  function createObject()
165  {
166  global $rbacsystem;
167 
168  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
169 
170  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
171  {
172  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
173  }
174  else
175  {
176  global $tpl;
177 
178  $this->initSettingsForm("create");
179  $this->getSettingsFormValues("create");
180  $html1 = $this->form_gui->getHtml();
181 
182  $this->initImportForm("wiki");
183  $html2 = $this->form->getHTML();
184 
185  $tpl->setContent($html1."<br/><br/>".$html2);
186  }
187  }
188 
194  public function initImportForm($a_new_type = "")
195  {
196  global $lng, $ilCtrl;
197 
198  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
199  $this->form = new ilPropertyFormGUI();
200  $this->form->setTarget("_top");
201 
202  // Import file
203  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
204  $fi = new ilFileInputGUI($lng->txt("import_file"), "importfile");
205  $fi->setSuffixes(array("zip"));
206  $this->form->addItem($fi);
207 
208  $this->form->addCommandButton("importFile", $lng->txt("import"));
209  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
210  $this->form->setTitle($lng->txt($a_new_type."_import"));
211 
212  $this->form->setFormAction($ilCtrl->getFormAction($this));
213  }
214 
220  function importFileObject()
221  {
222  global $rbacsystem, $objDefinition, $tpl, $lng;
223 
224  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
225 
226  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
227  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
228  {
229  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
230  }
231  $this->ctrl->setParameter($this, "new_type", $new_type);
232  $this->initImportForm($new_type);
233  if ($this->form->checkInput())
234  {
235  // todo: make some check on manifest file
236  include_once("./Services/Export/classes/class.ilImport.php");
237  $imp = new ilImport((int) $_GET['ref_id']);
238  $new_id = $imp->importObject($newObj, $_FILES["importfile"]["tmp_name"],
239  $_FILES["importfile"]["name"], $new_type);
240 
241  // put new object id into tree
242  if ($new_id > 0)
243  {
244  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
245  $newObj->createReference();
246  $newObj->putInTree($_GET["ref_id"]);
247  $newObj->setPermissions($_GET["ref_id"]);
248  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
249  $this->afterSave($newObj);
250  }
251  return;
252  }
253 
254  $this->form->setValuesByPost();
255  $tpl->setContent($this->form->getHtml());
256  }
257 
262  function afterSave($newObj)
263  {
264  // always send a message
265  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
266 
267  ilUtil::redirect(ilObjWikiGUI::getGotoLink($newObj->getRefId()));
268  }
269 
274  function saveObject()
275  {
276  global $rbacadmin, $tpl, $lng, $rbacsystem;
277 
278  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "wiki"))
279  {
280  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
281  }
282 
283  $this->initSettingsForm("create");
284  if ($this->form_gui->checkInput())
285  {
286  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")))
287  {
288  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
289  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
290  }
291  else
292  {
293  //
294  $_POST["Fobject"]["title"] = $this->form_gui->getInput("title");
295  $_POST["Fobject"]["desc"] = $this->form_gui->getInput("description");
296 
297  // create and insert forum in objecttree
298  $newObj = parent::saveObject();
299 
300  $newObj->setTitle($this->form_gui->getInput("title"));
301  $newObj->setDescription($this->form_gui->getInput("description"));
302  $newObj->setIntroduction($this->form_gui->getInput("intro"));
303  $newObj->setStartPage($this->form_gui->getInput("startpage"));
304  $newObj->setShortTitle($this->form_gui->getInput("shorttitle"));
305  $newObj->setRating($this->form_gui->getInput("rating"));
306  $newObj->setOnline($this->form_gui->getInput("online"));
307  $newObj->update();
308 
309  // add first page
310 
311 
312  // always send a message
313  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
314 
315  //ilUtil::redirect("ilias.php?baseClass=ilWikiHandlerGUI&ref_id=".$newObj->getRefId()."&cmd=editSettings");
316  ilUtil::redirect(ilObjWikiGUI::getGotoLink($newObj->getRefId()));
317  }
318  }
319 
320  $this->form_gui->setValuesByPost();
321  $tpl->setContent($this->form_gui->getHtml());
322  }
323 
329  function infoScreenObject()
330  {
331  $this->checkPermission("visible");
332  $this->ctrl->setCmd("showSummary");
333  $this->ctrl->setCmdClass("ilinfoscreengui");
334  $this->infoScreen();
335  }
336 
340  function infoScreen()
341  {
342  global $ilAccess, $ilUser, $ilTabs, $lng;
343 
344  $ilTabs->activateTab("info_short");
345 
346  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId()))
347  {
348  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
349  }
350 
351  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
352  $info = new ilInfoScreenGUI($this);
353  $info->enablePrivateNotes();
354  if (trim($this->object->getIntroduction()) != "")
355  {
356  $info->addSection($lng->txt("wiki_introduction"));
357  $info->addProperty("", nl2br($this->object->getIntroduction()));
358  }
359 
360  // feedback from tutor; mark, status, comment
361  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
362  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
363  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
364  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
365  $status = ilWikiContributor::_lookupStatus($this->object->getId(), $ilUser->getId());
366  if ($lpcomment != "" || $mark != "" || $status != ilWikiContributor::STATUS_NOT_GRADED)
367  {
368  $info->addSection($this->lng->txt("wiki_feedback_from_tutor"));
369  if ($lpcomment != "")
370  {
371  $info->addProperty($this->lng->txt("wiki_comment"),
372  $lpcomment);
373  }
374  if ($mark != "")
375  {
376  $info->addProperty($this->lng->txt("wiki_mark"),
377  $mark);
378  }
379 
380  if ($status == ilWikiContributor::STATUS_PASSED)
381  {
382  $info->addProperty($this->lng->txt("status"),
383  $this->lng->txt("wiki_passed"));
384  }
385  if ($status == ilWikiContributor::STATUS_FAILED)
386  {
387  $info->addProperty($this->lng->txt("status"),
388  $this->lng->txt("wiki_failed"));
389  }
390  }
391 
392  /*
393  $info->enableNews();
394  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
395  {
396  //$info->enableNewsEditing();
397  $info->setBlockProperty("news", "settings", true);
398  }*/
399 
400  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
401  {
402  $info->addButton($lng->txt("wiki_start_page"), ilObjWikiGUI::getGotoLink($this->object->getRefId()));
403  }
404 
405  // general information
406  $this->lng->loadLanguageModule("meta");
407  $this->lng->loadLanguageModule("wiki");
408 
409  //$info->addSection($this->lng->txt("meta_general"));
410  //$info->addProperty($this->lng->txt("mcst_nr_items"),
411  // (int) count($med_items));
412 
413  // forward the command
414  $this->ctrl->forwardCommand($info);
415 
416  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
417  {
418 // $this->setSideBlock();
419  }
420  }
421 
426  {
427  global $ilCtrl;
428 
429  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId()));
430  }
431 
435  function addPageTabs()
436  {
437  global $ilTabs, $ilCtrl;
438 
439  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
440  $ilCtrl->setParameter($this, "wpg_id",
441  ilWikiPage::getPageIdForTitle($this->object->getId(), ilWikiUtil::makeDbTitle($_GET["page"])));
442  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
443  $ilTabs->addTarget("wiki_what_links_here",
444  $this->ctrl->getLinkTargetByClass("ilwikipagegui",
445  "whatLinksHere"), "whatLinksHere");
446  //$ilTabs->addTarget("wiki_print_view",
447  // $this->ctrl->getLinkTarget($this,
448  // "printViewSelection"), "printViewSelection");
449  $ilTabs->addTarget("wiki_print_view",
450  $this->ctrl->getLinkTargetByClass("ilwikipagegui",
451  "printViewSelection"), "printViewSelection");
452  }
453 
457  function addPagesSubTabs()
458  {
459  global $ilTabs, $ilCtrl;
460 
461  $ilTabs->activateTab("wiki_pages");
462 
463  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
464  $ilCtrl->setParameter($this, "wpg_id",
465  ilWikiPage::getPageIdForTitle($this->object->getId(),
466  ilWikiUtil::makeDbTitle($_GET["page"])));
467  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
468  $ilTabs->addSubTabTarget("wiki_all_pages",
469  $this->ctrl->getLinkTarget($this, "allPages"), "allPages");
470  $ilTabs->addSubTabTarget("wiki_recent_changes",
471  $this->ctrl->getLinkTarget($this, "recentChanges"), "recentChanges");
472  $ilTabs->addSubTabTarget("wiki_new_pages",
473  $this->ctrl->getLinkTarget($this, "newPages"), "newPages");
474  $ilTabs->addSubTabTarget("wiki_popular_pages",
475  $this->ctrl->getLinkTarget($this, "popularPages"), "popularPages");
476  $ilTabs->addSubTabTarget("wiki_orphaned_pages",
477  $this->ctrl->getLinkTarget($this, "orphanedPages"), "orphanedPages");
478  }
479 
485  function getTabs($tabs_gui)
486  {
487  global $ilCtrl, $ilAccess, $ilTabs, $lng;
488 
489  // wiki tabs
490  if (in_array($ilCtrl->getCmdClass(), array("", "ilobjwikigui",
491  "ilinfoscreengui", "ilpermissiongui", "ilexportgui")))
492  {
493  if ($_GET["page"] != "")
494  {
495  $tabs_gui->setBackTarget($lng->txt("wiki_last_visited_page"),
496  $this->getGotoLink($_GET["ref_id"],
497  ilWikiUtil::makeDbTitle($_GET["page"])));
498  }
499 
500  // pages
501  if ($ilAccess->checkAccess('read', "", $this->object->getRefId()))
502  {
503  $ilTabs->addTab("wiki_pages",
504  $lng->txt("wiki_pages"),
505  $this->ctrl->getLinkTarget($this, "allPages"));
506  }
507 
508  // info screen
509  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
510  {
511  $ilTabs->addTab("info_short",
512  $lng->txt("info_short"),
513  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
514  }
515 
516  // settings
517  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
518  {
519  $ilTabs->addTab("settings",
520  $lng->txt("settings"),
521  $this->ctrl->getLinkTarget($this, "editSettings"));
522  }
523 
524  // contributors
525  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
526  {
527  $ilTabs->addTab("wiki_contributors",
528  $lng->txt("wiki_contributors"),
529  $this->ctrl->getLinkTarget($this, "listContributors"));
530  }
531 
532  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
533  {
534  $ilTabs->addTab("export",
535  $lng->txt("export"),
536  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
537  }
538 
539 
540  // edit permissions
541  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
542  {
543  $ilTabs->addTab("perm_settings",
544  $lng->txt("perm_settings"),
545  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
546  }
547  }
548  }
549 
553  function setSettingsSubTabs($a_active)
554  {
555  global $ilTabs, $ilCtrl, $lng;
556 
557  if (in_array($a_active,
558  array("general_settings", "style")))
559  {
560  // general properties
561  $ilTabs->addSubTab("general_settings",
562  $lng->txt("wiki_general_settings"),
563  $ilCtrl->getLinkTarget($this, 'editSettings'));
564 
565  // style properties
566  $ilTabs->addSubTab("style",
567  $lng->txt("wiki_style"),
568  $ilCtrl->getLinkTarget($this, 'editStyleProperties'));
569 
570  $ilTabs->activateSubTab($a_active);
571  }
572  }
573 
578  {
579  global $tpl;
580 
581  $this->checkPermission("write");
582 
583  $this->setSettingsSubTabs("general_settings");
584 
585  $this->initSettingsForm();
586  $this->getSettingsFormValues();
587 
588  $tpl->setContent($this->form_gui->getHtml());
589  $this->setSideBlock();
590  }
591 
595  function initSettingsForm($a_mode = "edit")
596  {
597  global $tpl, $lng, $ilCtrl, $ilTabs;
598 
599  $lng->loadLanguageModule("wiki");
600  $ilTabs->activateTab("settings");
601 
602  include("Services/Form/classes/class.ilPropertyFormGUI.php");
603  $this->form_gui = new ilPropertyFormGUI();
604 
605  // Title
606  $tit = new ilTextInputGUI($lng->txt("title"), "title");
607  $tit->setRequired(true);
608  $this->form_gui->addItem($tit);
609 
610  // Short Title
611  // The problem with the short title is, that it is per object
612  // and can't be a substitute for a ref id in the permanent link
613 /*
614  $stit = new ilRegExpInputGUI($lng->txt("wiki_short_title"), "shorttitle");
615  $stit->setPattern("/^[^0-9][^ _\&]+$/");
616  $stit->setRequired(false);
617  $stit->setNoMatchMessage($lng->txt("wiki_msg_short_name_regexp")." &amp; _");
618  $stit->setSize(20);
619  $stit->setMaxLength(20);
620  $stit->setInfo($lng->txt("wiki_short_title_desc2"));
621  $this->form_gui->addItem($stit);
622 */
623 
624  // Description
625  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
626  $this->form_gui->addItem($des);
627 
628  // Introduction
629  $intro = new ilTextAreaInputGUI($lng->txt("wiki_introduction"), "intro");
630  $intro->setCols(40);
631  $intro->setRows(4);
632  $this->form_gui->addItem($intro);
633 
634  // Start Page
635  $sp = new ilTextInputGUI($lng->txt("wiki_start_page"), "startpage");
636  $sp->setMaxLength(200);
637  $sp->setRequired(true);
638  $this->form_gui->addItem($sp);
639 
640  // Online
641  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
642  $this->form_gui->addItem($online);
643 
644  $rating = new ilCheckboxInputGUI($lng->txt("wiki_activate_rating"), "rating");
645  $this->form_gui->addItem($rating);
646 
647  // Form action and save button
648  $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_wiki.gif"));
649  if ($a_mode != "create")
650  {
651  $this->form_gui->setTitle($lng->txt("wiki_settings"));
652  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
653  }
654  else
655  {
656  $this->form_gui->setTitle($lng->txt("wiki_new"));
657  $this->form_gui->addCommandButton("save", $lng->txt("wiki_add"));
658  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
659  }
660 
661  // set values
662  if ($a_mode == "create")
663  {
664  $ilCtrl->setParameter($this, "new_type", "wiki");
665  }
666 
667  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
668  }
669 
670  function getSettingsFormValues($a_mode = "edit")
671  {
672  global $lng, $ilUser;
673 
674  // set values
675  if ($a_mode == "create")
676  {
677  $values["startpage"] = $lng->txt("wiki_main_page");
678  $this->form_gui->setValuesByArray($values);
679  }
680  else
681  {
682  $values["online"] = $this->object->getOnline();
683  $values["title"] = $this->object->getTitle();
684  $values["startpage"] = $this->object->getStartPage();
685  $values["shorttitle"] = $this->object->getShortTitle();
686  $values["description"] = $this->object->getDescription();
687  $values["rating"] = $this->object->getRating();
688  $values["intro"] = $this->object->getIntroduction();
689 
690  $this->form_gui->setValuesByArray($values);
691  }
692  }
693 
694 
699  {
700  global $ilCtrl, $lng, $ilUser;
701 
702  $this->checkPermission("write");
703 
704  $this->initSettingsForm();
705 
706  if ($this->form_gui->checkInput())
707  {
708  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")) &&
709  $this->form_gui->getInput("shorttitle") != $this->object->getShortTitle())
710  {
711  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
712  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
713  }
714  else
715  {
716  $this->object->setTitle($this->form_gui->getInput("title"));
717  $this->object->setDescription($this->form_gui->getInput("description"));
718  $this->object->setOnline($this->form_gui->getInput("online"));
719  $this->object->setStartPage($this->form_gui->getInput("startpage"));
720  $this->object->setShortTitle($this->form_gui->getInput("shorttitle"));
721  $this->object->setRating($this->form_gui->getInput("rating"));
722  $this->object->setIntroduction($this->form_gui->getInput("intro"));
723  $this->object->update();
724 
725  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
726  $ilCtrl->redirect($this, "editSettings");
727  }
728  }
729 
730  $this->form_gui->setValuesByPost();
731  $this->tpl->setContent($this->form_gui->getHTML());
732  }
733 
738  {
739  global $tpl, $ilTabs;
740 
741  $this->checkPermission("write");
742  $ilTabs->activateTab("wiki_contributors");
743 
744  include_once("./Modules/Wiki/classes/class.ilWikiContributorsTableGUI.php");
745 
746  $table_gui = new ilWikiContributorsTableGUI($this, "listContributors",
747  $this->object->getId());
748 
749  $tpl->setContent($table_gui->getHTML());
750 
751  $this->setSideBlock();
752  }
753 
757  function saveGradingObject()
758  {
759  global $ilCtrl, $lng;
760 
761  $this->checkPermission("write");
762 
763  $users = (is_array($_POST["sel_user_id"]))
764  ? $_POST["sel_user_id"]
765  : (is_array($_POST["user_id"])
766  ? $_POST["user_id"]
767  : array());
768 
769  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
770  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
771  $saved = false;
772  foreach($users as $user_id)
773  {
774  if ($user_id != "")
775  {
776  ilWikiContributor::_writeStatus($this->object->getId(), $user_id,
777  ilUtil::stripSlashes($_POST["status"][$user_id]));
778  $marks_obj = new ilLPMarks($this->object->getId(),$user_id);
779  $marks_obj->setMark(ilUtil::stripSlashes($_POST['mark'][$user_id]));
780  $marks_obj->setComment(ilUtil::stripSlashes($_POST['lcomment'][$user_id]));
781  $marks_obj->update();
782  $saved = true;
783  }
784  }
785  if ($saved)
786  {
787  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
788  }
789 
790  $ilCtrl->redirect($this, "listContributors");
791  }
792 
793  // add wiki to locator
794  function addLocatorItems()
795  {
796  global $ilLocator;
797 
798  if (is_object($this->object))
799  {
800  $ilLocator->addItem($this->object->getTitle(),
801  $this->getGotoLink($this->object->getRefId()), "", $_GET["ref_id"]);
802  }
803  }
804 
805  function _goto($a_target)
806  {
807  global $ilAccess, $ilErr, $lng, $ilNavigationHistory;
808 
809  $i = strpos($a_target, "_");
810  if ($i > 0)
811  {
812  $a_page = substr($a_target, $i+1);
813  $a_target = substr($a_target, 0, $i);
814  }
815 
816  if ($ilAccess->checkAccess("read", "", $a_target))
817  {
818  $_GET["cmd"] = "viewPage";
819  $_GET["ref_id"] = $a_target;
820  $_GET["page"] = $a_page;
821  $_GET["baseClass"] = "ilwikihandlergui";
822  $_GET["cmdClass"] = "ilobjwikigui";
823 /* if ($a_page != "")
824  {
825  $add = "&amp;page=".rawurlencode($_GET["page"]);
826  $ilNavigationHistory->addItem($_GET["ref_id"],
827  "./goto.php?target=wiki_".$_GET["ref_id"].$add, "wiki");
828  }*/
829  include("ilias.php");
830  exit;
831  }
832  else if ($ilAccess->checkAccess("visible", "", $a_target))
833  {
834  $_GET["cmd"] = "infoScreen";
835  $_GET["ref_id"] = $tarr[0];
836  include("repository.php");
837  exit;
838  }
839  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
840  {
841  $_GET["cmd"] = "frameset";
842  $_GET["target"] = "";
843  $_GET["ref_id"] = ROOT_FOLDER_ID;
844  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
846  include("repository.php");
847  exit;
848  }
849 
850  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
851  }
852 
856  static function getGotoLink($a_ref_id, $a_page = "")
857  {
858  if ($a_page == "")
859  {
861  }
862 
863  $goto = "goto.php?target=wiki_".$a_ref_id."_".
864  ilWikiUtil::makeUrlTitle($a_page);
865 
866  return $goto;
867  }
868 
872  function viewPageObject()
873  {
874  global $lng, $ilCtrl, $tpl, $ilTabs, $ilAccess;
875 
876  $this->checkPermission("read");
877 
878  $ilTabs->clearTargets();
879 
880  $page = ($_GET["page"] != "")
881  ? $_GET["page"]
882  : $this->object->getStartPage();
883  $_GET["page"] = $page;
884 
885  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
886  if (!ilWikiPage::exists($this->object->getId(), $page))
887  {
888  $page = $this->object->getStartPage();
889  }
890 
891  if (!ilWikiPage::exists($this->object->getId(), $page))
892  {
893  ilUtil::sendInfo($lng->txt("wiki_no_start_page"), true);
894  $ilCtrl->redirect($this, "infoScreen");
895  return;
896  }
897 
898  // page exists, show it !
899  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($page));
900 
901  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
902  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
903  ilWikiUtil::makeDbTitle($page), 0, $this->object->getRefId());
904  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
905  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
906  $this->object->getStyleSheetId(), "wiki"));
907 
908  $this->setContentStyleSheet();
909  //$wpage_gui->setOutputMode(IL_PAGE_PREVIEW);
910 
911  //$wpage_gui->setSideBlock();
912  $ilCtrl->setCmdClass("ilwikipagegui");
913  $ilCtrl->setCmd("preview");
914  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
915  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()))
916  {
917  $wpage_gui->setEnableEditing(false);
918  }
919 
920  $html = $ilCtrl->forwardCommand($wpage_gui);
921  //$this->addPageTabs();
922 
923  $tpl->setContent($html);
924  }
925 
929  function allPagesObject()
930  {
931  global $tpl;
932 
933  $this->checkPermission("read");
934 
935  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
936 
937  $this->addPagesSubTabs();
938 
939  $table_gui = new ilWikiPagesTableGUI($this, "allPages",
940  $this->object->getId(), IL_WIKI_ALL_PAGES);
941 
942  $this->setSideBlock();
943  $tpl->setContent($table_gui->getHTML());
944  }
945 
950  {
951  global $tpl;
952 
953  $this->checkPermission("read");
954 
955  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
956 
957  $this->addPagesSubTabs();
958 
959  $table_gui = new ilWikiPagesTableGUI($this, "popularPages",
960  $this->object->getId(), IL_WIKI_POPULAR_PAGES);
961 
962  $this->setSideBlock();
963  $tpl->setContent($table_gui->getHTML());
964  }
965 
970  {
971  global $tpl;
972 
973  $this->checkPermission("read");
974 
975  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
976 
977  $this->addPagesSubTabs();
978 
979  $table_gui = new ilWikiPagesTableGUI($this, "orphanedPages",
980  $this->object->getId(), IL_WIKI_ORPHANED_PAGES);
981 
982  $this->setSideBlock();
983  $tpl->setContent($table_gui->getHTML());
984  }
985 
991  function gotoPageObject($a_page = "")
992  {
993  global $ilCtrl;
994 
995  if ($a_page == "")
996  {
997  $a_page = $_GET["page"];
998  }
999 
1000  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1001  if (ilWikiPage::_wikiPageExists($this->object->getId(),
1002  ilWikiUtil::makeDbTitle($a_page)))
1003  {
1004  // to do: get rid of this redirect
1005  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $a_page));
1006  }
1007  else
1008  {
1009  // create the page
1010  $page = new ilWikiPage();
1011  $page->setWikiId($this->object->getId());
1012  $page->setTitle(ilWikiUtil::makeDbTitle($_GET["page"]));
1013  $page->create();
1014 
1015  // redirect to newly created page
1016  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1017  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1018  }
1019  }
1020 
1026  function randomPageObject()
1027  {
1028  $this->checkPermission("read");
1029 
1030  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1031  $page = ilWikiPage::getRandomPage($this->object->getId());
1032  $this->gotoPageObject($page);
1033  }
1034 
1039  {
1040  global $tpl;
1041 
1042  $this->checkPermission("read");
1043 
1044  include_once("./Modules/Wiki/classes/class.ilWikiRecentChangesTableGUI.php");
1045 
1046  $this->addPagesSubTabs();
1047 
1048  $table_gui = new ilWikiRecentChangesTableGUI($this, "recentChanges",
1049  $this->object->getId());
1050 
1051  $this->setSideBlock();
1052  $tpl->setContent($table_gui->getHTML());
1053  }
1054 
1055  function setSideBlock($a_wpg_id = 0)
1056  {
1057  global $tpl;
1058 
1059  // side block
1060  include_once("./Modules/Wiki/classes/class.ilWikiSideBlockGUI.php");
1061  $wiki_side_block = new ilWikiSideBlockGUI();
1062  if ($a_wpg_id > 0)
1063  {
1064  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1065  $wiki_side_block->setPageObject(new ilWikiPage($a_wpg_id));
1066  }
1067 
1068  // search block
1069  include_once("./Modules/Wiki/classes/class.ilWikiSearchBlockGUI.php");
1070  $wiki_search_block = new ilWikiSearchBlockGUI();
1071  $rcontent = $wiki_side_block->getHTML().$wiki_search_block->getHTML();
1072  $tpl->setRightContent($rcontent);
1073  }
1074 
1078  function newPagesObject()
1079  {
1080  global $tpl;
1081 
1082  $this->checkPermission("read");
1083 
1084  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
1085 
1086  $this->addPagesSubTabs();
1087 
1088  $table_gui = new ilWikiPagesTableGUI($this, "newPages",
1089  $this->object->getId(), IL_WIKI_NEW_PAGES);
1090 
1091  $this->setSideBlock();
1092  $tpl->setContent($table_gui->getHTML());
1093  }
1094 
1095 
1099  function printViewObject()
1100  {
1101  $this->checkPermission("read");
1102 
1103  switch ($_POST["sel_type"])
1104  {
1105  case "wiki":
1106  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1107  $pages = ilWikiPage::getAllPages($this->object->getId());
1108  foreach ($pages as $p)
1109  {
1110  $pg_ids[] = $p["id"];
1111  }
1112  break;
1113 
1114  case "selection":
1115  if (is_array($_POST["obj_id"]))
1116  {
1117  $pg_ids = $_POST["obj_id"];
1118  }
1119  else
1120  {
1121  $pg_ids[] = $_GET["wpg_id"];
1122  }
1123  break;
1124 
1125  default:
1126  $pg_ids[] = $_GET["wpg_id"];
1127  break;
1128  }
1129 
1130  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
1131 
1132  $tpl = new ilTemplate("tpl.main.html", true, true);
1133  $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
1134  $this->setContentStyleSheet($tpl);
1135 
1136  // syntax style
1137  $tpl->setCurrentBlock("SyntaxStyle");
1138  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1140  $tpl->parseCurrentBlock();
1141 
1142 
1143  // determine target frames for internal links
1144 
1145  foreach ($pg_ids as $p_id)
1146  {
1147  $page_gui = new ilWikiPageGUI($p_id);
1148  $page_gui->setOutputMode("print");
1149  $page_content.= $page_gui->showPage();
1150  }
1151  $tpl->setVariable("CONTENT", '<div class="ilInvisibleBorder">'.$page_content.'</div>'.
1152  '<script type="text/javascript" language="javascript1.2">
1153  <!--
1154  // Do print the page
1155  if (typeof(window.print) != \'undefined\')
1156  {
1157  window.print();
1158  }
1159  //-->
1160  </script>');
1161  $tpl->show(false);
1162  exit;
1163  }
1164 
1169  {
1170  global $tpl, $ilTabs, $ilCtrl, $lng;
1171 
1172  $this->checkPermission("read");
1173 
1174  include_once("./Modules/Wiki/classes/class.ilWikiSearchResultsTableGUI.php");
1175 
1176  $ilTabs->setTabActive("wiki_search_results");
1177 
1178  if (trim($_POST["search_term"]) == "")
1179  {
1180  ilUtil::sendFailure($lng->txt("wiki_please_enter_search_term"), true);
1181  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1182  }
1183 
1184  $search_results = ilObjWiki::_performSearch($this->object->getId(),
1185  ilUtil::stripSlashes($_POST["search_term"]));
1186  $table_gui = new ilWikiSearchResultsTableGUI($this, "performSearch",
1187  $this->object->getId(), $search_results);
1188 
1189  $this->setSideBlock();
1190  $tpl->setContent($table_gui->getHTML());
1191  }
1192 
1196  function setContentStyleSheet($a_tpl = null)
1197  {
1198  global $tpl;
1199 
1200  if ($a_tpl != null)
1201  {
1202  $ctpl = $a_tpl;
1203  }
1204  else
1205  {
1206  $ctpl = $tpl;
1207  }
1208 
1209  $ctpl->setCurrentBlock("ContentStyle");
1210  $ctpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1211  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
1212  $ctpl->parseCurrentBlock();
1213 
1214  }
1215 
1216 
1221  {
1222  global $ilTabs, $tpl;
1223 
1224  $this->checkPermission("write");
1225 
1226  $this->initStylePropertiesForm();
1227  $tpl->setContent($this->form->getHTML());
1228 
1229  $ilTabs->activateTab("settings");
1230  $this->setSettingsSubTabs("style");
1231 
1232  $this->setSideBlock();
1233  }
1234 
1239  {
1240  global $ilCtrl, $lng, $ilTabs, $ilSetting;
1241 
1242  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1243  $lng->loadLanguageModule("style");
1244 
1245  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1246  $this->form = new ilPropertyFormGUI();
1247 
1248  $fixed_style = $ilSetting->get("fixed_content_style_id");
1249  $style_id = $this->object->getStyleSheetId();
1250 
1251  if ($fixed_style > 0)
1252  {
1253  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1254  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
1255  $this->lng->txt("global_fixed").")");
1256  $this->form->addItem($st);
1257  }
1258  else
1259  {
1260  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
1261  $_GET["ref_id"]);
1262 
1263  $st_styles[0] = $this->lng->txt("default");
1264  ksort($st_styles);
1265 
1266  if ($style_id > 0)
1267  {
1268  // individual style
1269  if (!ilObjStyleSheet::_lookupStandard($style_id))
1270  {
1271  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1272  $st->setValue(ilObject::_lookupTitle($style_id));
1273  $this->form->addItem($st);
1274 
1275 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
1276 
1277  // delete command
1278  $this->form->addCommandButton("editStyle",
1279  $lng->txt("style_edit_style"));
1280  $this->form->addCommandButton("deleteStyle",
1281  $lng->txt("style_delete_style"));
1282 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
1283  }
1284  }
1285 
1286  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
1287  {
1288  $style_sel = ilUtil::formSelect ($style_id, "style_id",
1289  $st_styles, false, true);
1290  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
1291  $style_sel->setOptions($st_styles);
1292  $style_sel->setValue($style_id);
1293  $this->form->addItem($style_sel);
1294 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
1295  $this->form->addCommandButton("saveStyleSettings",
1296  $lng->txt("save"));
1297  $this->form->addCommandButton("createStyle",
1298  $lng->txt("sty_create_ind_style"));
1299  }
1300  }
1301  $this->form->setTitle($lng->txt("wiki_style"));
1302  $this->form->setFormAction($ilCtrl->getFormAction($this));
1303  }
1304 
1309  {
1310  global $ilCtrl;
1311 
1312  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
1313  }
1314 
1318  function editStyleObject()
1319  {
1320  global $ilCtrl;
1321 
1322  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
1323  }
1324 
1329  {
1330  global $ilCtrl;
1331 
1332  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
1333  }
1334 
1339  {
1340  global $ilSetting;
1341 
1342  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1343  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1344  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1345  || $this->object->getStyleSheetId() == 0))
1346  {
1347  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1348  $this->object->update();
1349  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1350  }
1351  $this->ctrl->redirect($this, "editStyleProperties");
1352  }
1353 
1354 }
1355 ?>