portfolio MDL-20896 added the ability to set mime info for "intended" files

This means for places in Moodle that are going to write a file, like a
CSV file, they can set the intended mimetype of the generated file.

Previously you had to use a stored_file object.

This also gets rid of portfolio_fake_add_url function and replaces the
data module implementation with a button.  I also refactored
portfolio_add_button::to_html to use moodle_url so it's easy to return
the same parameters to hidden form fields, an escaped url (for a link),
and a non escaped url (to redirect to, which is what the data module
does)
This commit is contained in:
Penny Leach
2009-12-15 12:36:49 +00:00
parent ecea942368
commit 521a6ab04d
8 changed files with 110 additions and 78 deletions
+8 -3
View File
@@ -98,11 +98,16 @@ if($mform->is_cancelled()) {
}
if (array_key_exists('portfolio', $formdata) && !empty($formdata['portfolio'])) {
// fake portfolio callback stuff and redirect
// fake portfolio callback stuff and redirect
$formdata['id'] = $cm->id;
$formdata['exporttype'] = 'csv'; // force for now
require_once($CFG->libdir . '/portfoliolib.php');
$url = portfolio_fake_add_url($formdata['portfolio'], 'data_portfolio_caller', '/mod/data/locallib.php', $formdata, array(PORTFOLIO_FORMAT_SPREADSHEET));
$button = new portfolio_add_button();
$button->set_callback_options('data_portfolio_caller', $formdata, '/mod/data/locallib.php');
if ($formdata['exporttype'] == 'csv') {
$button->set_format_by_intended_file('csv'); // so we can do mime checking
}
$url = $button->to_html(PORTFOLIO_ADD_FAKE_URL);
$url .= '&instance=' . $formdata['portfolio']; // add on the instance since we know it
redirect($url);
}