当前位置: 首页>>代码示例>>PHP>>正文


PHP FormValidator::addText方法代码示例

本文整理汇总了PHP中FormValidator::addText方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::addText方法的具体用法?PHP FormValidator::addText怎么用?PHP FormValidator::addText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormValidator的用法示例。


在下文中一共展示了FormValidator::addText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createAnswersForm

 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 public function createAnswersForm($form)
 {
     $defaults = array();
     $nb_matches = $nb_options = 2;
     $matches = array();
     $answer = null;
     $counter = 1;
     if (isset($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0) {
             for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                 $correct = $answer->isCorrect($i);
                 if (empty($correct)) {
                     $matches[$answer->selectAutoId($i)] = chr(64 + $counter);
                     $counter++;
                 }
             }
         }
     }
     if ($form->isSubmitted()) {
         $nb_matches = $form->getSubmitValue('nb_matches');
         $nb_options = $form->getSubmitValue('nb_options');
         if (isset($_POST['lessOptions'])) {
             $nb_matches--;
             $nb_options--;
         }
         if (isset($_POST['moreOptions'])) {
             $nb_matches++;
             $nb_options++;
         }
     } else {
         if (!empty($this->id)) {
             if (count($answer->nbrAnswers) > 0) {
                 $nb_matches = $nb_options = 0;
                 for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                     if ($answer->isCorrect($i)) {
                         $nb_matches++;
                         $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
                         $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
                         $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i];
                     } else {
                         $nb_options++;
                         $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
                     }
                 }
             }
         } else {
             $defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1');
             $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
             $defaults['matches[2]'] = '2';
             $defaults['option[1]'] = get_lang('DefaultMatchingOptA');
             $defaults['option[2]'] = get_lang('DefaultMatchingOptB');
         }
     }
     if (empty($matches)) {
         for ($i = 1; $i <= $nb_options; ++$i) {
             // fill the array with A, B, C.....
             $matches[$i] = chr(64 + $i);
         }
     } else {
         for ($i = $counter; $i <= $nb_options; ++$i) {
             // fill the array with A, B, C.....
             $matches[$i] = chr(64 + $i);
         }
     }
     $form->addElement('hidden', 'nb_matches', $nb_matches);
     $form->addElement('hidden', 'nb_options', $nb_options);
     // DISPLAY MATCHES
     $html = '<table class="table table-striped table-hover">
         <thead>
             <tr>
                 <th width="5%">' . get_lang('Number') . '</th>
                 <th width="70%">' . get_lang('Answer') . '</th>
                 <th width="15%">' . get_lang('MatchesTo') . '</th>
                 <th width="10%">' . get_lang('Weighting') . '</th>
             </tr>
         </thead>
         <tbody>';
     $form->addHeader(get_lang('MakeCorrespond'));
     $form->addHtml($html);
     if ($nb_matches < 1) {
         $nb_matches = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_matches; ++$i) {
         $renderer =& $form->defaultRenderer();
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "answer[{$i}]");
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "matches[{$i}]");
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "weighting[{$i}]");
         $form->addHtml('<tr>');
         $form->addHtml("<td>{$i}</td>");
         $form->addText("answer[{$i}]", null);
         $form->addSelect("matches[{$i}]", null, $matches);
         $form->addText("weighting[{$i}]", null, true, ['value' => 10]);
         $form->addHtml('</tr>');
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:matching.class.php

示例2: elseif

        echo '</table>';
    } else {
        echo '<div><em>' . get_lang('ThereIsNoAThematicSection') . '</em></div>';
    }
} elseif ($action == 'thematic_add' || $action == 'thematic_edit') {
    // Display form
    $form = new FormValidator('thematic_add', 'POST', 'index.php?action=thematic_add&' . api_get_cidreq());
    if ($action == 'thematic_edit') {
        $form->addElement('header', '', get_lang('EditThematicSection'));
    }
    $form->addElement('hidden', 'sec_token', $token);
    $form->addElement('hidden', 'action', $action);
    if (!empty($thematic_id)) {
        $form->addElement('hidden', 'thematic_id', $thematic_id);
    }
    $form->addText('title', get_lang('Title'), true, array('size' => '50'));
    $form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
    $form->addButtonSave(get_lang('Save'));
    $show_form = true;
    if (!empty($thematic_data)) {
        if (api_get_session_id()) {
            if ($thematic_data['session_id'] != api_get_session_id()) {
                $show_form = false;
                Display::display_error_message(get_lang('NotAllowedClickBack'), false);
            }
        }
        // set default values
        $default['title'] = $thematic_data['title'];
        $default['content'] = $thematic_data['content'];
        $form->setDefaults($default);
    }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:thematic.php

示例3: FormValidator

    }
}
$allSkills = $objSkill->get_all();
$allGradebooks = $objGradebook->find('all');
$skillList = [0 => get_lang('None')];
$gradebookList = [];
foreach ($allSkills as $skill) {
    $skillList[$skill['id']] = $skill['name'];
}
foreach ($allGradebooks as $gradebook) {
    $gradebookList[$gradebook['id']] = $gradebook['name'];
}
/* Form */
$createForm = new FormValidator('skill_create');
$createForm->addHeader(get_lang('CreateSkill'));
$createForm->addText('name', get_lang('Name'), true, ['id' => 'name']);
$createForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']);
$createForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']);
$createForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]);
$createForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]);
$createForm->addButtonSave(get_lang('Save'));
$createForm->addHidden('id', null);
$createForm->setDefaults($formDefaultValues);
if ($createForm->validate()) {
    $created = $objSkill->add($createForm->getSubmitValues());
    if ($created) {
        Display::return_message(get_lang('TheSkillHasBeenCreated'), 'success');
    } else {
        Display::return_message(get_lang('CannotCreateSkill'), 'error');
    }
    header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php');
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:skill_create.php

示例4: getCategoryForm

 /**
  * @param int $id
  * @param string $action
  *
  * @return FormValidator
  */
 public static function getCategoryForm($id, $action)
 {
     $form = new FormValidator('category', 'post', api_get_self() . '?action=' . $action . '&' . api_get_cidreq());
     $defaults = [];
     if ($action == 'addcategory') {
         $form->addHeader(get_lang('CategoryAdd'));
         $my_cat_title = get_lang('CategoryAdd');
     } else {
         $form->addHeader(get_lang('CategoryMod'));
         $my_cat_title = get_lang('CategoryMod');
         $defaults = self::getCategory($id);
     }
     $form->addHidden('id', $id);
     $form->addText('category_title', get_lang('CategoryName'));
     $form->addTextarea('description', get_lang('Description'));
     $form->addButtonSave($my_cat_title, 'submitCategory');
     $form->setDefaults($defaults);
     return $form;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:25,代码来源:link.lib.php

示例5: isset

        $groups = SystemAnnouncementManager::get_announcement_groups($announcement->id);
        $values['group'] = isset($groups['group_id']) ? $groups['group_id'] : 0;
        $action_todo = true;
        break;
}
if ($action_todo) {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
        $form_title = get_lang('AddNews');
        $url = api_get_self();
    } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $form_title = get_lang('EditNews');
        $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');
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:system_announcements.php

示例6: create_dir_form

 /**
  * Creates form that asks for the directory name.
  * @return string	html-output text for the form
  */
 public static function create_dir_form($dirId)
 {
     global $document_id;
     $form = new FormValidator('create_dir_form', 'post', api_get_self() . '?' . api_get_cidreq());
     $form->addElement('hidden', 'create_dir', 1);
     $form->addElement('hidden', 'dir_id', intval($document_id));
     $form->addElement('hidden', 'id', intval($dirId));
     $form->addElement('header', get_lang('CreateDir'));
     $form->addText('dirname', get_lang('NewDir'), array('autofocus' => 'autofocus'));
     $form->addButtonCreate(get_lang('CreateFolder'));
     return $form->returnForm();
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:16,代码来源:document.lib.php

示例7: get_search_form

 /**
  * Show the search form
  * @param string $query the value of the search box
  * @return string HTML form
  */
 public static function get_search_form($query)
 {
     $searchType = isset($_GET['search_type']) ? $_GET['search_type'] : null;
     $form = new FormValidator('search_user', 'get', api_get_path(WEB_PATH) . 'main/social/search.php', '', array(), FormValidator::LAYOUT_HORIZONTAL);
     $form->addText('q', get_lang('UsersGroups'), false);
     $options = array(0 => get_lang('Select'), 1 => get_lang('User'), 2 => get_lang('Group'));
     $form->addSelect('search_type', get_lang('Type'), $options, array('onchange' => 'javascript: extra_field_toogle();'));
     // Extra fields
     $extraFields = UserManager::get_extra_filtrable_fields();
     $defaults = [];
     if (is_array($extraFields) && count($extraFields) > 0) {
         foreach ($extraFields as $extraField) {
             $varName = 'field_' . $extraField['variable'];
             $options = [0 => get_lang('Select')];
             foreach ($extraField['data'] as $option) {
                 $checked = '';
                 if (isset($_GET[$varName])) {
                     if ($_GET[$varName] == $option[1]) {
                         $defaults[$option[1]] = true;
                     }
                 }
                 $options[$option[1]] = $option[1];
             }
             $form->addSelect($varName, $extraField['name'], $options);
         }
     }
     $defaults['search_type'] = intval($searchType);
     $defaults['q'] = api_htmlentities(Security::remove_XSS($query));
     $form->setDefaults($defaults);
     $form->addButtonSearch(get_lang('Search'));
     $js = '<script>
     extra_field_toogle();
     function extra_field_toogle() {
         if (jQuery("select[name=search_type]").val() != "1") { jQuery(".extra_field").hide(); } else { jQuery(".extra_field").show(); }
     }
     </script>';
     return $js . $form->returnForm();
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:43,代码来源:usermanager.lib.php

示例8: intval

$tpl = Container::getTwig();
$load_user = 0;
if (isset($_GET['load_user'])) {
    $load_user = 1;
}
$skill_condition = '';
$tpl->addGlobal('skill_id_to_load', '');
if (isset($_GET['skill_id'])) {
    $skillId = intval($_GET['skill_id']);
    $skill_condition = '&skill_id=' . $skillId;
    $tpl->addGlobal('skill_id_to_load', $skillId);
}
$url = api_get_path(WEB_AJAX_PATH) . "skill.ajax.php?a=get_skills_tree_json&load_user={$load_user}";
$tpl->addGlobal('wheel_url', $url);
$url = api_get_path(WEB_AJAX_PATH) . 'skill.ajax.php?1=1';
$tpl->addGlobal('url', $url);
$tpl->addGlobal('isAdministration', true);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
$dialogForm->addLabel(get_lang('Name'), Display::tag('p', null, ['id' => 'name', 'class' => 'form-control-static']));
$dialogForm->addLabel(get_lang('ShortCode'), Display::tag('p', null, ['id' => 'short_code', 'class' => 'form-control-static']));
$dialogForm->addLabel(get_lang('Parent'), Display::tag('p', null, ['id' => 'parent', 'class' => 'form-control-static']));
$dialogForm->addLabel([get_lang('Gradebook'), get_lang('WithCertificate')], Display::tag('ul', null, ['id' => 'gradebook', 'class' => 'form-control-static list-unstyled']));
$dialogForm->addLabel(get_lang('Description'), Display::tag('p', null, ['id' => 'description', 'class' => 'form-control-static']));
$tpl->addGlobal('dialogForm', $dialogForm->returnForm());
$saveProfileForm = new FormValidator('form', 'post', null, null, ['id' => 'dialog-form-profile']);
$saveProfileForm->addHidden('profile_id', null);
$saveProfileForm->addText('name', get_lang('Name'), true, ['id' => 'name_profile']);
$saveProfileForm->addTextarea('description', get_lang('Description'), ['id' => 'description_profile', 'rows' => 6]);
$tpl->addGlobal('saveProfileForm', $saveProfileForm->returnForm());
echo $tpl->render('@template_style/skill/skill_wheel.html.twig');
Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';
开发者ID:daffef,项目名称:chamilo-lms,代码行数:31,代码来源:skills_wheel.php

示例9: FormValidator

    // Create directory
    if (!$is_certificate_mode) {
        $actionsLeft .= Display::url(Display::return_icon('new_folder.png', get_lang('CreateDir'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'document/document.php?' . api_get_cidreq() . '&id=' . $document_id . '&createdir=1');
    }
}
require 'document_slideshow.inc.php';
if ($image_present && !isset($_GET['keyword'])) {
    $actionsLeft .= Display::url(Display::return_icon('slideshow.png', get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'document/slideshow.php?' . api_get_cidreq() . '&curdirpath=' . $curdirpathurl);
}
if (api_is_allowed_to_edit(null, true)) {
    $actionsLeft .= Display::url(Display::return_icon('percentage.png', get_lang('DocumentQuota'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'document/document_quota.php?' . api_get_cidreq());
}
if (!$is_certificate_mode) {
    /* BUILD SEARCH FORM */
    $form = new FormValidator('search_document', 'get', api_get_self() . '?' . api_get_cidreq(), '', array(), FormValidator::LAYOUT_INLINE);
    $form->addText('keyword', '', false, array('class' => 'col-md-2'));
    $form->addElement('hidden', 'cidReq', api_get_course_id());
    $form->addElement('hidden', 'id_session', api_get_session_id());
    $form->addElement('hidden', 'gidReq', $groupId);
    $form->addButtonSearch(get_lang('Search'));
    $actionsRight = $form->returnForm();
}
$table_footer = '';
$total_size = 0;
$sortable_data = array();
if (isset($documentAndFolders) && is_array($documentAndFolders)) {
    if ($groupId == 0 || GroupManager::user_has_access($userId, $groupId, GroupManager::GROUP_TOOL_DOCUMENTS)) {
        $count = 1;
        $countedPaths = array();
        $countedPaths = array();
        foreach ($documentAndFolders as $key => $document_data) {
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:document.php

示例10: document_exists

// Filename
$form->addElement('hidden', 'title_edited', 'false', 'id="title_edited"');
/**
 * Check if a document width the chosen filename already exists
 */
function document_exists($filename)
{
    global $dir;
    $cleanName = api_replace_dangerous_char($filename);
    // No "dangerous" files
    $cleanName = disable_dangerous_file($cleanName);
    return !DocumentManager::documentExists($dir . $cleanName . '.html', api_get_course_info(), api_get_session_id(), api_get_group_id());
}
// Add group to the form
if ($is_certificate_mode) {
    $form->addText('title', get_lang('CertificateName'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
} else {
    $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus'));
}
// Show read-only box only in groups
if (!empty($groupId)) {
    $group[] = $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
}
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists');
$current_session_id = api_get_session_id();
$form->addHtmlEditor('content', '', true, false, $editorConfig);
// Comment-field
$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit);
// If we are not in the certificates creation, display a folder chooser for the
// new document created
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:create_document.php

示例11: createAnswersForm

 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 function createAnswersForm($form)
 {
     $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
     $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
     $obj_ex = Session::read('objExercise');
     $html = '<table class="table table-striped table-hover">';
     $html .= '<thead>';
     $html .= '<tr>';
     $html .= '<th width="10">' . get_lang('Number') . '</th>';
     $html .= '<th width="10">' . get_lang('True') . '</th>';
     $html .= '<th width="50%">' . get_lang('Comment') . '</th>';
     $html .= '<th width="50%">' . get_lang('Answer') . '</th>';
     $html .= '</tr>';
     $html .= '</thead>';
     $html .= '<tbody>';
     $form->addHeader(get_lang('Answers'));
     $form->addHtml($html);
     $defaults = array();
     $correct = 0;
     $answer = false;
     if (!empty($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
             $nb_answers = $answer->nbrAnswers;
         }
     }
     $form->addElement('hidden', 'nb_answers');
     $boxes_names = array();
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_answers; ++$i) {
         $form->addHtml('<tr>');
         if (is_object($answer)) {
             $defaults['answer[' . $i . ']'] = $answer->answer[$i];
             $defaults['comment[' . $i . ']'] = $answer->comment[$i];
             $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
             $defaults['correct[' . $i . ']'] = $answer->correct[$i];
         } else {
             $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2');
             $defaults['comment[1]'] = get_lang('DefaultMultipleComment2');
             $defaults['correct[1]'] = true;
             $defaults['weighting[1]'] = 10;
             $defaults['answer[2]'] = get_lang('DefaultMultipleAnswer1');
             $defaults['comment[2]'] = get_lang('DefaultMultipleComment1');
             $defaults['correct[2]'] = false;
         }
         $renderer =& $form->defaultRenderer();
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']');
         $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
         $answer_number->freeze();
         $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox" style="margin-left: 0em;"');
         $boxes_names[] = 'correct[' . $i . ']';
         $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
         $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
         $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
         $form->addHtml('</tr>');
     }
     $form->addElement('html', '</tbody></table>');
     $form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
     //only 1 answer the all deal ...
     $form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]);
     global $text;
     //ie6 fix
     if ($obj_ex->edit_exercise_in_lp == true) {
         // setting the save button here and not in the question class.php
         $buttonGroup = [$form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true), $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true), $form->addButtonSave($text, 'submitQuestion', true)];
         $form->addGroup($buttonGroup);
     }
     $defaults['correct'] = $correct;
     if (!empty($this->id)) {
         $form->setDefaults($defaults);
     } else {
         if ($this->isContent == 1) {
             $form->setDefaults($defaults);
         }
     }
     $form->setConstants(array('nb_answers' => $nb_answers));
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:88,代码来源:multiple_answer_combination.class.php

示例12: header

if ($form->validate()) {
    $formValues = $form->getSubmitValues();
    if (!$formValues['payment_type']) {
        Display::addFlash(Display::return_message($plugin->get_lang('NeedToSelectPaymentType'), 'error', false));
        header('Location:' . api_get_self() . '?' . $queryString);
        exit;
    }
    $saleId = $plugin->registerSale($item['id'], $formValues['payment_type']);
    if ($saleId !== false) {
        $_SESSION['bc_sale_id'] = $saleId;
        header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/process_confirm.php');
    }
    exit;
}
$form->addHeader($plugin->get_lang('UserInformation'));
$form->addText('name', get_lang('Name'), false, ['cols-size' => [5, 7, 0]]);
$form->addText('username', get_lang('Username'), false, ['cols-size' => [5, 7, 0]]);
$form->addText('email', get_lang('EmailAddress'), false, ['cols-size' => [5, 7, 0]]);
$form->addHeader($plugin->get_lang('PaymentMethods'));
$paymentTypesOptions = $plugin->getPaymentTypes();
if (!$paypalEnabled) {
    unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL]);
}
if (!$transferEnabled) {
    unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER]);
}
$form->addRadio('payment_type', null, $paymentTypesOptions);
$form->addHidden('t', intval($_GET['t']));
$form->addHidden('i', intval($_GET['i']));
$form->freeze(['name', 'username', 'email']);
$form->setDefaults(['name' => $userInfo['complete_name'], 'username' => $userInfo['username'], 'email' => $userInfo['email']]);
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:process.php

示例13: createAnswersForm


//.........这里部分代码省略.........
     }
     $temp_scenario = array();
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_answers; ++$i) {
         $form->addHtml('<tr>');
         if (isset($answer) && is_object($answer)) {
             if ($answer->correct[$i]) {
                 $correct = $i;
             }
             $defaults['answer[' . $i . ']'] = $answer->answer[$i];
             $defaults['comment[' . $i . ']'] = $answer->comment[$i];
             $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
             $item_list = explode('@@', $answer->destination[$i]);
             $try = isset($item_list[0]) ? $item_list[0] : '';
             $lp = isset($item_list[1]) ? $item_list[1] : '';
             $list_dest = isset($item_list[2]) ? $item_list[2] : '';
             $url = isset($item_list[3]) ? $item_list[3] : '';
             if ($try == 0) {
                 $try_result = 0;
             } else {
                 $try_result = 1;
             }
             if ($url == 0) {
                 $url_result = '';
             } else {
                 $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"');
         $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editor_config);
         $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
         if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
             $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $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' => 'col-md-2', '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->addHtmlEditor('comment[' . $i . ']', null, null, false, $editor_config);
         }
         $form->addText('weighting[' . $i . ']', null, null, array('value' => '0'));
         $form->addHtml('</tr>');
     }
     $form->addHtml('</tbody>');
     $form->addHtml('</table>');
     global $text;
     $buttonGroup = [];
     //ie6 fix
     if ($obj_ex->edit_exercise_in_lp == true) {
         //setting the save button here and not in the question class.php
         $buttonGroup[] = $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true);
         $buttonGroup[] = $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true);
         $buttonGroup[] = $form->addButtonSave($text, 'submitQuestion', true);
         $form->addGroup($buttonGroup);
     }
     // 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));
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:101,代码来源:unique_answer.class.php

示例14: api_get_self

<?php

/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for creating course category
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
* @package chamilo.auth
*/
// Acces rights: anonymous users can't do anything usefull here.
api_block_anonymous_users();
$stok = Security::get_token();
?>
<!-- Actions: The menu with the different options in cathe course management -->
<div id="actions" class="actions">
    <a href="<?php 
echo api_get_self();
?>
?action=sortmycourses">
        <?php 
echo Display::return_icon('back.png', get_lang('Back'), '', '32');
?>
    </a>
</div>

<?php 
$form = new FormValidator('create_course_category', 'post', api_get_self() . '?createcoursecategory');
$form->addHidden('sec_token', $stok);
$form->addText('title_course_category', get_lang('Name'));
$form->addButtonSave(get_lang('AddCategory'), 'create_course_category');
$form->display();
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:30,代码来源:categories_list.php

示例15: ON

$sql = "SELECT user_id,lastname,firstname FROM {$table_user} WHERE status=1" . $order_clause;
// Filtering teachers when creating a course.
if (api_is_multiple_url_enabled()) {
    $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
    $sql = "SELECT u.user_id,lastname,firstname FROM {$table_user} as u\n            INNER JOIN {$access_url_rel_user_table} url_rel_user\n            ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=" . api_get_current_access_url_id() . " AND status=1" . $order_clause;
}
$res = Database::query($sql);
$teachers = array();
while ($obj = Database::fetch_object($res)) {
    $teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
}
// Build the form.
$form = new FormValidator('update_course');
$form->addElement('header', $tool_name);
// Title
$form->addText('title', get_lang('Title'), true);
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
// Code
$form->addText('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')), false, ['maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE, 'pattern' => '[a-zA-Z0-9]+', 'title' => get_lang('OnlyLettersAndNumbers')]);
$form->applyFilter('visual_code', 'api_strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$form->addRule('visual_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE);
$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select"  style="width:350px" multiple="multiple" ');
$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');
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:course_add.php


注:本文中的FormValidator::addText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。