diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index 3a5a841aa7..6908736d43 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -11,7 +11,7 @@ * @package chamilo.admin */ -define('CSS_UPLOAD_PATH', api_get_path(SYS_APP_PATH).'Resources/public/css/themes/'); +define('CSS_UPLOAD_PATH', api_get_path(SYS_APP_PATH) . 'Resources/public/css/themes/'); use Symfony\Component\Filesystem\Filesystem; @@ -33,14 +33,14 @@ function handle_regions() api_get_utc_datetime(), $user_id ); - Display :: display_confirmation_message(get_lang('SettingsStored')); + Display:: display_confirmation_message(get_lang('SettingsStored')); } $plugin_obj = new AppPlugin(); - $possible_plugins = $plugin_obj->read_plugins_from_path(); + $possible_plugins = $plugin_obj->read_plugins_from_path(); $installed_plugins = $plugin_obj->get_installed_plugins(); - echo '
'; + echo ''; } function handle_extensions() { echo Display::page_subheader(get_lang('ConfigureExtensions')); - echo ''.get_lang('Ppt2lp').''; + echo '' . get_lang('Ppt2lp') . ''; } + /** * This function allows easy activating and inactivating of plugins * @todo: a similar function needs to be written to activate or inactivate additional tools. @@ -121,7 +123,7 @@ function handle_plugins() api_get_utc_datetime(), $user_id ); - Display :: display_confirmation_message(get_lang('SettingsStored')); + Display:: display_confirmation_message(get_lang('SettingsStored')); } $all_plugins = $plugin_obj->read_plugins_from_path(); @@ -129,7 +131,7 @@ function handle_plugins() //Plugins NOT installed echo Display::page_subheader(get_lang('Plugins')); - echo ''; } @@ -231,19 +235,35 @@ function handle_stylesheets() 'post', 'settings.php?category=Stylesheets#tabs-3' ); - $form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); + $form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), + array('size' => '40', 'maxlength' => '40')); $form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet')); - $allowed_file_types = array('css', 'zip', 'jpeg', 'jpg', 'png', 'gif', 'ico', 'psd', 'xcf', 'svg', 'webp', 'woff', 'woff2'); + $allowed_file_types = array( + 'css', + 'zip', + 'jpeg', + 'jpg', + 'png', + 'gif', + 'ico', + 'psd', + 'xcf', + 'svg', + 'webp', + 'woff', + 'woff2' + ); - $form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types); + $form->addRule('new_stylesheet', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', + 'filetype', $allowed_file_types); $form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addButtonUpload(get_lang('Upload'), 'stylesheet_upload'); $show_upload_form = false; if (!is_writable(CSS_UPLOAD_PATH)) { - Display::display_error_message(CSS_UPLOAD_PATH.get_lang('IsNotWritable')); + Display::display_error_message(CSS_UPLOAD_PATH . get_lang('IsNotWritable')); } else { // Uploading a new stylesheet. if ($_configuration['access_url'] == 1) { @@ -284,12 +304,12 @@ function handle_stylesheets() $form_change = new FormValidator( 'stylesheet_upload', 'post', - api_get_self().'?category=Stylesheets', + api_get_self() . '?category=Stylesheets', null, array('id' => 'stylesheets_id') ); - $list_of_names = array(); + $list_of_names = array(); $selected = ''; $dirpath = ''; $safe_style_dir = ''; @@ -301,7 +321,7 @@ function handle_stylesheets() // Skip directories starting with a '.' continue; } - $dirpath = CSS_UPLOAD_PATH.$style_dir; + $dirpath = CSS_UPLOAD_PATH . $style_dir; if (is_dir($dirpath)) { if ($style_dir != '.' && $style_dir != '..') { @@ -322,7 +342,7 @@ function handle_stylesheets() $show_name = ucwords(str_replace('_', ' ', $style_dir)); if ($is_style_changeable) { - $list_of_names[$style_dir] = $show_name; + $list_of_names[$style_dir] = $show_name; } $counter++; } @@ -348,78 +368,83 @@ function handle_stylesheets() Display::display_normal_message(get_lang('Saved')); } if (isset($_POST['download'])) { - $arch = api_get_path(SYS_ARCHIVE_PATH).$safe_style_dir.'.zip'; - $dir = api_get_path(SYS_CSS_PATH).'themes/'.$safe_style_dir; + $arch = api_get_path(SYS_ARCHIVE_PATH) . $safe_style_dir . '.zip'; + $dir = api_get_path(SYS_CSS_PATH) . 'themes/' . $safe_style_dir; if (is_dir($dir)) { $zip = new PclZip($arch); // Remove path prefix except the style name and put file on disk - $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($safe_style_dir))); + $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir, 0, -strlen($safe_style_dir))); //@TODO: use more generic script to download. - $str = ''.get_lang('ClickHereToDownloadTheFile').''; + $str = '' . get_lang('ClickHereToDownloadTheFile') . ''; Display::display_normal_message($str, false); } else { Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning')); } } } - + $logoForm = new FormValidator( 'logo_upload', 'post', 'settings.php?category=Stylesheets#tabs-2' ); - - $logoForm->addHtml(Display::return_message(sprintf(get_lang('TheLogoMustBeSizeXAndFormatY'), '250 x 70', 'PNG'), 'info')); - - $dir = api_get_path(SYS_PUBLIC_PATH).'css/themes/' . $selected . '/images/'; - $url = api_get_path(WEB_CSS_PATH).'themes/' . $selected . '/images/'; + + $logoForm->addHtml(Display::return_message(sprintf(get_lang('TheLogoMustBeSizeXAndFormatY'), '250 x 70', 'PNG'), + 'info')); + + $dir = api_get_path(SYS_PUBLIC_PATH) . 'css/themes/' . $selected . '/images/'; + $url = api_get_path(WEB_CSS_PATH) . 'themes/' . $selected . '/images/'; $logoFileName = 'header-logo.png'; $newLogoFileName = 'header-logo-custom.png'; - - if (is_file($dir.$newLogoFileName)) { - $logoForm->addLabel(get_lang('CurrentLogo'), '