Example #1
0
/**
 * This function displays the form for import of the zip file with qti2
 */
function ch_qti2_display_form()
{
    $name_tools = get_lang('ImportQtiQuiz');
    $form = '<div class="actions">';
    $form .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'exercice/exercise.php?show=test&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>';
    $form .= '</div>';
    $formValidator = new FormValidator('qti_upload', 'post', api_get_self() . "?" . api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));
    $formValidator->addElement('header', $name_tools);
    $formValidator->addElement('file', 'userFile', get_lang('DownloadFile'));
    $formValidator->addButtonImport(get_lang('Upload'));
    $form .= $formValidator->returnForm();
    echo $form;
}
    // if the warning message is too long then we display the warning message trough a session
    if ($error_kind_file) {
        Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption')));
    } else {
        Display::addFlash(Display::return_message($see_message_import));
        header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?&sec_token=' . $tok);
        exit;
    }
}
Display::display_header($tool_name);
$form = new FormValidator('user_update_import', 'post', api_get_self());
$form->addElement('header', $tool_name);
$form->addElement('hidden', 'formSent');
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
$group = array();
$form->addButtonImport(get_lang('Import'));
$defaults['formSent'] = 1;
$defaults['sendMail'] = 0;
$defaults['file_type'] = 'csv';
$form->setDefaults($defaults);
$form->display();
$list = array();
$list_reponse = array();
$result_xml = '';
$i = 0;
$count_fields = count($extra_fields);
if ($count_fields > 0) {
    foreach ($extra_fields as $extra) {
        $list[] = $extra[1];
        $list_reponse[] = 'xxx';
        $spaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
Example #3
0
    $form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
    $form->addButtonSave(get_lang('Save'));
    $show_form = true;
    if (!empty($thematic_data)) {
        if (api_get_session_id()) {
            if ($thematic_data['session_id'] != api_get_session_id()) {
                $show_form = false;
                Display::display_error_message(get_lang('NotAllowedClickBack'), false);
            }
        }
        // set default values
        $default['title'] = $thematic_data['title'];
        $default['content'] = $thematic_data['content'];
        $form->setDefaults($default);
    }
    // error messages
    if (isset($error)) {
        Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
    }
    if ($show_form) {
        $form->display();
    }
} elseif ($action == 'thematic_import_select') {
    // Create form to upload csv file.
    $form = new FormValidator('thematic_import', 'POST', 'index.php?action=thematic_import&' . api_get_cidreq() . $url_token);
    $form->addElement('header', get_lang('ImportThematic'));
    $form->addElement('file', 'file');
    $form->addElement('checkbox', 'replace', null, get_lang('DeleteAllThematic'));
    $form->addButtonImport(get_lang('Import'), 'SubmitImport');
    $form->display();
}
Example #4
0
 /**
  * @return FormValidator
  */
 public function getImportCalendarForm()
 {
     $form = new FormValidator('frm_import_ical', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&type=' . $this->type, array('enctype' => 'multipart/form-data'));
     $form->addElement('header', get_lang('ICalFileImport'));
     $form->addElement('file', 'ical_import', get_lang('ICalFileImport'));
     $form->addRule('ical_import', get_lang('ThisFieldIsRequired'), 'required');
     $form->addButtonImport(get_lang('Import'), 'ical_submit');
     return $form;
 }
echo '<a href="../session/session_list.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
if (!empty($error_message)) {
    Display::display_normal_message($error_message, false);
}
$form = new FormValidator('import_sessions', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data'));
$form->addElement('hidden', 'formSent', 1);
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
$form->addElement('radio', 'file_type', [get_lang('FileType'), Display::url(get_lang('ExampleCSVFile'), api_get_path(WEB_CODE_PATH) . 'admin/example_session.csv', ['target' => '_blank'])], 'CSV', 'csv');
$form->addElement('radio', 'file_type', [null, Display::url(get_lang('ExampleXMLFile'), api_get_path(WEB_CODE_PATH) . 'admin/example_session.xml', ['target' => '_blank'])], 'XML', 'xml');
$form->addElement('checkbox', 'overwrite', null, get_lang('IfSessionExistsUpdate'));
$form->addElement('checkbox', 'delete_users_not_in_list', null, get_lang('DeleteUsersNotInList'));
$form->addElement('checkbox', 'update_course_coaches', null, get_lang('CleanAndUpdateCourseCoaches'));
$form->addElement('checkbox', 'add_me_as_coach', null, get_lang('AddMeAsCoach'));
$form->addElement('checkbox', 'sendMail', null, get_lang('SendMailToUsers'));
$form->addButtonImport(get_lang('ImportSession'));
$defaults = array('sendMail' => 'true', 'file_type' => 'csv');
$form->setDefaults($defaults);
Display::display_normal_message(get_lang('TheXMLImportLetYouAddMoreInfoAndCreateResources'));
$form->display();
?>
<p><?php 
echo get_lang('CSVMustLookLike') . ' (' . get_lang('MandatoryFields') . ')';
?>
 :</p>
<blockquote>
<pre>
<strong>SessionName</strong>;Coach;<strong>DateStart</strong>;<strong>DateEnd</strong>;Users;Courses;VisibilityAfterExpiration
<strong>Example 1</strong>;username;<strong>yyyy/mm/dd;yyyy/mm/dd</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...];read_only
<strong>Example 2</strong>;username;<strong>yyyy/mm/dd;yyyy/mm/dd</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...];accessible
<strong>Example 3</strong>;username;<strong>yyyy/mm/dd;yyyy/mm/dd</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...];not_accessible
Example #6
0
        }
        $form->addElement('select', 'backup_server', '', $options, 'style="margin-left: 50px;"');
        $form->addElement('html', '<script type="text/javascript">document.import_backup_form.backup_server.disabled=true;</script>');
    } else {
        $form->addElement('radio', '', '', '<i>' . get_lang('NoBackupsAvailable') . '</i>', '', 'disabled="true"');
    }
    $form->addElement('html', '<br /><br />');
    $form->addElement('radio', 'import_option', '', get_lang('ImportFullBackup'), 'full_backup', 'id="import_option_1" class="checkbox"');
    $form->addElement('radio', 'import_option', '', get_lang('LetMeSelectItems'), 'select_items', 'id="import_option_2" class="checkbox"');
    $form->addElement('html', '<br /><br />');
    $form->addElement('html', get_lang('SameFilename'));
    $form->addElement('html', '<br /><br />');
    $form->addElement('radio', 'same_file_name_option', '', get_lang('SameFilenameSkip'), FILE_SKIP, 'id="same_file_name_option_1" class="checkbox"');
    $form->addElement('radio', 'same_file_name_option', '', get_lang('SameFilenameRename'), FILE_RENAME, 'id="same_file_name_option_2" class="checkbox"');
    $form->addElement('radio', 'same_file_name_option', '', get_lang('SameFilenameOverwrite'), FILE_OVERWRITE, 'id="same_file_name_option_3" class="checkbox"');
    $form->addElement('html', '<br />');
    $form->addButtonImport(get_lang('ImportBackup'));
    $values['backup_type'] = 'local';
    $values['import_option'] = 'full_backup';
    $values['same_file_name_option'] = FILE_OVERWRITE;
    $form->setDefaults($values);
    $form->add_progress_bar();
    // When progress bar appears we have to hide the title "Select backup file".
    $form->updateAttributes(array('onsubmit' => str_replace('javascript: ', 'javascript: page_title = getElementById(\'page_title\'); if (page_title) { setTimeout(\'page_title.style.display = \\\'none\\\';\', 2000); } ', $form->getAttribute('onsubmit'))));
    // Add Security token
    $token = Security::get_token();
    $form->addElement('hidden', 'sec_token');
    $form->setConstants(array('sec_token' => $token));
    $form->display();
}
Display::display_footer();
Example #7
0
}
if (isset($errors) && count($errors) != 0) {
    $error_message = '<ul>';
    foreach ($errors as $index => $error_course) {
        $error_message .= '<li>' . get_lang('Line') . ' ' . $error_course['line'] . ': <strong>' . $error_course['error'] . '</strong>: ';
        $error_message .= get_lang('Course') . ': ' . $error_course['Title'] . ' (' . $error_course['Code'] . ')';
        $error_message .= '</li>';
    }
    $error_message .= '</ul>';
    Display::display_error_message($error_message, false);
}
$form = new FormValidator('import', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data'));
$form->addHeader($tool_name);
$form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation'));
$form->addElement('checkbox', 'add_me_as_teacher', null, get_lang('AddMeAsTeacherInCourses'));
$form->addButtonImport(get_lang('Import'), 'save');
$form->addElement('hidden', 'formSent', 1);
$form->display();
?>
<div style="clear: both;"></div>
<p><?php 
echo get_lang('CSVMustLookLike') . ' (' . get_lang('MandatoryFields') . ')';
?>
 :</p>

<blockquote>
<pre>
<strong>Code</strong>;<strong>Title</strong>;<strong>CourseCategory</strong>;Teacher;Language
BIO0015;Biology;BIO;teacher1;english
BIO0016;Maths;MATH;teacher2|teacher3;english
BIO0017;Language;LANG;;english
/**
 * @return FormValidator
 */
function importCategoryForm()
{
    $form = new FormValidator('import', 'post', api_get_self() . '?action=import_category&' . api_get_cidreq());
    //$form->addElement('header', get_lang('ImportGroups'));
    $form->addElement('file', 'file', get_lang('ImportCSVFileLocation'));
    $form->addRule('file', get_lang('ThisFieldIsRequired'), 'required');
    //$form->addElement('label', null, Display::url(get_lang('ExampleCSVFile'), api_get_path(WEB_CODE_PATH).'group/example.csv'));
    $form->addButtonImport(get_lang('Import'));
    return $form;
}