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


PHP FormValidator::applyFilter方法代码示例

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


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

示例1: display_item_form

 /**
  * Return the HTML form to display an item (generally a section/module item)
  * @param	string	Item type (module/dokeos_module)
  * @param	string	Title (optional, only when creating)
  * @param	string	Action ('add'/'edit')
  * @param	integer	lp_item ID
  * @param	mixed	Extra info
  * @return	string 	HTML form
  */
 public function display_item_form($item_type, $title = '', $action = 'add_item', $id = 0, $extra_info = 'new')
 {
     $course_id = api_get_course_int_id();
     $_course = api_get_course_info();
     global $charset;
     $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     if ($id != 0 && is_array($extra_info)) {
         $item_title = $extra_info['title'];
         $item_description = $extra_info['description'];
         $item_path = api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/scorm/' . $this->path . '/' . stripslashes($extra_info['path']);
         $item_path_fck = '/scorm/' . $this->path . '/' . stripslashes($extra_info['path']);
     } else {
         $item_title = '';
         $item_description = '';
         $item_path_fck = '';
     }
     if ($id != 0 && is_array($extra_info)) {
         $parent = $extra_info['parent_item_id'];
     } else {
         $parent = 0;
     }
     $id = intval($id);
     $sql = "SELECT * FROM " . $tbl_lp_item . "\n                WHERE\n                    c_id = " . $course_id . " AND\n                    lp_id = " . $this->lp_id . " AND\n                    id != {$id}";
     if ($item_type == 'module') {
         $sql .= " AND parent_item_id = 0";
     }
     $result = Database::query($sql);
     $arrLP = array();
     while ($row = Database::fetch_array($result)) {
         $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], 'path' => $row['path'], 'description' => $row['description'], 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite'], 'display_order' => $row['display_order']);
     }
     $this->tree_array($arrLP);
     $arrLP = isset($this->arrMenu) ? $this->arrMenu : null;
     unset($this->arrMenu);
     $url = api_get_self() . '?' . api_get_cidreq() . '&action=' . $action . '&type=' . $item_type . '&lp_id=' . $this->lp_id;
     $form = new FormValidator('form', 'POST', $url);
     $defaults['title'] = !empty($item_title) ? api_html_entity_decode($item_title, ENT_QUOTES, $charset) : '';
     $defaults['description'] = $item_description;
     $form->addElement('header', $title);
     //$arrHide = array($id);
     $arrHide[0]['value'] = Security::remove_XSS($this->name);
     $arrHide[0]['padding'] = 20;
     $charset = api_get_system_encoding();
     if ($item_type != 'module' && $item_type != 'dokeos_module') {
         for ($i = 0; $i < count($arrLP); $i++) {
             if ($action != 'add') {
                 if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
                     $arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
                     if ($parent == $arrLP[$i]['id']) {
                         $s_selected_parent = $arrHide[$arrLP[$i]['id']];
                     }
                 }
             } else {
                 if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
                     $arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
                     if ($parent == $arrLP[$i]['id']) {
                         $s_selected_parent = $arrHide[$arrLP[$i]['id']];
                     }
                 }
             }
         }
         if ($action != 'move') {
             $form->addElement('text', 'title', get_lang('Title'));
             $form->applyFilter('title', 'html_filter');
             $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
         } else {
             $form->addElement('hidden', 'title');
         }
         $parent_select = $form->addElement('select', 'parent', get_lang('Parent'), '', array('id' => 'idParent', 'onchange' => "javascript: load_cbo(this.value);"));
         foreach ($arrHide as $key => $value) {
             $parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"');
         }
         if (!empty($s_selected_parent)) {
             $parent_select->setSelected($s_selected_parent);
         }
     }
     if (is_array($arrLP)) {
         reset($arrLP);
     }
     $arrHide = array();
     // POSITION
     for ($i = 0; $i < count($arrLP); $i++) {
         if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) {
             //this is the same!
             if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) {
                 $s_selected_position = $arrLP[$i]['id'];
             } elseif ($action == 'add') {
                 $s_selected_position = $arrLP[$i]['id'];
             }
//.........这里部分代码省略.........
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:101,代码来源:learnpath.class.php

示例2: setForm

 /**
  * @param FormValidator $form
  * @param string        $type
  * @param array         $data
  */
 public function setForm($form, $type = 'add', $data = array())
 {
     switch ($type) {
         case 'add':
             $header = get_lang('Add');
             break;
         case 'edit':
             $header = get_lang('Edit');
             break;
     }
     $form->addElement('header', $header);
     //Name
     $form->addElement('text', 'name', get_lang('Name'), array('maxlength' => 255));
     $form->applyFilter('name', 'html_filter');
     $form->applyFilter('name', 'trim');
     $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('name', '', 'maxlength', 255);
     // Description
     $form->addElement('textarea', 'description', get_lang('Description'), array('cols' => 58));
     $form->applyFilter('description', 'html_filter');
     $form->applyFilter('description', 'trim');
     if ($this->showGroupTypeSetting) {
         $form->addElement('checkbox', 'group_type', null, get_lang('SocialGroup'));
     }
     // url
     $form->addElement('text', 'url', get_lang('Url'));
     $form->applyFilter('url', 'html_filter');
     $form->applyFilter('url', 'trim');
     // Picture
     $allowed_picture_types = $this->getAllowedPictureExtensions();
     $form->addElement('file', 'picture', get_lang('AddPicture'));
     $form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
     if (isset($data['picture']) && strlen($data['picture']) > 0) {
         $picture = $this->get_picture_group($data['id'], $data['picture'], 80);
         $img = '<img src="' . $picture['file'] . '" />';
         $form->addElement('label', null, $img);
         $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
     }
     $form->addElement('select', 'visibility', get_lang('GroupPermissions'), $this->getGroupStatusList());
     $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
     // Setting the form elements
     if ($type == 'add') {
         $form->addButtonCreate($header);
     } else {
         $form->addButtonUpdate($header);
     }
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:52,代码来源:usergroup.lib.php

示例3: urldecode

      textarea = document.forms[0].description.value;
   }
}
</script>';
// Database table definitions
if (!empty($_GET['message'])) {
    $message = urldecode($_GET['message']);
}
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$tool_name = get_lang('AddGroups');
// Create the form
$form = new FormValidator('group_add');
$form->addElement('header', $tool_name);
// name
$form->addElement('text', 'name', get_lang('Name'), array('size' => 60, 'maxlength' => 120));
$form->applyFilter('name', 'html_filter');
$form->applyFilter('name', 'trim');
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
// Description
$form->addElement('textarea', 'description', get_lang('Description'), array('rows' => 3, 'cols' => 58, 'onKeyDown' => "text_longitud()", 'onKeyUp' => "text_longitud()"));
$form->applyFilter('description', 'html_filter');
$form->applyFilter('description', 'trim');
// url
$form->addElement('text', 'url', get_lang('URL'), array('size' => 35));
$form->applyFilter('url', 'html_filter');
$form->applyFilter('url', 'trim');
// Picture
$form->addElement('file', 'picture', get_lang('AddPicture'));
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(', ', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
//Group Parentship
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:group_add.php

示例4: array

$table_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD);
$table_uf_opt = Database::get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
$table_uf_val = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'user_fields.php', 'name' => get_lang('UserFields'));
if ($_GET['action'] != 'edit') {
    $tool_name = get_lang('AddUserFields');
} else {
    $tool_name = get_lang('EditUserFields');
}
// Create the form
$form = new FormValidator('user_fields_add');
$form->addElement('header', '', $tool_name);
// Field display name
$form->addElement('text', 'fieldtitle', get_lang('FieldTitle'));
$form->applyFilter('fieldtitle', 'html_filter');
$form->applyFilter('fieldtitle', 'trim');
$form->addRule('fieldtitle', get_lang('ThisFieldIsRequired'), 'required');
// Field type
$types = UserManager::get_user_field_types();
$form->addElement('select', 'fieldtype', get_lang('FieldType'), $types, array('onchange' => 'change_image_user_field(this.value)'));
$form->addRule('fieldtype', get_lang('ThisFieldIsRequired'), 'required');
//Advanced parameters
$form->addElement('advanced_settings', '<a href="javascript://" onclick=" return advanced_parameters()"><span id="img_plus_and_minus"><div style="vertical-align:top;" >' . $showImg . '&nbsp;' . get_lang('AdvancedParameters') . '</div></span></a>');
//When edit, the combobox displey the field type displeyed else none
if (isset($_GET['action']) && $_GET['action'] == 'edit' && in_array($_GET['field_type'], array(3, 4, 5, 8))) {
    $form->addElement('html', '<div id="options" style="display:block">');
} else {
    $form->addElement('html', '<div id="options" style="display:none">');
}
//field label
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:user_fields_add.php

示例5: array

$table_uf_opt = Database::get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
$table_uf_val = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
$interbreadcrumb[] = array('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
if ($_GET['action'] != 'edit') {
    $tool_name = get_lang('AddSpecificSearchField');
} else {
    $tool_name = get_lang('EditSpecificSearchField');
}
// Create the form
$form = new FormValidator('specific_fields_add');
// Field variable name
$form->addElement('hidden', 'field_id', (int) $_REQUEST['field_id']);
$form->addElement('text', 'field_name', get_lang('FieldName'));
$form->applyFilter('field_name', 'html_filter');
$form->applyFilter('field_name', 'trim');
$form->addRule('field_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('field_name', get_lang('OnlyLettersAndNumbersAllowed'), 'username');
$form->addRule('field_name', '', 'maxlength', 20);
// Set default values (only not empty when editing)
$defaults = array();
if (is_numeric($_REQUEST['field_id'])) {
    $form_information = get_specific_field_list(array('id' => (int) $_GET['field_id']));
    $defaults['field_name'] = $form_information[0]['name'];
}
$form->setDefaults($defaults);
// Submit button
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="add"');
// Validate form
if ($form->validate()) {
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:specific_fields_add.php

示例6: set_extra_fields_in_form

    /**
     * @param FormValidator $form
     * @param array $extraData
     * @param string $form_name
     * @param bool $admin_permissions
     * @param int $user_id
     * @param array $extra
     * @param int $itemId
     *
     * @return array
     */
    public function set_extra_fields_in_form($form, $extraData, $form_name, $admin_permissions = false, $user_id = null, $extra = array(), $itemId = null)
    {
        $user_id = intval($user_id);
        $type = $this->type;
        // User extra fields
        if ($type == 'user') {
            $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC', true, null, true);
        }
        $jquery_ready_content = null;
        if (!empty($extra)) {
            foreach ($extra as $field_details) {
                // Getting default value id if is set
                $defaultValueId = null;
                if (isset($field_details['options']) && !empty($field_details['options'])) {
                    $valueToFind = null;
                    if (isset($field_details['field_default_value'])) {
                        $valueToFind = $field_details['field_default_value'];
                    }
                    // If a value is found we override the default value
                    if (isset($extraData['extra_' . $field_details['field_variable']])) {
                        $valueToFind = $extraData['extra_' . $field_details['field_variable']];
                    }
                    foreach ($field_details['options'] as $option) {
                        if ($option['option_value'] == $valueToFind) {
                            $defaultValueId = $option['id'];
                        }
                    }
                }
                if (!$admin_permissions) {
                    if ($field_details['field_visible'] == 0) {
                        continue;
                    }
                }
                switch ($field_details['field_type']) {
                    case ExtraField::FIELD_TYPE_TEXT:
                        $form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('class' => 'span4'));
                        $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes');
                        $form->applyFilter('extra_' . $field_details['field_variable'], 'trim');
                        if (!$admin_permissions) {
                            if ($field_details['field_visible'] == 0) {
                                $form->freeze('extra_' . $field_details['field_variable']);
                            }
                        }
                        break;
                    case ExtraField::FIELD_TYPE_TEXTAREA:
                        $form->add_html_editor('extra_' . $field_details['field_variable'], $field_details['field_display_text'], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
                        $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes');
                        $form->applyFilter('extra_' . $field_details['field_variable'], 'trim');
                        if (!$admin_permissions) {
                            if ($field_details['field_visible'] == 0) {
                                $form->freeze('extra_' . $field_details['field_variable']);
                            }
                        }
                        break;
                    case ExtraField::FIELD_TYPE_RADIO:
                        $group = array();
                        if (isset($field_details['options']) && !empty($field_details['options'])) {
                            foreach ($field_details['options'] as $option_details) {
                                $options[$option_details['option_value']] = $option_details['option_display_text'];
                                $group[] = $form->createElement('radio', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']);
                            }
                        }
                        $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], '');
                        if (!$admin_permissions) {
                            if ($field_details['field_visible'] == 0) {
                                $form->freeze('extra_' . $field_details['field_variable']);
                            }
                        }
                        break;
                    case ExtraField::FIELD_TYPE_CHECKBOX:
                        $group = array();
                        if (isset($field_details['options']) && !empty($field_details['options'])) {
                            foreach ($field_details['options'] as $option_details) {
                                $options[$option_details['option_value']] = $option_details['option_display_text'];
                                $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']);
                            }
                        } else {
                            // We assume that is a switch on/off with 1 and 0 as values
                            $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], null, 'Yes <br />', null);
                        }
                        $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], '');
                        if (!$admin_permissions) {
                            if ($field_details['field_visible'] == 0) {
                                $form->freeze('extra_' . $field_details['field_variable']);
                            }
                        }
                        break;
                    case ExtraField::FIELD_TYPE_SELECT:
                        $get_lang_variables = false;
//.........这里部分代码省略.........
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:extra_field.lib.php

示例7: display_document_form


//.........这里部分代码省略.........
     }
     $sql = "SELECT * FROM " . $tbl_lp_item . "\n                WHERE c_id = " . $course_id . " AND lp_id = " . $this->lp_id;
     $result = Database::query($sql);
     $arrLP = array();
     while ($row = Database::fetch_array($result)) {
         $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], 'path' => $row['path'], 'description' => $row['description'], 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'display_order' => $row['display_order'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite']);
     }
     $this->tree_array($arrLP);
     $arrLP = null;
     if (isset($this->arrMenu)) {
         $arrLP = $this->arrMenu;
         unset($this->arrMenu);
     }
     if ($action == 'add') {
         $return .= get_lang('CreateTheDocument');
     } elseif ($action == 'move') {
         $return .= get_lang('MoveTheCurrentDocument');
     } else {
         $return .= get_lang('EditTheCurrentDocument');
     }
     $return .= '</legend>';
     if (isset($_GET['edit']) && $_GET['edit'] == 'true') {
         $return .= Display::return_warning_message('<strong>' . get_lang('Warning') . ' !</strong><br />' . get_lang('WarningEditingDocument'), false);
     }
     $form = new FormValidator('form', 'POST', api_get_self() . '?' . $_SERVER['QUERY_STRING'], '', array('enctype' => "multipart/form-data"));
     $defaults['title'] = Security::remove_XSS($item_title);
     if (empty($item_title)) {
         $defaults['title'] = Security::remove_XSS($item_title);
     }
     $defaults['description'] = $item_description;
     $form->addElement('html', $return);
     if ($action != 'move') {
         $form->addElement('text', 'title', get_lang('Title'), array('id' => 'idTitle', 'class' => 'span4'));
         $form->applyFilter('title', 'html_filter');
     }
     //$arrHide = array($id);
     $arrHide[0]['value'] = $this->name;
     $arrHide[0]['padding'] = 3;
     for ($i = 0; $i < count($arrLP); $i++) {
         if ($action != 'add') {
             if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
                 $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
                 $arrHide[$arrLP[$i]['id']]['padding'] = 3 + $arrLP[$i]['depth'] * 10;
                 if ($parent == $arrLP[$i]['id']) {
                     $s_selected_parent = $arrHide[$arrLP[$i]['id']];
                 }
             }
         } else {
             if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') {
                 $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
                 $arrHide[$arrLP[$i]['id']]['padding'] = 3 + $arrLP[$i]['depth'] * 10;
                 if ($parent == $arrLP[$i]['id']) {
                     $s_selected_parent = $arrHide[$arrLP[$i]['id']];
                 }
             }
         }
     }
     $parent_select = $form->addElement('select', 'parent', get_lang('Parent'), '', 'class="learnpath_item_form" id="idParent" style="width:40%;" onchange="javascript: load_cbo(this.value);"');
     $my_count = 0;
     foreach ($arrHide as $key => $value) {
         if ($my_count != 0) {
             // The LP name is also the first section and is not in the same charset like the other sections.
             $value['value'] = Security::remove_XSS($value['value']);
             $parent_select->addOption($value['value'], $key, 'style="padding-left:' . $value['padding'] . 'px;"');
         } else {
             $value['value'] = Security::remove_XSS($value['value']);
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:67,代码来源:learnpath.class.php

示例8: setGroupForm

 /**
  * @param FormValidator $form
  * @param array
  *
  * @return FormValidator
  */
 public static function setGroupForm($form, $groupData = array())
 {
     // Name
     $form->addElement('text', 'name', get_lang('Name'), array('maxlength' => 120));
     $form->applyFilter('name', 'html_filter');
     $form->applyFilter('name', 'trim');
     $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
     // Description
     $form->addElement('textarea', 'description', get_lang('Description'), array('cols' => 58, 'onKeyDown' => "textarea_maxlength()", 'onKeyUp' => "textarea_maxlength()"));
     $form->applyFilter('description', 'html_filter');
     $form->applyFilter('description', 'trim');
     $form->addRule('name', '', 'maxlength', 255);
     // Url
     $form->addElement('text', 'url', 'URL');
     $form->applyFilter('url', 'html_filter');
     $form->applyFilter('url', 'trim');
     // Picture
     $form->addElement('file', 'picture', get_lang('AddPicture'));
     $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
     $form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
     if (!empty($groupData)) {
         if (isset($groupData['picture_uri']) && strlen($groupData['picture_uri']) > 0) {
             $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
         }
     }
     // Status
     $status = array();
     $status[GROUP_PERMISSION_OPEN] = get_lang('Open');
     $status[GROUP_PERMISSION_CLOSED] = get_lang('Closed');
     $form->addElement('select', 'visibility', get_lang('GroupPermissions'), $status, array());
     if (!empty($groupData)) {
         if (self::canLeaveFeatureEnabled($groupData)) {
             $form->addElement('checkbox', 'allow_members_leave_group', '', get_lang('AllowMemberLeaveGroup'));
         }
         // Set default values
         $form->setDefaults($groupData);
     }
     return $form;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:45,代码来源:group_portal_manager.lib.php

示例9: addCourseAction

 /**
  * @Route("/add_course", name="add_course")
  * @Method({"GET|POST"})
  * @Security("has_role('ROLE_USER')")
  *
  * @return Response
  */
 public function addCourseAction()
 {
     // "Course validation" feature. This value affects the way of a new course creation:
     // true  - the new course is requested only and it is created after approval;
     // false - the new course is created immediately, after filling this form.
     $courseValidation = false;
     if (api_get_setting('course.course_validation') == 'true' && !api_is_platform_admin()) {
         $courseValidation = true;
     }
     // Displaying the header.
     $tool_name = $courseValidation ? get_lang('CreateCourseRequest') : get_lang('CreateSite');
     if (api_get_setting('course.allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) {
         api_not_allowed(true);
     }
     // Check access rights.
     if (!api_is_allowed_to_create_course()) {
         api_not_allowed(true);
     }
     $url = $this->generateUrl('add_course');
     // Build the form.
     $form = new \FormValidator('add_course', 'post', $url);
     // Form title
     $form->addElement('header', $tool_name);
     // Title
     $form->addElement('text', 'title', array(get_lang('CourseName'), get_lang('Ex')), array('id' => 'title'));
     $form->applyFilter('title', 'html_filter');
     $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
     $form->addButtonAdvancedSettings('advanced_params');
     $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
     // Category category.
     $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
     $form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url));
     // Course code
     $form->addText('wanted_code', array(get_lang('Code'), get_lang('OnlyLettersAndNumbers')), '', array('maxlength' => \CourseManager::MAX_COURSE_LENGTH_CODE, 'pattern' => '[a-zA-Z0-9]+', 'title' => get_lang('OnlyLettersAndNumbers')));
     $form->applyFilter('wanted_code', 'html_filter');
     $form->addRule('wanted_code', get_lang('Max'), 'maxlength', \CourseManager::MAX_COURSE_LENGTH_CODE);
     // The teacher
     //array(get_lang('Professor'), null), null, array('size' => '60', 'disabled' => 'disabled'));
     $titular =& $form->addElement('hidden', 'tutor_name', '');
     if ($courseValidation) {
         // Description of the requested course.
         $form->addElement('textarea', 'description', get_lang('Description'), array('rows' => '3'));
         // Objectives of the requested course.
         $form->addElement('textarea', 'objetives', get_lang('Objectives'), array('rows' => '3'));
         // Target audience of the requested course.
         $form->addElement('textarea', 'target_audience', get_lang('TargetAudience'), array('rows' => '3'));
     }
     // Course language.
     $form->addElement('select_language', 'course_language', get_lang('Ln'), array(), array('style' => 'width:150px'));
     $form->applyFilter('select_language', 'html_filter');
     // Exemplary content checkbox.
     $form->addElement('checkbox', 'exemplary_content', null, get_lang('FillWithExemplaryContent'));
     if ($courseValidation) {
         // A special URL to terms and conditions that is set
         // in the platform settings page.
         $terms_and_conditions_url = trim(api_get_setting('course_validation_terms_and_conditions_url'));
         // If the special setting is empty,
         // then we may get the URL from Chamilo's module "Terms and conditions",
         // if it is activated.
         if (empty($terms_and_conditions_url)) {
             if (api_get_setting('registration.allow_terms_conditions') == 'true') {
                 $terms_and_conditions_url = api_get_path(WEB_CODE_PATH);
                 $terms_and_conditions_url .= 'auth/inscription.php?legal';
             }
         }
         if (!empty($terms_and_conditions_url)) {
             // Terms and conditions to be accepted before sending a course request.
             $form->addElement('checkbox', 'legal', null, get_lang('IAcceptTermsAndConditions'), 1);
             $form->addRule('legal', get_lang('YouHaveToAcceptTermsAndConditions'), 'required');
             // Link to terms and conditions.
             $link_terms_and_conditions = '
                 <script>
                 function MM_openBrWindow(theURL, winName, features) { //v2.0
                     window.open(theURL,winName,features);
                 }
                 </script>
             ';
             $link_terms_and_conditions .= \Display::url(get_lang('ReadTermsAndConditions'), '#', ['onclick' => "javascript:MM_openBrWindow('{$terms_and_conditions_url}', 'Conditions', 'scrollbars=yes, width=800');"]);
             $form->addElement('label', null, $link_terms_and_conditions);
         }
     }
     $obj = new \GradeModel();
     $obj->fill_grade_model_select_in_form($form);
     $form->addElement('html', '</div>');
     // Submit button.
     $form->addButtonCreate($courseValidation ? get_lang('CreateThisCourseRequest') : get_lang('CreateCourseArea'));
     // Set default values.
     if (isset($_user['language']) && $_user['language'] != '') {
         $values['course_language'] = $_user['language'];
     } else {
         $values['course_language'] = api_get_setting('language.platform_language');
     }
     $form->setDefaults($values);
//.........这里部分代码省略.........
开发者ID:daffef,项目名称:chamilo-lms,代码行数:101,代码来源:UserPortalController.php

示例10: array

if (api_get_setting('registration.allow_terms_conditions') == 'true') {
    $display_all_form = !isset($_SESSION['update_term_and_condition']['user_id']);
} else {
    $display_all_form = true;
}
if ($display_all_form) {
    if (api_is_western_name_order()) {
        //	FIRST NAME and LAST NAME
        $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled'));
        $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled'));
    } else {
        //	LAST NAME and FIRST NAME
        $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40, 'disabled' => 'disabled'));
        $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40, 'disabled' => 'disabled'));
    }
    $form->applyFilter('firstname', 'trim');
    $form->applyFilter('lastname', 'trim');
    $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
    //	EMAIL
    $form->addElement('text', 'email', get_lang('Email'), array('size' => 40, 'disabled' => 'disabled'));
    if (api_get_setting_in_list('registration.required_profile_fields', 'email')) {
        $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
    }
    $form->addRule('email', get_lang('EmailWrong'), 'email');
    /*if (api_get_setting('openid_authentication') == 'true') {
          $form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40, 'disabled' => 'disabled'));
      }*/
    //	USERNAME
    $form->addElement('text', 'username', get_lang('UserName'), array('size' => USERNAME_MAX_LENGTH, 'disabled' => 'disabled'));
    $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:configure_inscription.php

示例11: rand

// COURSE SETTINGS
$form->addElement('html', '<div><h3>' . Display::return_icon('settings.png', Security::remove_XSS(get_lang('CourseSettings')), '', ICON_SIZE_SMALL) . ' ' . Security::remove_XSS(get_lang('CourseSettings')) . '</h3><div>');
$image_html = '';
// Display course picture
$course_path = api_get_path(SYS_COURSE_PATH) . $currentCourseRepository;
// course path
if (file_exists($course_path . '/course-pic85x85.png')) {
    $course_web_path = api_get_path(WEB_COURSE_PATH) . $currentCourseRepository;
    // course web path
    $course_medium_image = $course_web_path . '/course-pic85x85.png?' . rand(1, 1000);
    // redimensioned image 85x85
    $image_html = '<div class="row"><label class="col-md-2 control-label">' . get_lang('Image') . '</label> <div class="col-md-8"><img src="' . $course_medium_image . '" /></div></div>';
}
$form->addElement('html', $image_html);
$form->addText('title', get_lang('Title'), true);
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
$form->addElement('select', 'category_code', get_lang('Fac'), $categories, ['style' => 'width:350px', 'id' => 'category_code']);
$form->addElement('select_language', 'course_language', array(get_lang('Ln'), get_lang('TipLang')));
$form->addText('department_name', get_lang('Department'), false);
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');
$form->addText('department_url', get_lang('DepartmentUrl'), false);
$form->applyFilter('department_url', 'html_filter');
// Picture
$form->addElement('file', 'picture', get_lang('AddPicture'), array('id' => 'picture', 'class' => 'picture-form'));
$form->addHtml('' . '<div class="form-group">' . '<label for="cropImage" id="labelCropImage" class="col-sm-2 control-label"></label>' . '<div class="col-sm-8">' . '<div id="cropImage" class="cropCanvas">' . '<img id="previewImage" >' . '</div>' . '<div>' . '<button class="btn btn-primary hidden" name="cropButton" id="cropButton"><em class="fa fa-crop"></em> ' . get_lang('CropYourPicture') . '</button>' . '</div>' . '</div>' . '</div>' . '');
$form->addHidden('cropResult', '');
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
//$form->addElement('html', '<div class="form-group "><div class="col-md-2"></div> <div class="col-md-8 help-image">'.get_lang('UniqueAnswerImagePreferredSize200x150').'</div></div>');
开发者ID:daffef,项目名称:chamilo-lms,代码行数:31,代码来源:infocours.php

示例12: FormValidator

    exit;
}
$currentUserId = api_get_user_id();
$currentUser = $entityManager->find('ChamiloUserBundle:User', $currentUserId);
$allowExport = $currentUser ? $currentUser->getId() === $skillIssue->getUser()->getId() : false;
$allowComment = $currentUser ? Skill::userCanAddFeedbackToUser($currentUser, $skillIssue->getUser()) : false;
$skillIssueDate = api_get_local_time($skillIssue->getAcquiredSkillAt());
$skillIssueInfo = ['id' => $skillIssue->getId(), 'datetime' => api_format_date($skillIssueDate, DATE_TIME_FORMAT_SHORT), 'argumentation' => $skillIssue->getArgumentation(), 'source_name' => $skillIssue->getSourceName(), 'user_id' => $skillIssue->getUser()->getId(), 'user_complete_name' => $skillIssue->getUser()->getCompleteName(), 'skill_badge_image' => $skillIssue->getSkill()->getWebIconPath(), 'skill_name' => $skillIssue->getSkill()->getName(), 'skill_short_code' => $skillIssue->getSkill()->getShortCode(), 'skill_description' => $skillIssue->getSkill()->getDescription(), 'skill_criteria' => $skillIssue->getSkill()->getCriteria(), 'badge_asserion' => [$skillIssue->getAssertionUrl()], 'comments' => [], 'feedback_average' => $skillIssue->getAverage()];
$skillIssueComments = $skillIssue->getComments(true);
foreach ($skillIssueComments as $comment) {
    $commentDate = api_get_local_time($comment->getFeedbackDateTime());
    $skillIssueInfo['comments'][] = ['text' => $comment->getFeedbackText(), 'value' => $comment->getFeedbackValue(), 'giver_complete_name' => $comment->getFeedbackGiver()->getCompleteName(), 'datetime' => api_format_date($commentDate, DATE_TIME_FORMAT_SHORT)];
}
$form = new FormValidator('comment');
$form->addTextarea('comment', get_lang('NewComment'), ['rows' => 4]);
$form->applyFilter('comment', 'trim');
$form->addRule('comment', get_lang('ThisFieldIsRequired'), 'required');
$form->addSelect('value', [get_lang('Value'), get_lang('RateTheSkillInPractice')], ['-', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
$form->addHidden('user', $skillIssue->getUser()->getId());
$form->addHidden('issue', $skillIssue->getId());
$form->addButtonSend(get_lang('Send'));
if ($form->validate() && $allowComment) {
    $values = $form->exportValues();
    $skillUserComment = new Chamilo\CoreBundle\Entity\SkillRelUserComment();
    $skillUserComment->setFeedbackDateTime(new DateTime())->setFeedbackGiver($currentUser)->setFeedbackText($values['comment'])->setFeedbackValue($values['value'] ? $values['value'] : null)->setSkillRelUser($skillIssue);
    $entityManager->persist($skillUserComment);
    $entityManager->flush();
    header("Location: " . $skillIssue->getIssueUrl());
    exit;
}
if ($allowExport) {
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:issued.php

示例13: switch

             $row['category'] = 0;
         }
         if (is_array($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']])) {
             // we are sure that the other site have a selected value
             if ($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value'] != '') {
                 $row['selected_value'] = $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value'];
             }
         }
         // there is no else because we load the default $row['selected_value'] of the main Dokeos site
     }
 }
 switch ($row['type']) {
     case 'textfield':
         if ($row['variable'] == 'account_valid_duration') {
             $form->addElement('text', $row['variable'], get_lang($row['comment']), array('maxlength' => '5'));
             $form->applyFilter($row['variable'], 'html_filter');
             $default_values[$row['variable']] = $row['selected_value'];
         } else {
             $form->addElement('text', $row['variable'], get_lang($row['comment']), $hideme);
             $form->applyFilter($row['variable'], 'html_filter');
             $default_values[$row['variable']] = $row['selected_value'];
         }
         break;
     case 'textarea':
         $form->addElement('textarea', $row['variable'], get_lang($row['comment']), $hideme);
         $default_values[$row['variable']] = $row['selected_value'];
         break;
     case 'radio':
         $values = get_settings_options($row['variable']);
         $group = array();
         if (is_array($values)) {
开发者ID:RusticiSoftware,项目名称:SCORMCloud_DokeosMod,代码行数:31,代码来源:settings.php

示例14: array

$form->addElement('hidden', 'survey_language');
$form->addElement('datepickerdate', 'start_date', get_lang('StartDate'), array('form_name' => 'survey'));
$form->addElement('datepickerdate', 'end_date', get_lang('EndDate'), array('form_name' => 'survey'));
$form->addElement('checkbox', 'anonymous', null, get_lang('Anonymous'));
$form->addElement('html_editor', 'survey_introduction', get_lang('SurveyIntroduction'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false));
$form->addElement('html_editor', 'survey_thanks', get_lang('SurveyThanks'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false));
// Aditional Parameters
$form->addElement('advanced_settings', '<a href="javascript: void(0);" onclick="javascript: advanced_parameters();" >
        <span id="plus_minus">&nbsp;' . Display::return_icon('div_show.gif', null, array('style' => 'vertical-align:middle')) . '&nbsp;' . get_lang('AdvancedParameters') . '</span></a>');
$form->addElement('html', '<div id="options" style="display: none;">');
if (Gradebook::is_active()) {
    // An option: Qualify the fact that survey has been answered in the gradebook
    $form->addElement('checkbox', 'survey_qualify_gradebook', null, get_lang('QualifyInGradebook'), 'onclick="javascript: if (this.checked) { document.getElementById(\'gradebook_options\').style.display = \'block\'; } else { document.getElementById(\'gradebook_options\').style.display = \'none\'; }"');
    $form->addElement('html', '<div id="gradebook_options"' . ($gradebook_link_id ? '' : ' style="display:none"') . '>');
    $form->addElement('text', 'survey_weight', get_lang('QualifyWeight'), 'value="0.00" style="width: 40px;" onfocus="javascript: this.select();"');
    $form->applyFilter('survey_weight', 'html_filter');
    $form->addElement('html', '</div>');
}
// Personality/Conditional Test Options
$surveytypes[0] = get_lang('Normal');
$surveytypes[1] = get_lang('Conditional');
if ($_GET['action'] == 'add') {
    $form->addElement('hidden', 'survey_type', 0);
    require_once api_get_path(LIBRARY_PATH) . 'surveymanager.lib.php';
    $survey_tree = new SurveyTree();
    $list_surveys = $survey_tree->createList($survey_tree->surveylist);
    $list_surveys[0] = '';
    $form->addElement('select', 'parent_id', get_lang('ParentSurvey'), $list_surveys);
    $defaults['parent_id'] = 0;
}
if ($survey_data['survey_type'] == 1 || $_GET['action'] == 'add') {
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:create_new_survey.php

示例15: isset

$exercise_redirect = isset($_REQUEST['e']) && !empty($_REQUEST['e']) ? $_REQUEST['e'] : null;
if (!empty($course_code_redirect)) {
    Session::write('course_redirect', $course_code_redirect);
    Session::write('exercise_redirect', $exercise_redirect);
}
if ($user_already_registered_show_terms == false) {
    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));
    }
    $form->applyFilter(array('lastname', 'firstname'), 'trim');
    $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
    // EMAIL
    $form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
    if (api_get_setting('registration', 'email') == 'true') {
        $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
    }
    if (api_get_setting('profile.login_is_email') == 'true') {
        $form->applyFilter('email', 'trim');
        if (api_get_setting('registration', 'email') != 'true') {
            $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
        }
        $form->addRule('email', sprintf(get_lang('UsernameMaxXCharacters'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
        $form->addRule('email', get_lang('UserTaken'), 'username_available');
    }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:inscription.php


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