本文整理汇总了PHP中FormValidator::add_textfield方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::add_textfield方法的具体用法?PHP FormValidator::add_textfield怎么用?PHP FormValidator::add_textfield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::add_textfield方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
} else {
$form->display();
}
break;
case 'edit':
$item = Rsys::get_item($_GET['id']);
$cats = Rsys::get_category();
foreach ($cats as $cat) {
$catOptions[$cat['id']] = $cat['name'];
}
$interbreadcrumb[] = array("url" => "m_item.php", "name" => $tool_name);
Display::display_header(str_replace('#ITEM#', $item['name'], get_lang('EditItem')));
api_display_tool_title(get_lang('EditItem2'));
$form = new FormValidator('item', 'post', 'm_item.php?action=edit');
$form->addElement('select', 'category_id', get_lang('Category'), $catOptions);
$form->add_textfield('name', get_lang('ItemName'), array('maxlength' => '128'));
$form->addElement('textarea', 'description', get_lang('ItemDescription'), array('rows' => '3', 'cols' => '40'));
$form->addRule('category_id', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('hidden', 'id', $item['id']);
$form->addElement('submit', 'submit', get_lang('Ok'));
$form->setDefaults($item);
if ($form->validate()) {
$values = $form->exportValues();
if (Rsys::edit_item($values['id'], $values['name'], $values['description'], $values['category_id'], $values['course_id'])) {
Display::display_normal_message(Rsys::get_return_msg(get_lang('ItemEdited'), "m_item.php", $tool_name), false);
} else {
Display::display_normal_message(Rsys::get_return_msg(get_lang('ItemExist'), "m_item.php?action=edit&id=" . $values['id'], get_lang('EditItem2')), false);
}
} else {
$form->display();
}
示例2: isset
$values['lang'] = $announcement->lang;
$values['action'] = 'edit';
$groups = SystemAnnouncementManager::get_announcement_groups($announcement->id);
$values['group'] = isset($groups[0]['group_id']) ? $groups[0]['group_id'] : 0;
$action_todo = true;
break;
}
if ($action_todo) {
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
$form_title = get_lang('AddNews');
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
$form_title = get_lang('EditNews');
}
$form = new FormValidator('system_announcement');
$form->addElement('header', '', $form_title);
$form->add_textfield('title', get_lang('Title'), true, array('class' => 'span4'));
$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);
if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
$form->addElement('textarea', 'content', get_lang('Content'));
} else {
$form->add_html_editor('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'));
示例3: floatval
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
}
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook=' . Security::remove_XSS($_SESSION['gradebook']);
}
if (!$error) {
$token = Security::get_token();
}
$attendance_weight = floatval($attendance_weight);
// display form
$form = new FormValidator('attendance_edit', 'POST', 'index.php?action=attendance_edit&' . api_get_cidreq() . '&attendance_id=' . $attendance_id . $param_gradebook);
$form->addElement('header', '', get_lang('Edit'));
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'attendance_id', $attendance_id);
$form->add_textfield('title', get_lang('Title'), true, array('size' => '50'));
$form->applyFilter('title', 'html_filter');
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
// Adavanced Parameters
if (Gradebook::is_active()) {
if (!empty($attendance_qualify_title) || !empty($attendance_weight)) {
$form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="id_qualify_options" style="display:block">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), array('checked' => 'true', 'onclick' => 'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}'));
$form->addElement('html', '<div id="options_field" style="display:block">');
} else {
$form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="id_qualify_options" style="display:none">');
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$form->addElement('html', '<div id="options_field" style="display:none">');
}
示例4: array
$form->addElement('style_submit_button', 'submit', get_lang('CreateResourceType'),'class="add"');
if ($form->validate()) {
$values = $form->exportValues();
if (Rsys :: add_category($values['name']))
Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeAdded'), "m_category.php", $tool_name),false);
else
Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeExist'), "m_category.php?action=add", get_lang('AddNewResourceType')),false);
} else
$form->display();
break;
case 'edit' :
$interbreadcrumb[] = array ("url" => "m_category.php", "name" => $tool_name);
Display :: display_header(get_lang('EditResourceType'));
api_display_tool_title(get_lang('EditResourceType'));
$form = new FormValidator('category', 'post', 'm_category.php?action=edit');
$form->add_textfield('name', get_lang('ResourceTypeName'), true, array ('maxlength' => '128'));
$form->addElement('hidden', 'id', intval($_GET['id']));
$form->addElement('style_submit_button', 'submit', get_lang('ModifyResourceType'),'class="save"');
$form->setDefaults(Rsys :: get_category($_GET['id']));
if ($form->validate()) {
$values = $form->exportValues();
if (Rsys :: edit_category($values['id'], $values['name']))
Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeEdited'), "m_category.php", $tool_name),false);
else
Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeExist'), "m_category.php?action=edit&id=".$values['id'], get_lang('EditRight')),false);
} else
$form->display();
break;
case 'delete' :
$result = Rsys :: delete_category($_GET['id']);
ob_start();
示例5: array
}
break;
}
}
$content = '';
$message = '';
$actions = '';
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
// Get all course categories
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
$tool_name = get_lang('SearchACourse');
//api_display_tool_title($tool_name);
$form = new FormValidator('advanced_course_search', 'get');
$form->addElement('header', $tool_name);
$form->add_textfield('keyword_code', get_lang('CourseCode'), false);
$form->add_textfield('keyword_title', get_lang('Title'), false);
// Category code
$url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
$form->addElement('select_ajax', 'keyword_category', get_lang('CourseFaculty'), null, array('url' => $url));
$el = $form->addElement('select_language', 'keyword_language', get_lang('CourseLanguage'));
$el->addOption(get_lang('All'), '%');
$form->addElement('radio', 'keyword_visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
$form->addElement('radio', 'keyword_visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$form->addElement('radio', 'keyword_visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
$form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
$form->addElement('radio', 'keyword_visibility', null, get_lang('All'), '%');
$form->addElement('radio', 'keyword_subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$form->addElement('radio', 'keyword_subscribe', null, get_lang('Denied'), 0);
$form->addElement('radio', 'keyword_subscribe', null, get_lang('All'), '%');
示例6: tinyint
$form->addElement('hidden', 'id');
} else {
// Checks if the field was created in the table Category. It creates it if is neccesary
$table_category = Database::get_course_table(TABLE_GROUP_CATEGORY);
if (!Database::query("SELECT wiki_state FROM {$table_category} WHERE c_id = {$course_id}")) {
Database::query("ALTER TABLE {$table_category} ADD wiki_state tinyint(3) UNSIGNED NOT NULL default '1' WHERE c_id = {$course_id}");
}
// Create a new category
$action = 'add_category';
$form = new FormValidator('group_category');
}
$form->addElement('html', '<div class="sectiontitle" >' . $nameTools);
$form->addElement('html', '</div>');
// If categories allowed, show title & description field
if (api_get_setting('allow_group_categories') == 'true') {
$form->add_textfield('title', get_lang('Title'));
$form->addElement('textarea', 'description', get_lang('Description'), array('cols' => 50, 'rows' => 6));
} else {
$form->addElement('hidden', 'title');
$form->addElement('hidden', 'description');
}
// Action
$form->addElement('hidden', 'action');
// Groups per user
$group = array();
$group[] = $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartBeforeNumber'));
$possible_values = array();
for ($i = 1; $i <= 10; $i++) {
$possible_values[$i] = $i;
}
$possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
示例7: function
}
/* MAIN CODE */
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$("#max_member").on("focus", function() {
$("#max_member_selected").attr("checked", true);
});
});
</script>';
// Build form
$form = new FormValidator('group_edit', 'post', api_get_self() . '?' . api_get_cidreq());
$form->addElement('header', $nameTools);
$form->addElement('hidden', 'action');
$form->addElement('hidden', 'referer');
// Group name
$form->add_textfield('name', get_lang('GroupName'));
// Description
$form->addElement('textarea', 'description', get_lang('Description'), array('class' => 'span6', 'rows' => 6));
// Getting course info
$course = $app['orm.em']->getRepository('Entity\\Course')->find(api_get_course_int_id());
//Getting subscribed students
$subscribedUsers = $app['orm.em']->getRepository('Entity\\Course')->getSubscribedStudents($course);
$subscribedUsers = $subscribedUsers->getQuery();
$subscribedUsers = $subscribedUsers->execute();
// Getting all users
$complete_user_list = array();
foreach ($subscribedUsers as $user) {
$complete_user_list[$user->getUserId()] = $user->getCompleteNameWithClasses();
}
$possible_users = array();
foreach ($complete_user_list as $userId => $user) {
示例8: manage_form
function manage_form($default, $select_from_user_list = null, $sent_to = null)
{
$group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
$param_f = isset($_GET['f']) ? Security::remove_XSS($_GET['f']) : '';
$form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data'));
if (empty($group_id)) {
if (isset($select_from_user_list)) {
$form->add_textfield('id_text_name', get_lang('SendMessageTo'), true, array('class' => 'span4', 'id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off'));
$form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" > </div>');
$form->addElement('hidden', 'user_list', 0, array('id' => 'user_list'));
} else {
if (!empty($sent_to)) {
$form->addElement('html', $sent_to);
}
if (empty($default['users'])) {
//fb select
$form->addElement('select', 'users', get_lang('SendMessageTo'), array(), array('id' => 'users'));
} else {
$form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user'));
}
}
} else {
$usergroup = new UserGroup();
$group_info = $usergroup->get($group_id);
$form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name']));
$form->addElement('hidden', 'group_id', $group_id);
$form->addElement('hidden', 'parent_id', $message_id);
}
$form->add_textfield('title', get_lang('Subject'), true, array('class' => 'span4'));
$form->add_html_editor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '95%', 'Height' => '250'));
if (isset($_GET['re_id'])) {
$message_reply_info = MessageManager::get_message_by_id($_GET['re_id']);
$default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title'];
$form->addElement('hidden', 're_id', intval($_GET['re_id']));
$form->addElement('hidden', 'save_form', 'save_form');
//adding reply mail
$user_reply_info = UserManager::get_user_info_by_id($message_reply_info['user_sender_id']);
$default['content'] = '<br />' . sprintf(get_lang('XWroteY'), api_get_person_name($user_reply_info['firstname'], $user_reply_info['lastname']), Security::filter_terms($message_reply_info['content']));
}
if (empty($group_id)) {
$form->addElement('advanced_settings', get_lang('FilesAttachment') . '<span id="filepaths">
<div id="filepath_1">
<input type="file" name="attach_1"/><br />
' . get_lang('Description') . ' <input type="text" name="legend[]" /><br /><br />
</div>
</span>');
$form->addElement('advanced_settings', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
}
$form->addElement('style_submit_button', 'compose', api_xml_http_response_encode(get_lang('SendMessage')), 'class="save"');
$form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
if (!empty($group_id) && !empty($message_id)) {
$message_info = MessageManager::get_message_by_id($message_id);
$default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title'];
}
$form->setDefaults($default);
$html = '';
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$user_list = $default['users'];
$file_comments = $_POST['legend'];
$title = $default['title'];
$content = $default['content'];
$group_id = isset($default['group_id']) ? $default['group_id'] : null;
$parent_id = $default['parent_id'];
if (is_array($user_list) && count($user_list) > 0) {
//all is well, send the message
foreach ($user_list as $user) {
$res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id, null, null, api_get_user_id());
if ($res) {
if (is_string($res)) {
$html .= Display::return_message($res, 'error');
} else {
$user_info = api_get_user_info($user);
$html .= Display::return_message(get_lang('MessageSentTo') . " <b>" . $user_info['complete_name'] . "</b>", 'confirmation', false);
}
}
}
} else {
Display::display_error_message('ErrorSendingMessage');
}
}
Security::clear_token();
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$html .= $form->return_form();
}
return $html;
}
示例9: array
// Form title.
$form->addElement('header', $tool_name);
// Title.
$form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title'));
$form->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
// Course category.
$url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
$categoryList = array();
if (!empty($course_request_info['category_code'])) {
$data = getCategory($course_request_info['category_code']);
$categoryList[] = array('id' => $data['code'], 'text' => $data['name']);
}
$form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url, 'defaults' => $categoryList));
// Course code.
$form->add_textfield('wanted_code', get_lang('Code'), false, array('size' => '$maxlength', 'maxlength' => $maxlength));
$form->applyFilter('wanted_code', 'html_filter');
$form->addRule('wanted_code', get_lang('Max'), 'maxlength', $maxlength);
$form->addRule('wanted_code', get_lang('ThisFieldIsRequired'), 'required');
// The teacher.
$titular = $form->add_textfield('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled'));
// Description of the requested course.
$form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
$form->addRule('description', get_lang('ThisFieldIsRequired'), 'required');
// Objectives of the requested course.
$form->addElement('textarea', 'objetives', get_lang('Objectives'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
$form->addRule('objetives', get_lang('ThisFieldIsRequired'), 'required');
// Target audience of the requested course.
$form->addElement('textarea', 'target_audience', get_lang('TargetAudience'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
$form->addRule('target_audience', get_lang('ThisFieldIsRequired'), 'required');
// Course language.
示例10: add_edit_template
/**
* Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version August 2008
* @since Dokeos 1.8.6
*/
function add_edit_template()
{
// initiate the object
$form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . $_GET['action'] . '&id=' . $_GET['id']);
// settting the form elements: the header
if ($_GET['action'] == 'add') {
$title = get_lang('AddTemplate');
} else {
$title = get_lang('EditTemplate');
}
$form->addElement('header', '', $title);
// settting the form elements: the title of the template
$form->add_textfield('title', get_lang('Title'), false);
// settting the form elements: the content of the template (wysiwyg editor)
$form->addElement('html_editor', 'template_text', get_lang('Text'));
// settting the form elements: the form to upload an image to be used with the template
$form->addElement('file', 'template_image', get_lang('Image'), '');
// settting the form elements: a little bit information about the template image
$form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
// getting all the information of the template when editing a template
if ($_GET['action'] == 'edit') {
// Database table definition
$table_system_template = Database::get_main_table('system_template');
$sql = "SELECT * FROM {$table_system_template} WHERE id = '" . Database::escape_string($_GET['id']) . "'";
$result = api_sql_query($sql, __FILE__, __LINE__);
$row = Database::fetch_array($result);
$defaults['template_id'] = $_GET['id'];
$defaults['template_text'] = $row['content'];
$defaults['title'] = $row['title'];
// adding an extra field: a hidden field with the id of the template we are editing
$form->addElement('hidden', 'template_id');
// adding an extrra field: a preview of the image that is currently used
if (!empty($row['image'])) {
$form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>');
} else {
$form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>');
}
// setting the information of the template that we are editing
$form->setDefaults($defaults);
}
// settting the form elements: the submit button
$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
// setting the rules: the required fields
$form->addRule('title', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('template_text', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required');
// if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
if ($form->validate()) {
// exporting the values
$values = $form->exportValues();
// upload the file
if (!empty($_FILES['template_image']['name'])) {
include_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
$upload_ok = process_uploaded_file($_FILES['template_image']);
if ($upload_ok) {
// Try to add an extension to the file if it hasn't one
$new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
// upload dir
$upload_dir = api_get_path(SYS_PATH) . 'home/default_platform_document/';
// create dir if not exists
if (!is_dir($upload_dir)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770');
$res = @mkdir($upload_dir, $perm);
}
// resize image to max default and upload
require_once api_get_path(LIBRARY_PATH) . 'image.lib.php';
$temp = new image($_FILES['template_image']['tmp_name']);
$picture_infos = @getimagesize($_FILES['template_image']['tmp_name']);
$max_width_for_picture = 100;
if ($picture_infos[0] > $max_width_for_picture) {
$thumbwidth = $max_width_for_picture;
if (empty($thumbwidth) or $thumbwidth == 0) {
$thumbwidth = $max_width_for_picture;
}
$new_height = round($thumbwidth / $picture_infos[0] * $picture_infos[1]);
$temp->resize($thumbwidth, $new_height, 0);
}
$type = $picture_infos[2];
switch (!empty($type)) {
case 2:
$temp->send_image('JPG', $upload_dir . $new_file_name);
break;
case 3:
$temp->send_image('PNG', $upload_dir . $new_file_name);
break;
case 1:
$temp->send_image('GIF', $upload_dir . $new_file_name);
break;
}
}
}
// store the information in the database (as insert or as update)
$table_system_template = Database::get_main_table('system_template');
//.........这里部分代码省略.........
示例11: rand
if (!empty($picture['name'])) {
$picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']);
}
}
// 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"><div class="formw"><img src="' . $course_medium_image . '" /></div></div>';
}
$form->addElement('html', $image_html);
$form->add_textfield('title', get_lang('Title'), true, array('class' => 'span6'));
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
$form->addElement('select', 'category_code', get_lang('Fac'), $categories, array('style' => 'width:350px', 'class' => 'chzn-select', 'id' => 'category_code'));
$form->addElement('select_language', 'course_language', array(get_lang('Ln'), get_lang('TipLang')));
$form->add_textfield('department_name', get_lang('Department'), false, array('class' => 'span5'));
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');
$form->add_textfield('department_url', get_lang('DepartmentUrl'), false, array('class' => 'span5'));
$form->applyFilter('department_url', 'html_filter');
// 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 (api_get_setting('pdf_export_watermark_by_course') == 'true') {
$url = PDF::get_watermark($course_code);
示例12: FormValidator
$form = new FormValidator('add_course');
// Form title
$form->addElement('header', $tool_name);
// Title
$form->addElement('text', 'title', array(get_lang('CourseName'), get_lang('Ex')), array('class' => 'span6', 'id' => 'title'));
$form->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="advanced_params_options">');
// Course category.
$categories_select = $form->addElement('select', 'category_code', array(get_lang('Fac'), get_lang('TargetFac')), array(), array('id' => 'category_code', 'class' => 'chzn-select', 'style' => 'width:350px'));
$form->applyFilter('category_code', 'html_filter');
$categories_select->addOption('-', '');
CourseManager::select_and_sort_categories($categories_select);
// Course code
$form->add_textfield('wanted_code', array(get_lang('Code'), get_lang('OnlyLettersAndNumbers')), '', array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE));
$form->applyFilter('wanted_code', 'html_filter');
$form->addRule('wanted_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE);
// The teacher
//get_lang('ExplicationTrainers')
$titular =& $form->addElement('hidden', 'tutor_name', '');
//array(get_lang('Professor'), null), null, array('size' => '60', 'disabled' => 'disabled'));
//$form->applyFilter('tutor_name', 'html_filter');
if ($course_validation_feature) {
// Description of the requested course.
$form->addElement('textarea', 'description', get_lang('Description'), array('class' => 'span6', 'rows' => '3'));
//$form->addRule('description', get_lang('ThisFieldIsRequired'), 'required');
// Objectives of the requested course.
$form->addElement('textarea', 'objetives', get_lang('Objectives'), array('class' => 'span6', 'rows' => '3'));
//$form->addRule('objetives', get_lang('ThisFieldIsRequired'), 'required');
// Target audience of the requested course.
示例13: status_filter
function status_filter($status)
{
$statusname = api_get_status_langvars();
return $statusname[$status];
}
// INIT SECTION
$action = isset($_GET["action"]) ? $_GET["action"] : null;
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array("url" => 'group_list.php', "name" => get_lang('GroupList'));
$tool_name = get_lang('SearchAUser');
Display::display_header($tool_name);
//api_display_tool_title($tool_name);
$form = new FormValidator('advanced_search', 'get');
$form->addElement('header', '', $tool_name);
$form->add_textfield('keyword_firstname', get_lang('FirstName'), false);
$form->add_textfield('keyword_lastname', get_lang('LastName'), false);
$form->add_textfield('keyword_username', get_lang('LoginName'), false);
$form->add_textfield('keyword_email', get_lang('Email'), false);
$form->add_textfield('keyword_officialcode', get_lang('OfficialCode'), false);
$status_options = array();
$status_options['%'] = get_lang('All');
$status_options[STUDENT] = get_lang('Student');
$status_options[COURSEMANAGER] = get_lang('Teacher');
$status_options[SESSIONADMIN] = get_lang('Administrator');
//
$form->addElement('select', 'keyword_status', get_lang('Status'), $status_options);
$active_group = array();
$active_group[] = $form->createElement('checkbox', 'keyword_active', '', get_lang('Active'));
$active_group[] = $form->createElement('checkbox', 'keyword_inactive', '', get_lang('Inactive'));
$form->addGroup($active_group, '', get_lang('ActiveAccount'), '<br/>', false);
示例14: array
// Resetting the course id.
$cidReset = true;
// Including some necessary dokeos files.
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'classmanager.lib.php';
// Setting the section (for the tabs).
$this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions.
api_protect_admin_script();
// Setting breadcrumbs.
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'class_list.php', 'name' => get_lang('AdminClasses'));
// Setting the name of the tool.
$tool_name = get_lang('AddClasses');
$tool_name = get_lang('ModifyClassInfo');
$class_id = intval($_GET['idclass']);
$class = ClassManager::get_class_info($class_id);
$form = new FormValidator('edit_class', 'post', 'class_edit.php?idclass=' . $class_id);
$form->add_textfield('name', get_lang('ClassName'));
$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="add"');
$form->setDefaults(array('name' => $class['name']));
if ($form->validate()) {
$values = $form->exportValues();
ClassManager::set_name($values['name'], $class_id);
header('Location: class_list.php');
}
Display::display_header($tool_name);
//api_display_tool_title($tool_name);
$form->display();
// Displaying the footer.
Display::display_footer();
示例15: add_edit_template
/**
* Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version August 2008
* @since Dokeos 1.8.6
*/
function add_edit_template()
{
// Initialize the object.
$form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . Security::remove_XSS($_GET['action']) . '&id=' . Security::remove_XSS($_GET['id']));
// Settting the form elements: the header.
if ($_GET['action'] == 'add') {
$title = get_lang('AddTemplate');
} else {
$title = get_lang('EditTemplate');
}
$form->addElement('header', $title);
// Settting the form elements: the title of the template.
$form->add_textfield('title', get_lang('Title'), false);
// Settting the form elements: the content of the template (wysiwyg editor).
$form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400'));
// Settting the form elements: the form to upload an image to be used with the template.
$form->addElement('file', 'template_image', get_lang('Image'), '');
// Settting the form elements: a little bit information about the template image.
$form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
// Getting all the information of the template when editing a template.
if ($_GET['action'] == 'edit') {
// Database table definition.
$table_system_template = Database::get_main_table('system_template');
$sql = "SELECT * FROM {$table_system_template} WHERE id = '" . Database::escape_string($_GET['id']) . "'";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$defaults['template_id'] = intval($_GET['id']);
$defaults['template_text'] = $row['content'];
// Forcing get_lang().
$defaults['title'] = get_lang($row['title']);
// Adding an extra field: a hidden field with the id of the template we are editing.
$form->addElement('hidden', 'template_id');
// Adding an extra field: a preview of the image that is currently used.
if (!empty($row['image'])) {
$form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_DATA_PATH) . 'document_templates/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>');
} else {
$form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_DATA_PATH) . 'document_templates/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>');
}
// Setting the information of the template that we are editing.
$form->setDefaults($defaults);
}
// Setting the form elements: the submit button.
$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
// Setting the rules: the required fields.
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('template_text', get_lang('ThisFieldIsRequired'), 'required');
// if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
// Exporting the values.
$values = $form->exportValues();
// Upload the file.
if (!empty($_FILES['template_image']['name'])) {
$upload_ok = FileManager::process_uploaded_file($_FILES['template_image']);
if ($upload_ok) {
// Try to add an extension to the file if it hasn't one.
$new_file_name = FileManager::add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
// The upload directory.
$upload_dir = api_get_path(SYS_DATA_PATH) . 'document_templates/';
// Resize the preview image to max default and upload.
$temp = new Image($_FILES['template_image']['tmp_name']);
$picture_info = $temp->get_image_info();
$max_width_for_picture = 100;
if ($picture_info['width'] > $max_width_for_picture) {
$thumbwidth = $max_width_for_picture;
if (empty($thumbwidth) || $thumbwidth == 0) {
$thumbwidth = $max_width_for_picture;
}
$new_height = round($thumbwidth / $picture_info['width'] * $picture_info['height']);
$temp->resize($thumbwidth, $new_height, 0);
}
$temp->send_image($upload_dir . $new_file_name);
}
}
// Store the information in the database (as insert or as update).
$table_system_template = Database::get_main_table('system_template');
if ($_GET['action'] == 'add') {
$content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>' . Database::escape_string($values['template_text']) . '</body>';
$sql = "INSERT INTO {$table_system_template} (title, content, image) VALUES ('" . Database::escape_string($values['title']) . "','" . $content_template . "','" . Database::escape_string($new_file_name) . "')";
Database::query($sql);
// Display a feedback message.
Display::display_confirmation_message(get_lang('TemplateAdded'));
echo '<a href="settings.php?category=Templates&action=add">' . Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM) . '</a>';
} else {
$content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>' . Database::escape_string($values['template_text']) . '</body>';
$sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "', content = '" . $content_template . "'";
if (!empty($new_file_name)) {
$sql .= ", image = '" . Database::escape_string($new_file_name) . "'";
}
$sql .= " WHERE id='" . Database::escape_string($_GET['id']) . "'";
Database::query($sql);
// Display a feedback message.
//.........这里部分代码省略.........