ILIAS  Release_4_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 "./classes/class.ilObjectGUI.php";
5 require_once "./Modules/Wiki/classes/class.ilObjWiki.php";
6 
7 
19 {
24  function ilObjWikiGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
25  {
26  global $ilCtrl, $lng;
27 
28  $this->type = "wiki";
29  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
30  $lng->loadLanguageModule("wiki");
31 
32  if ($_GET["page"] != "")
33  {
34  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
35  }
36  }
37 
38  function &executeCommand()
39  {
40  global $ilUser, $ilCtrl, $tpl, $ilTabs, $ilAccess;
41 
42  $next_class = $this->ctrl->getNextClass($this);
43  $cmd = $this->ctrl->getCmd();
44 
45  $this->prepareOutput();
46 
47  switch($next_class)
48  {
49  case "ilinfoscreengui":
50  $this->checkPermission("visible");
51  $this->infoScreen(); // forwards command
52  break;
53 
54  case 'ilpermissiongui':
55  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
56  $perm_gui =& new ilPermissionGUI($this);
57  $ret =& $this->ctrl->forwardCommand($perm_gui);
58  break;
59 
60  case 'ilwikipagegui':
61  $this->checkPermission("read");
62  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
63  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
64  ilWikiUtil::makeDbTitle($_GET["page"]), $_GET["old_nr"]);
65  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
66  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
67  $this->object->getStyleSheetId(), "wiki"));
68  $this->setContentStyleSheet();
69 
70  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
71  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()))
72  {
73  $wpage_gui->setEnableEditing(false);
74  }
75  $ret = $this->ctrl->forwardCommand($wpage_gui);
76  if ($ret != "")
77  {
78  $tpl->setContent($ret);
79  }
80  break;
81 
82  case 'ilpublicuserprofilegui':
83  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
84  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
85  $ret = $this->ctrl->forwardCommand($profile_gui);
86  $tpl->setContent($ret);
87  break;
88 
89  case "ilobjstylesheetgui":
90  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
91  $this->ctrl->setReturn($this, "editStyleProperties");
92  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
93  $style_gui->omitLocator();
94  if ($cmd == "create" || $_GET["new_type"]=="sty")
95  {
96  $style_gui->setCreationMode(true);
97  }
98 
99  if ($cmd == "confirmedDelete")
100  {
101  $this->object->setStyleSheetId(0);
102  $this->object->update();
103  }
104 
105  $ret = $this->ctrl->forwardCommand($style_gui);
106 
107  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
108  {
109  $style_id = $ret;
110  $this->object->setStyleSheetId($style_id);
111  $this->object->update();
112  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
113  }
114  break;
115 
116  default:
117  if(!$cmd)
118  {
119  $cmd = "infoScreen";
120  }
121  $cmd .= "Object";
122  if ($cmd != "infoScreenObject")
123  {
124  $this->checkPermission("read");
125  }
126  else
127  {
128  $this->checkPermission("visible");
129  }
130  $this->$cmd();
131  break;
132  }
133 
134  return $ret;
135  }
136 
140  function viewObject()
141  {
142  $this->checkPermission("read");
143  $this->gotoStartPageObject();
144  }
145 
151  function createObject()
152  {
153  global $rbacsystem;
154 
155  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
156 
157  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
158  {
159  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
160  }
161  else
162  {
163  global $tpl;
164 
165  $this->initSettingsForm("create");
166  $this->getSettingsFormValues("create");
167  $tpl->setContent($this->form_gui->getHtml());
168  }
169  }
170 
171 
176  function saveObject()
177  {
178  global $rbacadmin, $tpl, $lng, $rbacsystem;
179 
180  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "wiki"))
181  {
182  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
183  }
184 
185  $this->initSettingsForm("create");
186  if ($this->form_gui->checkInput())
187  {
188  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")))
189  {
190  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
191  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
192  }
193  else
194  {
195  //
196  $_POST["Fobject"]["title"] = $this->form_gui->getInput("title");
197  $_POST["Fobject"]["desc"] = $this->form_gui->getInput("description");
198 
199  // create and insert forum in objecttree
200  $newObj = parent::saveObject();
201 
202  $newObj->setTitle($this->form_gui->getInput("title"));
203  $newObj->setDescription($this->form_gui->getInput("description"));
204  $newObj->setIntroduction($this->form_gui->getInput("intro"));
205  $newObj->setStartPage($this->form_gui->getInput("startpage"));
206  $newObj->setShortTitle($this->form_gui->getInput("shorttitle"));
207  $newObj->setRating($this->form_gui->getInput("rating"));
208  $newObj->setOnline($this->form_gui->getInput("online"));
209  $newObj->update();
210 
211  // setup rolefolder & default local roles
212  //$roles = $newObj->initDefaultRoles();
213 
214  // ...finally assign role to creator of object
215  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
216 
217  // add first page
218 
219 
220  // always send a message
221  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
222 
223  //ilUtil::redirect("ilias.php?baseClass=ilWikiHandlerGUI&ref_id=".$newObj->getRefId()."&cmd=editSettings");
224  ilUtil::redirect(ilObjWikiGUI::getGotoLink($newObj->getRefId()));
225  }
226  }
227 
228  $this->form_gui->setValuesByPost();
229  $tpl->setContent($this->form_gui->getHtml());
230  }
231 
237  function infoScreenObject()
238  {
239  $this->checkPermission("visible");
240  $this->ctrl->setCmd("showSummary");
241  $this->ctrl->setCmdClass("ilinfoscreengui");
242  $this->infoScreen();
243  }
244 
248  function infoScreen()
249  {
250  global $ilAccess, $ilUser, $lng;
251 
252  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId()))
253  {
254  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
255  }
256 
257  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
258  $info = new ilInfoScreenGUI($this);
259  $info->enablePrivateNotes();
260  if (trim($this->object->getIntroduction()) != "")
261  {
262  $info->addSection($lng->txt("wiki_introduction"));
263  $info->addProperty("", nl2br($this->object->getIntroduction()));
264  }
265 
266  // feedback from tutor; mark, status, comment
267  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
268  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
269  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
270  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
271  $status = ilWikiContributor::_lookupStatus($this->object->getId(), $ilUser->getId());
272  if ($lpcomment != "" || $mark != "" || $status != ilWikiContributor::STATUS_NOT_GRADED)
273  {
274  $info->addSection($this->lng->txt("wiki_feedback_from_tutor"));
275  if ($lpcomment != "")
276  {
277  $info->addProperty($this->lng->txt("wiki_comment"),
278  $lpcomment);
279  }
280  if ($mark != "")
281  {
282  $info->addProperty($this->lng->txt("wiki_mark"),
283  $mark);
284  }
285 
286  if ($status == ilWikiContributor::STATUS_PASSED)
287  {
288  $info->addProperty($this->lng->txt("status"),
289  $this->lng->txt("wiki_passed"));
290  }
291  if ($status == ilWikiContributor::STATUS_FAILED)
292  {
293  $info->addProperty($this->lng->txt("status"),
294  $this->lng->txt("wiki_failed"));
295  }
296  }
297 
298  /*
299  $info->enableNews();
300  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
301  {
302  //$info->enableNewsEditing();
303  $info->setBlockProperty("news", "settings", true);
304  }*/
305 
306  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
307  {
308  $info->addButton($lng->txt("wiki_start_page"), ilObjWikiGUI::getGotoLink($this->object->getRefId()));
309  }
310 
311  // general information
312  $this->lng->loadLanguageModule("meta");
313  $this->lng->loadLanguageModule("wiki");
314 
315  //$info->addSection($this->lng->txt("meta_general"));
316  //$info->addProperty($this->lng->txt("mcst_nr_items"),
317  // (int) count($med_items));
318 
319  // forward the command
320  $this->ctrl->forwardCommand($info);
321 
322  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
323  {
324  $this->setSideBlock();
325  }
326  }
327 
332  {
333  global $ilCtrl;
334 
335  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId()));
336  }
337 
341  function addPageTabs()
342  {
343  global $ilTabs, $ilCtrl;
344 
345  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
346  $ilCtrl->setParameter($this, "wpg_id",
347  ilWikiPage::getPageIdForTitle($this->object->getId(), ilWikiUtil::makeDbTitle($_GET["page"])));
348  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
349  $ilTabs->addTarget("wiki_what_links_here",
350  $this->ctrl->getLinkTargetByClass("ilwikipagegui",
351  "whatLinksHere"), "whatLinksHere");
352  $ilTabs->addTarget("wiki_print_view",
353  $this->ctrl->getLinkTarget($this,
354  "printView"), "printView");
355  }
356 
360  function addPagesSubTabs()
361  {
362  global $ilTabs, $ilCtrl;
363 
364  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
365  $ilCtrl->setParameter($this, "wpg_id",
366  ilWikiPage::getPageIdForTitle($this->object->getId(),
367  ilWikiUtil::makeDbTitle($_GET["page"])));
368  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
369  $ilTabs->addSubTabTarget("wiki_all_pages",
370  $this->ctrl->getLinkTarget($this, "allPages"), "allPages");
371  $ilTabs->addSubTabTarget("wiki_recent_changes",
372  $this->ctrl->getLinkTarget($this, "recentChanges"), "recentChanges");
373  $ilTabs->addSubTabTarget("wiki_new_pages",
374  $this->ctrl->getLinkTarget($this, "newPages"), "newPages");
375  $ilTabs->addSubTabTarget("wiki_popular_pages",
376  $this->ctrl->getLinkTarget($this, "popularPages"), "popularPages");
377  $ilTabs->addSubTabTarget("wiki_orphaned_pages",
378  $this->ctrl->getLinkTarget($this, "orphanedPages"), "orphanedPages");
379  }
380 
386  function getTabs($tabs_gui)
387  {
388  global $ilCtrl, $ilAccess, $lng;
389 
390  // wiki tabs
391  if (in_array($ilCtrl->getCmdClass(), array("", "ilobjwikigui",
392  "ilinfoscreengui", "ilpermissiongui")))
393  {
394  if ($_GET["page"] != "")
395  {
396  $tabs_gui->setBackTarget($lng->txt("wiki_last_visited_page"),
397  $this->getGotoLink($_GET["ref_id"],
398  ilWikiUtil::makeDbTitle($_GET["page"])));
399  }
400 
401  // info screen
402  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
403  {
404  $force_active = ($ilCtrl->getNextClass() == "ilinfoscreengui"
405  || $_GET["cmd"] == "infoScreen")
406  ? true
407  : false;
408  $tabs_gui->addTarget("info_short",
409  $this->ctrl->getLinkTargetByClass(
410  "ilinfoscreengui", "showSummary"),
411  "showSummary",
412  "", "", $force_active);
413  }
414 
415  // settings
416  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
417  {
418  $tabs_gui->addTarget("settings",
419  $this->ctrl->getLinkTarget($this, "editSettings"), array("editSettings"),
420  array(strtolower(get_class($this)), ""));
421  }
422 
423  // pages
424  if ($ilAccess->checkAccess('read', "", $this->object->getRefId()))
425  {
426  $tabs_gui->addTarget("wiki_pages",
427  $this->ctrl->getLinkTarget($this, "allPages"),
428  "allPages");
429  }
430 
431  // contributors
432  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
433  {
434  $tabs_gui->addTarget("wiki_contributors",
435  $this->ctrl->getLinkTarget($this, "listContributors"), array("listContributors"),
436  array(strtolower(get_class($this)), ""));
437  }
438 
439  // edit permissions
440  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
441  {
442  $tabs_gui->addTarget("perm_settings",
443  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), array("perm","info","owner"), 'ilpermissiongui');
444  }
445  }
446  }
447 
451  function setSettingsSubTabs($a_active)
452  {
453  global $ilTabs, $ilCtrl, $lng;
454 
455  if (in_array($a_active,
456  array("general_settings", "style")))
457  {
458  // general properties
459  $ilTabs->addSubTab("general_settings",
460  $lng->txt("wiki_general_settings"),
461  $ilCtrl->getLinkTarget($this, 'editSettings'));
462 
463  // style properties
464  $ilTabs->addSubTab("style",
465  $lng->txt("wiki_style"),
466  $ilCtrl->getLinkTarget($this, 'editStyleProperties'));
467 
468  $ilTabs->activateSubTab($a_active);
469  }
470  }
471 
476  {
477  global $tpl;
478 
479  $this->checkPermission("write");
480 
481  $this->setSettingsSubTabs("general_settings");
482 
483  $this->initSettingsForm();
484  $this->getSettingsFormValues();
485 
486  $tpl->setContent($this->form_gui->getHtml());
487  $this->setSideBlock();
488  }
489 
493  function initSettingsForm($a_mode = "edit")
494  {
495  global $tpl, $lng, $ilCtrl;
496 
497  $lng->loadLanguageModule("wiki");
498 
499  include("Services/Form/classes/class.ilPropertyFormGUI.php");
500  $this->form_gui = new ilPropertyFormGUI();
501 
502  // Title
503  $tit = new ilTextInputGUI($lng->txt("title"), "title");
504  $tit->setRequired(true);
505  $this->form_gui->addItem($tit);
506 
507  // Short Title
508  // The problem with the short title is, that it is per object
509  // and can't be a substitute for a ref id in the permanent link
510 /*
511  $stit = new ilRegExpInputGUI($lng->txt("wiki_short_title"), "shorttitle");
512  $stit->setPattern("/^[^0-9][^ _\&]+$/");
513  $stit->setRequired(false);
514  $stit->setNoMatchMessage($lng->txt("wiki_msg_short_name_regexp")." &amp; _");
515  $stit->setSize(20);
516  $stit->setMaxLength(20);
517  $stit->setInfo($lng->txt("wiki_short_title_desc2"));
518  $this->form_gui->addItem($stit);
519 */
520 
521  // Description
522  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
523  $this->form_gui->addItem($des);
524 
525  // Introduction
526  $intro = new ilTextAreaInputGUI($lng->txt("wiki_introduction"), "intro");
527  $intro->setCols(40);
528  $intro->setRows(4);
529  $this->form_gui->addItem($intro);
530 
531  // Start Page
532  $sp = new ilTextInputGUI($lng->txt("wiki_start_page"), "startpage");
533  $sp->setMaxLength(200);
534  $sp->setRequired(true);
535  $this->form_gui->addItem($sp);
536 
537  // Online
538  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
539  $this->form_gui->addItem($online);
540 
541  $rating = new ilCheckboxInputGUI($lng->txt("wiki_activate_rating"), "rating");
542  $this->form_gui->addItem($rating);
543 
544  // Form action and save button
545  $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_wiki.gif"));
546  if ($a_mode != "create")
547  {
548  $this->form_gui->setTitle($lng->txt("wiki_settings"));
549  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
550  }
551  else
552  {
553  $this->form_gui->setTitle($lng->txt("wiki_new"));
554  $this->form_gui->addCommandButton("save", $lng->txt("wiki_add"));
555  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
556  }
557 
558  // set values
559  if ($a_mode == "create")
560  {
561  $ilCtrl->setParameter($this, "new_type", "wiki");
562  }
563 
564  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
565  }
566 
567  function getSettingsFormValues($a_mode = "edit")
568  {
569  global $lng;
570 
571  // set values
572  if ($a_mode == "create")
573  {
574  $values["startpage"] = $lng->txt("wiki_main_page");
575  $this->form_gui->setValuesByArray($values);
576  }
577  else
578  {
579  $values["online"] = $this->object->getOnline();
580  $values["title"] = $this->object->getTitle();
581  $values["startpage"] = $this->object->getStartPage();
582  $values["shorttitle"] = $this->object->getShortTitle();
583  $values["description"] = $this->object->getDescription();
584  $values["rating"] = $this->object->getRating();
585  $values["intro"] = $this->object->getIntroduction();
586  $this->form_gui->setValuesByArray($values);
587  }
588  }
589 
590 
595  {
596  global $ilCtrl, $lng;
597 
598  $this->checkPermission("write");
599 
600  $this->initSettingsForm();
601 
602  if ($this->form_gui->checkInput())
603  {
604  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")) &&
605  $this->form_gui->getInput("shorttitle") != $this->object->getShortTitle())
606  {
607  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
608  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
609  }
610  else
611  {
612  $this->object->setTitle($this->form_gui->getInput("title"));
613  $this->object->setDescription($this->form_gui->getInput("description"));
614  $this->object->setOnline($this->form_gui->getInput("online"));
615  $this->object->setStartPage($this->form_gui->getInput("startpage"));
616  $this->object->setShortTitle($this->form_gui->getInput("shorttitle"));
617  $this->object->setRating($this->form_gui->getInput("rating"));
618  $this->object->setIntroduction($this->form_gui->getInput("intro"));
619  $this->object->update();
620 
621  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
622  $ilCtrl->redirect($this, "editSettings");
623  }
624  }
625 
626  $this->form_gui->setValuesByPost();
627  $this->tpl->setContent($this->form_gui->getHTML());
628  }
629 
634  {
635  global $tpl;
636 
637  $this->checkPermission("write");
638 
639  include_once("./Modules/Wiki/classes/class.ilWikiContributorsTableGUI.php");
640 
641  $table_gui = new ilWikiContributorsTableGUI($this, "listContributors",
642  $this->object->getId());
643 
644  $tpl->setContent($table_gui->getHTML());
645 
646  $this->setSideBlock();
647  }
648 
652  function saveGradingObject()
653  {
654  global $ilCtrl, $lng;
655 
656  $this->checkPermission("write");
657 
658  $users = (is_array($_POST["sel_user_id"]))
659  ? $_POST["sel_user_id"]
660  : (is_array($_POST["user_id"])
661  ? $_POST["user_id"]
662  : array());
663 
664  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
665  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
666  $saved = false;
667  foreach($users as $user_id)
668  {
669  if ($user_id != "")
670  {
671  ilWikiContributor::_writeStatus($this->object->getId(), $user_id,
672  ilUtil::stripSlashes($_POST["status"][$user_id]));
673  $marks_obj = new ilLPMarks($this->object->getId(),$user_id);
674  $marks_obj->setMark(ilUtil::stripSlashes($_POST['mark'][$user_id]));
675  $marks_obj->setComment(ilUtil::stripSlashes($_POST['lcomment'][$user_id]));
676  $marks_obj->update();
677  $saved = true;
678  }
679  }
680  if ($saved)
681  {
682  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
683  }
684 
685  $ilCtrl->redirect($this, "listContributors");
686  }
687 
688  // add wiki to locator
689  function addLocatorItems()
690  {
691  global $ilLocator;
692 
693  if (is_object($this->object))
694  {
695  $ilLocator->addItem($this->object->getTitle(),
696  $this->getGotoLink($this->object->getRefId()), "", $_GET["ref_id"]);
697  }
698  }
699 
700  function _goto($a_target)
701  {
702  global $ilAccess, $ilErr, $lng, $ilNavigationHistory;
703 
704  $i = strpos($a_target, "_");
705  if ($i > 0)
706  {
707  $a_page = substr($a_target, $i+1);
708  $a_target = substr($a_target, 0, $i);
709  }
710 
711  if ($ilAccess->checkAccess("read", "", $a_target))
712  {
713  $_GET["cmd"] = "viewPage";
714  $_GET["ref_id"] = $a_target;
715  $_GET["page"] = $a_page;
716  $_GET["baseClass"] = "ilwikihandlergui";
717  $_GET["cmdClass"] = "ilobjwikigui";
718 /* if ($a_page != "")
719  {
720  $add = "&amp;page=".rawurlencode($_GET["page"]);
721  $ilNavigationHistory->addItem($_GET["ref_id"],
722  "./goto.php?target=wiki_".$_GET["ref_id"].$add, "wiki");
723  }*/
724  include("ilias.php");
725  exit;
726  }
727  else if ($ilAccess->checkAccess("visible", "", $a_target))
728  {
729  $_GET["cmd"] = "infoScreen";
730  $_GET["ref_id"] = $tarr[0];
731  include("repository.php");
732  exit;
733  }
734  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
735  {
736  $_GET["cmd"] = "frameset";
737  $_GET["target"] = "";
738  $_GET["ref_id"] = ROOT_FOLDER_ID;
739  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
741  include("repository.php");
742  exit;
743  }
744 
745  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
746  }
747 
751  static function getGotoLink($a_ref_id, $a_page = "")
752  {
753  if ($a_page == "")
754  {
756  }
757 
758  $goto = "./goto.php?target=wiki_".$a_ref_id."_".
759  ilWikiUtil::makeUrlTitle($a_page);
760 
761  return $goto;
762  }
763 
767  function viewPageObject()
768  {
769  global $lng, $ilCtrl, $tpl, $ilTabs, $ilAccess;
770 
771  $this->checkPermission("read");
772 
773  $ilTabs->clearTargets();
774 
775  $page = ($_GET["page"] != "")
776  ? $_GET["page"]
777  : $this->object->getStartPage();
778  $_GET["page"] = $page;
779 
780  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
781  if (!ilWikiPage::exists($this->object->getId(), $page))
782  {
783  $page = $this->object->getStartPage();
784  }
785 
786  if (!ilWikiPage::exists($this->object->getId(), $page))
787  {
788  ilUtil::sendInfo($lng->txt("wiki_no_start_page"), true);
789  $ilCtrl->redirect($this, "infoScreen");
790  return;
791  }
792 
793  // page exists, show it !
794  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($page));
795 
796  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
797  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
798  ilWikiUtil::makeDbTitle($page));
799  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
800  $wpage_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
801  $this->object->getStyleSheetId(), "wiki"));
802 
803  $this->setContentStyleSheet();
804  //$wpage_gui->setOutputMode(IL_PAGE_PREVIEW);
805 
806  //$wpage_gui->setSideBlock();
807  $ilCtrl->setCmdClass("ilwikipagegui");
808  $ilCtrl->setCmd("preview");
809  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
810  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()))
811  {
812  $wpage_gui->setEnableEditing(false);
813  }
814 
815  $html = $ilCtrl->forwardCommand($wpage_gui);
816  //$this->addPageTabs();
817 
818  $tpl->setContent($html);
819  }
820 
824  function allPagesObject()
825  {
826  global $tpl;
827 
828  $this->checkPermission("read");
829 
830  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
831 
832  $this->addPagesSubTabs();
833 
834  $table_gui = new ilWikiPagesTableGUI($this, "allPages",
835  $this->object->getId(), IL_WIKI_ALL_PAGES);
836 
837  $this->setSideBlock();
838  $tpl->setContent($table_gui->getHTML());
839  }
840 
845  {
846  global $tpl, $ilTabs;
847 
848  $this->checkPermission("read");
849 
850  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
851 
852  $this->addPagesSubTabs();
853  $ilTabs->setTabActive("wiki_pages");
854 
855  $table_gui = new ilWikiPagesTableGUI($this, "popularPages",
856  $this->object->getId(), IL_WIKI_POPULAR_PAGES);
857 
858  $this->setSideBlock();
859  $tpl->setContent($table_gui->getHTML());
860  }
861 
866  {
867  global $tpl, $ilTabs;
868 
869  $this->checkPermission("read");
870 
871  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
872 
873  $this->addPagesSubTabs();
874  $ilTabs->setTabActive("wiki_pages");
875 
876  $table_gui = new ilWikiPagesTableGUI($this, "orphanedPages",
877  $this->object->getId(), IL_WIKI_ORPHANED_PAGES);
878 
879  $this->setSideBlock();
880  $tpl->setContent($table_gui->getHTML());
881  }
882 
888  function gotoPageObject($a_page = "")
889  {
890  global $ilCtrl;
891 
892  if ($a_page == "")
893  {
894  $a_page = $_GET["page"];
895  }
896 
897  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
898  if (ilWikiPage::_wikiPageExists($this->object->getId(),
899  ilWikiUtil::makeDbTitle($a_page)))
900  {
901  // to do: get rid of this redirect
902  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $a_page));
903  }
904  else
905  {
906  // create the page
907  $page = new ilWikiPage();
908  $page->setWikiId($this->object->getId());
909  $page->setTitle(ilWikiUtil::makeDbTitle($_GET["page"]));
910  $page->create();
911 
912  // redirect to newly created page
913  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
914  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
915  }
916  }
917 
923  function randomPageObject()
924  {
925  $this->checkPermission("read");
926 
927  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
928  $page = ilWikiPage::getRandomPage($this->object->getId());
929  $this->gotoPageObject($page);
930  }
931 
936  {
937  global $tpl, $ilTabs;
938 
939  $this->checkPermission("read");
940 
941  include_once("./Modules/Wiki/classes/class.ilWikiRecentChangesTableGUI.php");
942 
943  $this->addPagesSubTabs();
944  $ilTabs->setTabActive("wiki_pages");
945 
946  $table_gui = new ilWikiRecentChangesTableGUI($this, "recentChanges",
947  $this->object->getId());
948 
949  $this->setSideBlock();
950  $tpl->setContent($table_gui->getHTML());
951  }
952 
953  function setSideBlock($a_wpg_id = 0)
954  {
955  global $tpl;
956 
957  // side block
958  include_once("./Modules/Wiki/classes/class.ilWikiSideBlockGUI.php");
959  $wiki_side_block = new ilWikiSideBlockGUI();
960  if ($a_wpg_id > 0)
961  {
962  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
963  $wiki_side_block->setPageObject(new ilWikiPage($a_wpg_id));
964  }
965 
966  // search block
967  include_once("./Modules/Wiki/classes/class.ilWikiSearchBlockGUI.php");
968  $wiki_search_block = new ilWikiSearchBlockGUI();
969  $rcontent = $wiki_side_block->getHTML().$wiki_search_block->getHTML();
970  $tpl->setRightContent($rcontent);
971  }
972 
976  function newPagesObject()
977  {
978  global $tpl, $ilTabs;
979 
980  $this->checkPermission("read");
981 
982  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
983 
984  $this->addPagesSubTabs();
985  $ilTabs->setTabActive("wiki_pages");
986 
987  $table_gui = new ilWikiPagesTableGUI($this, "newPages",
988  $this->object->getId(), IL_WIKI_NEW_PAGES);
989 
990  $this->setSideBlock();
991  $tpl->setContent($table_gui->getHTML());
992  }
993 
997  function printViewObject()
998  {
999  $this->checkPermission("read");
1000 
1001  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
1002  $page_gui = new ilWikiPageGUI($_GET["wpg_id"]);
1003  $tpl = new ilTemplate("tpl.main.html", true, true);
1004  $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
1005  $this->setContentStyleSheet();
1006 
1007  // syntax style
1008  $this->tpl->setCurrentBlock("SyntaxStyle");
1009  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
1011  $this->tpl->parseCurrentBlock();
1012 
1013 
1014  // determine target frames for internal links
1015  $page_gui->setOutputMode("print");
1016  $page_content = $page_gui->showPage();
1017  $tpl->setVariable("CONTENT", '<div class="ilInvisibleBorder">'.$page_content.'</div>'.
1018  '<script type="text/javascript" language="javascript1.2">
1019  <!--
1020  // Do print the page
1021  if (typeof(window.print) != \'undefined\')
1022  {
1023  window.print();
1024  }
1025  //-->
1026  </script>');
1027  $tpl->show(false);
1028  exit;
1029  }
1030 
1035  {
1036  global $tpl, $ilTabs, $ilCtrl, $lng;
1037 
1038  $this->checkPermission("read");
1039 
1040  include_once("./Modules/Wiki/classes/class.ilWikiSearchResultsTableGUI.php");
1041 
1042  $ilTabs->setTabActive("wiki_search_results");
1043 
1044  if (trim($_POST["search_term"]) == "")
1045  {
1046  ilUtil::sendFailure($lng->txt("wiki_please_enter_search_term"), true);
1047  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1048  }
1049 
1050  $search_results = ilObjWiki::_performSearch($this->object->getId(),
1051  ilUtil::stripSlashes($_POST["search_term"]));
1052  $table_gui = new ilWikiSearchResultsTableGUI($this, "performSearch",
1053  $this->object->getId(), $search_results);
1054 
1055  $this->setSideBlock();
1056  $tpl->setContent($table_gui->getHTML());
1057  }
1058 
1063  {
1064  global $tpl;
1065 
1066  $tpl->setCurrentBlock("ContentStyle");
1067  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1068  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
1069  $tpl->parseCurrentBlock();
1070 
1071  }
1072 
1073 
1078  {
1079  global $ilTabs, $tpl;
1080 
1081  $this->checkPermission("write");
1082 
1083  $this->initStylePropertiesForm();
1084  $tpl->setContent($this->form->getHTML());
1085 
1086  $ilTabs->activateTab("settings");
1087  $this->setSettingsSubTabs("style");
1088 
1089  $this->setSideBlock();
1090  }
1091 
1096  {
1097  global $ilCtrl, $lng, $ilTabs, $ilSetting;
1098 
1099  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1100  $lng->loadLanguageModule("style");
1101 
1102  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1103  $this->form = new ilPropertyFormGUI();
1104 
1105  $fixed_style = $ilSetting->get("fixed_content_style_id");
1106  $style_id = $this->object->getStyleSheetId();
1107 
1108  if ($fixed_style > 0)
1109  {
1110  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1111  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
1112  $this->lng->txt("global_fixed").")");
1113  $this->form->addItem($st);
1114  }
1115  else
1116  {
1117  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
1118  $_GET["ref_id"]);
1119 
1120  $st_styles[0] = $this->lng->txt("default");
1121  ksort($st_styles);
1122 
1123  if ($style_id > 0)
1124  {
1125  // individual style
1126  if (!ilObjStyleSheet::_lookupStandard($style_id))
1127  {
1128  $st = new ilNonEditableValueGUI($lng->txt("style_current_style"));
1129  $st->setValue(ilObject::_lookupTitle($style_id));
1130  $this->form->addItem($st);
1131 
1132 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "edit"));
1133 
1134  // delete command
1135  $this->form->addCommandButton("editStyle",
1136  $lng->txt("style_edit_style"));
1137  $this->form->addCommandButton("deleteStyle",
1138  $lng->txt("style_delete_style"));
1139 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "delete"));
1140  }
1141  }
1142 
1143  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
1144  {
1145  $style_sel = ilUtil::formSelect ($style_id, "style_id",
1146  $st_styles, false, true);
1147  $style_sel = new ilSelectInputGUI($lng->txt("style_current_style"), "style_id");
1148  $style_sel->setOptions($st_styles);
1149  $style_sel->setValue($style_id);
1150  $this->form->addItem($style_sel);
1151 //$this->ctrl->getLinkTargetByClass("ilObjStyleSheetGUI", "create"));
1152  $this->form->addCommandButton("saveStyleSettings",
1153  $lng->txt("save"));
1154  $this->form->addCommandButton("createStyle",
1155  $lng->txt("sty_create_ind_style"));
1156  }
1157  }
1158  $this->form->setTitle($lng->txt("wiki_style"));
1159  $this->form->setFormAction($ilCtrl->getFormAction($this));
1160  }
1161 
1166  {
1167  global $ilCtrl;
1168 
1169  $ilCtrl->redirectByClass("ilobjstylesheetgui", "create");
1170  }
1171 
1175  function editStyleObject()
1176  {
1177  global $ilCtrl;
1178 
1179  $ilCtrl->redirectByClass("ilobjstylesheetgui", "edit");
1180  }
1181 
1186  {
1187  global $ilCtrl;
1188 
1189  $ilCtrl->redirectByClass("ilobjstylesheetgui", "delete");
1190  }
1191 
1196  {
1197  global $ilSetting;
1198 
1199  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1200  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1201  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1202  || $this->object->getStyleSheetId() == 0))
1203  {
1204  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1205  $this->object->update();
1206  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1207  }
1208  $this->ctrl->redirect($this, "editStyleProperties");
1209  }
1210 
1211 }
1212 ?>