index.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. /**
  10. * Code
  11. */
  12. use \ChamiloSession as Session;
  13. // name of the language file that needs to be included
  14. $language_file = 'wiki';
  15. // including the global initialization file
  16. //require_once '../inc/global.inc.php';
  17. require_once 'wiki.inc.php';
  18. global $charset;
  19. $wiki = new Wiki();
  20. $wiki->charset = $charset;
  21. // section (for the tabs)
  22. $this_section = SECTION_COURSES;
  23. $current_course_tool = TOOL_WIKI;
  24. //require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  25. $course_id = api_get_course_int_id();
  26. $session_id = api_get_session_id();
  27. $condition_session = api_get_session_condition($session_id);
  28. $course_id = api_get_course_int_id();
  29. $groupId = api_get_group_id();
  30. // additional style information
  31. $htmlHeadXtra[] ='<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'wiki/css/default.css"/>';
  32. // javascript for advanced parameters menu
  33. $htmlHeadXtra[] = '<script>
  34. function advanced_parameters() {
  35. if (document.getElementById(\'options\').style.display == \'none\') {
  36. document.getElementById(\'options\').style.display = \'block\';
  37. document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_hide.gif', get_lang('Hide'), array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  38. } else {
  39. document.getElementById(\'options\').style.display = \'none\';
  40. document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif', get_lang('Show'), array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  41. }
  42. }
  43. function setFocus() {
  44. $("#search_title").focus();
  45. }
  46. $(document).ready(function() {
  47. setFocus();
  48. $("#start_date_toggle").click(function() {
  49. $("#start_date").toggle();
  50. });
  51. $("#end_date_toggle").click(function() {
  52. $("#end_date").toggle();
  53. });
  54. });
  55. </script>';
  56. /* Constants and variables */
  57. $tool_name = get_lang('ToolWiki');
  58. /* ACCESS */
  59. api_protect_course_script();
  60. api_block_anonymous_users();
  61. /* TRACKING */
  62. Event::event_access_tool(TOOL_WIKI);
  63. if ($groupId) {
  64. $group_properties = GroupManager::get_group_properties($groupId);
  65. $interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH)."group/group.php", "name" => get_lang('Groups'));
  66. $interbreadcrumb[] = array(
  67. "url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?gidReq=".$groupId,
  68. "name" => get_lang('GroupSpace').' '.$group_properties['name']
  69. );
  70. //ensure this tool in groups whe it's private or deactivated
  71. if ($group_properties['wiki_state'] == 0) {
  72. api_not_allowed();
  73. } elseif ($group_properties['wiki_state']==2) {
  74. if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id())) {
  75. api_not_allowed();
  76. }
  77. }
  78. }
  79. $is_allowed_to_edit = api_is_allowed_to_edit(false, true);
  80. // The page we are dealing with
  81. $page = isset($_GET['title']) ? $_GET['title']: 'index';
  82. $action = isset($_GET['action']) ? $_GET['action'] : 'showpage';
  83. $view = isset($_GET['view']) ? $_GET['view'] : null;
  84. $wiki->page = $page;
  85. $wiki->action = $action;
  86. /* MAIN CODE */
  87. /* ACTIONS */
  88. $wiki->blockConcurrentEditions(api_get_user_id(), $action);
  89. /* MAIN WIKI AREA */
  90. ob_start();
  91. $wiki->handleAction($action);
  92. $content = ob_get_contents();
  93. ob_end_clean();
  94. Display::display_header($tool_name, 'Wiki');
  95. // check last version
  96. if (!empty($view)) {
  97. $wiki->setWikiData($view);
  98. $wiki->checkLastVersion($view);
  99. }
  100. // Tool introduction
  101. Display::display_introduction_section(TOOL_WIKI);
  102. $wiki->showActionBar();
  103. echo $wiki->getMessages();
  104. echo $content;
  105. Display::display_footer();