faq.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 '../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"><img src="'.api_get_path(WEB_IMG_PATH).'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('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300'));
  19. $form->addButtonSave(get_lang('Ok'), 'faq_submit');
  20. $faq_content = @(string)file_get_contents(api_get_path(SYS_APP_PATH).'home/faq.html');
  21. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  22. $form->setDefaults(array('faq_content' => $faq_content));
  23. if ($form->validate()) {
  24. $content = $form->getSubmitValue('faq_content');
  25. $fpath = api_get_path(SYS_APP_PATH).'home/'.$faq_file;
  26. if (is_file($fpath) && is_writeable($fpath)) {
  27. $fp = fopen(api_get_path(SYS_APP_PATH).'home/'.$faq_file, 'w');
  28. fwrite($fp, $content);
  29. fclose($fp);
  30. } else {
  31. Display::display_warning_message(get_lang('WarningFaqFileNonWriteable'));
  32. }
  33. echo $content;
  34. } else {
  35. $form->display();
  36. }
  37. } else {
  38. $faq_content = @(string)file_get_contents(api_get_path(SYS_APP_PATH).'home/'.$faq_file);
  39. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  40. echo $faq_content;
  41. }
  42. Display::display_footer();