ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjWikiGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once "./classes/class.ilObjectGUI.php";
25 require_once "./Modules/Wiki/classes/class.ilObjWiki.php";
26 
27 
39 {
44  function ilObjWikiGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
45  {
46  global $ilCtrl, $lng;
47 
48  $this->type = "wiki";
49  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
50  $lng->loadLanguageModule("wiki");
51 
52  if ($_GET["page"] != "")
53  {
54  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
55  }
56  }
57 
58  function &executeCommand()
59  {
60  global $ilUser, $ilCtrl, $tpl, $ilTabs, $ilAccess;
61 
62  $next_class = $this->ctrl->getNextClass($this);
63  $cmd = $this->ctrl->getCmd();
64 
65  $this->prepareOutput();
66 
67  switch($next_class)
68  {
69  case "ilinfoscreengui":
70  $this->checkPermission("visible");
71  $this->infoScreen(); // forwards command
72  break;
73 
74  case 'ilpermissiongui':
75  include_once("./classes/class.ilPermissionGUI.php");
76  $perm_gui =& new ilPermissionGUI($this);
77  $ret =& $this->ctrl->forwardCommand($perm_gui);
78  break;
79 
80  case 'ilwikipagegui':
81  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
82  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
83  ilWikiUtil::makeDbTitle($_GET["page"]), $_GET["old_nr"]);
84 
85  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
86  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()))
87  {
88  $wpage_gui->setEnableEditing(false);
89  }
90  $ret = $this->ctrl->forwardCommand($wpage_gui);
91  if ($ret != "")
92  {
93  $tpl->setContent($ret);
94  }
95  break;
96 
97  case 'ilpublicuserprofilegui':
98  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
99  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
100  $ret = $this->ctrl->forwardCommand($profile_gui);
101  $tpl->setContent($ret);
102  break;
103 
104  default:
105  if(!$cmd)
106  {
107  $cmd = "infoScreen";
108  }
109  $cmd .= "Object";
110  if ($cmd != "infoScreenObject")
111  {
112  $this->checkPermission("read");
113  }
114  else
115  {
116  $this->checkPermission("visible");
117  }
118  $this->$cmd();
119  break;
120  }
121 
122  return $ret;
123  }
124 
128  function viewObject()
129  {
130  $this->checkPermission("read");
131  $this->gotoStartPageObject();
132  }
133 
139  function createObject()
140  {
141  global $rbacsystem;
142 
143  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
144 
145  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
146  {
147  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
148  }
149  else
150  {
151  global $tpl;
152 
153  $this->initSettingsForm("create");
154  $this->getSettingsFormValues("create");
155  $tpl->setContent($this->form_gui->getHtml());
156  }
157  }
158 
159 
164  function saveObject()
165  {
166  global $rbacadmin, $tpl, $lng, $rbacsystem;
167 
168  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "wiki"))
169  {
170  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
171  }
172 
173  $this->initSettingsForm("create");
174  if ($this->form_gui->checkInput())
175  {
176  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")))
177  {
178  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
179  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
180  }
181  else
182  {
183  //
184  $_POST["Fobject"]["title"] = $this->form_gui->getInput("title");
185  $_POST["Fobject"]["desc"] = $this->form_gui->getInput("description");
186 
187  // create and insert forum in objecttree
188  $newObj = parent::saveObject();
189 
190  $newObj->setTitle($this->form_gui->getInput("title"));
191  $newObj->setDescription($this->form_gui->getInput("description"));
192  $newObj->setIntroduction($this->form_gui->getInput("intro"));
193  $newObj->setStartPage($this->form_gui->getInput("startpage"));
194  $newObj->setShortTitle($this->form_gui->getInput("shorttitle"));
195  $newObj->setRating($this->form_gui->getInput("rating"));
196  $newObj->setOnline($this->form_gui->getInput("online"));
197  $newObj->update();
198 
199  // setup rolefolder & default local roles
200  //$roles = $newObj->initDefaultRoles();
201 
202  // ...finally assign role to creator of object
203  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
204 
205  // add first page
206 
207 
208  // always send a message
209  ilUtil::sendInfo($this->lng->txt("object_added"),true);
210 
211  //ilUtil::redirect("ilias.php?baseClass=ilWikiHandlerGUI&ref_id=".$newObj->getRefId()."&cmd=editSettings");
212  ilUtil::redirect(ilObjWikiGUI::getGotoLink($newObj->getRefId()));
213  }
214  }
215 
216  $this->form_gui->setValuesByPost();
217  $tpl->setContent($this->form_gui->getHtml());
218  }
219 
225  function infoScreenObject()
226  {
227  $this->checkPermission("visible");
228  $this->ctrl->setCmd("showSummary");
229  $this->ctrl->setCmdClass("ilinfoscreengui");
230  $this->infoScreen();
231  }
232 
236  function infoScreen()
237  {
238  global $ilAccess, $ilUser, $lng;
239 
240  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId()))
241  {
242  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
243  }
244 
245  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
246  $info = new ilInfoScreenGUI($this);
247  $info->enablePrivateNotes();
248  if (trim($this->object->getIntroduction()) != "")
249  {
250  $info->addSection($lng->txt("wiki_introduction"));
251  $info->addProperty("", nl2br($this->object->getIntroduction()));
252  }
253 
254  // feedback from tutor; mark, status, comment
255  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
256  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
257  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
258  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
259  $status = ilWikiContributor::_lookupStatus($this->object->getId(), $ilUser->getId());
260  if ($lpcomment != "" || $mark != "" || $status != ilWikiContributor::STATUS_NOT_GRADED)
261  {
262  $info->addSection($this->lng->txt("wiki_feedback_from_tutor"));
263  if ($lpcomment != "")
264  {
265  $info->addProperty($this->lng->txt("wiki_comment"),
266  $lpcomment);
267  }
268  if ($mark != "")
269  {
270  $info->addProperty($this->lng->txt("wiki_mark"),
271  $mark);
272  }
273 
274  if ($status == ilWikiContributor::STATUS_PASSED)
275  {
276  $info->addProperty($this->lng->txt("status"),
277  $this->lng->txt("wiki_passed"));
278  }
279  if ($status == ilWikiContributor::STATUS_FAILED)
280  {
281  $info->addProperty($this->lng->txt("status"),
282  $this->lng->txt("wiki_failed"));
283  }
284  }
285 
286  /*
287  $info->enableNews();
288  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
289  {
290  //$info->enableNewsEditing();
291  $info->setBlockProperty("news", "settings", true);
292  }*/
293 
294  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
295  {
296  $info->addButton($lng->txt("wiki_start_page"), ilObjWikiGUI::getGotoLink($this->object->getRefId()));
297  }
298 
299  // general information
300  $this->lng->loadLanguageModule("meta");
301  $this->lng->loadLanguageModule("wiki");
302 
303  //$info->addSection($this->lng->txt("meta_general"));
304  //$info->addProperty($this->lng->txt("mcst_nr_items"),
305  // (int) count($med_items));
306 
307  // forward the command
308  $this->ctrl->forwardCommand($info);
309 
310  if ($ilAccess->checkAccess("read", "", $this->object->getRefId()))
311  {
312  $this->setSideBlock();
313  }
314  }
315 
320  {
321  global $ilCtrl;
322 
323  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId()));
324  }
325 
329  function addPageTabs()
330  {
331  global $ilTabs, $ilCtrl;
332 
333  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
334  $ilCtrl->setParameter($this, "wpg_id",
335  ilWikiPage::getPageIdForTitle($this->object->getId(), ilWikiUtil::makeDbTitle($_GET["page"])));
336  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
337  $ilTabs->addTarget("wiki_what_links_here",
338  $this->ctrl->getLinkTargetByClass("ilwikipagegui",
339  "whatLinksHere"), "whatLinksHere");
340  $ilTabs->addTarget("wiki_print_view",
341  $this->ctrl->getLinkTarget($this,
342  "printView"), "printView");
343  }
344 
348  function addPagesSubTabs()
349  {
350  global $ilTabs, $ilCtrl;
351 
352  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
353  $ilCtrl->setParameter($this, "wpg_id",
354  ilWikiPage::getPageIdForTitle($this->object->getId(),
355  ilWikiUtil::makeDbTitle($_GET["page"])));
356  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($_GET["page"]));
357  $ilTabs->addSubTabTarget("wiki_all_pages",
358  $this->ctrl->getLinkTarget($this, "allPages"), "allPages");
359  $ilTabs->addSubTabTarget("wiki_recent_changes",
360  $this->ctrl->getLinkTarget($this, "recentChanges"), "recentChanges");
361  $ilTabs->addSubTabTarget("wiki_new_pages",
362  $this->ctrl->getLinkTarget($this, "newPages"), "newPages");
363  $ilTabs->addSubTabTarget("wiki_popular_pages",
364  $this->ctrl->getLinkTarget($this, "popularPages"), "popularPages");
365  $ilTabs->addSubTabTarget("wiki_orphaned_pages",
366  $this->ctrl->getLinkTarget($this, "orphanedPages"), "orphanedPages");
367  }
368 
374  function getTabs($tabs_gui)
375  {
376  global $ilCtrl, $ilAccess, $lng;
377 
378  // wiki tabs
379  if (in_array($ilCtrl->getCmdClass(), array("", "ilobjwikigui",
380  "ilinfoscreengui", "ilpermissiongui")))
381  {
382  if ($_GET["page"] != "")
383  {
384  $tabs_gui->setBackTarget($lng->txt("wiki_last_visited_page"),
385  $this->getGotoLink($_GET["ref_id"],
386  ilWikiUtil::makeDbTitle($_GET["page"])));
387  }
388 
389  // info screen
390  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
391  {
392  $force_active = ($ilCtrl->getNextClass() == "ilinfoscreengui"
393  || $_GET["cmd"] == "infoScreen")
394  ? true
395  : false;
396  $tabs_gui->addTarget("info_short",
397  $this->ctrl->getLinkTargetByClass(
398  "ilinfoscreengui", "showSummary"),
399  "showSummary",
400  "", "", $force_active);
401  }
402 
403  // settings
404  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
405  {
406  $tabs_gui->addTarget("settings",
407  $this->ctrl->getLinkTarget($this, "editSettings"), array("editSettings"),
408  array(strtolower(get_class($this)), ""));
409  }
410 
411  // pages
412  if ($ilAccess->checkAccess('read', "", $this->object->getRefId()))
413  {
414  $tabs_gui->addTarget("wiki_pages",
415  $this->ctrl->getLinkTarget($this, "allPages"),
416  "allPages");
417  }
418 
419  // contributors
420  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
421  {
422  $tabs_gui->addTarget("wiki_contributors",
423  $this->ctrl->getLinkTarget($this, "listContributors"), array("listContributors"),
424  array(strtolower(get_class($this)), ""));
425  }
426 
427  // edit permissions
428  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
429  {
430  $tabs_gui->addTarget("perm_settings",
431  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), array("perm","info","owner"), 'ilpermissiongui');
432  }
433  }
434  }
435 
440  {
441  global $tpl;
442 
443  $this->checkPermission("write");
444 
445  $this->initSettingsForm();
446  $this->getSettingsFormValues();
447 
448  $tpl->setContent($this->form_gui->getHtml());
449  $this->setSideBlock();
450  }
451 
455  function initSettingsForm($a_mode = "edit")
456  {
457  global $tpl, $lng, $ilCtrl;
458 
459  $lng->loadLanguageModule("wiki");
460 
461  include("Services/Form/classes/class.ilPropertyFormGUI.php");
462  $this->form_gui = new ilPropertyFormGUI();
463 
464  // Title
465  $tit = new ilTextInputGUI($lng->txt("title"), "title");
466  $tit->setRequired(true);
467  $this->form_gui->addItem($tit);
468 
469  // Short Title
470  // The problem with the short title is, that it is per object
471  // and can't be a substitute for a ref id in the permanent link
472 /*
473  $stit = new ilRegExpInputGUI($lng->txt("wiki_short_title"), "shorttitle");
474  $stit->setPattern("/^[^0-9][^ _\&]+$/");
475  $stit->setRequired(false);
476  $stit->setNoMatchMessage($lng->txt("wiki_msg_short_name_regexp")." &amp; _");
477  $stit->setSize(20);
478  $stit->setMaxLength(20);
479  $stit->setInfo($lng->txt("wiki_short_title_desc2"));
480  $this->form_gui->addItem($stit);
481 */
482 
483  // Description
484  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
485  $this->form_gui->addItem($des);
486 
487  // Introduction
488  $intro = new ilTextAreaInputGUI($lng->txt("wiki_introduction"), "intro");
489  $intro->setCols(40);
490  $intro->setRows(4);
491  $this->form_gui->addItem($intro);
492 
493  // Start Page
494  $sp = new ilTextInputGUI($lng->txt("wiki_start_page"), "startpage");
495  $sp->setMaxLength(200);
496  $sp->setRequired(true);
497  $this->form_gui->addItem($sp);
498 
499  // Online
500  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
501  $this->form_gui->addItem($online);
502 
503  $rating = new ilCheckboxInputGUI($lng->txt("wiki_activate_rating"), "rating");
504  $this->form_gui->addItem($rating);
505 
506  // Form action and save button
507  $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_wiki.gif"));
508  if ($a_mode != "create")
509  {
510  $this->form_gui->setTitle($lng->txt("wiki_settings"));
511  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
512  }
513  else
514  {
515  $this->form_gui->setTitle($lng->txt("wiki_new"));
516  $this->form_gui->addCommandButton("save", $lng->txt("wiki_add"));
517  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
518  }
519 
520  // set values
521  if ($a_mode == "create")
522  {
523  $ilCtrl->setParameter($this, "new_type", "wiki");
524  }
525 
526  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
527  }
528 
529  function getSettingsFormValues($a_mode = "edit")
530  {
531  global $lng;
532 
533  // set values
534  if ($a_mode == "create")
535  {
536  $values["startpage"] = $lng->txt("wiki_main_page");
537  $this->form_gui->setValuesByArray($values);
538  }
539  else
540  {
541  $values["online"] = $this->object->getOnline();
542  $values["title"] = $this->object->getTitle();
543  $values["startpage"] = $this->object->getStartPage();
544  $values["shorttitle"] = $this->object->getShortTitle();
545  $values["description"] = $this->object->getDescription();
546  $values["rating"] = $this->object->getRating();
547  $values["intro"] = $this->object->getIntroduction();
548  $this->form_gui->setValuesByArray($values);
549  }
550  }
551 
552 
557  {
558  global $ilCtrl, $lng;
559 
560  $this->checkPermission("write");
561 
562  $this->initSettingsForm();
563 
564  if ($this->form_gui->checkInput())
565  {
566  if (!ilObjWiki::checkShortTitleAvailability($this->form_gui->getInput("shorttitle")) &&
567  $this->form_gui->getInput("shorttitle") != $this->object->getShortTitle())
568  {
569  $short_item = $this->form_gui->getItemByPostVar("shorttitle");
570  $short_item->setAlert($lng->txt("wiki_short_title_already_in_use"));
571  }
572  else
573  {
574  $this->object->setTitle($this->form_gui->getInput("title"));
575  $this->object->setDescription($this->form_gui->getInput("description"));
576  $this->object->setOnline($this->form_gui->getInput("online"));
577  $this->object->setStartPage($this->form_gui->getInput("startpage"));
578  $this->object->setShortTitle($this->form_gui->getInput("shorttitle"));
579  $this->object->setRating($this->form_gui->getInput("rating"));
580  $this->object->setIntroduction($this->form_gui->getInput("intro"));
581  $this->object->update();
582 
583  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
584  $ilCtrl->redirect($this, "editSettings");
585  }
586  }
587 
588  $this->form_gui->setValuesByPost();
589  $this->tpl->setContent($this->form_gui->getHTML());
590  }
591 
596  {
597  global $tpl;
598 
599  $this->checkPermission("write");
600 
601  include_once("./Modules/Wiki/classes/class.ilWikiContributorsTableGUI.php");
602 
603  $table_gui = new ilWikiContributorsTableGUI($this, "listContributors",
604  $this->object->getId());
605 
606  $tpl->setContent($table_gui->getHTML());
607 
608  $this->setSideBlock();
609  }
610 
614  function saveGradingObject()
615  {
616  global $ilCtrl;
617 
618  $this->checkPermission("write");
619 
620  $users = (is_array($_POST["sel_user_id"]))
621  ? $_POST["sel_user_id"]
622  : (is_array($_POST["user_id"])
623  ? $_POST["user_id"]
624  : array());
625 
626  include_once("./Modules/Wiki/classes/class.ilWikiContributor.php");
627  include_once("./Services/Tracking/classes/class.ilLPMarks.php");
628  foreach($users as $user_id)
629  {
630  ilWikiContributor::_writeStatus($this->object->getId(), $user_id,
631  ilUtil::stripSlashes($_POST["status"][$user_id]));
632  $marks_obj = new ilLPMarks($this->object->getId(),$user_id);
633  $marks_obj->setMark(ilUtil::stripSlashes($_POST['mark'][$user_id]));
634  $marks_obj->setComment(ilUtil::stripSlashes($_POST['lcomment'][$user_id]));
635  $marks_obj->update();
636  }
637 
638  $ilCtrl->redirect($this, "listContributors");
639  }
640 
641  // add wiki to locator
642  function addLocatorItems()
643  {
644  global $ilLocator;
645 
646  if (is_object($this->object))
647  {
648  $ilLocator->addItem($this->object->getTitle(),
649  $this->getGotoLink($this->object->getRefId()), "", $_GET["ref_id"]);
650  }
651  }
652 
653  function _goto($a_target)
654  {
655  global $ilAccess, $ilErr, $lng, $ilNavigationHistory;
656 
657  $i = strpos($a_target, "_");
658  if ($i > 0)
659  {
660  $a_page = substr($a_target, $i+1);
661  $a_target = substr($a_target, 0, $i);
662  }
663 
664  if ($ilAccess->checkAccess("read", "", $a_target))
665  {
666  $_GET["cmd"] = "viewPage";
667  $_GET["ref_id"] = $a_target;
668  $_GET["page"] = $a_page;
669  $_GET["baseClass"] = "ilwikihandlergui";
670  $_GET["cmdClass"] = "ilobjwikigui";
671 /* if ($a_page != "")
672  {
673  $add = "&amp;page=".rawurlencode($_GET["page"]);
674  $ilNavigationHistory->addItem($_GET["ref_id"],
675  "./goto.php?target=wiki_".$_GET["ref_id"].$add, "wiki");
676  }*/
677  include("ilias.php");
678  exit;
679  }
680  else if ($ilAccess->checkAccess("visible", "", $a_target))
681  {
682  $_GET["cmd"] = "infoScreen";
683  $_GET["ref_id"] = $tarr[0];
684  include("repository.php");
685  exit;
686  }
687  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
688  {
689  $_GET["cmd"] = "frameset";
690  $_GET["target"] = "";
691  $_GET["ref_id"] = ROOT_FOLDER_ID;
692  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
694  include("repository.php");
695  exit;
696  }
697 
698  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
699  }
700 
704  static function getGotoLink($a_ref_id, $a_page = "")
705  {
706  if ($a_page == "")
707  {
709  }
710 
711  $goto = "./goto.php?target=wiki_".$a_ref_id."_".
712  ilWikiUtil::makeUrlTitle($a_page);
713 
714  return $goto;
715  }
716 
720  function viewPageObject()
721  {
722  global $lng, $ilCtrl, $tpl, $ilTabs, $ilAccess;
723 
724  $this->checkPermission("read");
725 
726  $ilTabs->clearTargets();
727 
728  $page = ($_GET["page"] != "")
729  ? $_GET["page"]
730  : $this->object->getStartPage();
731  $_GET["page"] = $page;
732 
733  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
734  if (!ilWikiPage::exists($this->object->getId(), $page))
735  {
736  $page = $this->object->getStartPage();
737  }
738 
739  if (!ilWikiPage::exists($this->object->getId(), $page))
740  {
741  ilUtil::sendInfo($lng->txt("wiki_no_start_page"), true);
742  $ilCtrl->redirect($this, "infoScreen");
743  return;
744  }
745 
746  // page exists, show it !
747  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($page));
748 
749  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
750  $wpage_gui = ilWikiPageGUI::getGUIForTitle($this->object->getId(),
751  ilWikiUtil::makeDbTitle($page));
752  //$wpage_gui->setOutputMode(IL_PAGE_PREVIEW);
753 
754  //$wpage_gui->setSideBlock();
755  $ilCtrl->setCmdClass("ilwikipagegui");
756  $ilCtrl->setCmd("preview");
757  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
758  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()))
759  {
760  $wpage_gui->setEnableEditing(false);
761  }
762 
763  $html = $ilCtrl->forwardCommand($wpage_gui);
764  //$this->addPageTabs();
765 
766  $tpl->setContent($html);
767  }
768 
772  function allPagesObject()
773  {
774  global $tpl;
775 
776  $this->checkPermission("read");
777 
778  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
779 
780  $this->addPagesSubTabs();
781 
782  $table_gui = new ilWikiPagesTableGUI($this, "allPages",
783  $this->object->getId(), IL_WIKI_ALL_PAGES);
784 
785  $this->setSideBlock();
786  $tpl->setContent($table_gui->getHTML());
787  }
788 
793  {
794  global $tpl, $ilTabs;
795 
796  $this->checkPermission("read");
797 
798  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
799 
800  $this->addPagesSubTabs();
801  $ilTabs->setTabActive("wiki_pages");
802 
803  $table_gui = new ilWikiPagesTableGUI($this, "popularPages",
804  $this->object->getId(), IL_WIKI_POPULAR_PAGES);
805 
806  $this->setSideBlock();
807  $tpl->setContent($table_gui->getHTML());
808  }
809 
814  {
815  global $tpl, $ilTabs;
816 
817  $this->checkPermission("read");
818 
819  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
820 
821  $this->addPagesSubTabs();
822  $ilTabs->setTabActive("wiki_pages");
823 
824  $table_gui = new ilWikiPagesTableGUI($this, "orphanedPages",
825  $this->object->getId(), IL_WIKI_ORPHANED_PAGES);
826 
827  $this->setSideBlock();
828  $tpl->setContent($table_gui->getHTML());
829  }
830 
836  function gotoPageObject($a_page = "")
837  {
838  global $ilCtrl;
839 
840  if ($a_page == "")
841  {
842  $a_page = $_GET["page"];
843  }
844 
845  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
846  if (ilWikiPage::_wikiPageExists($this->object->getId(),
847  ilWikiUtil::makeDbTitle($a_page)))
848  {
849  // to do: get rid of this redirect
850  ilUtil::redirect(ilObjWikiGUI::getGotoLink($this->object->getRefId(), $a_page));
851  }
852  else
853  {
854  // create the page
855  $page = new ilWikiPage();
856  $page->setWikiId($this->object->getId());
857  $page->setTitle(ilWikiUtil::makeDbTitle($_GET["page"]));
858  $page->create();
859 
860  // redirect to newly created page
861  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
862  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
863  }
864  }
865 
871  function randomPageObject()
872  {
873  $this->checkPermission("read");
874 
875  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
876  $page = ilWikiPage::getRandomPage($this->object->getId());
877  $this->gotoPageObject($page);
878  }
879 
884  {
885  global $tpl, $ilTabs;
886 
887  $this->checkPermission("read");
888 
889  include_once("./Modules/Wiki/classes/class.ilWikiRecentChangesTableGUI.php");
890 
891  $this->addPagesSubTabs();
892  $ilTabs->setTabActive("wiki_pages");
893 
894  $table_gui = new ilWikiRecentChangesTableGUI($this, "recentChanges",
895  $this->object->getId());
896 
897  $this->setSideBlock();
898  $tpl->setContent($table_gui->getHTML());
899  }
900 
901  function setSideBlock($a_wpg_id = 0)
902  {
903  global $tpl;
904 
905  // side block
906  include_once("./Modules/Wiki/classes/class.ilWikiSideBlockGUI.php");
907  $wiki_side_block = new ilWikiSideBlockGUI();
908  if ($a_wpg_id > 0)
909  {
910  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
911  $wiki_side_block->setPageObject(new ilWikiPage($a_wpg_id));
912  }
913 
914  // search block
915  include_once("./Modules/Wiki/classes/class.ilWikiSearchBlockGUI.php");
916  $wiki_search_block = new ilWikiSearchBlockGUI();
917  $rcontent = $wiki_side_block->getHTML().$wiki_search_block->getHTML();
918  $tpl->setRightContent($rcontent);
919  }
920 
924  function newPagesObject()
925  {
926  global $tpl, $ilTabs;
927 
928  $this->checkPermission("read");
929 
930  include_once("./Modules/Wiki/classes/class.ilWikiPagesTableGUI.php");
931 
932  $this->addPagesSubTabs();
933  $ilTabs->setTabActive("wiki_pages");
934 
935  $table_gui = new ilWikiPagesTableGUI($this, "newPages",
936  $this->object->getId(), IL_WIKI_NEW_PAGES);
937 
938  $this->setSideBlock();
939  $tpl->setContent($table_gui->getHTML());
940  }
941 
945  function printViewObject()
946  {
947  $this->checkPermission("read");
948 
949  include_once("./Modules/Wiki/classes/class.ilWikiPageGUI.php");
950  $page_gui = new ilWikiPageGUI($_GET["wpg_id"]);
951  $tpl = new ilTemplate("tpl.main.html", true, true);
952  $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
953  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
955 
956  // syntax style
957  $this->tpl->setCurrentBlock("SyntaxStyle");
958  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
960  $this->tpl->parseCurrentBlock();
961 
962 
963  // determine target frames for internal links
964  $page_gui->setOutputMode("print");
965  $page_content = $page_gui->showPage();
966  $tpl->setVariable("CONTENT",
967  '<div class="ilInvisibleBorder">'.$page_content.'</div>');
968  $tpl->show(false);
969  exit;
970  }
971 
976  {
977  global $tpl, $ilTabs;
978 
979  $this->checkPermission("read");
980 
981  include_once("./Modules/Wiki/classes/class.ilWikiSearchResultsTableGUI.php");
982 
983  $ilTabs->setTabActive("wiki_search_results");
984 
985  $search_results = ilObjWiki::_performSearch($this->object->getId(),
986  ilUtil::stripSlashes($_POST["search_term"]));
987  $table_gui = new ilWikiSearchResultsTableGUI($this, "performSearch",
988  $this->object->getId(), $search_results);
989 
990  $this->setSideBlock();
991  $tpl->setContent($table_gui->getHTML());
992  }
993 
994 }
995 ?>