diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php index 2e6e59db..f1314be6 100644 --- a/controller/documentcontroller.php +++ b/controller/documentcontroller.php @@ -222,11 +222,38 @@ class DocumentController extends Controller { $content = file_get_contents(dirname(__DIR__) . self::ODT_TEMPLATE_PATH); } + $discovery_parsed = null; + try { + $discovery = $this->getDiscovery(); + + $loadEntities = libxml_disable_entity_loader(true); + $discovery_parsed = simplexml_load_string($discovery); + libxml_disable_entity_loader($loadEntities); + + if ($discovery_parsed === false) { + $this->cache->remove('discovery.xml'); + $wopiRemote = $this->settings->getAppValue('richdocuments', 'wopi_url'); + + return array( + 'status' => 'error', + 'message' => $this->l10n->t('Collabora Online: discovery.xml from "%s" is not a well-formed XML string.', array($wopiRemote)), + 'hint' => $this->l10n->t('Please contact the "%s" administrator.', array($wopiRemote)) + ); + } + } + catch (ResponseException $e) { + return array( + 'status' => 'error', + 'message' => $e->getMessage() + ); + } + if ($content && $view->file_put_contents($path, $content)){ $info = $view->getFileInfo($path); $response = array( 'status' => 'success', - 'fileid' => $info['fileid'] + 'fileid' => $info['fileid'], + 'urlsrc' => $this->getWopiSrcUrl($discovery_parsed, $mimetype, 'edit') ); } else { $response = array( diff --git a/js/documents.js b/js/documents.js index bb680262..52b30bf0 100644 --- a/js/documents.js +++ b/js/documents.js @@ -463,6 +463,8 @@ var documentsMain = { { mimetype : mimetype }, function(response){ if (response && response.fileid){ + docElem.attr('data-id', response.fileid); + docElem.find('a').attr('urlsrc', response.urlsrc); documentsMain.prepareSession(); documentsMain.joinSession(response.fileid); } else {