From b197e576c05bc9c4e49a06f9a514d3d6745b0ec0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 18 Feb 2014 17:58:05 +0100 Subject: [PATCH] Minor - fixing PHP notices. --- main/help/faq.php | 45 +++++++++++++++++------------------ main/help/help.php | 19 +++++++++------ main/inc/lib/template.lib.php | 28 +++++++++++----------- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/main/help/faq.php b/main/help/faq.php index fabc7b1fab..d208b42858 100644 --- a/main/help/faq.php +++ b/main/help/faq.php @@ -14,39 +14,38 @@ $language_file = 'help'; require_once '../inc/global.inc.php'; - -$help_name = Security::remove_XSS($_GET['open']); +$help_name = isset($_GET['open']) ? Security::remove_XSS($_GET['open']) : null; Display :: display_header(get_lang('Faq')); if (api_is_platform_admin()) { - echo ' '; + echo ' '; } echo Display::page_header(get_lang('Faq')); $faq_file = 'faq.html'; if (!empty($_GET['edit']) && $_GET['edit'] == 'true' && api_is_platform_admin()) { - $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true'); - $form -> add_html_editor('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300')); - $form -> addElement('style_submit_button', 'faq_submit', get_lang('Ok')); - $faq_content = @(string)file_get_contents(api_get_path(SYS_PATH).'home/faq.html'); - $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content))); - $form -> setDefaults(array('faq_content' => $faq_content)); - if ($form -> validate()) { - $content = $form -> getSubmitValue('faq_content'); - $fpath = api_get_path(SYS_PATH).'home/'.$faq_file; - if (is_file($fpath) && is_writeable($fpath)) { - $fp = fopen(api_get_path(SYS_PATH).'home/'.$faq_file, 'w'); - fwrite($fp, $content); - fclose($fp); - } else { - Display::display_warning_message(get_lang('WarningFaqFileNonWriteable')); - } - echo $content; - } else { - $form -> display(); - } + $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true'); + $form->add_html_editor('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300')); + $form->addElement('style_submit_button', 'faq_submit', get_lang('Ok')); + $faq_content = @(string)file_get_contents(api_get_path(SYS_PATH).'home/faq.html'); + $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content))); + $form->setDefaults(array('faq_content' => $faq_content)); + if ($form->validate()) { + $content = $form->getSubmitValue('faq_content'); + $fpath = api_get_path(SYS_PATH).'home/'.$faq_file; + if (is_file($fpath) && is_writeable($fpath)) { + $fp = fopen(api_get_path(SYS_PATH).'home/'.$faq_file, 'w'); + fwrite($fp, $content); + fclose($fp); + } else { + Display::display_warning_message(get_lang('WarningFaqFileNonWriteable')); + } + echo $content; + } else { + $form->display(); + } } else { $faq_content = @(string)file_get_contents(api_get_path(SYS_PATH).'home/'.$faq_file); $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content))); diff --git a/main/help/help.php b/main/help/help.php index 27aa7a331d..20e2633021 100644 --- a/main/help/help.php +++ b/main/help/help.php @@ -13,15 +13,20 @@ // Language file that needs to be included $language_file = 'help'; require_once '../inc/global.inc.php'; -$help_name = Security::remove_XSS($_GET['open']); +$help_name = isset($_GET['open']) ? Security::remove_XSS($_GET['open']) : null; +if (empty($help_name)) { + api_not_allowed(true); +} ?> - - + + + - - -
- \ No newline at end of file + +
+ + + diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index a09eb071c3..639c5bb8eb 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -194,29 +194,29 @@ class Template return $result; } - function set_help($help_input = null) + /** + * @param string $helpInput + */ + function set_help($helpInput = null) { - if (!empty($help_input)) { - $help = $help_input; + if (!empty($helpInput)) { + $help = $helpInput; } else { $help = $this->help; } - $help_content = ''; + $content = ''; if (api_get_setting('enable_help_link') == 'true') { if (!empty($help)) { - $help = Security::remove_XSS($help); - $help_content = '
  • '; - $help_content .= ''; - $help_content .= ''.get_lang(
-                        'Help'
-                    ).''; - $help_content .= '
  • '; + $help = Security::remove_XSS($help); + $content = '
  • '; + $content .= Display::url( + Display::return_icon('help.large.png', get_lang('Help')), + api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help.'&height=400&width=600', array('class' => 'ajax')); + $content .= '
  • '; } } - $this->assign('help_content', $help_content); + $this->assign('help_content', $content); } /*