Commit ba21253c authored by Hamish Friedlander's avatar Hamish Friedlander

Merge branch 'fix/31issues' of /home/git/repositories/silverstripe/documentconverter

parents 24a72d33 b74f2614
......@@ -26,6 +26,8 @@
*/
class DocumentImportInnerField extends UploadField {
private static $allowed_actions = array('upload');
public static $importer_class = 'DocumentImportIFrameField_Importer';
/**
......@@ -223,15 +225,19 @@ class DocumentImportInnerField extends UploadField {
return $content;
}
// you need Tidy, i.e. port install php5-tidy
// Clean up with tidy (requires tidy module)
$tidy = new Tidy();
$tidy->parseString($content, array('output-xhtml' => true), 'utf8');
$tidy->cleanRepair();
// Add a header that makes DOMDocument UTF-8 safe
$html = str_replace('<head>', '<head><meta http-equiv="content-type" content="text/html; charset=utf-8">', $tidy);
// Load in the HTML
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
libxml_use_internal_errors(true);
$doc->loadHTML('' . $tidy);
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
......
jQuery.entwine('documentimport', function($) {
$('div.documentimport').entwine({
/**
* Trigger page reload after the document has been imported.
......@@ -6,10 +7,17 @@ jQuery.entwine('documentimport', function($) {
onfileuploaddone: function(e, data) {
var responseText = data.jqXHR.responseText;
var responseJSON = JSON.parse(responseText);
var error = responseJSON[0].error;
if (!error) {
$('.cms-container').entwine('.ss').loadPanel(document.location.href, null, {reload: Math.random()});
$('.cms-tree').entwine('.ss.tree').updateNodesFromServer([$('#Form_EditForm_ID').val()]);
// Update the tree - LeftAndMain.Tree/updateNodesFromServer doesn't handle children being added or removed
var pageID = $('#Form_EditForm_ID').val();
$('.cms-tree').jstree('refresh', $('#record-'+pageID));
// Then reload the page, suppressing change warnings. Ideally this should wait till tree refresh done.
$('.cms-edit-form').removeClass('changed');
$('.cms-container').entwine('.ss').loadPanel(document.location.href, null, null, true);
}
},
......@@ -19,6 +27,7 @@ jQuery.entwine('documentimport', function($) {
onfileuploadsubmit: function (e, data) {
var form = this.closest('form');
var field = this.closest('.documentimport');
data.formData = $.extend(data.formData, {
// Re-add the original fields (this call unfortunately overrides the orignal formData option).
SecurityID: form.find(':input[name=SecurityID]').val(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment