chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | /* For licensing terms, see /license.txt */ |
||
| 3 | |||
| 4 | /** |
||
| 5 | * This script displays a help window. |
||
| 6 | */ |
||
| 7 | |||
| 8 | use Chamilo\CoreBundle\Enums\ActionIcon; |
||
| 9 | |||
| 10 | require_once __DIR__.'/../inc/global.inc.php'; |
||
| 11 | $help_name = isset($_GET['open']) ? Security::remove_XSS($_GET['open']) : null; |
||
| 12 | |||
| 13 | Display::display_header(get_lang('Frequently Asked Question')); |
||
| 14 | |||
| 15 | if (api_is_platform_admin()) { |
||
| 16 | echo ' <a href="faq.php?edit=true">'.Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL).'</a>'; |
||
| 17 | } |
||
| 18 | |||
| 19 | echo Display::page_header(get_lang('Frequently Asked Question')); |
||
| 20 | |||
| 21 | $faq_file = 'faq.html'; |
||
| 22 | if (!empty($_GET['edit']) && 'true' == $_GET['edit'] && api_is_platform_admin()) { |
||
| 23 | $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true'); |
||
| 24 | $form->addHtmlEditor( |
||
| 25 | 'faq_content', |
||
| 26 | null, |
||
| 27 | false, |
||
| 28 | false, |
||
| 29 | ['ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300'] |
||
| 30 | ); |
||
| 31 | $form->addButtonSave(get_lang('Validate'), 'faq_submit'); |
||
| 32 | $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH).'home/faq.html'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 33 | $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content))); |
||
| 34 | $form->setDefaults(['faq_content' => $faq_content]); |
||
| 35 | if ($form->validate()) { |
||
| 36 | $content = $form->getSubmitValue('faq_content'); |
||
| 37 | $fpath = api_get_path(SYS_APP_PATH).'home/'.$faq_file; |
||
| 38 | if (is_file($fpath) && is_writeable($fpath)) { |
||
| 39 | $fp = fopen(api_get_path(SYS_APP_PATH).'home/'.$faq_file, 'w'); |
||
| 40 | fwrite($fp, $content); |
||
| 41 | fclose($fp); |
||
| 42 | } else { |
||
| 43 | echo Display::return_message(sprintf(get_lang('Could not write to %s'), $faq_file), 'warning'); |
||
| 44 | } |
||
| 45 | echo $content; |
||
| 46 | } else { |
||
| 47 | $form->display(); |
||
| 48 | } |
||
| 49 | } else { |
||
| 50 | $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH).'home/'.$faq_file); |
||
| 51 | $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content))); |
||
| 52 | echo $faq_content; |
||
| 53 | } |
||
| 54 | |||
| 55 | Display::display_footer(); |
||
| 56 |