faq.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script displays a help window.
  5. *
  6. * @package chamilo.help
  7. */
  8. // Language file that needs to be included
  9. $language_file = 'help';
  10. require_once '../inc/global.inc.php';
  11. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  12. $help_name = Security::remove_XSS($_GET['open']);
  13. header('Content-Type: text/html; charset='. api_get_system_encoding());
  14. ?>
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  16. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
  17. <head>
  18. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
  19. <title>
  20. <?php echo get_lang('H'.$help_name); ?>
  21. </title>
  22. <style type="text/css" media="screen, projection">
  23. /*<![CDATA[*/
  24. @import "<?php echo api_get_path(WEB_CSS_PATH); ?>chamilo/default.css";
  25. /*]]>*/
  26. </style>
  27. <?php
  28. if (api_get_setting('stylesheets') != '') {
  29. ?>
  30. <style type="text/css" media="screen, projection">
  31. /*<![CDATA[*/
  32. @import "<?php echo api_get_path(WEB_CSS_PATH), api_get_setting('stylesheets'); ?>/default.css";
  33. /*]]>*/
  34. </style>
  35. <?php
  36. }
  37. ?>
  38. </head>
  39. <body dir="<?php echo api_get_text_direction(); ?>">
  40. <div style="margin:10px;">
  41. <div style="text-align:right;"><a href="javascript: window.close();"><?php echo get_lang('Close'); ?></a></div>
  42. <h4>
  43. <?php
  44. echo get_lang('Faq');
  45. if (api_is_platform_admin()) {
  46. echo '&nbsp;<a href="faq.php?edit=true"><img src="'.api_get_path(WEB_IMG_PATH).'edit.gif" /></a>';
  47. }
  48. ?>
  49. </h4>
  50. <?php
  51. $faq_file = 'faq.html';
  52. if (!empty($_GET['edit']) && $_GET['edit'] == 'true' && api_is_platform_admin()) {
  53. $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true');
  54. $form -> add_html_editor('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300'));
  55. $form -> addElement('submit', 'faq_submit', get_lang('Ok'));
  56. $faq_content = @(string)file_get_contents(api_get_path(SYS_PATH).'home/faq.html');
  57. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  58. $form -> setDefaults(array('faq_content' => $faq_content));
  59. if ($form -> validate()) {
  60. $content = $form -> getSubmitValue('faq_content');
  61. $fpath = api_get_path(SYS_PATH).'home/'.$faq_file;
  62. if (is_file($fpath) && is_writeable($fpath)) {
  63. $fp = fopen(api_get_path(SYS_PATH).'home/'.$faq_file, 'w');
  64. fwrite($fp, $content);
  65. fclose($fp);
  66. } else {
  67. echo get_lang('WarningFaqFileNonWriteable').'<br />';
  68. }
  69. echo $content;
  70. } else {
  71. $form -> display();
  72. }
  73. } else {
  74. $faq_content = @(string)file_get_contents(api_get_path(SYS_PATH).'home/'.$faq_file);
  75. $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
  76. echo $faq_content;
  77. }
  78. ?>
  79. <div style="text-align:right;"><a href="javascript: window.close();"><?php echo get_lang('Close'); ?></a></div>
  80. </div>
  81. </body>
  82. </html>