faq.php 1.8 KB

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