faq.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // Language file that needs to be included
  12. $language_file = 'help';
  13. require_once '../inc/global.inc.php';
  14. $help_name = Security::remove_XSS($_GET['open']);
  15. Display :: display_header(get_lang('Faq'));
  16. if (api_is_platform_admin()) {
  17. echo '&nbsp;<a href="faq.php?edit=true"><img src="'.api_get_path(WEB_IMG_PATH).'edit.png" /></a>';
  18. }
  19. echo Display::page_header(get_lang('Faq'));
  20. $faq_file = 'faq.html';
  21. if (!empty($_GET['edit']) && $_GET['edit'] == 'true' && api_is_platform_admin()) {
  22. $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true');
  23. $form -> add_html_editor('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300'));
  24. $form -> addElement('style_submit_button', 'faq_submit', get_lang('Ok'));
  25. $faq_content = @(string)file_get_contents(api_get_path(SYS_PATH).'home/faq.html');
  26. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  27. $form -> setDefaults(array('faq_content' => $faq_content));
  28. if ($form -> validate()) {
  29. $content = $form -> getSubmitValue('faq_content');
  30. $fpath = api_get_path(SYS_PATH).'home/'.$faq_file;
  31. if (is_file($fpath) && is_writeable($fpath)) {
  32. $fp = fopen(api_get_path(SYS_PATH).'home/'.$faq_file, 'w');
  33. fwrite($fp, $content);
  34. fclose($fp);
  35. } else {
  36. Display::display_warning_message(get_lang('WarningFaqFileNonWriteable'));
  37. }
  38. echo $content;
  39. } else {
  40. $form -> display();
  41. }
  42. } else {
  43. $faq_content = @(string)file_get_contents(api_get_path(SYS_PATH).'home/'.$faq_file);
  44. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  45. echo $faq_content;
  46. }
  47. Display::display_footer();