index.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  5. * @author Juan Carlos Raña <herodoto@telefonica.net>
  6. *
  7. * @package chamilo.wiki
  8. */
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. require_once 'wiki.inc.php';
  11. global $charset;
  12. $wiki = new Wiki();
  13. $wiki->charset = $charset;
  14. // section (for the tabs)
  15. $this_section = SECTION_COURSES;
  16. $current_course_tool = TOOL_WIKI;
  17. $course_id = api_get_course_int_id();
  18. $session_id = api_get_session_id();
  19. $condition_session = api_get_session_condition($session_id);
  20. $groupId = api_get_group_id();
  21. // additional style information
  22. $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'wiki/css/default.css"/>';
  23. // javascript for advanced parameters menu
  24. $htmlHeadXtra[] = '<script>
  25. function setFocus() {
  26. $("#search_title").focus();
  27. }
  28. $(function() {
  29. setFocus();
  30. $("#start_date_toggle").click(function() {
  31. $("#start_date").toggle();
  32. });
  33. $("#end_date_toggle").click(function() {
  34. $("#end_date").toggle();
  35. });
  36. });
  37. </script>';
  38. /* Constants and variables */
  39. $tool_name = get_lang('ToolWiki');
  40. /* ACCESS */
  41. api_protect_course_script();
  42. api_block_anonymous_users();
  43. api_protect_course_group(GroupManager::GROUP_TOOL_WIKI);
  44. Event::event_access_tool(TOOL_WIKI);
  45. if ($groupId) {
  46. $group_properties = GroupManager::get_group_properties($groupId);
  47. $interbreadcrumb[] = [
  48. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  49. 'name' => get_lang('Groups'),
  50. ];
  51. $interbreadcrumb[] = [
  52. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  53. 'name' => get_lang('GroupSpace').' '.Security::remove_XSS($group_properties['name']),
  54. ];
  55. }
  56. $is_allowed_to_edit = api_is_allowed_to_edit(false, true);
  57. // The page we are dealing with
  58. $page = isset($_GET['title']) ? $_GET['title'] : 'index';
  59. $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'showpage';
  60. $view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
  61. $wiki->page = $page;
  62. $wiki->action = $action;
  63. // Setting wiki data
  64. if (!empty($view)) {
  65. $wiki->setWikiData($view);
  66. }
  67. $wiki->blockConcurrentEditions(api_get_user_id(), $action);
  68. /* MAIN WIKI AREA */
  69. ob_start();
  70. $handleAction = $wiki->handleAction($action);
  71. if (!$handleAction && $action == 'export_to_pdf') {
  72. $wiki->handleAction('showpage');
  73. }
  74. $content = ob_get_contents();
  75. ob_end_clean();
  76. Display::display_header($tool_name, 'Wiki');
  77. // check last version
  78. if (!empty($view)) {
  79. $wiki->checkLastVersion($view);
  80. }
  81. // Tool introduction
  82. Display::display_introduction_section(TOOL_WIKI);
  83. $wiki->showActionBar();
  84. echo $content;
  85. Display::display_footer();