<form method="post" action="import.php" enctype="multipart/form-data">
<table border="0" cellpadding="3" cellspacing="3" width="100%">
-<tr>
- <td align="right" style="width:30%;vertical-align:top"><b><?php print_string("filetoimport","glossary") ?>:<br />
+ <tr>
+ <td align="right" style="width:30%;vertical-align:top"><?php print_string("filetoimport","glossary") ?>:
<?php
echo '(';
print_string("maxsize", "", display_size(get_max_upload_file_size($CFG->maxbytes, $course->maxbytes)));
echo ') ';
echo $OUTPUT->help_icon('filetoimport', 'glossary');
?>
- </b></td>
- <td style="width:70%">
- <?php
- require_once($CFG->dirroot.'/lib/uploadlib.php');
- upload_print_form_fragment(1,array('file'),null,false,null,0,0);
- ?>
- </td>
-</tr>
-<tr valign="top">
- <td align="right" colspan="2">
- <table border="0" cellpadding="0" cellspacing="3" width="100%">
- <tr>
- <td align="right" style="width:25%"><?php print_string("destination","glossary") ?>:</td>
- <td style="width:25%"><select size="1" name="dest">
- <option selected="selected" value="current"><?php print_string("currentglossary","glossary") ?></option>
- <option value="new"><?php print_string("newglossary","glossary") ?></option>
- </select> <?php echo $OUTPUT->help_icon('destination', 'glossary') ?></td>
+ </td>
+ <td style="width:70%">
+ <?php
+ require_once($CFG->dirroot.'/lib/uploadlib.php');
+ $options = new stdclass;
+ $options->maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes);
+ $options->itemid = file_get_unused_draft_itemid();
+ $options->accepted_types = array('markup');
+ $options->return_types = FILE_INTERNAL;
+ $options->context = $PAGE->context;
+ if (!empty($file)) {
+ $options->filename = $file->get_filename();
+ $options->filepath = '/';
+ }
+ $fp = new file_picker($options);
+ echo $OUTPUT->render($fp);
+ echo '<input type="hidden" name="file" id="id_file" value="'.$options->itemid.'" />';
+ $module = array('name'=>'form_filepicker', 'fullpath'=>'/lib/form/filepicker.js', 'requires'=>array('core_filepicker'));
+ $PAGE->requires->js_init_call('M.form_filepicker.init', array($fp->options), true, $module);
+ // upload_print_form_fragment(1,array('file'),null,false,null,0,0);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td align="right" style="width:25%"><?php print_string("destination","glossary") ?>: <?php echo $OUTPUT->help_icon('destination', 'glossary') ?></td>
+ <td style="width:25%">
+ <select size="1" name="dest">
+ <option selected="selected" value="current"><?php print_string("currentglossary","glossary") ?></option>
+ <option value="new"><?php print_string("newglossary","glossary") ?></option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
<td style="width:25%" align="right"><?php print_string("importcategories","glossary") ?>:</td>
<td style="width:25%"><input type="checkbox" name="catsincl" value="1" alt="<?php print_string("importcategories","glossary") ?>" /></td>
- </tr>
- </table>
- </td>
-</tr>
-<tr>
- <td align="right" colspan="2">
- <table border="0" cellpadding="3" cellspacing="3" width="100%">
- <tr>
- <td style="width:50%" align="right"><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
- <td style="width:50%"><input type="reset" value="<?php print_string("revert") ?>" /></td>
- </tr>
- </table>
- </td>
-</tr>
+ </tr>
</table>
-<div>
+<div class="mdl-align">
<input type="hidden" name="id" value="<?php p($id) ?>" />
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<input type="hidden" name="step" value="1" />
+<input type="submit" value="<?php print_string("savechanges") ?>" />
+<input type="reset" value="<?php print_string("revert") ?>" />
</div>
</form>
$mode = optional_param('mode', 'letter', PARAM_ALPHA );
$hook = optional_param('hook', 'ALL', PARAM_ALPHANUM);
+$file = optional_param('file', 0, PARAM_INT); // xml file
$url = new moodle_url('/mod/glossary/import.php', array('id'=>$id));
if ($step !== 0) {
echo $OUTPUT->heading($strimportentries);
if ( !$step ) {
+ // display upload form
echo $OUTPUT->box_start('glossarydisplay generalbox');
include("import.html");
echo $OUTPUT->box_end();
-
echo $OUTPUT->footer();
exit;
}
require_sesskey();
$form = data_submitted();
-$file = $_FILES["file"];
-
-require_once($CFG->dirroot.'/lib/uploadlib.php');
-$um = new upload_manager('file',false,false,$course,false,0);
+$result = true;
+if (empty($file)) {
+ $result = false;
+} else {
+ $fs = get_file_storage();
+ $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $draftfiles = $fs->get_area_files($usercontext->id, 'user_draft', $file, 'id', false);
+ if (count($draftfiles)<1) {
+ $result = false;
+ } else {
+ $xmlfile = array_pop($draftfiles);
+ }
+}
-if (!$um->preprocess_files()) {
+if (!$result) {
echo $OUTPUT->box_start('glossarydisplay generalbox');
echo $OUTPUT->continue_button('import.php?id='.$id);
echo $OUTPUT->box_end();
-
echo $OUTPUT->footer();
die();
}
-if ($xml = glossary_read_imported_file($file['tmp_name']) ) {
+if ($xml = glossary_read_imported_file($xmlfile->get_content())) {
+ $xmlfile->delete();
$importedentries = 0;
$importedcats = 0;
// rejected entries
if ($rejections) {
+ echo $OUTPUT->heading(get_string("rejectionrpt","glossary"), 4);
echo '<table class="glossaryimportexport">';
- echo '<tr><td align="center" colspan="2" width="100%"><strong>' . get_string("rejectionrpt","glossary") . '</strong></tr>';
echo $rejections;
echo '</table><hr />';
}
}
echo $OUTPUT->box_end();
} else {
- notice(get_string('errorparsingxml', 'glossary'));
+ echo $OUTPUT->box_start('glossarydisplay generalbox');
+ echo get_string('errorparsingxml', 'glossary');
+ echo $OUTPUT->continue_button('import.php?id='.$id);
+ echo $OUTPUT->box_end();
}
/// Finish the page