本文整理汇总了PHP中FormValidator::addHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::addHtml方法的具体用法?PHP FormValidator::addHtml怎么用?PHP FormValidator::addHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::addHtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$form->freeze('openid');
}
$form->applyFilter('openid', 'trim');
}*/
// PHONE
$form->addElement('text', 'phone', get_lang('Phone'), array('size' => 20));
if (api_get_setting('profile', 'phone') !== 'true') {
$form->freeze('phone');
}
$form->applyFilter('phone', 'stripslashes');
$form->applyFilter('phone', 'trim');
$form->applyFilter('phone', 'html_filter');
// PICTURE
if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') {
$form->addElement('file', 'picture', $user_data['picture_uri'] != '' ? get_lang('UpdateImage') : get_lang('AddImage'), array('id' => 'picture_form', 'class' => 'picture-form'));
$form->addHtml('' . '<div class="form-group">' . '<label for="cropImage" id="labelCropImage" class="col-sm-2 control-label"></label>' . '<div class="col-sm-8">' . '<div id="cropImage" class="cropCanvas">' . '<img id="previewImage" >' . '</div>' . '<div>' . '<button class="btn btn-primary hidden" name="cropButton" id="cropButton"><em class="fa fa-crop"></em> ' . get_lang('CropYourPicture') . '</button>' . '</div>' . '</div>' . '</div>' . '');
$form->addHidden('cropResult', '');
$form->add_progress_bar();
if (!empty($user_data['picture_uri'])) {
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
}
$allowed_picture_types = api_get_supported_image_extensions();
$form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(', ', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
}
// LANGUAGE
$form->addElement('select_language', 'language', get_lang('Language'));
if (api_get_setting('profile', 'language') !== 'true') {
$form->freeze('language');
}
//THEME
if (is_profile_editable() && api_get_setting('profile.user_selected_theme') == 'true') {
示例2: createAnswersForm
/**
* function which redefines Question::createAnswersForm
* @param FormValidator $form
*/
function createAnswersForm($form)
{
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
$obj_ex = Session::read('objExercise');
$html = '<table class="table table-striped table-hover">';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th width="10">' . get_lang('Number') . '</th>';
$html .= '<th width="10">' . get_lang('True') . '</th>';
$html .= '<th width="50%">' . get_lang('Comment') . '</th>';
$html .= '<th width="50%">' . get_lang('Answer') . '</th>';
$html .= '</tr>';
$html .= '</thead>';
$html .= '<tbody>';
$form->addHeader(get_lang('Answers'));
$form->addHtml($html);
$defaults = array();
$correct = 0;
$answer = false;
if (!empty($this->id)) {
$answer = new Answer($this->id);
$answer->read();
if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
$nb_answers = $answer->nbrAnswers;
}
}
$form->addElement('hidden', 'nb_answers');
$boxes_names = array();
if ($nb_answers < 1) {
$nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
for ($i = 1; $i <= $nb_answers; ++$i) {
$form->addHtml('<tr>');
if (is_object($answer)) {
$defaults['answer[' . $i . ']'] = $answer->answer[$i];
$defaults['comment[' . $i . ']'] = $answer->comment[$i];
$defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
$defaults['correct[' . $i . ']'] = $answer->correct[$i];
} else {
$defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2');
$defaults['comment[1]'] = get_lang('DefaultMultipleComment2');
$defaults['correct[1]'] = true;
$defaults['weighting[1]'] = 10;
$defaults['answer[2]'] = get_lang('DefaultMultipleAnswer1');
$defaults['comment[2]'] = get_lang('DefaultMultipleComment1');
$defaults['correct[2]'] = false;
}
$renderer =& $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct[' . $i . ']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']');
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
$answer_number->freeze();
$form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox" style="margin-left: 0em;"');
$boxes_names[] = 'correct[' . $i . ']';
$form->addElement('html_editor', 'answer[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
$form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
$form->addHtml('</tr>');
}
$form->addElement('html', '</tbody></table>');
$form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
//only 1 answer the all deal ...
$form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]);
global $text;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
// setting the save button here and not in the question class.php
$buttonGroup = [$form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true), $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true), $form->addButtonSave($text, 'submitQuestion', true)];
$form->addGroup($buttonGroup);
}
$defaults['correct'] = $correct;
if (!empty($this->id)) {
$form->setDefaults($defaults);
} else {
if ($this->isContent == 1) {
$form->setDefaults($defaults);
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
}
示例3: setForm
/**
* @param FormValidator $form
*
* @return array
*/
public static function setForm(FormValidator &$form, $sessionId = 0)
{
$categoriesList = SessionManager::get_all_session_category();
$userInfo = api_get_user_info();
$categoriesOptions = array('0' => get_lang('None'));
if ($categoriesList != false) {
foreach ($categoriesList as $categoryItem) {
$categoriesOptions[$categoryItem['id']] = $categoryItem['name'];
}
}
// Database Table Definitions
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$form->addElement('text', 'name', get_lang('SessionName'), array('maxlength' => 50));
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('name', get_lang('SessionNameAlreadyExists'), 'callback', 'check_session_name');
if (!api_is_platform_admin() && api_is_teacher()) {
$form->addElement('select', 'coach_username', get_lang('CoachName'), [api_get_user_id() => $userInfo['complete_name']], array('id' => 'coach_username', 'class' => 'chzn-select', 'style' => 'width:370px;'));
} else {
$sql = "SELECT COUNT(1) FROM {$tbl_user} WHERE status = 1";
$rs = Database::query($sql);
$countUsers = Database::result($rs, 0, 0);
if (intval($countUsers) < 50) {
$orderClause = "ORDER BY ";
$orderClause .= api_sort_by_first_name() ? "firstname, lastname, username" : "lastname, firstname, username";
$sql = "SELECT user_id, lastname, firstname, username\n FROM {$tbl_user}\n WHERE status = '1' " . $orderClause;
if (api_is_multiple_url_enabled()) {
$userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$accessUrlId = api_get_current_access_url_id();
if ($accessUrlId != -1) {
$sql = "SELECT user.user_id, username, lastname, firstname\n FROM {$tbl_user} user\n INNER JOIN {$userRelAccessUrlTable} url_user\n ON (url_user.user_id = user.user_id)\n WHERE\n access_url_id = {$accessUrlId} AND\n status = 1 " . $orderClause;
}
}
$result = Database::query($sql);
$coachesList = Database::store_result($result);
$coachesOptions = array();
foreach ($coachesList as $coachItem) {
$coachesOptions[$coachItem['user_id']] = api_get_person_name($coachItem['firstname'], $coachItem['lastname']) . ' (' . $coachItem['username'] . ')';
}
$form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions);
} else {
$form->addElement('select_ajax', 'coach_username', get_lang('CoachName'), null, ['url' => api_get_path(WEB_AJAX_PATH) . 'session.ajax.php?a=search_general_coach', 'width' => '100%']);
}
}
$form->addRule('coach_username', get_lang('ThisFieldIsRequired'), 'required');
$form->addHtml('<div id="ajax_list_coachs"></div>');
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
$form->addSelect('session_category', get_lang('SessionCategory'), $categoriesOptions, array('id' => 'session_category', 'class' => 'chzn-select', 'style' => 'width:370px;'));
$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Minimal'));
$form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription'));
$visibilityGroup = array();
$visibilityGroup[] = $form->createElement('select', 'session_visibility', null, array(SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'), SESSION_VISIBLE => get_lang('SessionAccessible'), SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible'))));
$form->addGroup($visibilityGroup, 'visibility_group', get_lang('SessionVisibility'), null, false);
$options = [0 => get_lang('ByDuration'), 1 => get_lang('ByDates')];
$form->addSelect('access', get_lang('Access'), $options, array('onchange' => 'accessSwitcher()', 'id' => 'access'));
$form->addElement('html', '<div id="duration" style="display:none">');
$form->addElement('number', 'duration', array(get_lang('SessionDurationTitle'), get_lang('SessionDurationDescription')), array('maxlength' => 50));
$form->addElement('html', '</div>');
$form->addElement('html', '<div id="date_fields" style="display:none">');
// Dates
$form->addDateTimePicker('access_start_date', array(get_lang('SessionStartDate'), get_lang('SessionStartDateComment')), array('id' => 'access_start_date'));
$form->addDateTimePicker('access_end_date', array(get_lang('SessionEndDate'), get_lang('SessionEndDateComment')), array('id' => 'access_end_date'));
$form->addRule(array('access_start_date', 'access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
$form->addDateTimePicker('display_start_date', array(get_lang('SessionDisplayStartDate'), get_lang('SessionDisplayStartDateComment')), array('id' => 'display_start_date'));
$form->addDateTimePicker('display_end_date', array(get_lang('SessionDisplayEndDate'), get_lang('SessionDisplayEndDateComment')), array('id' => 'display_end_date'));
$form->addRule(array('display_start_date', 'display_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
$form->addDateTimePicker('coach_access_start_date', array(get_lang('SessionCoachStartDate'), get_lang('SessionCoachStartDateComment')), array('id' => 'coach_access_start_date'));
$form->addDateTimePicker('coach_access_end_date', array(get_lang('SessionCoachEndDate'), get_lang('SessionCoachEndDateComment')), array('id' => 'coach_access_end_date'));
$form->addRule(array('coach_access_start_date', 'coach_access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
$form->addElement('html', '</div>');
$form->addCheckBox('send_subscription_notification', [get_lang('SendSubscriptionNotification'), get_lang('SendAnEmailWhenAUserBeingSubscribed')]);
// Extra fields
$extra_field = new ExtraField('session');
$extra = $extra_field->addElements($form, $sessionId);
$form->addElement('html', '</div>');
$js = $extra['jquery_ready_content'];
return ['js' => $js];
}
示例4: createAnswersForm
/**
* function which redefines Question::createAnswersForm
* @param FormValidator $form
*/
public function createAnswersForm($form)
{
// Getting the exercise list
$obj_ex = Session::read('objExercise');
$editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
//this line defines how many questions by default appear when creating a choice question
// The previous default value was 2. See task #1759.
$nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4;
$nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
/*
Types of Feedback
$feedback_option[0]=get_lang('Feedback');
$feedback_option[1]=get_lang('DirectFeedback');
$feedback_option[2]=get_lang('NoFeedback');
*/
$feedback_title = '';
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
//Scenario
$comment_title = '<th width="20%">' . get_lang('Comment') . '</th>';
$feedback_title = '<th width="20%">' . get_lang('Scenario') . '</th>';
} else {
$comment_title = '<th width="40%">' . get_lang('Comment') . '</th>';
}
$html = '<table class="table table-striped table-hover">
<thead>
<tr style="text-align: center;">
<th width="5%">' . get_lang('Number') . '</th>
<th width="5%"> ' . get_lang('True') . '</th>
<th width="40%">' . get_lang('Answer') . '</th>
' . $comment_title . '
' . $feedback_title . '
<th width="10%">' . get_lang('Weighting') . '</th>
</tr>
</thead>
<tbody>';
$form->addHeader(get_lang('Answers'));
$form->addHtml($html);
$defaults = array();
$correct = 0;
if (!empty($this->id)) {
$answer = new Answer($this->id);
$answer->read();
if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
$nb_answers = $answer->nbrAnswers;
}
}
$form->addElement('hidden', 'nb_answers');
//Feedback SELECT
$question_list = $obj_ex->selectQuestionList();
$select_question = array();
$select_question[0] = get_lang('SelectTargetQuestion');
if (is_array($question_list)) {
foreach ($question_list as $key => $questionid) {
//To avoid warning messages
if (!is_numeric($questionid)) {
continue;
}
$question = Question::read($questionid);
$select_question[$questionid] = 'Q' . $key . ' :' . cut($question->selectTitle(), 20);
}
}
$select_question[-1] = get_lang('ExitTest');
$list = new LearnpathList(api_get_user_id());
$flat_list = $list->get_flat_list();
$select_lp_id = array();
$select_lp_id[0] = get_lang('SelectTargetLP');
foreach ($flat_list as $id => $details) {
$select_lp_id[$id] = cut($details['lp_name'], 20);
}
$temp_scenario = array();
if ($nb_answers < 1) {
$nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
for ($i = 1; $i <= $nb_answers; ++$i) {
$form->addHtml('<tr>');
if (isset($answer) && is_object($answer)) {
if ($answer->correct[$i]) {
$correct = $i;
}
$defaults['answer[' . $i . ']'] = $answer->answer[$i];
$defaults['comment[' . $i . ']'] = $answer->comment[$i];
$defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
$item_list = explode('@@', $answer->destination[$i]);
$try = isset($item_list[0]) ? $item_list[0] : '';
$lp = isset($item_list[1]) ? $item_list[1] : '';
$list_dest = isset($item_list[2]) ? $item_list[2] : '';
$url = isset($item_list[3]) ? $item_list[3] : '';
if ($try == 0) {
$try_result = 0;
} else {
$try_result = 1;
}
if ($url == 0) {
$url_result = '';
} else {
//.........这里部分代码省略.........
示例5: FormValidator
$result = Database::query($sql);
$numberofpages = Database::num_rows($result) + 1;
// Displaying the form with the questions
if (isset($_GET['show'])) {
$show = (int) $_GET['show'] + 1;
} else {
$show = 0;
}
$url = api_get_self() . '?survey_id=' . Security::remove_XSS($survey_id) . '&show=' . $show;
$form = new FormValidator('question', 'post', $url);
if (is_array($questions) && count($questions) > 0) {
foreach ($questions as $key => &$question) {
$ch_type = 'ch_' . $question['type'];
/** @var survey_question $display */
$display = new $ch_type();
$form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">');
$form->addHtml($question['survey_question']);
$display->render($form, $question);
$form->addHtml('</div></div>');
}
}
if ($show < $numberofpages || !$_GET['show'] && count($questions) > 0) {
if ($show == 0) {
$form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large');
} else {
$form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right');
}
}
if ($show >= $numberofpages && $_GET['show'] || isset($_GET['show']) && count($questions) == 0) {
if ($questions_exists == false) {
echo '<p>' . get_lang('ThereAreNotQuestionsForthisSurvey') . '</p>';
示例6: displayLoginForm
/**
* @return string
*/
public function displayLoginForm()
{
$form = new FormValidator('formLogin', 'POST', null, null, null, FormValidator::LAYOUT_BOX_NO_LABEL);
$form->addText('login', get_lang('UserName'), true, array('id' => 'login', 'autofocus' => 'autofocus', 'icon' => 'user fa-fw', 'placeholder' => get_lang('UserName')));
$form->addElement('password', 'password', get_lang('Pass'), array('id' => 'password', 'icon' => 'lock fa-fw', 'placeholder' => get_lang('Pass')));
// Captcha
$captcha = api_get_setting('allow_captcha');
$allowCaptcha = $captcha == 'true';
if ($allowCaptcha) {
$useCaptcha = isset($_SESSION['loginFailed']) ? $_SESSION['loginFailed'] : null;
if ($useCaptcha) {
$ajax = api_get_path(WEB_AJAX_PATH) . 'form.ajax.php?a=get_captcha';
$options = array('width' => 250, 'height' => 90, 'callback' => $ajax . '&var=' . basename(__FILE__, '.php'), 'sessionVar' => basename(__FILE__, '.php'), 'imageOptions' => array('font_size' => 20, 'font_path' => api_get_path(SYS_FONTS_PATH) . 'opensans/', 'font_file' => 'OpenSans-Regular.ttf'));
// Minimum options using all defaults (including defaults for Image_Text):
//$options = array('callback' => 'qfcaptcha_image.php');
$captcha_question = $form->addElement('CAPTCHA_Image', 'captcha_question', '', $options);
$form->addHtml(get_lang('ClickOnTheImageForANewOne'));
$form->addElement('text', 'captcha', get_lang('EnterTheLettersYouSee'));
$form->addRule('captcha', get_lang('EnterTheCharactersYouReadInTheImage'), 'required', null, 'client');
$form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question);
}
}
$form->addButton('submitAuth', get_lang('LoginEnter'), null, 'primary', null, 'btn-block');
$html = $form->returnForm();
if (api_get_setting('openid_authentication') == 'true') {
include_once 'main/auth/openid/login.php';
$html .= '<div>' . openid_form() . '</div>';
}
return $html;
}
示例7: getWallForm
/**
* @return string
*/
public static function getWallForm()
{
$form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php', null, array('enctype' => 'multipart/form-data'));
$form->addTextarea('social_wall_new_msg_main', null, ['placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout'), 'style' => 'width : 100%']);
$form->addHtml('<div class="form-group "><div class="url_preview col-md-9 panel-body"></div></div>');
$form->addButtonSend(get_lang('Post'));
$form->addHidden('url_content', '');
$html = Display::panel($form->returnForm(), get_lang('SocialWall'));
return $html;
}
示例8: FormValidator
$includeSessions = $plugin->get('include_sessions') === 'true';
$nameFilter = null;
$minFilter = 0;
$maxFilter = 0;
$form = new FormValidator('search_filter_form', 'get', null, null, [], FormValidator::LAYOUT_INLINE);
if ($form->validate()) {
$formValues = $form->getSubmitValues();
$nameFilter = isset($formValues['name']) ? $formValues['name'] : null;
$minFilter = isset($formValues['min']) ? $formValues['min'] : 0;
$maxFilter = isset($formValues['max']) ? $formValues['max'] : 0;
}
$form->addHeader($plugin->get_lang('SearchFilter'));
$form->addText('name', get_lang('SessionName'), false);
$form->addElement('number', 'min', $plugin->get_lang('MinimumPrice'), ['step' => '0.01', 'min' => '0']);
$form->addElement('number', 'max', $plugin->get_lang('MaximumPrice'), ['step' => '0.01', 'min' => '0']);
$form->addHtml('<hr>');
$form->addButtonFilter(get_lang('Search'));
$courseList = $plugin->getCatalogCourseList($nameFilter, $minFilter, $maxFilter);
//View
if (api_is_platform_admin()) {
$interbreadcrumb[] = ['url' => 'configuration.php', 'name' => $plugin->get_lang('AvailableCoursesConfiguration')];
$interbreadcrumb[] = ['url' => 'paymentsetup.php', 'name' => $plugin->get_lang('PaymentsConfiguration')];
} else {
$interbreadcrumb[] = ['url' => 'course_panel.php', 'name' => get_lang('TabsDashboard')];
}
$templateName = $plugin->get_lang('CourseListOnSale');
$tpl = new Template($templateName);
$tpl->assign('search_filter_form', $form->returnForm());
$tpl->assign('showing_courses', true);
$tpl->assign('courses', $courseList);
$tpl->assign('sessions_are_included', $includeSessions);
示例9: FormValidator
Export::arrayToCsv($listToExport, $archiveFile);
case 'xls':
Export::arrayToXls($listToExport, $archiveFile);
break;
}
} else {
Display::addFlash(Display::return_message(get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty')));
}
}
Display::display_header($tool_name);
$form = new FormValidator('export', 'post', api_get_self());
$form->addHeader($tool_name);
$form->addHidden('formSent', 1);
$form->addElement('radio', 'select_type', get_lang('Option'), get_lang('ExportAllCoursesList'), '1', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='none';}"]);
$form->addElement('radio', 'select_type', '', get_lang('ExportSelectedCoursesFromCoursesList'), '2', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='block';}"]);
if (!empty($course_list)) {
$form->addHtml('<div id="div-course-list" style="display:none">');
$coursesInList = [];
foreach ($course_list as $course) {
$coursesInList[$course['code']] = $course['title'] . ' (' . $course['code'] . ')';
}
$form->addSelect('course_code', get_lang('WhichCoursesToExport'), $coursesInList, ['multiple' => 'multiple']);
$form->addHtml('</div>');
}
$form->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV', 'csv', null);
$form->addElement('radio', 'file_type', '', 'XLS', 'xls', null);
$form->addElement('radio', 'file_type', null, 'XML', 'xml', null, array('id' => 'file_type_xml'));
$form->setDefaults(['select_type' => '1', 'file_type' => 'csv']);
$form->addButtonExport(get_lang('ExportCourses'));
$form->display();
Display::display_footer();
示例10: createAnswersForm
/**
* Function which redefines Question::createAnswersForm
* @param FormValidator $form
*/
public function createAnswersForm($form)
{
$defaults = array();
$nb_matches = $nb_options = 2;
$matches = array();
$answer = null;
if ($form->isSubmitted()) {
$nb_matches = $form->getSubmitValue('nb_matches');
$nb_options = $form->getSubmitValue('nb_options');
if (isset($_POST['lessMatches'])) {
$nb_matches--;
}
if (isset($_POST['moreMatches'])) {
$nb_matches++;
}
if (isset($_POST['lessOptions'])) {
$nb_options--;
}
if (isset($_POST['moreOptions'])) {
$nb_options++;
}
} else {
if (!empty($this->id)) {
$answer = new Answer($this->id);
$answer->read();
if (count($answer->nbrAnswers) > 0) {
$nb_matches = $nb_options = 0;
for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
if ($answer->isCorrect($i)) {
$nb_matches++;
$defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
$defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
$answerInfo = $answer->getAnswerByAutoId($answer->correct[$i]);
$defaults['matches[' . $nb_matches . ']'] = isset($answerInfo['answer']) ? $answerInfo['answer'] : '';
} else {
$nb_options++;
$defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
}
}
}
} else {
$defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1');
$defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
$defaults['matches[2]'] = '2';
$defaults['option[1]'] = get_lang('DefaultMatchingOptA');
$defaults['option[2]'] = get_lang('DefaultMatchingOptB');
}
}
for ($i = 1; $i <= $nb_matches; ++$i) {
$matches[$i] = $i;
}
$form->addElement('hidden', 'nb_matches', $nb_matches);
$form->addElement('hidden', 'nb_options', $nb_options);
// DISPLAY MATCHES
$html = '<table class="table table-striped table-hover">
<thead>
<tr>
<th width="85%">' . get_lang('Answer') . '</th>
<th width="15%">' . get_lang('MatchesTo') . '</th>
<th width="10">' . get_lang('Weighting') . '</th>
</tr>
</thead>
<tbody>';
$form->addHeader(get_lang('MakeCorrespond'));
$form->addHtml($html);
if ($nb_matches < 1) {
$nb_matches = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
for ($i = 1; $i <= $nb_matches; ++$i) {
$renderer =& $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "answer[{$i}]");
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "matches[{$i}]");
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "weighting[{$i}]");
$form->addHtml('<tr>');
$form->addText("answer[{$i}]", null);
$form->addSelect("matches[{$i}]", null, $matches);
$form->addText("weighting[{$i}]", null, true, ['value' => 10, 'style' => 'width: 60px;']);
$form->addHtml('</tr>');
}
$form->addHtml('</tbody></table>');
$renderer->setElementTemplate('<div class="form-group"><div class="col-sm-offset-2">{element}', 'lessMatches');
$renderer->setElementTemplate('{element}</div></div>', 'moreMatches');
global $text;
$group = [$form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true), $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true), $form->addButtonSave($text, 'submitQuestion', true)];
$form->addGroup($group);
if (!empty($this->id)) {
$form->setDefaults($defaults);
} else {
if ($this->isContent == 1) {
$form->setDefaults($defaults);
}
}
$form->setConstants(['nb_matches' => $nb_matches, 'nb_options' => $nb_options]);
}
示例11: isset
$selectedSale = isset($_GET['sale']) ? intval($_GET['sale']) : 0;
$searchTerm = '';
$form = new FormValidator('search', 'get');
if ($form->validate()) {
$selectedFilterType = $form->getSubmitValue('filter_type');
$selectedStatus = $form->getSubmitValue('status');
$searchTerm = $form->getSubmitValue('user');
if ($selectedStatus === false) {
$selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING;
}
if ($selectedFilterType === false) {
$selectedFilterType = '0';
}
}
$form->addRadio('filter_type', get_lang('Filter'), [$plugin->get_lang('ByStatus'), $plugin->get_lang('ByUser')]);
$form->addHtml('<div id="report-by-status" ' . ($selectedFilterType !== '0' ? 'style="display:none"' : '') . '>');
$form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses);
$form->addHtml('</div>');
$form->addHtml('<div id="report-by-user" ' . ($selectedFilterType !== '1' ? 'style="display:none"' : '') . '>');
$form->addText('user', get_lang('UserName'), false);
$form->addHtml('</div>');
$form->addButtonFilter(get_lang('Search'));
$form->setDefaults(['filter_type' => $selectedFilterType, 'status' => $selectedStatus]);
switch ($selectedFilterType) {
case '0':
$sales = $plugin->getSaleListByStatus($selectedStatus);
break;
case '1':
$sales = $plugin->getSaleListByUser($searchTerm);
break;
}
示例12: header
Display::addFlash(Display::return_message(get_lang('Updated')));
CourseHome::deleteIcon($id);
header('Location: ' . $currentUrl);
exit;
break;
case 'edit_icon':
$tool = CourseHome::getTool($id);
if (empty($tool)) {
api_not_allowed(true);
}
$interbreadcrumb[] = array('url' => api_get_self() . '?' . api_get_cidreq(), 'name' => get_lang('CustomizeIcons'));
$toolName = $tool['name'];
$currentUrl = api_get_self() . '?action=edit_icon&id=' . $id . '&' . api_get_cidreq();
$form = new FormValidator('icon_edit', 'post', $currentUrl);
$form->addHeader(get_lang('EditIcon'));
$form->addHtml('<div class="col-md-7">');
$form->addText('name', get_lang('Name'));
$form->addText('link', get_lang('Links'));
$allowed_picture_types = array('jpg', 'jpeg', 'png');
$form->addFile('icon', get_lang('CustomIcon'));
$form->addRule('icon', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
$form->addSelect('target', get_lang('LinkTarget'), ['_self' => get_lang('LinkOpenSelf'), '_blank' => get_lang('LinkOpenBlank')]);
$form->addSelect('visibility', get_lang('Visibility'), array(1 => get_lang('Visible'), 0 => get_lang('Invisible')));
$form->addTextarea('description', get_lang('Description'), array('rows' => '3', 'cols' => '40'));
$form->addButtonUpdate(get_lang('Update'));
$form->addHtml('</div>');
$form->addHtml('<div class="col-md-5">');
if (isset($tool['custom_icon']) && !empty($tool['custom_icon'])) {
$form->addLabel(get_lang('CurrentIcon'), Display::img(CourseHome::getCustomWebIconPath() . $tool['custom_icon']));
$form->addCheckBox('delete_icon', null, get_lang('DeletePicture'));
}
示例13: createAnswersForm
/**
* function which redefines Question::createAnswersForm
* @param FormValidator $form
*/
public function createAnswersForm($form)
{
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
// The previous default value was 2. See task #1759.
$nb_answers += isset($_POST['lessAnswers']) ? -1 : isset($_POST['moreAnswers']) ? 1 : 0;
$course_id = api_get_course_int_id();
$obj_ex = $_SESSION['objExercise'];
$renderer =& $form->defaultRenderer();
$defaults = array();
$html = '<table class="table table-striped table-hover">';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th>' . get_lang('Number') . '</th>';
$html .= '<th>' . get_lang('True') . '</th>';
$html .= '<th>' . get_lang('False') . '</th>';
$html .= '<th>' . get_lang('Answer') . '</th>';
// show column comment when feedback is enable
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$html .= '<th>' . get_lang('Comment') . '</th>';
}
$html .= '</tr>';
$html .= '</thead>';
$html .= '<tbody>';
$form->addHeader(get_lang('Answers'));
$form->addHtml($html);
$correct = 0;
$answer = null;
if (!empty($this->id)) {
$answer = new Answer($this->id);
$answer->read();
if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
$nb_answers = $answer->nbrAnswers;
}
}
$form->addElement('hidden', 'nb_answers');
$boxes_names = array();
if ($nb_answers < 1) {
$nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
// Can be more options
$option_data = Question::readQuestionOption($this->id, $course_id);
for ($i = 1; $i <= $nb_answers; ++$i) {
$form->addHtml('<tr>');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct[' . $i . ']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']');
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
$answer_number->freeze();
if (is_object($answer)) {
$defaults['answer[' . $i . ']'] = $answer->answer[$i];
$defaults['comment[' . $i . ']'] = $answer->comment[$i];
$correct = $answer->correct[$i];
$defaults['correct[' . $i . ']'] = $correct;
$j = 1;
if (!empty($option_data)) {
foreach ($option_data as $id => $data) {
$form->addElement('radio', 'correct[' . $i . ']', null, null, $id);
$j++;
if ($j == 3) {
break;
}
}
}
} else {
$form->addElement('radio', 'correct[' . $i . ']', null, null, 1);
$form->addElement('radio', 'correct[' . $i . ']', null, null, 2);
$defaults['answer[' . $i . ']'] = '';
$defaults['comment[' . $i . ']'] = '';
$defaults['correct[' . $i . ']'] = '';
}
$boxes_names[] = 'correct[' . $i . ']';
$form->addHtmlEditor("answer[{$i}]", get_lang('ThisFieldIsRequired'), true, true, ['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100']);
// show comment when feedback is enable
if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
}
$form->addHtml('</tr>');
}
$form->addHtml('</tbody></table>');
$correctInputTemplate = '<div class="form-group">';
$correctInputTemplate .= '<label class="col-sm-2 control-label">';
$correctInputTemplate .= '<span class="form_required">*</span>' . get_lang('Score');
$correctInputTemplate .= '</label>';
$correctInputTemplate .= '<div class="col-sm-8">';
$correctInputTemplate .= '<table>';
$correctInputTemplate .= '<tr>';
$correctInputTemplate .= '<td>';
$correctInputTemplate .= get_lang('Correct') . '{element}';
$correctInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
$correctInputTemplate .= '</td>';
$wrongInputTemplate = '<td>';
$wrongInputTemplate .= get_lang('Wrong') . '{element}';
$wrongInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
$wrongInputTemplate .= '</td>';
//.........这里部分代码省略.........
示例14: display_add_form
//.........这里部分代码省略.........
$form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
$form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'origin', $origin);
$form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
if (dropbox_cnf('allowOverwrite')) {
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
}
// List of all users in this course and all virtual courses combined with it
if (api_get_session_id()) {
$complete_user_list_for_dropbox = array();
if (api_get_setting('dropbox.dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id(), null, null, 0);
}
$complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id());
$generalCoachList = array();
$courseCoachList = array();
foreach ($complete_user_list2 as $coach) {
if ($coach['type'] == 'general_coach') {
$generalCoachList[] = $coach;
} else {
$courseCoachList[] = $coach;
}
}
$hideCourseCoach = api_get_setting('dropbox_hide_course_coach');
if ($hideCourseCoach == 'false') {
$complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $courseCoachList);
}
$hideGeneralCoach = api_get_setting('dropbox_hide_general_coach');
if ($hideGeneralCoach == 'false') {
$complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $generalCoachList);
}
} else {
if (api_get_setting('dropbox.dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
} else {
$complete_user_list_for_dropbox = CourseManager::getTeacherListFromCourse($course_info['real_id'], false);
}
}
if (!empty($complete_user_list_for_dropbox)) {
foreach ($complete_user_list_for_dropbox as $k => $e) {
$complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
}
$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
}
/*
Create the options inside the select box:
List all selected users their user id as value and a name string as display
*/
$current_user_id = '';
$options = array();
$userGroup = new UserGroup();
foreach ($complete_user_list_for_dropbox as $current_user) {
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['is_tutor'] == 1) && $current_user['user_id'] != $_user['user_id']) {
// Don't include yourself.
if ($current_user['user_id'] == $current_user_id) {
continue;
}
$userId = $current_user['user_id'];
$userInfo = api_get_user_info($userId);
if ($userInfo['status'] != INVITEE) {
$groupNameListToString = '';
if (!empty($groups)) {
$groupNameList = array_column($groups, 'name');
$groupNameListToString = ' - [' . implode(', ', $groupNameList) . ']';
}
$groups = $userGroup->getUserGroupListByUser($userId);
$full_name = $userInfo['complete_name'] . $groupNameListToString;
$current_user_id = $current_user['user_id'];
$options['user_' . $current_user_id] = $full_name;
}
}
}
/*
* Show groups
*/
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) {
$complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId'));
if (count($complete_group_list_for_dropbox) > 0) {
foreach ($complete_group_list_for_dropbox as $current_group) {
if ($current_group['number_of_members'] > 0) {
$options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users');
}
}
}
}
if (dropbox_cnf('allowJustUpload')) {
$options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect');
}
$form->addSelect('recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10'));
$form->addButtonUpload(get_lang('Upload'), 'submitWork');
$headers = array(get_lang('Upload'), get_lang('Upload') . ' (' . get_lang('Simple') . ')');
$multipleForm = new FormValidator('sent_multiple', 'post', '#', null, array('enctype' => 'multipart/form-data', 'id' => 'fileupload'));
$multipleForm->addSelect('recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'id' => 'recipient_form'));
$url = api_get_path(WEB_AJAX_PATH) . 'dropbox.ajax.php?' . api_get_cidreq() . '&a=upload_file&id=';
$multipleForm->addHtml('<div id="multiple_form" style="display:none">');
$multipleForm->addMultipleUpload($url);
$multipleForm->addHtml('</div>');
echo Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs');
}
示例15: Sequence
if ($formSequence->validate()) {
$values = $formSequence->exportValues();
$sequence = new Sequence();
$sequence->setName($values['name']);
$em->persist($sequence);
$em->flush();
header('Location: ' . api_get_self());
exit;
}
$selectSequence = new FormValidator('');
$selectSequence->addHidden('sequence_type', 'session');
$em = Database::getManager();
$sequenceList = $em->getRepository('ChamiloCoreBundle:Sequence')->findAll();
$selectSequence->addSelect('sequence', get_lang('Sequence'), $sequenceList, ['id' => 'sequence_id', 'cols-size' => [3, 7, 2]]);
$form = new FormValidator('');
$form->addHtml("<div class='col-md-6'>");
$form->addHidden('sequence_type', 'session');
$form->addSelect('sessions', get_lang('Sessions'), $sessionList, ['id' => 'item', 'cols-size' => [4, 7, 1]]);
$form->addButtonNext(get_lang('UseAsReference'), 'use_as_reference', ['cols-size' => [4, 7, 1]]);
$form->addHtml("</div>");
$form->addHtml("<div class='col-md-6'>");
$form->addSelect('requirements', get_lang('Requirements'), $sessionList, ['id' => 'requirements', 'cols-size' => [3, 7, 2]]);
$form->addButtonCreate(get_lang('SetAsRequirement'), 'set_requirement', false, ['cols-size' => [3, 7, 2]]);
$form->addHtml("</div>");
$formSave = new FormValidator('');
$formSave->addHidden('sequence_type', 'session');
$formSave->addButton('save_resource', get_lang('SaveSettings'), 'floppy-o', 'success', null, null, ['cols-size' => [1, 10, 1]]);
$tpl->assign('create_sequence', $formSequence->returnForm());
$tpl->assign('select_sequence', $selectSequence->returnForm());
$tpl->assign('configure_sequence', $form->returnForm());
$tpl->assign('save_sequence', $formSave->returnForm());