diff --git a/main/admin/settings.php b/main/admin/settings.php index c092e1828b..103e0d191c 100644 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -1,5 +1,5 @@ '.get_lang('UploadNewStylesheet').''; + $form = new FormValidator('stylesheet_upload','post','settings.php?category=stylesheets&showuploadform=true'); + $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'); + $form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types); + $form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); + $form->addElement('submit', 'stylesheet_upload', get_lang('Ok')); + if( $form->validate() AND is_writable(api_get_path(SYS_CODE_PATH).'css/')) + { + $values = $form->exportValues(); + $picture_element = & $form->getElement('new_stylesheet'); + $picture = $picture_element->getValue(); + upload_stylesheet($values, $picture); + Display::display_confirmation_message(get_lang('StylesheetAdded')); + } + else + { + if (!is_writable(api_get_path(SYS_CODE_PATH).'css/')) + { + Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable')); + } + else + { + if ($_GET['showuploadform'] == 'true') + { + echo '