faq.php 3.0 KB

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