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


PHP FormValidator::display方法代码示例

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


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

示例1: lp_upload_quiz_main

function lp_upload_quiz_main()
{
    // variable initialisation
    $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : null;
    $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data'));
    $form->addElement('header', get_lang('ImportExcelQuiz'));
    $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload'));
    $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')) . get_lang('DownloadExcelTemplate') . '</a>';
    $form->addElement('label', '', $link);
    $table = new HTML_Table(array('class' => 'table'));
    $tableList = array(UNIQUE_ANSWER => get_lang('UniqueSelect'), MULTIPLE_ANSWER => get_lang('MultipleSelect'), FILL_IN_BLANKS => get_lang('FillBlanks'), MATCHING => get_lang('Matching'), FREE_ANSWER => get_lang('FreeAnswer'), GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer'));
    $table->setHeaderContents(0, 0, get_lang('QuestionType'));
    $table->setHeaderContents(0, 1, '#');
    $row = 1;
    foreach ($tableList as $key => $label) {
        $table->setCellContents($row, 0, $label);
        $table->setCellContents($row, 1, $key);
        $row++;
    }
    $table = $table->toHtml();
    $form->addElement('label', get_lang('QuestionType'), $table);
    $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id' => 'user_custom_score'));
    $form->addElement('html', '<div id="options" style="display:none">');
    $form->addElement('text', 'correct_score', get_lang('CorrectScore'));
    $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore'));
    $form->addElement('html', '</div>');
    $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required');
    $form->add_progress_bar();
    $form->addButtonUpload(get_lang('Upload'), 'submit_upload_quiz');
    // Display the upload field
    $form->display();
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:32,代码来源:upload_exercise.php

示例2: lp_upload_quiz_main

function lp_upload_quiz_main()
{
    // variable initialisation
    $lp_id = Security::remove_XSS($_GET['lp_id']);
    $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data'));
    $form->addElement('header', get_lang('ImportExcelQuiz'));
    $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload'));
    $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate'), null, 16) . get_lang('DownloadExcelTemplate');
    $form->addElement('advanced_settings', $link);
    //button send document
    $form->addElement('style_submit_button', 'submit_upload_quiz', get_lang('Send'), 'class="upload"');
    // Display the upload field
    $form->display();
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:14,代码来源:upload_exercise.php

示例3: lp_upload_quiz_main

function lp_upload_quiz_main()
{
    // variable initialisation
    $lp_id = isset($_GET['lp_id']) ? Security::remove_XSS($_GET['lp_id']) : null;
    $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data'));
    $form->addElement('header', get_lang('ImportExcelQuiz'));
    $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload'));
    $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')) . get_lang('DownloadExcelTemplate') . '</a>';
    $form->addElement('label', '', $link);
    $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id' => 'user_custom_score'));
    $form->addElement('html', '<div id="options" style="display:none">');
    $form->addElement('text', 'correct_score', get_lang('CorrectScore'));
    $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore'));
    $form->addElement('html', '</div>');
    $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required');
    $form->add_progress_bar();
    $form->addButtonUpload(get_lang('Send'), 'submit_upload_quiz');
    // Display the upload field
    $form->display();
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:20,代码来源:upload_exercise.php

示例4: FormValidator

     $arrid[] = $questionId;
     $feedback_form = new FormValidator('frmcomments' . $questionId, 'post', '');
     $feedback_form->addElement('html', '<br>');
     $renderer =& $feedback_form->defaultRenderer();
     $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
     $renderer->setCustomElementTemplate('<div align="left">{element}</div>');
     $comnt = Event::get_comments($id, $questionId);
     $default = array('comments_' . $questionId => $comnt);
     if ($useAdvancedEditor) {
         $feedback_form->addElement('html_editor', 'comments_' . $questionId, null, null, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '100%', 'Height' => '120'));
     } else {
         $feedback_form->addElement('textarea', 'comments_' . $questionId);
     }
     $feedback_form->addElement('html', '<br>');
     $feedback_form->setDefaults($default);
     $feedback_form->display();
     echo '</div>';
 } else {
     $comnt = Event::get_comments($id, $questionId);
     echo '<br />';
     if (!empty($comnt)) {
         echo '<b>' . get_lang('Feedback') . '</b>';
         echo '<div id="question_feedback">' . $comnt . '</div>';
     }
 }
 if ($is_allowedToEdit && $isFeedbackAllowed) {
     if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
         $marksname = "marksName" . $questionId;
         echo '<div id="' . $marksname . '" style="display:none">';
         echo '<form name="marksform_' . $questionId . '" method="post" action="">';
         $arrmarks[] = $questionId;
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:exercise_show.php

示例5: forum_search

/**
 * Display the search form for the forum and display the search results
 * @return void display an HTML search results
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
 * @version march 2008, dokeos 1.8.5
 */
function forum_search()
{
    // Initialize the object.
    $form = new FormValidator('forumsearch', 'post', 'forumsearch.php?' . api_get_cidreq());
    // Setting the form elements.
    $form->addElement('header', '', get_lang('ForumSearch'));
    $form->addElement('text', 'search_term', get_lang('SearchTerm'), array('autofocus'));
    $form->applyFilter('search_term', 'html_filter');
    $form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation'));
    $form->addButtonSearch(get_lang('Search'));
    // Setting the rules.
    $form->addRule('search_term', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('search_term', get_lang('TooShort'), 'minlength', 3);
    // Validation or display.
    if ($form->validate()) {
        $values = $form->exportValues();
        $form->setDefaults($values);
        $form->display();
        // Display the search results.
        display_forum_search_results(stripslashes($values['search_term']));
    } else {
        $form->display();
    }
}
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:30,代码来源:forumfunction.inc.php

示例6: display_ical_import_form

function display_ical_import_form()
{
    $form = new FormValidator('frm_import_ical', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']), array('enctype' => 'multipart/form-data'));
    $form->addElement('header', get_lang('ICalFileImport'));
    $form->addElement('file', 'ical_import', get_lang('ICalFileImport'));
    $form->addRule('ical_import', get_lang('ThisFieldIsRequired'), 'required');
    $form->addElement('button', 'ical_submit', get_lang('Import'));
    $form->display();
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:9,代码来源:agenda.inc.php

示例7: validate_filter

$tool_name = get_lang('AddUsersToACourse');
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$htmlHeadXtra[] = '
<script type="text/javascript">
function validate_filter() {
        document.formulaire.form_sent.value=0;
        document.formulaire.submit();
}
</script>';
// displaying the header
Display::display_header($tool_name);
$link_add_group = '<a href="usergroups.php">' . Display::return_icon('multiple.gif', get_lang('RegistrationByUsersGroups')) . get_lang('RegistrationByUsersGroups') . '</a>';
echo '<div class="actions">' . $link_add_group . '</div>';
$form = new FormValidator('subscribe_user2course');
$form->addElement('header', '', $tool_name);
$form->display();
//checking for extra field with filter on
$extra_field_list = UserManager::get_extra_fields();
$new_field_list = array();
if (is_array($extra_field_list)) {
    foreach ($extra_field_list as $extra_field) {
        //if is enabled to filter and is a "<select>" field type
        if ($extra_field[8] == 1 && $extra_field[2] == 4) {
            $new_field_list[] = array('name' => $extra_field[3], 'variable' => $extra_field[1], 'data' => $extra_field[9]);
        }
    }
}
/* React on POSTed request */
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
    $form_sent = $_POST['form_sent'];
    $users = is_array($_POST['UserList']) ? $_POST['UserList'] : array();
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:subscribe_user2course.php

示例8: add_category_form

/**
 * form to add a category
 * @todo move to TestCategory.class.php
 * @param string $action
 */
function add_category_form($action)
{
    $action = Security::remove_XSS($action);
    // initiate the object
    $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $action);
    // Setting the form elements
    $form->addElement('header', get_lang('AddACategory'));
    $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
    $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Height' => '200'));
    $form->addButtonCreate(get_lang('AddTestCategory'), 'SubmitNote');
    // setting the rules
    $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
    // The validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            $v_name = Security::remove_XSS($values['category_name'], COURSEMANAGER);
            $v_description = Security::remove_XSS($values['category_description'], COURSEMANAGER);
            $objcat = new TestCategory(0, $v_name, $v_description);
            if ($objcat->addCategoryInBDD()) {
                Display::display_confirmation_message(get_lang('AddCategoryDone'));
            } else {
                Display::display_confirmation_message(get_lang('AddCategoryNameAlreadyExists'));
            }
        }
        Security::clear_token();
    } else {
        display_goback();
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:40,代码来源:tests_category.php

示例9: display_edit_blog_form

 /**
  * Blog admin | Display the form to edit a blog.
  *
  */
 public static function display_edit_blog_form($blog_id)
 {
     $course_id = api_get_course_int_id();
     $blog_id = intval($blog_id);
     $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
     $sql = "SELECT blog_id, blog_name, blog_subtitle FROM {$tbl_blogs} WHERE c_id = {$course_id} AND blog_id = '" . $blog_id . "'";
     $result = Database::query($sql);
     $blog = Database::fetch_array($result);
     // the form contained errors but we do not want to lose the changes the user already did
     if ($_POST) {
         $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
         $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
     }
     $form = new FormValidator('edit_blog', 'post', 'blog_admin.php?action=edit&blog_id=' . intval($_GET['blog_id']));
     $form->addElement('header', get_lang('EditBlog'));
     $form->addElement('text', 'blog_name', get_lang('Title'));
     $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle'));
     $form->addElement('hidden', 'edit_blog_submit', 'true');
     $form->addElement('hidden', 'blog_id', $blog['blog_id']);
     $form->addButtonSave(get_lang('Save'));
     $defaults = array();
     $defaults['blog_name'] = $blog['blog_name'];
     $defaults['blog_subtitle'] = $blog['blog_subtitle'];
     $form->setDefaults($defaults);
     $form->display();
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:30,代码来源:blog.lib.php

示例10: display

 function display()
 {
     parent::display();
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:4,代码来源:evalform.class.php

示例11: display_add_form

/**
* this function displays the form to upload a new item to the dropbox.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
{
    $course_info = api_get_course_info();
    $_user = api_get_user_info();
    $is_courseAdmin = api_is_course_admin();
    $is_courseTutor = api_is_course_tutor();
    $origin = isset($_GET['origin']) ? $_GET['origin'] : null;
    $token = Security::get_token();
    $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
    $form = new FormValidator('sent_form', 'post', api_get_self() . '?view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&' . api_get_cidreq(), null, array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);'));
    $form->addElement('header', get_lang('UploadNewFile'));
    $form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
    $form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
    $form->addElement('hidden', 'sec_token', $token);
    $form->addElement('hidden', 'origin', $origin);
    $form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
    if (dropbox_cnf('allowOverwrite')) {
        $form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
    }
    // List of all users in this course and all virtual courses combined with it
    if (api_get_session_id()) {
        $complete_user_list_for_dropbox = array();
        if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
            $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
        }
        $complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id());
        $complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $complete_user_list2);
    } else {
        if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
            $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
        } else {
            $complete_user_list_for_dropbox = CourseManager::get_teacher_list_from_course_code($course_info['code'], false);
        }
    }
    if (!empty($complete_user_list_for_dropbox)) {
        foreach ($complete_user_list_for_dropbox as $k => $e) {
            $complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
        }
        $complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
    }
    /*
        Create the options inside the select box:
        List all selected users their user id as value and a name string as display
    */
    $current_user_id = '';
    $options = array();
    foreach ($complete_user_list_for_dropbox as $current_user) {
        if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['tutor_id'] == 1) && $current_user['user_id'] != $_user['user_id']) {
            // Don't include yourself.
            if ($current_user['user_id'] == $current_user_id) {
                continue;
            }
            $full_name = $current_user['lastcommafirst'];
            $current_user_id = $current_user['user_id'];
            $options['user_' . $current_user_id] = $full_name;
            //echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
        }
    }
    /*
     * Show groups
     */
    if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) {
        $complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId'));
        if (count($complete_group_list_for_dropbox) > 0) {
            foreach ($complete_group_list_for_dropbox as $current_group) {
                if ($current_group['number_of_members'] > 0) {
                    //echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
                    $options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users');
                }
            }
        }
    }
    if (dropbox_cnf('allowJustUpload')) {
        //echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>';
        //echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
        $options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect');
    }
    $form->addElement('select', 'recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'class' => 'span4'));
    $form->addElement('button', 'submitWork', get_lang('Upload'));
    $form->display();
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:87,代码来源:dropbox_functions.inc.php

示例12: show_form_send_message

function show_form_send_message()
{
    global $isAdmin;
    global $ticket;
    global $subject;
    global $plugin;
    Display::div('', array('span2'));
    $form = new FormValidator('send_ticket', 'POST', api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'], '', array('enctype' => 'multipart/form-data', 'onsubmit' => 'return validate()', 'class' => 'span9 offset1 form-horizontal'));
    $form->addElement('text', 'subject', get_lang('Subject'), array('for' => 'subject', 'value' => $subject, 'style' => 'width: 540px;'));
    $form->addElement('hidden', 'ticket_id', $_GET['ticket_id']);
    $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '550', 'Height' => '250'));
    if ($isAdmin) {
        $form->addElement('checkbox', 'confirmation', null, $plugin->get_lang('RequestConfirmation'));
    }
    $form->addElement('html', '<span id="filepaths">');
    $form->addElement('html', '<div id="filepath_1">');
    $form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
    $form->addElement('html', '</div>');
    $form->addElement('html', '</span>');
    $form->addElement('html', '<div class="controls">');
    $form->addElement('html', '<span id="link-more-attach" >');
    $form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>');
    $form->addElement('html', '</span>');
    $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
    $form->addElement('html', '<br/>');
    $form->addElement('button', 'compose', get_lang('SendMessage'), null, null, null, 'save');
    $form->display();
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:28,代码来源:ticket_details.php

示例13: add_edit_template


//.........这里部分代码省略.........
    // 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');
        if ($_GET['action'] == 'add') {
            $sql = "INSERT INTO {$table_system_template} (title, content, image) VALUES ('" . Database::escape_string($values['title']) . "','" . Database::escape_string($values['template_text']) . "','" . Database::escape_string($new_file_name) . "')";
            $result = api_sql_query($sql, __FILE__, __LINE__);
            // display a feedback message
            Display::display_confirmation_message('TemplateAdded');
            echo '<a href="settings.php?category=Templates&amp;action=add">' . Display::return_icon('add_template.gif', get_lang('AddTemplate')) . get_lang('AddTemplate') . '</a>';
        } else {
            $sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "',\n\t\t\t\t\t\t\t\t\t\t\t   \t\t  content = '" . Database::escape_string($values['template_text']) . "'";
            if (!empty($new_file_name)) {
                $sql .= ", image = '" . Database::escape_string($new_file_name) . "'";
            }
            $sql .= " WHERE id='" . Database::escape_string($_GET['id']) . "'";
            $result = api_sql_query($sql, __FILE__, __LINE__);
            // display a feedback message
            Display::display_confirmation_message('TemplateEdited');
        }
        display_templates();
    } else {
        // display the form
        $form->display();
    }
}
开发者ID:RusticiSoftware,项目名称:SCORMCloud_DokeosMod,代码行数:101,代码来源:settings.php

示例14: display_addcategory_form

/**
* This function displays the form to add a new category.
*
* @param $category_name this parameter is the name of the category (used when no section is selected)
* @param $id this is the id of the category we are editing.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  @author Julio Montoya UI changes
 *
* @version march 2006
*/
function display_addcategory_form($category_name = '', $id = '', $action)
{
    $dropbox_cnf = getDropboxConf();
    $course_id = api_get_course_int_id();
    $title = get_lang('AddNewCategory');
    if (isset($id) && $id != '') {
        // retrieve the category we are editing
        $sql = "SELECT * FROM " . $dropbox_cnf['tbl_category'] . "\n                WHERE c_id = {$course_id} AND cat_id = " . intval($id) . "";
        $result = Database::query($sql);
        $row = Database::fetch_array($result);
        if (empty($category_name)) {
            // after an edit with an error we do not want to return to the
            // original name but the name we already modified.
            // (happens when createinrecievedfiles AND createinsentfiles are not checked)
            $category_name = $row['cat_name'];
        }
        if ($row['received'] == '1') {
            $target = 'received';
        }
        if ($row['sent'] == '1') {
            $target = 'sent';
        }
        $title = get_lang('EditCategory');
    }
    if ($action == 'addreceivedcategory') {
        $target = 'received';
    }
    if ($action == 'addsentcategory') {
        $target = 'sent';
    }
    if ($action == 'editcategory') {
        $text = get_lang('ModifyCategory');
    } elseif ($action == 'addreceivedcategory' || $action == 'addsentcategory') {
        $text = get_lang('CreateCategory');
    }
    $form = new FormValidator('add_new_category', 'post', api_get_self() . '?' . api_get_cidreq() . '&view=' . Security::remove_XSS($_GET['view']));
    $form->addElement('header', $title);
    if (isset($id) && $id != '') {
        $form->addElement('hidden', 'edit_id', intval($id));
    }
    $form->addElement('hidden', 'action', Security::remove_XSS($action));
    $form->addElement('hidden', 'target', Security::remove_XSS($target));
    $form->addElement('text', 'category_name', get_lang('CategoryName'));
    $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
    $form->addButtonSave($text, 'StoreCategory');
    $defaults = array();
    $defaults['category_name'] = $category_name;
    $form->setDefaults($defaults);
    $form->display();
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:61,代码来源:dropbox_functions.inc.php

示例15: forum_search

/**
 * Display the search form for the forum and display the search results
 * @return void display an HTML search results
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
 * @version march 2008, dokeos 1.8.5
 */
function forum_search()
{
    global $origin;
    // Initialize the object.
    $form = new FormValidator('forumsearch', 'post', 'forumsearch.php?origin=' . $origin . '');
    // Settting the form elements.
    $form->addElement('header', '', get_lang('ForumSearch'));
    $form->addElement('text', 'search_term', get_lang('SearchTerm'), 'class="input_titles" id="search_title"');
    $form->applyFilter('search_term', 'html_filter');
    $form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation'));
    $form->addElement('style_submit_button', null, get_lang('Search'), 'class="search"');
    // Setting the rules.
    $form->addRule('search_term', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('search_term', get_lang('TooShort'), 'minlength', 3);
    // Validation or display.
    if ($form->validate()) {
        $values = $form->exportValues();
        $form->setDefaults($values);
        $form->display();
        // Display the search results.
        display_forum_search_results(stripslashes($values['search_term']));
    } else {
        $form->display();
    }
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:forumfunction.inc.php


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