本文整理汇总了PHP中FormValidator::addButtonAdvancedSettings方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::addButtonAdvancedSettings方法的具体用法?PHP FormValidator::addButtonAdvancedSettings怎么用?PHP FormValidator::addButtonAdvancedSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::addButtonAdvancedSettings方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createForm
/**
* Creates the form to create / edit a question
* A subclass can redefine this function to add fields...
* @param FormValidator $form
*/
public function createForm(&$form)
{
echo '<style>
.media { display:none;}
</style>';
echo '<script>
// hack to hide http://cksource.com/forums/viewtopic.php?f=6&t=8700
function FCKeditor_OnComplete( editorInstance ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstance.Name)) {
HideFCKEditorByInstanceName (editorInstance.Name);
}
}
function HideFCKEditorByInstanceName ( editorInstanceName ) {
if (document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className == "HideFCKEditor" ) {
document.getElementById ( \'HiddenFCK\' + editorInstanceName ).className = "media";
}
}
</script>';
// question name
$form->addElement('text', 'questionName', get_lang('Question'));
$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
// default content
$isContent = isset($_REQUEST['isContent']) ? intval($_REQUEST['isContent']) : null;
// Question type
$answerType = isset($_REQUEST['answerType']) ? intval($_REQUEST['answerType']) : null;
$form->addElement('hidden', 'answerType', $answerType);
// html editor
$editorConfig = array('ToolbarSet' => 'TestQuestionDescription', 'Height' => '150');
if (!api_is_allowed_to_edit(null, true)) {
$editorConfig['UserStatus'] = 'student';
}
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
$form->addHtmlEditor('questionDescription', get_lang('QuestionDescription'), false, false, $editorConfig);
// hidden values
$my_id = isset($_REQUEST['myid']) ? intval($_REQUEST['myid']) : null;
$form->addElement('hidden', 'myid', $my_id);
if ($this->type != MEDIA_QUESTION) {
// Advanced parameters
$select_level = Question::get_default_levels();
$form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);
// Categories
$tabCat = TestCategory::getCategoriesIdAndName();
$form->addElement('select', 'questionCategory', get_lang('Category'), $tabCat);
if (in_array($this->type, array(UNIQUE_ANSWER, MULTIPLE_ANSWER))) {
$buttonValue = $this->type == UNIQUE_ANSWER ? 'ConvertToMultipleAnswer' : 'ConvertToUniqueAnswer';
$form->addElement('button', 'convertAnswer', get_lang($buttonValue));
}
//Medias
//$course_medias = Question::prepare_course_media_select(api_get_course_int_id());
//$form->addElement('select', 'parent_id', get_lang('AttachToMedia'), $course_medias);
}
$form->addElement('html', '</div>');
if (!isset($_GET['fromExercise'])) {
switch ($answerType) {
case 1:
$this->question = get_lang('DefaultUniqueQuestion');
break;
case 2:
$this->question = get_lang('DefaultMultipleQuestion');
break;
case 3:
$this->question = get_lang('DefaultFillBlankQuestion');
break;
case 4:
$this->question = get_lang('DefaultMathingQuestion');
break;
case 5:
$this->question = get_lang('DefaultOpenQuestion');
break;
case 9:
$this->question = get_lang('DefaultMultipleQuestion');
break;
}
}
// default values
$defaults = array();
$defaults['questionName'] = $this->question;
$defaults['questionDescription'] = $this->description;
$defaults['questionLevel'] = $this->level;
$defaults['questionCategory'] = $this->category;
// Came from he question pool
if (isset($_GET['fromExercise'])) {
$form->setDefaults($defaults);
}
if (!empty($_REQUEST['myid'])) {
$form->setDefaults($defaults);
} else {
if ($isContent == 1) {
$form->setDefaults($defaults);
}
}
}
示例2: floatval
if (!isset($error)) {
$token = Security::get_token();
}
$attendance_weight = floatval($attendance_weight);
// display form
$form = new FormValidator('attendance_edit', 'POST', 'index.php?action=attendance_edit&' . api_get_cidreq() . '&attendance_id=' . $attendance_id);
$form->addElement('header', '', get_lang('Edit'));
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'attendance_id', $attendance_id);
$form->addText('title', get_lang('Title'), true);
$form->applyFilter('title', 'html_filter');
$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
// Adavanced Parameters
if (Gradebook::is_active()) {
if (!empty($attendance_qualify_title) || !empty($attendance_weight)) {
$form->addButtonAdvancedSettings('id_qualify');
$form->addElement('html', '<div id="id_qualify_options" style="display:block">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), array('checked' => 'true', 'onclick' => 'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}'));
$form->addElement('html', '<div id="options_field" style="display:block">');
} else {
$form->addButtonAdvancedSettings('id_qualify');
$form->addElement('html', '<div id="id_qualify_options" style="display:none">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$form->addElement('html', '<div id="options_field" style="display:none">');
}
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook'));
$form->applyFilter('attendance_qualify_title', 'html_filter');
$form->addElement('text', 'attendance_weight', get_lang('QualifyWeight'), 'value="0.00" Style="width:40px" onfocus="javascript: this.select();"');
$form->applyFilter('attendance_weight', 'html_filter');
$form->addElement('html', '</div>');
示例3: show_edit_post_form
/**
* This function displays the form that is used to edit a post. This can be a new thread or a reply.
* @param array contains all the information about the current post
* @param array contains all the information about the current thread
* @param array contains all info about the current forum (to check if attachments are allowed)
* @param array contains the default values to fill the form
* @return void
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function show_edit_post_form($forum_setting, $current_post, $current_thread, $current_forum, $form_values = '', $id_attach = 0)
{
// Initialize the object.
$form = new FormValidator('edit_post', 'post', api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($_GET['forum']) . '&thread=' . Security::remove_XSS($_GET['thread']) . '&post=' . Security::remove_XSS($_GET['post']));
$form->addElement('header', get_lang('EditPost'));
// Setting the form elements.
$form->addElement('hidden', 'post_id', $current_post['post_id']);
$form->addElement('hidden', 'thread_id', $current_thread['thread_id']);
$form->addElement('hidden', 'id_attach', $id_attach);
if ($current_post['post_parent_id'] == 0) {
$form->addElement('hidden', 'is_first_post_of_thread', '1');
}
$form->addElement('text', 'post_title', get_lang('Title'));
$form->applyFilter('post_title', 'html_filter');
$form->addHtmlEditor('post_text', get_lang('Text'), null, null, api_is_allowed_to_edit(null, true) ? array('ToolbarSet' => 'Forum', 'Width' => '100%', 'Height' => '400') : array('ToolbarSet' => 'ForumStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student'));
$form->addRule('post_text', get_lang('ThisFieldIsRequired'), 'required');
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
if (!isset($_GET['edit'])) {
if (Gradebook::is_active()) {
$form->addElement('label', '<strong>' . get_lang('AlterQualifyThread') . '</strong>');
$form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, $_GET['thread'], api_get_session_id());
if (!empty($link_info)) {
$defaults['thread_qualify_gradebook'] = true;
$defaults['category_id'] = $link_info['category_id'];
} else {
$defaults['thread_qualify_gradebook'] = false;
$defaults['category_id'] = '';
}
} else {
$form->addElement('hidden', 'thread_qualify_gradebook', false);
$defaults['thread_qualify_gradebook'] = false;
}
if (!empty($defaults['thread_qualify_gradebook'])) {
$form->addElement('html', '<div id="options_field" style="display:block">');
} else {
$form->addElement('html', '<div id="options_field" style="display:none">');
}
// Loading gradebook select
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'), array('value' => $current_thread['thread_qualify_max'], 'style' => 'width:40px'));
$form->applyFilter('numeric_calification', 'html_filter');
$form->addElement('text', 'calification_notebook_title', get_lang('TitleColumnGradebook'), array('value' => $current_thread['thread_title_qualify']));
$form->applyFilter('calification_notebook_title', 'html_filter');
$form->addElement('text', 'weight_calification', array(get_lang('QualifyWeight'), null, ''), array('value' => $current_thread['thread_weight'], 'style' => 'width:40px'));
$form->applyFilter('weight_calification', 'html_filter');
$group = array();
$group[] = $form->createElement('radio', 'thread_peer_qualify', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'thread_peer_qualify', null, get_lang('No'), 0);
$form->addGroup($group, '', [get_lang('ForumThreadPeerScoring'), get_lang('ForumThreadPeerScoringComment')], ' ');
$form->addElement('html', '</div>');
}
if ($forum_setting['allow_post_notification']) {
$form->addElement('checkbox', 'post_notification', '', get_lang('NotifyByEmail') . ' (' . $current_post['email'] . ')');
}
if ($forum_setting['allow_sticky'] && api_is_allowed_to_edit(null, true) && $current_post['post_parent_id'] == 0) {
// The sticky checkbox only appears when it is the first post of a thread.
$form->addElement('checkbox', 'thread_sticky', '', get_lang('StickyPost'));
if ($current_thread['thread_sticky'] == 1) {
$defaults['thread_sticky'] = true;
}
}
if ($current_forum['allow_attachments'] == '1' || api_is_allowed_to_edit(null, true)) {
if (empty($form_values) && !isset($_POST['SubmitPost'])) {
//edit_added_resources('forum_post', $current_post['post_id']);
}
}
$form->addElement('html', '</div>');
$form->addFile('user_upload[]', get_lang('Attachment'));
$form->addButton('add_attachment', get_lang('AddAttachment'), 'paperclip', 'default', 'default', null, ['id' => 'reply-add-attachment']);
$form->addButtonUpdate(get_lang('ModifyThread'), 'SubmitPost');
// Setting the default values for the form elements.
$defaults['post_title'] = $current_post['post_title'];
$defaults['post_text'] = $current_post['post_text'];
if ($current_post['post_notification'] == 1) {
$defaults['post_notification'] = true;
}
if (!empty($form_values)) {
$defaults['post_notification'] = Security::remove_XSS($form_values['post_notification']);
$defaults['thread_sticky'] = Security::remove_XSS($form_values['thread_sticky']);
}
$defaults['thread_peer_qualify'] = intval($current_thread['thread_peer_qualify']);
$form->setDefaults($defaults);
// The course admin can make a thread sticky (=appears with special icon and always on top).
$form->addRule('post_title', get_lang('ThisFieldIsRequired'), 'required');
// Validation or display
if ($form->validate()) {
$values = $form->exportValues();
//.........这里部分代码省略.........
示例4: isset
// Form to select directory
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
if (!$is_certificate_mode) {
echo DocumentManager::build_directory_selector($folders, $document_id, isset($group_properties['directory']) ? $group_properties['directory'] : array());
}
$action = api_get_self() . '?' . api_get_cidreq() . '&id=' . $document_id;
$form = new FormValidator('upload', 'POST', $action . '#tabs-2', '', array('enctype' => 'multipart/form-data'));
$form->addElement('hidden', 'id', $document_id);
$form->addElement('hidden', 'curdirpath', $path);
$course_quota = format_file_size(DocumentManager::get_course_quota() - DocumentManager::documents_total_space());
$label = get_lang('MaxFileSize') . ': ' . ini_get('upload_max_filesize') . '<br/>' . get_lang('DocumentQuota') . ': ' . $course_quota;
$form->addElement('file', 'file', array(get_lang('File'), $label), 'style="width: 250px" id="user_upload"');
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'title_file'));
$form->addElement('textarea', 'comment', get_lang('Comment'));
// Advanced parameters
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
// Check box options
$form->addElement('checkbox', 'unzip', get_lang('Options'), get_lang('Uncompress'), 'onclick="javascript: check_unzip();" value="1"');
if (api_get_setting('search.search_enabled') == 'true') {
//TODO: include language file
$supported_formats = get_lang('SupportedFormatsForIndex') . ': HTML, PDF, TXT, PDF, Postscript, MS Word, RTF, MS Power Point';
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument') . '<div style="font-size: 80%" >' . $supported_formats . '</div>');
$form->addElement('html', '<br /><div class="sub-form">');
$form->addElement('html', '<div class="label">' . get_lang('SearchFeatureDocumentLanguage') . '</div>');
$form->addLabel(get_lang('Language'), api_get_languages_combo());
$form->addElement('html', '</div><div class="sub-form">');
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$form->addElement('text', $specific_field['code'], $specific_field['name']);
}
示例5: 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];
}
示例6: addCourseAction
/**
* @Route("/add_course", name="add_course")
* @Method({"GET|POST"})
* @Security("has_role('ROLE_USER')")
*
* @return Response
*/
public function addCourseAction()
{
// "Course validation" feature. This value affects the way of a new course creation:
// true - the new course is requested only and it is created after approval;
// false - the new course is created immediately, after filling this form.
$courseValidation = false;
if (api_get_setting('course.course_validation') == 'true' && !api_is_platform_admin()) {
$courseValidation = true;
}
// Displaying the header.
$tool_name = $courseValidation ? get_lang('CreateCourseRequest') : get_lang('CreateSite');
if (api_get_setting('course.allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) {
api_not_allowed(true);
}
// Check access rights.
if (!api_is_allowed_to_create_course()) {
api_not_allowed(true);
}
$url = $this->generateUrl('add_course');
// Build the form.
$form = new \FormValidator('add_course', 'post', $url);
// Form title
$form->addElement('header', $tool_name);
// Title
$form->addElement('text', 'title', array(get_lang('CourseName'), get_lang('Ex')), array('id' => 'title'));
$form->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
// Category category.
$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 code
$form->addText('wanted_code', array(get_lang('Code'), get_lang('OnlyLettersAndNumbers')), '', array('maxlength' => \CourseManager::MAX_COURSE_LENGTH_CODE, 'pattern' => '[a-zA-Z0-9]+', 'title' => get_lang('OnlyLettersAndNumbers')));
$form->applyFilter('wanted_code', 'html_filter');
$form->addRule('wanted_code', get_lang('Max'), 'maxlength', \CourseManager::MAX_COURSE_LENGTH_CODE);
// The teacher
//array(get_lang('Professor'), null), null, array('size' => '60', 'disabled' => 'disabled'));
$titular =& $form->addElement('hidden', 'tutor_name', '');
if ($courseValidation) {
// Description of the requested course.
$form->addElement('textarea', 'description', get_lang('Description'), array('rows' => '3'));
// Objectives of the requested course.
$form->addElement('textarea', 'objetives', get_lang('Objectives'), array('rows' => '3'));
// Target audience of the requested course.
$form->addElement('textarea', 'target_audience', get_lang('TargetAudience'), array('rows' => '3'));
}
// Course language.
$form->addElement('select_language', 'course_language', get_lang('Ln'), array(), array('style' => 'width:150px'));
$form->applyFilter('select_language', 'html_filter');
// Exemplary content checkbox.
$form->addElement('checkbox', 'exemplary_content', null, get_lang('FillWithExemplaryContent'));
if ($courseValidation) {
// A special URL to terms and conditions that is set
// in the platform settings page.
$terms_and_conditions_url = trim(api_get_setting('course_validation_terms_and_conditions_url'));
// If the special setting is empty,
// then we may get the URL from Chamilo's module "Terms and conditions",
// if it is activated.
if (empty($terms_and_conditions_url)) {
if (api_get_setting('registration.allow_terms_conditions') == 'true') {
$terms_and_conditions_url = api_get_path(WEB_CODE_PATH);
$terms_and_conditions_url .= 'auth/inscription.php?legal';
}
}
if (!empty($terms_and_conditions_url)) {
// Terms and conditions to be accepted before sending a course request.
$form->addElement('checkbox', 'legal', null, get_lang('IAcceptTermsAndConditions'), 1);
$form->addRule('legal', get_lang('YouHaveToAcceptTermsAndConditions'), 'required');
// Link to terms and conditions.
$link_terms_and_conditions = '
<script>
function MM_openBrWindow(theURL, winName, features) { //v2.0
window.open(theURL,winName,features);
}
</script>
';
$link_terms_and_conditions .= \Display::url(get_lang('ReadTermsAndConditions'), '#', ['onclick' => "javascript:MM_openBrWindow('{$terms_and_conditions_url}', 'Conditions', 'scrollbars=yes, width=800');"]);
$form->addElement('label', null, $link_terms_and_conditions);
}
}
$obj = new \GradeModel();
$obj->fill_grade_model_select_in_form($form);
$form->addElement('html', '</div>');
// Submit button.
$form->addButtonCreate($courseValidation ? get_lang('CreateThisCourseRequest') : get_lang('CreateCourseArea'));
// Set default values.
if (isset($_user['language']) && $_user['language'] != '') {
$values['course_language'] = $_user['language'];
} else {
$values['course_language'] = api_get_setting('language.platform_language');
}
$form->setDefaults($values);
//.........这里部分代码省略.........
示例7: getFormWork
/**
* @param FormValidator $form
* @param array $defaults
* @return FormValidator
*/
function getFormWork($form, $defaults = array())
{
if (!empty($defaults)) {
if (isset($defaults['submit'])) {
unset($defaults['submit']);
}
}
// Create the form that asks for the directory name
$form->addElement('text', 'new_dir', get_lang('AssignmentName'));
$form->addRule('new_dir', get_lang('ThisFieldIsRequired'), 'required');
$form->addHtmlEditor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
$form->addButtonAdvancedSettings('advanced_params', get_lang('AdvancedParameters'));
if (!empty($defaults) && (isset($defaults['enableEndDate']) || isset($defaults['enableExpiryDate']))) {
$form->addElement('html', '<div id="advanced_params_options" style="display:block">');
} else {
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
}
// QualificationOfAssignment
$form->addElement('text', 'qualification', get_lang('QualificationNumeric'));
if (api_get_session_id() != 0 && Gradebook::is_active() || api_get_session_id() == 0) {
$form->addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), array('id' => 'make_calification_id', 'onclick' => "javascript: if(this.checked) { document.getElementById('option1').style.display='block';}else{document.getElementById('option1').style.display='none';}"));
} else {
// QualificationOfAssignment
$form->addElement('hidden', 'make_calification', false);
}
if (!empty($defaults) && isset($defaults['category_id'])) {
$form->addElement('html', '<div id=\'option1\' style="display:block">');
} else {
$form->addElement('html', '<div id=\'option1\' style="display:none">');
}
// Loading Gradebook select
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'weight', get_lang('WeightInTheGradebook'));
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'id="expiry_date"');
if (isset($defaults['enableExpiryDate']) && $defaults['enableExpiryDate']) {
$form->addElement('html', '<div id="option2" style="display: block;">');
} else {
$form->addElement('html', '<div id="option2" style="display: none;">');
}
$currentDate = substr(api_get_local_time(), 0, 10);
if (!isset($defaults['expires_on'])) {
$date = substr($currentDate, 0, 10);
$defaults['expires_on'] = $date . ' 23:59';
}
if (!isset($defaults['ends_on'])) {
$date = substr($currentDate, 0, 10);
$defaults['ends_on'] = $date . ' 23:59';
}
$form->addElement('date_time_picker', 'expires_on', get_lang('ExpiresAt'));
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'id="end_date"');
if (isset($defaults['enableEndDate']) && $defaults['enableEndDate']) {
$form->addElement('html', '<div id="option3" style="display: block;">');
} else {
$form->addElement('html', '<div id="option3" style="display: none;">');
}
$form->addElement('date_time_picker', 'ends_on', get_lang('EndsAt'));
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
$form->addElement('select', 'allow_text_assignment', get_lang('DocumentType'), getUploadDocumentType());
$form->addElement('html', '</div>');
if (isset($defaults['enableExpiryDate']) && isset($defaults['enableEndDate'])) {
$form->addRule(array('expires_on', 'ends_on'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
}
if (!empty($defaults)) {
$form->setDefaults($defaults);
}
return $form;
}