本文整理汇总了PHP中FormValidator::createElement方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::createElement方法的具体用法?PHP FormValidator::createElement怎么用?PHP FormValidator::createElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::createElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
//make available wider as we need it in case of form reset (see below)
$nb_ext_auth_source_added = 0;
if (isset($extAuthSource) && count($extAuthSource) > 0) {
$auth_sources = array();
foreach ($extAuthSource as $key => $info) {
// @todo : make uniform external authentification configuration (ex : cas and external_login ldap)
// Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS
// extAuthSource always on for CAS even if not activated
// same action for file user_edit.php
if ($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true' || $key != CAS_AUTH_SOURCE) {
$auth_sources[$key] = $key;
$nb_ext_auth_source_added++;
}
}
if ($nb_ext_auth_source_added > 0) {
$group[] = $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication') . ' ', 2);
$group[] = $form->createElement('select', 'auth_source', null, $auth_sources);
$group[] = $form->createElement('static', '', '', '<br />');
}
}
$group[] = $form->createElement('radio', 'password_auto', get_lang('Password'), get_lang('AutoGeneratePassword') . '<br />', 1);
$group[] = $form->createElement('radio', 'password_auto', 'id="radio_user_password"', get_lang('EnterPassword'), 0);
$group[] = $form->createElement('password', 'password', null, array('id' => 'password', 'autocomplete' => 'off', 'onkeydown' => 'javascript: password_switch_radio_button();'));
$form->addGroup($group, 'password', get_lang('Password'), '');
$form->addGroupRule('password', get_lang('EnterPassword'), 'required', null, 1);
if ($checkPass) {
$passwordStrengthLabels = '
<div id="password-verdict"></div>
<div id="password-errors"></div>
<div id="password_progress" style="display:none"></div>
';
示例2: intval
$url = api_get_self() . '?id=' . intval($_GET['id']);
}
$form = new FormValidator('system_announcement', 'post', $url);
$form->addElement('header', '', $form_title);
$form->addText('title', get_lang('Title'), true);
$language_list = api_get_languages();
$language_list_with_keys = array();
$language_list_with_keys['all'] = get_lang('All');
for ($i = 0; $i < count($language_list['name']); $i++) {
$language_list_with_keys[$language_list['folder'][$i]] = $language_list['name'][$i];
}
$form->addElement('select', 'lang', get_lang('Language'), $language_list_with_keys);
$form->addHtmlEditor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300'));
$form->addDateRangePicker('range', get_lang('StartTimeWindow'), true, array('id' => 'date_range'));
$group = array();
$group[] = $form->createElement('checkbox', 'visible_teacher', null, get_lang('Teacher'));
$group[] = $form->createElement('checkbox', 'visible_student', null, get_lang('Student'));
$group[] = $form->createElement('checkbox', 'visible_guest', null, get_lang('Guest'));
$form->addGroup($group, null, get_lang('Visible'), '');
$form->addElement('hidden', 'id');
$userGroup = new UserGroup();
$group_list = $userGroup->get_all();
if (!empty($group_list)) {
$group_list = array_column($group_list, 'name', 'id');
$group_list[0] = get_lang('All');
$form->addElement('select', 'group', get_lang('AnnouncementForGroup'), $group_list);
}
$values['group'] = isset($values['group']) ? $values['group'] : '0';
$form->addElement('checkbox', 'send_mail', null, get_lang('SendMail'));
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
$form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
示例3: FormValidator
//exit;
}
}
Display::display_header($tool_name);
if (!empty($error_message)) {
Display::display_error_message($error_message);
}
if (!empty($see_message_import)) {
Display::display_normal_message($see_message_import);
}
$form = new FormValidator('user_import', 'post', 'skills_import.php');
$form->addElement('header', '', $tool_name);
$form->addElement('hidden', 'formSent');
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
$group = array();
$group[] = $form->createElement('radio', 'file_type', '', 'CSV (<a href="skill_example.csv" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv');
//$group[] = $form->createElement('radio', 'file_type', null, 'XML (<a href="skill_example.xml" target="_blank">'.get_lang('ExampleXMLFile').'</a>)', 'xml');
$form->addGroup($group, '', get_lang('FileType'), '<br/>');
$form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="save"');
$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) {
示例4: intval
/**
* @param FormValidator $form
* @param $extra_data
* @param $form_name
* @param bool $admin_permissions
* @param null $user_id
* @deprecated
* @return array
*/
static function set_extra_fields_in_form($form, $extra_data, $admin_permissions = false, $user_id = null)
{
$user_id = intval($user_id);
// EXTRA FIELDS
$extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
$jquery_ready_content = null;
foreach ($extra as $field_details) {
if (!$admin_permissions) {
if ($field_details[6] == 0) {
continue;
}
}
switch ($field_details[2]) {
case ExtraField::FIELD_TYPE_TEXT:
$form->addElement('text', 'extra_' . $field_details[1], $field_details[3], array('size' => 40));
$form->applyFilter('extra_' . $field_details[1], 'stripslashes');
$form->applyFilter('extra_' . $field_details[1], 'trim');
$form->applyFilter('extra_' . $field_details[1], 'html_filter');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_TEXTAREA:
$form->addHtmlEditor('extra_' . $field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
$form->applyFilter('extra_' . $field_details[1], 'stripslashes');
$form->applyFilter('extra_' . $field_details[1], 'trim');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_RADIO:
$group = array();
foreach ($field_details[9] as $option_id => $option_details) {
$options[$option_details[1]] = $option_details[2];
$group[] = $form->createElement('radio', 'extra_' . $field_details[1], $option_details[1], $option_details[2] . '<br />', $option_details[1]);
}
$form->addGroup($group, 'extra_' . $field_details[1], $field_details[3], '');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT:
$get_lang_variables = false;
if (in_array($field_details[1], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) {
$get_lang_variables = true;
}
$options = array();
foreach ($field_details[9] as $option_id => $option_details) {
if ($get_lang_variables) {
$options[$option_details[1]] = get_lang($option_details[2]);
} else {
$options[$option_details[1]] = $option_details[2];
}
}
if ($get_lang_variables) {
$field_details[3] = get_lang($field_details[3]);
}
$form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('id' => 'extra_' . $field_details[1]));
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$options = array();
foreach ($field_details[9] as $option_id => $option_details) {
$options[$option_details[1]] = $option_details[2];
}
$form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('multiple' => 'multiple'));
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_DATE:
$form->addDatePicker('extra_' . $field_details[1], $field_details[3]);
$defaults['extra_' . $field_details[1]] = date('Y-m-d 12:00:00');
$form->setDefaults($defaults);
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
//.........这里部分代码省略.........
示例5: createAnswersForm
//.........这里部分代码省略.........
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 = $item_list[0];
$lp = $item_list[1];
$list_dest = $item_list[2];
$url = $item_list[3];
if ($try == 0) {
$try_result = 0;
} else {
$try_result = 1;
}
if ($url == 0) {
$url_result = '';
} else {
$url_result = $url;
}
$temp_scenario['url' . $i] = $url_result;
$temp_scenario['try' . $i] = $try_result;
$temp_scenario['lp' . $i] = $lp;
$temp_scenario['destination' . $i] = $list_dest;
} else {
$defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1');
$defaults['weighting[1]'] = 10;
$defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
$defaults['weighting[2]'] = 0;
$temp_scenario['destination' . $i] = array('0');
$temp_scenario['lp' . $i] = array('0');
}
$defaults['scenario'] = $temp_scenario;
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct');
$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 . ']');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting[' . $i . ']');
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, ' value = "' . $i . '"');
$answer_number->freeze();
$form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
$form->addElement('html_editor', 'answer[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config);
$form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config);
// Direct feedback
//Adding extra feedback fields
$group = array();
$group['try' . $i] = $form->createElement('checkbox', 'try' . $i, null, get_lang('TryAgain'));
$group['lp' . $i] = $form->createElement('select', 'lp' . $i, get_lang('SeeTheory') . ': ', $select_lp_id);
$group['destination' . $i] = $form->createElement('select', 'destination' . $i, get_lang('GoToQuestion') . ': ', $select_question);
$group['url' . $i] = $form->createElement('text', 'url' . $i, get_lang('Other') . ': ', array('class' => 'span2', 'placeholder' => get_lang('Other')));
$form->addGroup($group, 'scenario');
$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}', 'scenario');
} else {
$form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config);
}
$form->addElement('text', 'weighting[' . $i . ']', null, array('class' => "span1", 'value' => '0'));
$form->addElement('html', '</tr>');
}
$form->addElement('html', '</table>');
$form->addElement('html', '<br />');
$navigator_info = api_get_navigator();
global $text, $class;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
$form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"');
$form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"');
$form->addElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
} else {
//setting the save button here and not in the question class.php
$form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"');
$form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"');
$form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
}
}
$renderer->setElementTemplate('{element} ', 'submitQuestion');
$renderer->setElementTemplate('{element} ', 'lessAnswers');
$renderer->setElementTemplate('{element} ', 'moreAnswers');
$form->addElement('html', '</div></div>');
// We check the first radio button to be sure a radio button will be check
if ($correct == 0) {
$correct = 1;
}
$defaults['correct'] = $correct;
if (!empty($this->id)) {
$form->setDefaults($defaults);
} else {
if ($this->isContent == 1) {
// Default sample content.
$form->setDefaults($defaults);
} else {
$form->setDefaults(array('correct' => 1));
}
}
$form->setConstants(array('nb_answers' => $nb_answers));
}
示例6: array
$form->applyFilter('course_teachers', 'html_filter');
// Category code
$url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
$form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url));
// Course department
$form->addText('department_name', get_lang('CourseDepartment'), false, array('size' => '60'));
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');
// Department URL
$form->addText('department_url', get_lang('CourseDepartmentURL'), false, array('size' => '60'));
$form->applyFilter('department_url', 'html_filter');
$form->addElement('select_language', 'course_language', get_lang('CourseLanguage'));
$form->applyFilter('select_language', 'html_filter');
$form->addElement('checkbox', 'exemplary_content', '', get_lang('FillWithExemplaryContent'));
$group = array();
$group[] = $form->createElement('radio', 'visibility', get_lang('CourseAccess'), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
$form->addGroup($group, '', get_lang('CourseAccess'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$form->addGroup($group, '', get_lang('Subscription'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get_lang('MB')));
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
示例7: createForm
/**
* Creates the form to create / edit an exercise
* @param FormValidator $form
*/
public function createForm($form, $type = 'full')
{
if (empty($type)) {
$type = 'full';
}
// form title
if (!empty($_GET['exerciseId'])) {
$form_title = get_lang('ModifyExercise');
} else {
$form_title = get_lang('NewEx');
}
$form->addElement('header', $form_title);
// Title.
$form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), array('id' => 'exercise_title'));
$form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
$editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
if (is_array($type)) {
$editor_config = array_merge($editor_config, $type);
}
$form->addHtmlEditor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config);
if ($type == 'full') {
//Can't modify a DirectFeedback question
if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) {
// feedback type
$radios_feedback = array();
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
if (api_get_setting('exercise.enable_quiz_scenario') == 'true') {
//Can't convert a question from one feedback to another if there is more than 1 question already added
if ($this->selectNbrQuestions() == 0) {
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
}
}
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
$form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), '');
// Type of results display on the final page
$radios_results_disabled = array();
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2'));
//$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'), '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()'));
$form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
// Type of questions disposition on page
$radios = array();
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all'));
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one'));
$form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
} else {
// if is Directfeedback but has not questions we can allow to modify the question type
if ($this->selectNbrQuestions() == 0) {
// feedback type
$radios_feedback = array();
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
if (api_get_setting('exercise.enable_quiz_scenario') == 'true') {
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
}
$radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
$form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
//$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
$radios_results_disabled = array();
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
$form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
// Type of questions disposition on page
$radios = array();
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
$form->addGroup($radios, null, get_lang('ExerciseType'));
} else {
//Show options freeze
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
$result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
$result_disable_group->freeze();
//we force the options to the DirectFeedback exercisetype
$form->addElement('hidden', 'exerciseFeedbackType', EXERCISE_FEEDBACK_TYPE_DIRECT);
$form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
// Type of questions disposition on page
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all'));
$radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one'));
$type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
$type_group->freeze();
}
}
// number of random question
$max = $this->id > 0 ? $this->selectNbrQuestions() : 10;
$option = range(0, $max);
$option[0] = get_lang('No');
$option[-1] = get_lang('AllQuestionsShort');
$form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id' => 'randomQuestions'));
// Random answers
$radios_random_answers = array();
$radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1');
$radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0');
//.........这里部分代码省略.........
示例8: array
$value = 0;
if (isset($includedFields[$itemCol['id']]) && in_array($item['id'], $includedFields[$itemCol['id']])) {
$value = 1;
$attributes['checked'] = 'checked';
}
$element = Display::input('checkbox', $id, null, $attributes);
$table->setCellContents($row, $column, $element);
$form->addElement('hidden', 'hidden_' . $idForm, $value, array('id' => 'hidden_' . $id));
$column++;
}
$row++;
}
if (!empty($roleId)) {
$form->addElement('html', $table->toHtml());
$group = array();
$group[] = $form->createElement('button', 'submit', get_lang('Save'));
$group[] = $form->createElement('button', 'select_all', get_lang('SelectAll'), array('class' => 'btn select_all'));
$group[] = $form->createElement('button', 'unselect_all', get_lang('UnSelectAll'), array('class' => 'btn unselect_all'));
$form->addGroup($group, '', null, ' ');
$form->setDefaults(array('status' => $roleId));
} else {
$form->addElement('button', 'submit', get_lang('Edit'));
}
$form->display();
if ($form->validate()) {
$values = $form->getSubmitValues();
$result = $values['hidden_extra_field_status'];
if (!empty($result)) {
foreach ($result as $id => $items) {
foreach ($items as $subItemId => $value) {
$extraFieldOptionRelFieldOption = $app['orm.em']->getRepository('Entity\\ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_id, 'fieldOptionId' => $subItemId, 'roleId' => $roleId, 'relatedFieldOptionId' => $id));
示例9: get_settings_form
/**
* Returns an HTML form (generated by FormValidator) of the plugin settings
* @return string FormValidator-generated form
*/
public function get_settings_form()
{
$result = new FormValidator($this->get_name());
$defaults = array();
foreach ($this->fields as $name => $type) {
$value = $this->get($name);
$defaults[$name] = $value;
$type = isset($type) ? $type : 'text';
$help = null;
if ($this->get_lang_plugin_exists($name . '_help')) {
$help = $this->get_lang($name . '_help');
}
switch ($type) {
case 'html':
$result->addElement('html', $this->get_lang($name));
break;
case 'wysiwyg':
$result->add_html_editor($name, $this->get_lang($name));
break;
case 'text':
$result->addElement($type, $name, array($this->get_lang($name), $help));
break;
case 'boolean':
$group = array();
$group[] = $result->createElement('radio', $name, '', get_lang('Yes'), 'true');
$group[] = $result->createElement('radio', $name, '', get_lang('No'), 'false');
$result->addGroup($group, null, array($this->get_lang($name), $help));
break;
}
}
$result->setDefaults($defaults);
$result->addElement('style_submit_button', 'submit_button', $this->get_lang('Save'));
return $result;
}
示例10: create_group_date_select
/**
* Create a group of select from a date
* @param FormValidator $form
* @param string $prefix
* @return array
*/
function create_group_date_select($form, $prefix = '')
{
$minute = range(10, 59);
$d_year = date('Y');
array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');
$group_name = array(
$form->createElement('select', $prefix.'day', '', array_combine(range(1, 31), range(1, 31))),
$form->createElement('select', $prefix.'month', '', array_combine(range(1, 12), api_get_months_long())),
$form->createElement('select', $prefix.'year', '', array($d_year => $d_year, $d_year + 1 => $d_year + 1)),
$form->createElement('select', $prefix.'hour', '', array_combine(range(0, 23), range(0, 23))),
$form->createElement('select', $prefix.'minute', '', $minute)
);
return $group_name;
}
示例11: generate_settings_form
function generate_settings_form($settings, $settings_by_access_list)
{
global $_configuration, $settings_to_avoid, $convert_byte_to_mega_list;
$table_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$form = new FormValidator('settings', 'post', 'settings.php?category=' . Security::remove_XSS($_GET['category']));
$form->addElement('hidden', 'search_field', !empty($_GET['search_field']) ? Security::remove_XSS($_GET['search_field']) : null);
$url_id = api_get_current_access_url_id();
if (!empty($_configuration['multiple_access_urls']) && api_is_global_platform_admin() && $url_id == 1) {
$group = array();
$group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll'));
$group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll'));
$form->addGroup($group, 'buttons_in_action_right');
}
$default_values = array();
$url_info = api_get_access_url($url_id);
$i = 0;
foreach ($settings as $row) {
if (in_array($row['variable'], array_keys($settings_to_avoid))) {
continue;
}
if (!empty($_configuration['multiple_access_urls'])) {
if (api_is_global_platform_admin()) {
if ($row['access_url_locked'] == 0) {
if ($url_id == 1) {
if ($row['access_url_changeable'] == '1') {
$form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "0" data_to_send = "' . $row['variable'] . '" href="javascript:void(0);">' . Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')) . '</a></div>');
} else {
$form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "1" data_to_send = "' . $row['variable'] . '" href="javascript:void(0);">' . Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')) . '</a></div>');
}
} else {
if ($row['access_url_changeable'] == '1') {
$form->addElement('html', '<div style="float: right;">' . Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')) . '</div>');
} else {
$form->addElement('html', '<div style="float: right;">' . Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')) . '</div>');
}
}
}
}
}
$hideme = array();
$hide_element = false;
if ($_configuration['access_url'] != 1) {
if ($row['access_url_changeable'] == 0) {
// We hide the element in other cases (checkbox, radiobutton) we 'freeze' the element.
$hide_element = true;
$hideme = array('disabled');
} elseif ($url_info['active'] == 1) {
// We show the elements.
if (empty($row['variable'])) {
$row['variable'] = 0;
}
if (empty($row['subkey'])) {
$row['subkey'] = 0;
}
if (empty($row['category'])) {
$row['category'] = 0;
}
if (is_array($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']])) {
// We are sure that the other site have a selected value.
if ($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value'] != '') {
$row['selected_value'] = $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value'];
}
}
// There is no else{} statement because we load the default $row['selected_value'] of the main Chamilo site.
}
}
switch ($row['type']) {
case 'textfield':
if (in_array($row['variable'], $convert_byte_to_mega_list)) {
$form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment']), get_lang('MB')), array('maxlength' => '8'));
$form->applyFilter($row['variable'], 'html_filter');
$default_values[$row['variable']] = round($row['selected_value'] / 1024 / 1024, 1);
} elseif ($row['variable'] == 'account_valid_duration') {
$form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('maxlength' => '5'));
$form->applyFilter($row['variable'], 'html_filter');
$default_values[$row['variable']] = $row['selected_value'];
// For platform character set selection: Conversion of the textfield to a select box with valid values.
} elseif ($row['variable'] == 'platform_charset') {
continue;
} else {
$hideme['class'] = 'col-md-4';
$form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $hideme);
$form->applyFilter($row['variable'], 'html_filter');
$default_values[$row['variable']] = $row['selected_value'];
}
break;
case 'textarea':
if ($row['variable'] == 'header_extra_content') {
$file = api_get_path(SYS_PATH) . api_get_home_path() . 'header_extra_content.txt';
$value = '';
if (file_exists($file)) {
$value = file_get_contents($file);
}
$form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows' => '10'), $hideme);
$default_values[$row['variable']] = $value;
} elseif ($row['variable'] == 'footer_extra_content') {
$file = api_get_path(SYS_PATH) . api_get_home_path() . 'footer_extra_content.txt';
$value = '';
if (file_exists($file)) {
$value = file_get_contents($file);
//.........这里部分代码省略.........
示例12: FormValidator
// Build the form
$form = new FormValidator('update_course');
$form->addElement('header', get_lang('Course') . ' #' . $course_info['real_id'] . ' ' . $course_code);
$form->addElement('hidden', 'code', $course_code);
//title
$form->add_textfield('title', get_lang('Title'), true, array('class' => 'span6'));
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
// Code
$element = $form->addElement('text', 'real_code', array(get_lang('CourseCode'), get_lang('ThisValueCantBeChanged')));
$element->freeze();
// Visual code
$form->add_textfield('visual_code', array(get_lang('VisualCode'), get_lang('OnlyLettersAndNumbers'), get_lang('ThisValueIsUsedInTheCourseURL')), true, array('class' => 'span4'));
$form->applyFilter('visual_code', 'strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$group = array($form->createElement('select', 'platform_teachers', '', $teachers, ' id="platform_teachers" multiple=multiple size="4" style="width:300px;"'), $form->createElement('select', 'course_teachers', '', $course_teachers, ' id="course_teachers" multiple=multiple size="4" style="width:300px;"'));
$element_template = <<<EOT
\t<div class="control-group">
\t\t<label>
\t\t\t<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
\t\t</label>
\t\t<div class="controls">
\t\t\t<table cellpadding="0" cellspacing="0">
\t\t\t\t<tr>
\t\t\t\t\t<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error -->\t<td>{element}</td>
\t\t\t\t</tr>
\t\t\t</table>
\t\t</div>
\t</div>
EOT;
$renderer = $form->defaultRenderer();
示例13: Template
if (count($certificateStudent['certificates']) > 0) {
$certificateStudents[] = $certificateStudent;
}
}
}
}
}
/* View */
$template = new Template(get_lang('GradebookListOfStudentsCertificates'));
if (Session::has('reportErrorMessage')) {
$template->assign('errorMessage', Session::read('reportErrorMessage'));
}
$searchBySessionCourseDateForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php');
$searchBySessionCourseDateForm->addSelect('session', get_lang('Sessions'), $sessions, ['id' => 'session']);
$searchBySessionCourseDateForm->addSelect('course', get_lang('Courses'), $courses, ['id' => 'course']);
$searchBySessionCourseDateForm->addGroup([$searchBySessionCourseDateForm->createElement('select', 'month', null, $months, ['id' => 'month']), $searchBySessionCourseDateForm->createElement('text', 'year', null, ['id' => 'year', 'placeholder' => get_lang('Year')])], null, get_lang('Date'));
$searchBySessionCourseDateForm->addButtonSearch();
$searchBySessionCourseDateForm->setDefaults(['session' => $selectedSession, 'course' => $selectedCourse, 'month' => $selectedMonth, 'year' => $selectedYear]);
if (api_is_student_boss()) {
foreach ($userList as $studentId) {
$students[$studentId] = api_get_user_info($studentId)['complete_name_with_username'];
}
$searchByStudentForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php');
$searchByStudentForm->addSelect('student', get_lang('Students'), $students, ['id' => 'student']);
$searchByStudentForm->addButtonSearch();
$searchByStudentForm->setDefaults(['student' => $selectedStudent]);
$template->assign('searchByStudentForm', $searchByStudentForm->returnForm());
}
$template->assign('searchBySessionCourseDateForm', $searchBySessionCourseDateForm->returnForm());
$template->assign('sessions', $sessions);
$template->assign('courses', $courses);
示例14: array
if (!api_is_platform_admin()) {
$sql .= ' AND cu.status=1 ';
}
$sql .= ' AND target_course_code IS NULL AND cu.user_id = ' . $user_info['user_id'] . ' AND c.code != ' . "'" . $course_info['sysCode'] . "'" . ' ORDER BY title ASC';
$res = Database::query($sql);
if (Database::num_rows($res) == 0) {
Display::display_normal_message(get_lang('NoDestinationCoursesAvailable'));
} else {
$options = array();
while ($obj = Database::fetch_object($res)) {
$options[$obj->code] = $obj->title;
}
$form = new FormValidator('copy_course', 'post', 'copy_course.php?' . api_get_cidreq());
$form->addElement('header', '');
$form->addElement('select', 'destination_course', get_lang('SelectDestinationCourse'), $options);
$group = array();
$group[] = $form->createElement('radio', 'copy_option', null, get_lang('FullCopy'), 'full_copy');
$group[] = $form->createElement('radio', 'copy_option', null, get_lang('LetMeSelectItems'), 'select_items');
$form->addGroup($group, '', get_lang('SelectOptionForBackup'));
$group = array();
$group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameSkip'), FILE_SKIP);
$group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameRename'), FILE_RENAME);
$group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameOverwrite'), FILE_OVERWRITE);
$form->addGroup($group, '', get_lang('SameFilename'));
$form->add_progress_bar();
$form->addElement('style_submit_button', 'submit', get_lang('CopyCourse'), 'class="save"');
$form->setDefaults(array('copy_option' => 'select_items', 'same_file_name_option' => FILE_OVERWRITE));
$form->display();
}
}
Display::display_footer();
示例15: FormValidator
$token = md5(uniqid(rand(), TRUE));
$_SESSION['thematic_advance_token'] = $token;
}
// display form
$form = new FormValidator('thematic_advance', 'POST', 'index.php?action=thematic_advance_list&thematic_id=' . $thematic_id . '&' . api_get_cidreq(), '', 'style="width: 100%;"');
$form->addElement('header', $header_form);
$form->addElement('hidden', 'thematic_advance_token', $token);
$form->addElement('hidden', 'action', $action);
if (!empty($thematic_advance_id)) {
$form->addElement('hidden', 'thematic_advance_id', $thematic_advance_id);
}
if (!empty($thematic_id)) {
$form->addElement('hidden', 'thematic_id', $thematic_id);
}
$radios = array();
$radios[] = $form->createElement('radio', 'start_date_type', null, get_lang('StartDateFromAnAttendance'), '1', array('onclick' => 'check_per_attendance(this)', 'id' => 'from_attendance'));
$radios[] = $form->createElement('radio', 'start_date_type', null, get_lang('StartDateCustom'), '2', array('onclick' => 'check_per_custom_date(this)', 'id' => 'custom_date'));
$form->addGroup($radios, null, get_lang('StartDateOptions'));
if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
$form->addElement('html', '<div id="div_custom_datetime" style="display:block">');
} else {
$form->addElement('html', '<div id="div_custom_datetime" style="display:none">');
}
$form->addElement('datepicker', 'custom_start_date', get_lang('StartDate'), array('form_name' => 'thematic_advance'));
$form->addElement('html', '</div>');
if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:none">');
} else {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:block">');
}
if (count($attendance_select) > 1) {