calendar.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /* For license terms, see /license.txt */
  3. require_once __DIR__.'/../../main/inc/global.inc.php';
  4. $calendarId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
  5. $plugin = LearningCalendarPlugin::create();
  6. $item = $plugin->getCalendar($calendarId);
  7. $plugin->protectCalendar($item);
  8. $isoCode = api_get_language_isocode();
  9. $htmlHeadXtra[] = api_get_asset('bootstrap-year-calendar/js/bootstrap-year-calendar.js');
  10. $calendarLanguage = 'en';
  11. if ($isoCode !== 'en') {
  12. $file = 'bootstrap-year-calendar/js/languages/bootstrap-year-calendar.'.$isoCode.'.js';
  13. $path = api_get_path(SYS_PUBLIC_PATH).'assets/'.$file;
  14. if (file_exists($path)) {
  15. $htmlHeadXtra[] = api_get_asset($file);
  16. $calendarLanguage = $isoCode;
  17. }
  18. }
  19. $htmlHeadXtra[] = api_get_css_asset('bootstrap-year-calendar/css/bootstrap-year-calendar.css');
  20. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
  21. $formToString = '';
  22. $template = new Template();
  23. $actionLeft = Display::url(
  24. Display::return_icon(
  25. 'back.png',
  26. get_lang('Add'),
  27. null,
  28. ICON_SIZE_MEDIUM
  29. ),
  30. api_get_path(WEB_PLUGIN_PATH).'learning_calendar/start.php'
  31. );
  32. $actions = Display::toolbarAction('toolbar-forum', [$actionLeft]);
  33. $eventList = $plugin->getEventTypeList();
  34. $template->assign('events', $eventList);
  35. $template->assign('calendar_language', $calendarLanguage);
  36. $template->assign('ajax_url', api_get_path(WEB_PLUGIN_PATH).'learning_calendar/ajax.php?id='.$calendarId);
  37. $template->assign('header', $item['title']);
  38. $content = $template->fetch('learning_calendar/view/calendar.tpl');
  39. $template->assign('actions', $actions);
  40. $template->assign('content', $content);
  41. $template->display_one_col_template();