示例#1
0
        // FILE MANAGER
        $mform->addElement('filemanager', 'attachments', 'File Manager label', null, $filemanageropts);
        // Buttons
        $this->add_action_buttons();
    }
}
// ===============
//
//
// PAGE LOGIC
//
//
// ===============
$filemanageropts = array('subdirs' => 0, 'maxbytes' => '0', 'maxfiles' => 50, 'context' => $context);
$customdata = array('filemanageropts' => $filemanageropts);
$mform = new simplehtml_form(null, $customdata);
// CONFIGURE FILE MANAGER
// From http://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#filemanager
$itemid = 0;
// This is used to distinguish between multiple file areas, e.g. different student's assignment submissions, or attachments to different forum posts, in this case we use '0' as there is no relevant id to use
$draftitemid = file_get_submitted_draft_itemid('attachments');
// Copy all the files from the 'real' area, into the draft area
file_prepare_draft_area($draftitemid, $context->id, 'local_filemanager', 'attachment', $itemid, $filemanageropts);
// Prepare the data to pass into the form - normally we would load this from a database, but, here, we have no 'real' record to load
$entry = new stdClass();
$entry->attachments = $draftitemid;
// Add the draftitemid to the form, so that 'file_get_submitted_draft_itemid' can retrieve it
// Set form data
$mform->set_data($entry);
// ===============
//
示例#2
0
require_once '../../config.php';
require_once 'simplehtml_form.php';
global $DB, $OUTPUT, $PAGE, $COURSE;
$courseid = required_param('courseid', PARAM_INT);
$blockid = required_param('blockid', PARAM_INT);
$id = optional_param('id', 0, PARAM_INT);
$component = required_param('component', PARAM_RAW);
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
    print_error('invalidcourse', 'block_simplehtml', $courseid);
}
require_login($course);
$PAGE->set_url('/blocks/simplehtml/view.php', array('id' => $courseid));
$PAGE->set_pagelayout('standard');
$PAGE->set_heading(get_string('edithtml', 'block_simplehtml'));
$PAGE->set_title('Nuevo Rea');
$simplehtml = new simplehtml_form();
$toform['blockid'] = $blockid;
$toform['courseid'] = $courseid;
$toform['component'] = $component;
$toform['id'] = $id;
$simplehtml->set_data($toform);
$settingsnode = $PAGE->settingsnav->add(get_string('simplehtmlsettings', 'block_simplehtml'));
$editurl = new moodle_url('/blocks/simplehtml/view.php', array('id' => $id, 'courseid' => $courseid, 'blockid' => $blockid, 'component' => $component));
$editnode = $settingsnode->add(get_string('editpage', 'block_simplehtml'), $editurl);
$editnode->make_active();
$url = new moodle_url('/course/view.php', array('id' => $courseid));
if ($simplehtml->is_cancelled()) {
    redirect($url);
} else {
    if ($simplehtml->get_data()) {
        $fromform = $simplehtml->get_data();
示例#3
0
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
 *
 * @package local
 * @subpackage modulo basico
 * @copyright 2015 Santiago Vergara Solar (contacto@santiagovergara.com)
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(__FILE__) . '../../../config.php';
// Require
require_once 'form.php';
//require
/*	If i like login require in this page  */
// require_login ();
#necessary
$baseurl = new moodle_url('/local/pluginbasico/index.php');
$context = context_system::instance();
$PAGE->set_context($context);
$PAGE->set_url($baseurl);
$PAGE->set_pagelayout('standard');
echo $OUTPUT->header();
#code here {{
$form = new simplehtml_form();
$form->display();
#}}
/* Standar form */
echo $OUTPUT->footer();
示例#4
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();
    }
}
示例#5
0
<?php

require_once '../../config.php';
require_once 'formdesign.php';
global $DB;
global $USER;
$PAGE->set_pagelayout('admin');
$mform = new simplehtml_form();
if ($mform->is_cancelled()) {
} else {
    if ($fromform = $mform->get_data()) {
        $record = new stdClass();
        $record->id = '';
        $record->name = $fromform->name;
        $record->text = $fromform->text['text'];
        $record->format = $fromform->text['format'];
        //		print_object($record);
        $DB->insert_record('form', $record, true, false);
        //		$mform->display();
        echo "Changes have been made.";
        echo $OUTPUT->header();
    } else {
        echo $OUTPUT->header();
        $result = $_SESSION['admission'];
        print_object($result);
        //		print_object($USER->id);
        //		$mform->set_data(array ($result=>name,$result=>text) );
        $mform->set_data($result);
        //		$mform-> getElement ('text') -> SetValue (array ('text' => $result[text]));
        $mform->display();
        echo $OUTPUT->footer();