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


PHP FormValidator::freeze方法代码示例

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


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

示例1: return_form

 /**
  * Returns a Form validator Obj
  * @todo the form should be auto generated
  * @param   string  url
  * @param   string  action add, edit
  * @return  obj     form validator obj
  */
 public function return_form($url, $action)
 {
     $oFCKeditor = new FCKeditor('description');
     $oFCKeditor->ToolbarSet = 'careers';
     $oFCKeditor->Width = '100%';
     $oFCKeditor->Height = '200';
     $oFCKeditor->Value = '';
     $oFCKeditor->CreateHtml();
     $form = new FormValidator('career', '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->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers', 'Width' => '100%', 'Height' => '250'));
     $status_list = $this->get_status_list();
     $form->addElement('select', 'status', get_lang('Status'), $status_list);
     if ($action == 'edit') {
         $form->addElement('text', 'created_at', get_lang('CreatedAt'));
         $form->freeze('created_at');
     }
     if ($action == 'edit') {
         $form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
     } else {
         $form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
     }
     // Setting the defaults
     $defaults = $this->get($id);
     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('name', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:50,代码来源:event_email_template.class.php

示例2: FormValidator

    // We use the same form as in auth/profile.php
    $form = new FormValidator(
        'profile',
        'post',
        api_get_self()."?".str_replace('&show_form=1', '&show_form=1', $_SERVER['QUERY_STRING']),
        null,
        array('style' => 'width: 75%; float: '.($text_dir == 'rtl' ? 'right;' : 'left;'))
    );

    if (api_is_western_name_order()) {
        if ($list['firstname'] == 1) {
            //FIRST NAME
            $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
            if (api_get_setting('profile', 'name') !== 'true') {
                $form->freeze(array('firstname'));
            }
            $form->applyFilter(array('firstname'), 'stripslashes');
            $form->applyFilter(array('firstname'), 'trim');
            $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
        }
        if ($list['lastname'] == 1) {
            //    LAST NAME
            $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
            if (api_get_setting('profile', 'name') !== 'true') {
                $form->freeze(array('lastname'));
            }
            $form->applyFilter(array('lastname'), 'stripslashes');
            $form->applyFilter(array('lastname'), 'trim');
            $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
        }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:30,代码来源:fillsurvey.php

示例3: intval

    /**
     * @param FormValidator $form
     * @param $extra_data
     * @param $form_name
     * @param bool $admin_permissions
     * @param null $user_id
     * @deprecated
     * @return array
     */
    static function set_extra_fields_in_form($form, $extra_data, $admin_permissions = false, $user_id = null)
    {
        $user_id = intval($user_id);
        // EXTRA FIELDS
        $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
        $jquery_ready_content = null;
        foreach ($extra as $field_details) {
            if (!$admin_permissions) {
                if ($field_details[6] == 0) {
                    continue;
                }
            }
            switch ($field_details[2]) {
                case ExtraField::FIELD_TYPE_TEXT:
                    $form->addElement('text', 'extra_' . $field_details[1], $field_details[3], array('size' => 40));
                    $form->applyFilter('extra_' . $field_details[1], 'stripslashes');
                    $form->applyFilter('extra_' . $field_details[1], 'trim');
                    $form->applyFilter('extra_' . $field_details[1], 'html_filter');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_TEXTAREA:
                    $form->addHtmlEditor('extra_' . $field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
                    $form->applyFilter('extra_' . $field_details[1], 'stripslashes');
                    $form->applyFilter('extra_' . $field_details[1], 'trim');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_RADIO:
                    $group = array();
                    foreach ($field_details[9] as $option_id => $option_details) {
                        $options[$option_details[1]] = $option_details[2];
                        $group[] = $form->createElement('radio', 'extra_' . $field_details[1], $option_details[1], $option_details[2] . '<br />', $option_details[1]);
                    }
                    $form->addGroup($group, 'extra_' . $field_details[1], $field_details[3], '');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_SELECT:
                    $get_lang_variables = false;
                    if (in_array($field_details[1], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) {
                        $get_lang_variables = true;
                    }
                    $options = array();
                    foreach ($field_details[9] as $option_id => $option_details) {
                        if ($get_lang_variables) {
                            $options[$option_details[1]] = get_lang($option_details[2]);
                        } else {
                            $options[$option_details[1]] = $option_details[2];
                        }
                    }
                    if ($get_lang_variables) {
                        $field_details[3] = get_lang($field_details[3]);
                    }
                    $form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('id' => 'extra_' . $field_details[1]));
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
                    $options = array();
                    foreach ($field_details[9] as $option_id => $option_details) {
                        $options[$option_details[1]] = $option_details[2];
                    }
                    $form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('multiple' => 'multiple'));
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_DATE:
                    $form->addDatePicker('extra_' . $field_details[1], $field_details[3]);
                    $defaults['extra_' . $field_details[1]] = date('Y-m-d 12:00:00');
                    $form->setDefaults($defaults);
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
//.........这里部分代码省略.........
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:101,代码来源:usermanager.lib.php

示例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', 'field_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', 'class' => 'chzn-select', 'data-placeholder' => get_lang('Select')));
     $form->addElement('label', get_lang('Example'), '<div id="example">-</div>');
     $form->addElement('text', 'field_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_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', 'field_default_value', get_lang('FieldDefaultValue'), array('id' => 'field_default_value', 'class' => 'span5'));
     $group = array();
     $group[] = $form->createElement('radio', 'field_visible', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'field_visible', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('Visible'), '', false);
     $group = array();
     $group[] = $form->createElement('radio', 'field_changeable', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'field_changeable', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('FieldChangeability'), '', false);
     $group = array();
     $group[] = $form->createElement('radio', 'field_filter', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'field_filter', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('FieldFilter'), '', false);
     $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->addElement('button', 'submit', get_lang('Modify'), 'class="save"');
     } else {
         $defaults['field_visible'] = 0;
         $defaults['field_changeable'] = 0;
         $defaults['field_filter'] = 0;
         $form->addElement('button', 'submit', get_lang('Add'), 'class="save"');
     }
     /*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('field_display_text', get_lang('ThisFieldIsRequired'), 'required');
     //$form->addRule('field_variable', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('field_type', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:83,代码来源:extra_field.lib.php

示例5: 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 string HTML form
  */
 public function return_form($url, $action)
 {
     $form_name = $this->type . '_field';
     $form = new FormValidator($form_name, 'post', $url);
     // Settting 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', 'option_display_text', get_lang('Name'), array('class' => 'span5'));
     $form->addElement('text', 'option_value', get_lang('Value'), array('class' => 'span5'));
     $form->addElement('text', 'option_order', get_lang('Order'), array('class' => 'span2'));
     $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->addElement('button', 'submit', get_lang('Modify'), 'class="save"');
     } else {
         $form->addElement('button', 'submit', get_lang('Add'), 'class="save"');
     }
     $form->setDefaults($defaults);
     // Setting the rules
     $form->addRule('option_display_text', get_lang('ThisFieldIsRequired'), 'required');
     //$form->addRule('field_variable', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('option_value', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:41,代码来源:extra_field_option.lib.php

示例6: unset

$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']]);
$form->addButton('submit', $plugin->get_lang('ConfirmOrder'), 'check', 'success');
// View
$templateName = $plugin->get_lang('PaymentMethods');
$interbreadcrumb[] = array("url" => "course_catalog.php", "name" => $plugin->get_lang('CourseListOnSale'));
$tpl = new Template($templateName);
$tpl->assign('buying_course', $buyingCourse);
$tpl->assign('buying_session', $buyingSession);
$tpl->assign('user', api_get_user_info());
$tpl->assign('form', $form->returnForm());
if ($buyingCourse) {
    $tpl->assign('course', $courseInfo);
} elseif ($buyingSession) {
    $tpl->assign('session', $sessionInfo);
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:process.php

示例7: handle_stylesheets


//.........这里部分代码省略.........
        }
    }
    // Stylesheet upload.
    if (isset($_POST['stylesheet_upload'])) {
        if ($form->validate()) {
            $values = $form->exportValues();
            $picture_element = $form->getElement('new_stylesheet');
            $picture = $picture_element->getValue();
            $result = upload_stylesheet($values, $picture);
            // Add event to the system log.
            $user_id = api_get_user_id();
            $category = $_GET['category'];
            Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
            if ($result) {
                Display::display_confirmation_message(get_lang('StylesheetAdded'));
            }
        }
    }
    $form_change = new FormValidator('stylesheet_upload', 'post', api_get_self() . '?category=Stylesheets', null, array('id' => 'stylesheets_id'));
    $list_of_names = array();
    $selected = '';
    $dirpath = '';
    $safe_style_dir = '';
    if ($handle = @opendir(CSS_UPLOAD_PATH)) {
        $counter = 1;
        while (false !== ($style_dir = readdir($handle))) {
            if (substr($style_dir, 0, 1) == '.') {
                // Skip directories starting with a '.'
                continue;
            }
            $dirpath = CSS_UPLOAD_PATH . $style_dir;
            if (is_dir($dirpath)) {
                if ($style_dir != '.' && $style_dir != '..') {
                    if (isset($_POST['style']) && (isset($_POST['preview']) || isset($_POST['download'])) && $_POST['style'] == $style_dir) {
                        $safe_style_dir = $style_dir;
                    } else {
                        if ($currentstyle == $style_dir || $style_dir == 'chamilo' && !$currentstyle) {
                            if (isset($_POST['style'])) {
                                $selected = Database::escape_string($_POST['style']);
                            } else {
                                $selected = $style_dir;
                            }
                        }
                    }
                    $show_name = ucwords(str_replace('_', ' ', $style_dir));
                    if ($is_style_changeable) {
                        $list_of_names[$style_dir] = $show_name;
                    }
                    $counter++;
                }
            }
        }
        closedir($handle);
    }
    // Sort styles in alphabetical order.
    asort($list_of_names);
    $select_list = array();
    foreach ($list_of_names as $style_dir => $item) {
        $select_list[$style_dir] = $item;
    }
    $styles =& $form_change->addElement('select', 'style', get_lang('NameStylesheet'), $select_list);
    $styles->setSelected($selected);
    if ($form_change->validate()) {
        // Submit stylesheets.
        if (isset($_POST['save'])) {
            store_stylesheets();
            Display::display_normal_message(get_lang('Saved'));
        }
        if (isset($_POST['download'])) {
            $arch = api_get_path(SYS_ARCHIVE_PATH) . $safe_style_dir . '.zip';
            $dir = api_get_path(SYS_CSS_PATH) . 'themes/' . $safe_style_dir;
            if (is_dir($dir)) {
                $zip = new PclZip($arch);
                // Remove path prefix except the style name and put file on disk
                $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir, 0, -strlen($safe_style_dir)));
                //@TODO: use more generic script to download.
                $str = '<a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '">' . get_lang('ClickHereToDownloadTheFile') . '</a>';
                Display::display_normal_message($str, false);
            } else {
                Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning'));
            }
        }
    }
    if ($is_style_changeable) {
        $group = [$form_change->addButtonSave(get_lang('SaveSettings'), 'save', true), $form_change->addButtonPreview(get_lang('Preview'), 'preview', true), $form_change->addButtonDownload(get_lang('Download'), 'download', true)];
        $form_change->addGroup($group);
        if ($show_upload_form) {
            echo '<script>
            $(function() {
                $( "#tabs" ).tabs();
            });
            </script>';
            echo Display::tabs(array(get_lang('Update'), get_lang('UploadNewStylesheet')), array($form_change->return_form(), $form->return_form()));
        } else {
            $form_change->display();
        }
    } else {
        $form_change->freeze();
    }
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:settings.lib.php

示例8: array

$language_file = array('index', 'admin', 'registration');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
if (empty($_user['user_id'])) {
    api_not_allowed(true);
}
if (empty($_SESSION['origin_url'])) {
    $origin_url = $_SERVER['HTTP_REFERER'];
    Session::write('origin_url', $origin_url);
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
$form = new FormValidator('email_editor', 'post');
$form->addElement('hidden', 'dest');
$form->addElement('text', 'email_address', get_lang('EmailDestination'));
$form->addElement('text', 'email_title', get_lang('EmailTitle'), array('class' => 'span5'));
$form->freeze('email_address');
$form->addElement('textarea', 'email_text', get_lang('EmailText'), array('class' => 'span5', 'rows' => '6'));
$form->addRule('email_address', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('email_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('email_text', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('email_address', get_lang('EmailWrong'), 'email');
$form->addElement('button', 'submit', get_lang('SendMail'));
switch ($action) {
    case 'subscribe_me_to_session':
        $sessionName = isset($_GET['session']) ? Security::remove_XSS($_GET['session']) : null;
        $objTemplate = new Template();
        $objTemplate->assign('session_name', $sessionName);
        $objTemplate->assign('user', api_get_user_info());
        $mailTemplate = $objTemplate->get_template('mail/subscribe_me_to_session.tpl');
        $emailDest = api_get_setting('emailAdministrator');
        $emailTitle = get_lang('SubscribeToSessionRequest');
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:email_editor.php

示例9: array

    $group[] = $form->createElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
    $form->addGroup($group, '', array(get_lang("AllowLearningPathTheme")), '');
}
$allowLPReturnLink = api_get_setting('course.allow_lp_return_link');
if ($allowLPReturnLink === 'true') {
    $group = array($form->createElement('radio', 'lp_return_link', get_lang('LpReturnLink'), get_lang('RedirectToTheLearningPathList'), 1), $form->createElement('radio', 'lp_return_link', null, get_lang('RedirectToCourseHome'), 0));
    $form->addGroup($group, '', array(get_lang("LpReturnLink")), '');
}
if (is_settings_editable()) {
    $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
} else {
    // Is it allowed to edit the course settings?
    if (!is_settings_editable()) {
        $disabled_output = "disabled";
    }
    $form->freeze();
}
$form->addElement('html', '</div></div>');
// THEMATIC ADVANCE SETTINGS
$form->addElement('html', '<div><h3>' . Display::return_icon('course_progress.png', Security::remove_XSS(get_lang('ThematicAdvanceConfiguration')), '', ICON_SIZE_SMALL) . ' ' . Security::remove_XSS(get_lang('ThematicAdvanceConfiguration')) . '</h3><div>');
$group = array();
$group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', get_lang('InfoAboutAdvanceInsideHomeCourse'), get_lang('DisplayAboutLastDoneAdvance'), 1);
$group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDone'), 2);
$group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDoneAndLastDoneAdvance'), 3);
$group[] = $form->createElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DoNotDisplayAnyAdvance'), 0);
$form->addGroup($group, '', array(get_lang("InfoAboutAdvanceInsideHomeCourse")), '');
$form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
$form->addElement('html', '</div></div>');
// Document settings
$form->addElement('html', '<div><h3>' . Display::return_icon('folder.png', Security::remove_XSS(get_lang('Documents')), '', ICON_SIZE_SMALL) . ' ' . Security::remove_XSS(get_lang('Documents')) . '</h3><div>');
$group = array($form->createElement('radio', 'show_system_folders', null, get_lang('Yes'), 1), $form->createElement('radio', 'show_system_folders', null, get_lang('No'), 2));
开发者ID:daffef,项目名称:chamilo-lms,代码行数:31,代码来源:infocours.php

示例10: return_form

 /**
  * Returns a Form validator Obj
  * @todo the form should be auto generated
  * @param   string $url
  * @param   string $action
  *
  * @return  FormValidator
  */
 public function return_form($url, $action = 'add')
 {
     $form = new FormValidator('promotion', 'post', $url);
     // Setting the form elements
     $header = get_lang('Add');
     if ($action == 'edit') {
         $header = get_lang('Modify');
     }
     $id = isset($_GET['id']) ? intval($_GET['id']) : '';
     $form->addElement('header', '', $header);
     $form->addElement('hidden', 'id', $id);
     $form->addElement('text', 'name', get_lang('Name'), array('size' => '70', 'id' => 'name'));
     $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers', 'Width' => '100%', 'Height' => '250'));
     $career = new Career();
     $careers = $career->get_all();
     $career_list = array();
     foreach ($careers as $item) {
         $career_list[$item['id']] = $item['name'];
     }
     $form->addElement('select', 'career_id', get_lang('Career'), $career_list);
     $status_list = $this->get_status_list();
     $form->addElement('select', 'status', get_lang('Status'), $status_list);
     if ($action == 'edit') {
         $form->addElement('text', 'created_at', get_lang('CreatedAt'));
         $form->freeze('created_at');
     }
     if ($action == 'edit') {
         $form->addButtonSave(get_lang('Modify'), 'submit');
     } else {
         $form->addButtonCreate(get_lang('Add'), 'submit');
     }
     // Setting the defaults
     $defaults = $this->get($id);
     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('name', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:52,代码来源:promotion.lib.php

示例11: FormValidator

}
/*
 * Initialize the form.
 */
$form = new FormValidator('profile', 'post', api_get_self() . "?" . str_replace('&fe=1', '', Security::remove_XSS($_SERVER['QUERY_STRING'])), null);
if (api_is_western_name_order()) {
    //    FIRST NAME and LAST NAME
    $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
    $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
} else {
    //    LAST NAME and FIRST NAME
    $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40));
    $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
}
if (api_get_setting('profile', 'name') !== 'true') {
    $form->freeze(array('lastname', 'firstname'));
}
$form->applyFilter(array('lastname', 'firstname'), 'stripslashes');
$form->applyFilter(array('lastname', 'firstname'), 'trim');
$form->applyFilter(array('lastname', 'firstname'), 'html_filter');
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
//    USERNAME
$form->addElement('text', 'username', get_lang('UserName'), array('id' => 'username', 'maxlength' => USERNAME_MAX_LENGTH, 'size' => USERNAME_MAX_LENGTH));
if (api_get_setting('profile', 'login') !== 'true' || api_get_setting('login_is_email') == 'true') {
    $form->freeze('username');
}
$form->applyFilter('username', 'stripslashes');
$form->applyFilter('username', 'trim');
$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('username', get_lang('UsernameWrong'), 'username');
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:profile.php

示例12: header

    $values = $form->exportValues();
    $skill = $skillRepo->find($values['skill']);
    if (!$skill) {
        Display::addFlash(Display::return_message(get_lang('SkillNotFound'), 'error'));
        header('Location: ' . api_get_self() . '?' . http_build_query(['user' => $user->getId()]));
        exit;
    }
    if ($user->hasSkill($skill)) {
        Display::addFlash(Display::return_message(sprintf(get_lang('TheUserXHasAlreadyAchievedTheSkillY'), $user->getCompleteName(), $skill->getName()), 'warning'));
        header('Location: ' . api_get_self() . '?' . http_build_query(['user' => $user->getId()]));
        exit;
    }
    $skillUser = new SkillRelUser();
    $skillUser->setUser($user);
    $skillUser->setSkill($skill);
    $skillUser->setArgumentation($values['argumentation']);
    $skillUser->setAcquiredSkillAt(new DateTime());
    $skillUser->setAssignedBy(0);
    $entityManager->persist($skillUser);
    $entityManager->flush();
    Display::addFlash(Display::return_message(sprintf(get_lang('SkillXAssignedToUserY'), $skill->getName(), $user->getCompleteName()), 'success'));
    header('Location: ' . api_get_path(WEB_PATH) . "badge/{$skill->getId()}/user/{$user->getId()}");
    exit;
}
$form->setDefaults(['user_name' => $user->getCompleteName()]);
$form->freeze(['user_name']);
//View
$template = new Template('');
$template->assign('header', get_lang('AssignSkill'));
$template->assign('content', $form->returnForm());
$template->display_one_col_template();
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:assign.php

示例13: FormValidator

$form = new FormValidator('beneficiaries');
$form->addText('product_type', $plugin->get_lang('ProductType'), false);
$form->addText('name', get_lang('Name'), false);
$visibleCheckbox = $form->addCheckBox('visible', $plugin->get_lang('VisibleInCatalog'), $plugin->get_lang('ShowOnCourseCatalog'));
$form->addElement('number', 'price', [$plugin->get_lang('Price'), null, $currencyIso], ['step' => 0.01]);
$beneficiariesSelect = $form->addSelect('beneficiaries', $plugin->get_lang('Beneficiaries'), null, ['multiple' => 'multiple']);
if ($editingCourse) {
    $beneficiariesSelect->addOptGroup($teachersOptions, get_lang('Teachers'));
} elseif ($editingSession) {
    $beneficiariesSelect->addOptGroup([$generalCoachOption], get_lang('SessionGeneralCoach'));
    $beneficiariesSelect->addOptGroup($courseCoachesOptions, get_lang('SessionCourseCoach'));
}
$form->addHidden('t', null);
$form->addHidden('i', null);
$form->addButtonSave(get_lang('Save'));
$form->freeze(['product_type', 'name']);
if ($form->validate()) {
    $formValues = $form->exportValues();
    $productItem = $plugin->getItemByProduct($formValues['i'], $formValues['t']);
    if (isset($formValues['visible'])) {
        if (!empty($productItem)) {
            $plugin->updateItem(['price' => floatval($formValues['price'])], $formValues['i'], $formValues['t']);
        } else {
            $itemId = $plugin->registerItem(['currency_id' => $currency['id'], 'product_type' => $formValues['t'], 'product_id' => intval($formValues['i']), 'price' => floatval($_POST['price'])]);
            $productItem['id'] = $itemId;
        }
        $plugin->deleteItemBeneficiaries($productItem['id']);
        if (isset($formValues['beneficiaries'])) {
            $plugin->registerItemBeneficiaries($productItem['id'], $formValues['beneficiaries']);
        }
    } else {
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:configure_course.php


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