示例#1
0
if ($simplehtml->is_cancelled()) {
    redirect($url);
} else {
    if ($simplehtml->get_data()) {
        $fromform = $simplehtml->get_data();
        if ($fromform->id != 0) {
            if (!$DB->update_record('block_simplehtml', $fromform)) {
                print_error('updateerror', 'block_simplehtml');
            }
        } else {
            if (!$DB->insert_record('block_simplehtml', $fromform)) {
                print_error('inserterror', 'block_simplehtml');
            }
        }
        redirect($url);
    } else {
        $site = get_site();
        echo $OUTPUT->header();
        if ($id) {
            $simplehtmlpage = $DB->get_record('block_simplehtml', array('id' => $id));
            if ($viewpage) {
                //block_simplehtml_print_page($simplehtmlpage);
            } else {
                $simplehtml->set_data($simplehtmlpage);
                $simplehtml->display();
            }
        } else {
            $simplehtml->display();
        }
    }
}
示例#2
0
        // SUCCESS
        echo '<h1>Success!</h1>';
        echo '<p>In this case you process validated data. $mform->get_data() returns data posted in form.<p>';
        echo "<p><center><a href='{$CFG->wwwroot}/local/filemanager'>Click here to return and see your File Manager!</a></center><p>";
        // Save the files submitted
        file_save_draft_area_files($draftitemid, $context->id, 'local_filemanager', 'attachment', $itemid, $filemanageropts);
        // Just to show they are all there - output a list of submitted files
        $fs = get_file_storage();
        /** @var stored_file[] $files */
        $files = $fs->get_area_files($context->id, 'local_filemanager', 'attachment', $itemid);
        echo '<p>List of files:</p>';
        echo '<ul>';
        foreach ($files as $file) {
            $out = $file->get_filename();
            if ($file->is_directory()) {
                $out = $file->get_filepath();
            } else {
                $fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
                $out = html_writer::link($fileurl, $out);
            }
            echo html_writer::tag('li', $out);
        }
        echo '</ul>';
    } else {
        // FAIL / DEFAULT
        echo '<h1>Display form</h1>';
        echo '<p>This is the form first display OR "errors"<p>';
        $mform->display();
    }
}
echo $OUTPUT->footer();
示例#3
0
<?php

require_once '../../config.php';
require_once 'formdesign1.php';
require_login();
global $DB;
global $USER;
$PAGE->set_pagelayout('admin');
$toform = new simplehtml_form();
if ($toform->is_cancelled()) {
} else {
    if ($fromform = $toform->get_data()) {
        //		print_object($fromform);
        $record = new stdClass();
        $result = new stdClass();
        $record->name = $fromform->name;
        //		print_object($record);
        $result = $DB->get_record('form', array('name' => $record->name), $fields = '*', $strictness = IGNORE_MISSING);
        //		$result = $DB->get_record_sql('SELECT * FROM {form}', array('name' => $record->name));
        //		print_object($result);
        //		$toform->set_data('$mform');
        //		print_object($mform);
        $_SESSION['admission'] = $result;
        redirect('fill_form.php?id=' . $USER->id);
    } else {
        echo $OUTPUT->header();
        $toform->display();
        echo $OUTPUT->footer();
    }
}