faq.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script displays a help window.
  5. *
  6. * @package chamilo.help
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. $help_name = isset($_GET['open']) ? Security::remove_XSS($_GET['open']) : null;
  10. Display::display_header(get_lang('Faq'));
  11. if (api_is_platform_admin()) {
  12. echo '&nbsp;<a href="faq.php?edit=true">'.Display::return_icon('edit.png').'</a>';
  13. }
  14. echo Display::page_header(get_lang('Faq'));
  15. $faq_file = 'faq.html';
  16. if (!empty($_GET['edit']) && $_GET['edit'] == 'true' && api_is_platform_admin()) {
  17. $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true');
  18. $form->addHtmlEditor(
  19. 'faq_content',
  20. null,
  21. false,
  22. false,
  23. ['ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300']
  24. );
  25. $form->addButtonSave(get_lang('Ok'), 'faq_submit');
  26. $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH).'home/faq.html');
  27. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  28. $form->setDefaults(['faq_content' => $faq_content]);
  29. if ($form->validate()) {
  30. $content = $form->getSubmitValue('faq_content');
  31. $fpath = api_get_path(SYS_APP_PATH).'home/'.$faq_file;
  32. if (is_file($fpath) && is_writeable($fpath)) {
  33. $fp = fopen(api_get_path(SYS_APP_PATH).'home/'.$faq_file, 'w');
  34. fwrite($fp, $content);
  35. fclose($fp);
  36. } else {
  37. echo Display::return_message(get_lang('WarningFaqFileNonWriteable'), 'warning');
  38. }
  39. echo $content;
  40. } else {
  41. $form->display();
  42. }
  43. } else {
  44. $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH).'home/'.$faq_file);
  45. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  46. echo $faq_content;
  47. }
  48. Display::display_footer();