本文整理汇总了PHP中FormValidator::addButtonUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::addButtonUpdate方法的具体用法?PHP FormValidator::addButtonUpdate怎么用?PHP FormValidator::addButtonUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::addButtonUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FormValidator
<td>' . GradebookUtils::build_type_icon_tag('evalnotempty') . '</td>
<td>' . $evaluationRow['name'] . ' ' . Display::label(get_lang('Evaluation')) . '</td>';
$output .= '<td>
<input type="hidden" name="eval_' . $evaluationRow['id'] . '" value="' . $evaluationRow['name'] . '" />
<input type="text" size="10" name="evaluation[' . $evaluationRow['id'] . ']" value="' . $item_weight . '"/>
</td></tr>';
}
$my_api_cidreq = api_get_cidreq();
if ($my_api_cidreq == '') {
$my_api_cidreq = 'cidReq=' . $my_category['course_code'];
}
$currentUrl = api_get_self() . '?' . api_get_cidreq() . '&selectcat=' . $my_selectcat;
$form = new FormValidator('auto_weight', 'post', $currentUrl);
$form->addHeader(get_lang('AutoWeight'));
$form->addLabel(null, get_lang('AutoWeightExplanation'));
$form->addButtonUpdate(get_lang('AutoWeight'));
if ($form->validate()) {
$itemCount = count($links) + count($evaluations);
$weight = round($original_total / $itemCount, 2);
$total = $weight * $itemCount;
$diff = null;
if ($original_total !== $total) {
if ($total > $original_total) {
$diff = $total - $original_total;
}
}
$total = 0;
$diffApplied = false;
foreach ($links as $link) {
$weightToApply = $weight;
if ($diffApplied == false) {
示例2: createForm
//.........这里部分代码省略.........
$form->addElement('html', '</div>');
$form->addElement('text', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), array('id' => 'pass_percentage'));
$form->addRule('pass_percentage', get_lang('Numeric'), 'numeric');
// add the text_when_finished textbox
$form->addHtmlEditor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config);
$defaults = array();
if (api_get_setting('search.search_enabled') === 'true') {
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
$form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$form->addElement('text', $specific_field['code'], $specific_field['name']);
$filter = array('c_id' => "'" . api_get_course_int_id() . "'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\'' . TOOL_QUIZ . '\'');
$values = get_specific_field_values_list($filter, array('value'));
if (!empty($values)) {
$arr_str_values = array();
foreach ($values as $value) {
$arr_str_values[] = $value['value'];
}
$defaults[$specific_field['code']] = implode(', ', $arr_str_values);
}
}
//$form->addElement ('html','</div>');
}
$form->addElement('html', '</div>');
//End advanced setting
$form->addElement('html', '</div>');
}
// submit
if (isset($_GET['exerciseId'])) {
$form->addButtonSave(get_lang('ModifyExercise'), 'submitExercise');
} else {
$form->addButtonUpdate(get_lang('ProcedToQuestions'), 'submitExercise');
}
$form->addRule('exerciseTitle', get_lang('GiveExerciseName'), 'required');
if ($type == 'full') {
// rules
$form->addRule('exerciseAttempts', get_lang('Numeric'), 'numeric');
$form->addRule('start_time', get_lang('InvalidDate'), 'datetime');
$form->addRule('end_time', get_lang('InvalidDate'), 'datetime');
}
// defaults
if ($type == 'full') {
if ($this->id > 0) {
if ($this->random > $this->selectNbrQuestions()) {
$defaults['randomQuestions'] = $this->selectNbrQuestions();
} else {
$defaults['randomQuestions'] = $this->random;
}
$defaults['randomAnswers'] = $this->selectRandomAnswers();
$defaults['exerciseType'] = $this->selectType();
$defaults['exerciseTitle'] = $this->get_formated_title();
$defaults['exerciseDescription'] = $this->selectDescription();
$defaults['exerciseAttempts'] = $this->selectAttempts();
$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg();
$defaults['review_answers'] = $this->review_answers;
$defaults['randomByCat'] = $this->selectRandomByCat();
$defaults['text_when_finished'] = $this->selectTextWhenFinished();
$defaults['display_category_name'] = $this->selectDisplayCategoryName();
$defaults['pass_percentage'] = $this->selectPassPercentage();
if ($this->start_time != '0000-00-00 00:00:00') {
$defaults['activate_start_date_check'] = 1;
}
示例3: return_form
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string $url
* @param string $action add, edit
*
* @return FormValidator form validator obj
*/
public function return_form($url, $action)
{
$form = new FormValidator('grades', 'post', $url);
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers', 'Width' => '100%', 'Height' => '250'));
$form->addElement('label', get_lang('Components'));
// Get components
$nr_items = 2;
$max = 10;
// Setting the defaults
$defaults = $this->get($id);
$components = $this->get_components($defaults['id']);
if ($action == 'edit') {
if (!empty($components)) {
$nr_items = count($components) - 1;
}
}
$form->addElement('hidden', 'maxvalue', '100');
$form->addElement('hidden', 'minvalue', '0');
$renderer =& $form->defaultRenderer();
$component_array = array();
for ($i = 0; $i <= $max; $i++) {
$counter = $i;
$form->addElement('text', 'components[' . $i . '][percentage]', null);
$form->addElement('text', 'components[' . $i . '][acronym]', null);
$form->addElement('text', 'components[' . $i . '][title]', null);
$form->addElement('hidden', 'components[' . $i . '][id]', null);
$template_percentage = '<div id=' . $i . ' style="display: ' . ($i <= $nr_items ? 'inline' : 'none') . ';" class="control-group">
<p>
<label class="control-label">{label}</label>
<div class="controls">
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
{element} <!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --> % = ';
$template_acronym = '
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
{element} {label} <!-- BEGIN error --><span class="form_error">{error}</span> <!-- END error -->';
$template_title = ' {element} <!-- BEGIN error --> <span class="form_error">{error}</span><!-- END error -->
<a href="javascript:plusItem(' . ($counter + 1) . ')">
<img style="display: ' . ($counter >= $nr_items ? 'inline' : 'none') . ';" id="plus-' . ($counter + 1) . '" src="../img/icons/22/add.png" alt="' . get_lang('Add') . '" title="' . get_lang('Add') . '"></img>
</a>
<a href="javascript:minItem(' . $counter . ')">
<img style="display: ' . ($counter >= $nr_items ? 'inline' : 'none') . ';" id="min-' . $counter . '" src="../img/delete.png" alt="' . get_lang('Delete') . '" title="' . get_lang('Delete') . '"></img>
</a>
</div></p></div>';
$renderer->setElementTemplate($template_title, 'components[' . $i . '][title]');
$renderer->setElementTemplate($template_percentage, 'components[' . $i . '][percentage]');
$renderer->setElementTemplate($template_acronym, 'components[' . $i . '][acronym]');
if ($i == 0) {
$form->addRule('components[' . $i . '][percentage]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components[' . $i . '][title]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components[' . $i . '][acronym]', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addRule('components[' . $i . '][percentage]', get_lang('OnlyNumbers'), 'numeric');
$form->addRule(array('components[' . $i . '][percentage]', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
$form->addRule(array('components[' . $i . '][percentage]', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
$component_array[] = 'components[' . $i . '][percentage]';
}
//New rule added in the formvalidator compare_fields that filters a group of fields in order to compare with the wanted value
$form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100');
$form->addElement('label', '', get_lang('AllMustWeight100'));
if ($action == 'edit') {
$form->addButtonUpdate(get_lang('Modify'));
} else {
$form->addButtonCreate(get_lang('Add'));
}
if (!empty($components)) {
$counter = 0;
foreach ($components as $component) {
foreach ($component as $key => $value) {
$defaults['components[' . $counter . '][' . $key . ']'] = $value;
}
$counter++;
}
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
示例4: return_form
/**
* @param string $url
* @param string $action
* @return FormValidator
*/
public function return_form($url, $action)
{
$form = new FormValidator($this->type . '_field', 'post', $url);
$form->addElement('hidden', 'type', $this->type);
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$form->addElement('hidden', 'id', $id);
// Setting the form elements
$header = get_lang('Add');
$defaults = array();
if ($action == 'edit') {
$header = get_lang('Modify');
// Setting the defaults
$defaults = $this->get($id);
}
$form->addElement('header', $header);
$form->addElement('text', 'display_text', get_lang('Name'), array('class' => 'span5'));
// Field type
$types = self::get_field_types();
$form->addElement('select', 'field_type', get_lang('FieldType'), $types, array('id' => 'field_type'));
$form->addElement('label', get_lang('Example'), '<div id="example">-</div>');
$form->addElement('text', 'variable', get_lang('FieldLabel'), array('class' => 'span5'));
$form->addElement('text', 'field_options', get_lang('FieldPossibleValues'), array('id' => 'field_options', 'class' => 'span6'));
$fieldWithOptions = array(ExtraField::FIELD_TYPE_RADIO, ExtraField::FIELD_TYPE_SELECT_MULTIPLE, ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_TAG, ExtraField::FIELD_TYPE_DOUBLE_SELECT);
if ($action == 'edit') {
if (in_array($defaults['field_type'], $fieldWithOptions)) {
$url = Display::url(get_lang('EditExtraFieldOptions'), 'extra_field_options.php?type=' . $this->type . '&field_id=' . $id);
$form->addElement('label', null, $url);
if ($defaults['field_type'] == ExtraField::FIELD_TYPE_SELECT) {
$urlWorkFlow = Display::url(get_lang('EditExtraFieldWorkFlow'), 'extra_field_workflow.php?type=' . $this->type . '&field_id=' . $id);
$form->addElement('label', null, $urlWorkFlow);
}
$form->freeze('field_options');
}
}
$form->addElement('text', 'default_value', get_lang('FieldDefaultValue'), array('id' => 'default_value'));
$group = array();
$group[] = $form->createElement('radio', 'visible', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'visible', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('Visible'), '', false);
$group = array();
$group[] = $form->createElement('radio', 'changeable', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'changeable', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('FieldChangeability'), '', false);
$group = array();
$group[] = $form->createElement('radio', 'filter', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'filter', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('FieldFilter'), '', false);
/* Enable this when field_loggeable is introduced as a table field (2.0)
$group = array();
$group[] = $form->createElement('radio', 'field_loggeable', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'field_loggeable', null, get_lang('No'), 0);
$form->addGroup($group, '', get_lang('FieldLoggeable'), '', false);
*/
$form->addElement('text', 'field_order', get_lang('FieldOrder'), array('class' => 'span1'));
if ($action == 'edit') {
$option = new ExtraFieldOption($this->type);
if ($defaults['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
$form->freeze('field_options');
}
$defaults['field_options'] = $option->get_field_options_by_field_to_string($id);
$form->addButtonUpdate(get_lang('Modify'));
} else {
$defaults['visible'] = 0;
$defaults['changeable'] = 0;
$defaults['filter'] = 0;
$form->addButtonCreate(get_lang('Add'));
}
/*if (!empty($defaults['created_at'])) {
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
}
if (!empty($defaults['updated_at'])) {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}*/
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('display_text', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('field_type', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
示例5: array
*/
// Resetting the course id.
$cidReset = true;
// Including some necessary dokeos files.
//require_once '../inc/global.inc.php';
// Setting the section (for the tabs).
$this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions.
api_protect_admin_script();
// Setting breadcrumbs.
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'class_list.php', 'name' => get_lang('AdminClasses'));
// Setting the name of the tool.
$tool_name = get_lang('AddClasses');
$tool_name = get_lang('ModifyClassInfo');
$class_id = intval($_GET['idclass']);
$class = ClassManager::get_class_info($class_id);
$form = new FormValidator('edit_class', 'post', 'class_edit.php?idclass=' . $class_id);
$form->addText('name', get_lang('ClassName'));
$form->addButtonUpdate(get_lang('Ok'));
$form->setDefaults(array('name' => $class['name']));
if ($form->validate()) {
$values = $form->exportValues();
ClassManager::set_name($values['name'], $class_id);
header('Location: class_list.php');
}
Display::display_header($tool_name);
//api_display_tool_title($tool_name);
$form->display();
// Displaying the footer.
Display::display_footer();
示例6: show_edit_forumcategory_form
/**
* This function displays the form that is used to edit a forum category.
* This is more or less a copy from the show_add_forumcategory_form function with the only difference that is uses
* some default values. I tried to have both in one function but this gave problems with the handle_forum_and_forumcategories function
* (storing was done twice)
*
* @param array
* @return void HTML
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function show_edit_forumcategory_form($inputvalues = array())
{
$categoryId = $inputvalues['cat_id'];
$form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq() . '&id=' . $categoryId);
// Setting the form elements.
$form->addElement('header', '', get_lang('EditForumCategory'));
$form->addElement('hidden', 'forum_category_id');
$form->addElement('text', 'forum_category_title', get_lang('Title'));
$form->addHtmlEditor('forum_category_comment', get_lang('Comment'), null, null, array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200'));
$form->addButtonUpdate(get_lang('ModifyCategory'), 'SubmitEditForumCategory');
// Setting the default values.
$defaultvalues['forum_category_id'] = $inputvalues['cat_id'];
$defaultvalues['forum_category_title'] = $inputvalues['cat_title'];
$defaultvalues['forum_category_comment'] = $inputvalues['cat_comment'];
$form->setDefaults($defaultvalues);
// Setting the rules.
$form->addRule('forum_category_title', get_lang('ThisFieldIsRequired'), 'required');
// Validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
store_forumcategory($values);
}
Security::clear_token();
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
}
示例7: array
$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->addButtonUpdate(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('ChamiloLMS\\Entity\\ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_id, 'fieldOptionId' => $subItemId, 'roleId' => $roleId, 'relatedFieldOptionId' => $id));
if ($value == 1) {
if (empty($extraFieldOptionRelFieldOption)) {
$extraFieldOptionRelFieldOption = new \ChamiloLMS\Entity\ExtraFieldOptionRelFieldOption();
$extraFieldOptionRelFieldOption->setFieldId($field_id);
$extraFieldOptionRelFieldOption->setFieldOptionId($subItemId);
$extraFieldOptionRelFieldOption->setRelatedFieldOptionId($id);
示例8: return_form
/**
* Returns an HTML form for the current field
* @param string URL to send the form to (action=...)
* @param string Type of action to offer through the form (edit, usually)
*
* @return FormValidator
*/
public function return_form($url, $action)
{
$form_name = $this->type . '_field';
$form = new FormValidator($form_name, 'post', $url);
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('hidden', 'type', $this->type);
$form->addElement('hidden', 'field_id', $this->field_id);
$form->addElement('text', 'display_text', get_lang('Name'));
$form->addElement('text', 'option_value', get_lang('Value'));
$form->addElement('text', 'option_order', get_lang('Order'));
$form->addElement('select', 'priority', get_lang('Priority'), $this->getPriorityOptions());
$form->addElement('textarea', 'priority_message', get_lang('PriorityOfMessage'));
$defaults = array();
if ($action == 'edit') {
// Setting the defaults
$defaults = $this->get($id);
$form->freeze('option_value');
$form->addButtonUpdate(get_lang('Modify'));
} else {
$form->addButtonCreate(get_lang('Add'));
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('display_text', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('option_value', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
示例9: foreach
foreach ($form_fields as &$field) {
$field_value = explode(':', $field);
if ($field_value[0] != '' && $field_value[1] != '') {
$defaults[$field_value[0]] = $field_value[1];
}
}
}
}
$form->addElement('html', '</div>');
}
}
$form->addElement('html', '</div><br />');
if (isset($_GET['survey_id']) && $_GET['action'] == 'edit') {
$class = 'save';
$text = get_lang('ModifySurvey');
$form->addButtonUpdate(get_lang('ModifySurvey'), 'submit_survey');
} else {
$class = 'add';
$text = get_lang('CreateSurvey');
$form->addButtonCreate(get_lang('CreateSurvey'), 'submit_survey');
}
// Setting the rules
if ($_GET['action'] == 'add') {
$form->addRule('survey_code', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('survey_code', '', 'maxlength', 20);
}
$form->addRule('survey_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('start_date', get_lang('InvalidDate'), 'date');
$form->addRule('end_date', get_lang('InvalidDate'), 'date');
$form->addRule(array('start_date', 'end_date'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
// Setting the default values
示例10: isset
}
if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
// Updated on field
$last_edit_date = api_get_local_time($last_edit_date);
$display_date = date_to_str_ago($last_edit_date) . ' <span class="dropbox_date">' . api_format_date($last_edit_date) . '</span>';
$form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
}
$form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
$checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
if ($readonly == 1) {
$checked->setChecked(true);
}
}
if ($is_certificate_mode) {
$form->addButtonUpdate(get_lang('SaveCertificate'));
} else {
$form->addButtonUpdate(get_lang('SaveDocument'));
}
$defaults['filename'] = $filename;
$defaults['extension'] = $extension;
$defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
$defaults['commentPath'] = $file;
$defaults['renameTo'] = $file_name;
$defaults['comment'] = $document_data['comment'];
$defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
$defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
$form->setDefaults($defaults);
show_return($parent_id, $dir_original, $call_from_tool, $slide_id, $is_certificate_mode);
if ($is_certificate_mode) {
$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id());
示例11: intval
}
$form->addCheckBox('send_email', null, get_lang('SendMailToStudent'));
// Check if user to qualify has some DRHs
$drhList = UserManager::getDrhListFromUser($work_item['user_id']);
if (!empty($drhList)) {
$form->addCheckBox('send_to_drh_users', null, get_lang('SendMailToHR'));
}
}
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
$form->addElement('hidden', 'item_to_edit', $item_id);
$form->addElement('hidden', 'sec_token', $token);
$text = get_lang('UpdateWork');
$class = 'save';
// fix the Ok button when we see the tool in the learn path
$form->addButtonUpdate($text);
$form->setDefaults($defaults);
$error_message = null;
$_course = api_get_course_info();
$currentCourseRepositorySys = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/';
$succeed = false;
if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
/*
* SPECIAL CASE ! For a work edited
*/
//Get the author ID for that document from the item_property table
$item_to_edit_id = intval($_POST['item_to_edit']);
$is_author = user_is_author($item_to_edit_id);
if ($is_author) {
$work_data = get_work_data_by_id($item_to_edit_id);
示例12: elseif
}
} elseif (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($_GET['notebook_id'])) {
// Action handling: Editing a note
if (!empty($_GET['isStudentView'])) {
NotebookManager::display_notes();
exit;
}
// Initialize the object
$form = new FormValidator('note', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '¬ebook_id=' . Security::remove_XSS($_GET['notebook_id']));
// Setting the form elements
$form->addElement('header', '', get_lang('ModifyNote'));
$form->addElement('hidden', 'notebook_id');
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '100'));
//$form->applyFilter('note_title', 'html_filter');
$form->addElement('html_editor', 'note_comment', get_lang('NoteComment'), null, api_is_allowed_to_edit() ? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300') : array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'));
$form->addButtonUpdate(get_lang('ModifyNote'), 'SubmitNote');
// Setting the defaults
$defaults = NotebookManager::get_note_information(Security::remove_XSS($_GET['notebook_id']));
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
$res = NotebookManager::update_note($values);
if ($res) {
Display::display_confirmation_message(get_lang('NoteUpdated'));
}
}
示例13: array
$form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)'));
} else {
$form->addElement('label', get_lang('Attendances'), '<strong><em>' . get_lang('ThereAreNoAttendancesInsideCourse') . '</em></strong>');
}
$form->addElement('html', '<div id="div_datetime_attendance">');
if (!empty($calendar_select)) {
$form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select, array('id' => 'start_date_select_calendar'));
}
$form->addElement('html', '</div>');
$form->addElement('html', '</div>');
$form->addText('duration_in_hours', get_lang('DurationInHours'), false, array('size' => '3', 'id' => 'duration_in_hours_element', 'autofocus' => 'autofocus'));
$form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded' => 'false', 'ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
if ($action == 'thematic_advance_add') {
$form->addButtonSave(get_lang('Save'));
} else {
$form->addButtonUpdate(get_lang('Save'));
}
//$form->addElement('html', '<a href="#" id="save_button" onclick="save();">Save</a>');
$attendance_select_item_id = null;
if (count($attendance_select) > 1) {
$i = 1;
foreach ($attendance_select as $key => $attendance_select_item) {
if ($i == 2) {
$attendance_select_item_id = $key;
break;
}
$i++;
}
if (!empty($attendance_select_item_id)) {
$default['attendance_select'] = $attendance_select_item_id;
if ($thematic_advance_id) {
示例14: array
$group[] =& $form->createElement('password', 'password', null, array('onkeydown' => 'javascript: password_switch_radio_button(document.user_add,"password[password_auto]");'));
$form->addGroup($group, 'password', get_lang('Password'), '');
// Send email
$group = array();
$group[] =& $form->createElement('radio', 'send_mail', null, get_lang('Yes'), 1);
$group[] =& $form->createElement('radio', 'send_mail', null, get_lang('No'), 0);
$form->addGroup($group, 'mail', get_lang('SendMailToNewUser'), ' ');
// Set default values
$defaults = array();
$defaults['username'] = $userInfo['username'];
$defaults['mail']['send_mail'] = 0;
$defaults['password']['password_auto'] = 1;
$form->setDefaults($defaults);
// Submit button
$select_level = array();
$html_results_enabled[] = $form->addButtonUpdate(get_lang('Update'), 'submit', true);
$form->addGroup($html_results_enabled);
// Validate form
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$user = $form->exportValues();
$email = $userInfo['email'];
$username = $userInfo['username'];
$send_mail = intval($user['mail']['send_mail']);
$auth_source = PLATFORM_AUTH_SOURCE;
$resetPassword = $user['password']['password_auto'] == '1' ? 0 : 2;
if (count($extAuthSource) > 0 && $user['password']['password_auto'] == '2') {
//$auth_source = $user['password']['auth_source'];
//$password = 'PLACEHOLDER';
} else {
示例15: FormValidator
break;
case 'edit_glossary':
if (is_numeric($_GET['glossary_id'])) {
// initiate the object
$form = new FormValidator('glossary', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&glossary_id=' . intval($_GET['glossary_id']) . '&' . api_get_cidreq());
// Setting the form elements
$form->addElement('header', '', get_lang('TermEdit'));
$form->addElement('hidden', 'glossary_id');
$form->addElement('text', 'glossary_title', get_lang('TermName'), array('size' => '80'));
//$form->applyFilter('glossary_title', 'html_filter');
$form->addHtmlEditor('glossary_comment', get_lang('TermDefinition'), false, false, array('ToolbarSet' => 'Glossary', 'Height' => '300'));
$element = $form->addElement('text', 'insert_date', get_lang('CreationDate'), array('size' => '100'));
$element->freeze();
$element = $form->addElement('text', 'update_date', get_lang('UpdateDate'), array('size' => '100'));
$element->freeze();
$form->addButtonUpdate(get_lang('TermUpdateButton'), 'SubmitGlossary');
// setting the defaults
$glossary_data = GlossaryManager::get_glossary_information($_GET['glossary_id']);
// Date treatment for timezones
if (!empty($glossary_data['insert_date']) && $glossary_data['insert_date'] != '0000-00-00 00:00:00:') {
$glossary_data['insert_date'] = api_get_local_time($glossary_data['insert_date']);
} else {
$glossary_data['insert_date'] = '';
}
if (!empty($glossary_data['update_date']) && $glossary_data['update_date'] != '0000-00-00 00:00:00:') {
$glossary_data['update_date'] = api_get_local_time($glossary_data['update_date']);
} else {
$glossary_data['update_date'] = '';
}
$form->setDefaults($glossary_data);
// setting the rules