$options = portfolio_instance_select(portfolio_instances(), $exporter->get('caller')->supported_formats(), get_class($exporter->get('caller')), $exporter->get('caller')->get_mimetype(), 'instance', true, true); if (empty($options)) { throw new portfolio_export_exception($exporter, 'noavailableplugins', 'portfolio'); } else { if (count($options) == 1) { // no point displaying a form, just redirect. $optionskeys = array_keys($options); $instance = array_shift($optionskeys); redirect($CFG->wwwroot . '/portfolio/add.php?id= ' . $exporter->get('id') . '&instance=' . $instance . '&sesskey=' . sesskey()); } } // be very selective about not including this unless we really need to require_once $CFG->libdir . '/portfolio/forms.php'; $mform = new portfolio_instance_select('', array('id' => $exporter->get('id'), 'caller' => $exporter->get('caller'), 'options' => $options)); if ($mform->is_cancelled()) { $exporter->cancel_request(); } else { if ($fromform = $mform->get_data()) { redirect($CFG->wwwroot . '/portfolio/add.php?instance=' . $fromform->instance . '&id=' . $exporter->get('id')); exit; } else { $exporter->print_header(get_string('selectplugin', 'portfolio')); echo $OUTPUT->box_start(); $mform->display(); echo $OUTPUT->box_end(); echo $OUTPUT->footer(); exit; } } } // if we haven't been passed &stage= grab it from the exporter.