diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php index 50eaf1ed..2e6e59db 100644 --- a/controller/documentcontroller.php +++ b/controller/documentcontroller.php @@ -120,6 +120,8 @@ class DocumentController extends Controller { throw new ResponseException($this->l10n->t('Collabora Online: Malformed URL "%s".', array($wopiRemote)), $admin_check); case '6': throw new ResponseException($this->l10n->t('Collabora Online: Cannot resolve the host "%s".', array($wopiRemote)), $admin_check); + case '7': + throw new ResponseException($this->l10n->t('Collabora Online: Cannot connect to the host "%s".', array($wopiRemote)), $admin_check); case '60': throw new ResponseException($this->l10n->t('Collabora Online: SSL certificate is not installed.'), $this->l10n->t('Please ask your administrator to add CollaboraCloudSuiteCA_ca-chain.cert.pem to the ownCloud\'s ca-bundle.crt, for example "cat /etc/loolwsd/CollaboraCloudSuiteCA_ca-chain.cert.pem >> owncloud/resources/config/ca-bundle.crt" . The exact error message was: ') . $error_message); } @@ -144,7 +146,7 @@ class DocumentController extends Controller { */ public function index(){ $wopiRemote = $this->settings->getAppValue('richdocuments', 'wopi_url'); - if (($parts = parse_url($wopiRemote))) { + if (($parts = parse_url($wopiRemote)) && isset($parts['scheme']) && isset($parts['host'])) { $webSocketProtocol = "ws://"; if ($parts['scheme'] == "https") { $webSocketProtocol = "wss://"; @@ -152,7 +154,7 @@ class DocumentController extends Controller { $webSocket = sprintf( "%s%s%s", $webSocketProtocol, - isset($parts['host']) ? $parts['host'] : "", + $parts['host'], isset($parts['port']) ? ":" . $parts['port'] : ""); } else { @@ -411,12 +413,21 @@ class DocumentController extends Controller { if ($discovery_parsed === false) { $this->cache->remove('discovery.xml'); + $wopiRemote = $this->settings->getAppValue('richdocuments', 'wopi_url'); - return responseError($this->l10n->t('Collabora Online: discovery.xml from "%s" is not a well-formed XML string.', array($wopiRemote)), $this->l10n->t('Please contact the "%s" administrator.', array($wopiRemote))); + 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 $this->responseError($e->getMessage(), $e->getHint()); + return array( + 'status' => 'error', + 'message' => $e->getMessage(), + 'hint' => $e->getHint() + ); } $fileIds = array(); diff --git a/js/documents.js b/js/documents.js index 45b7aa0d..63133565 100644 --- a/js/documents.js +++ b/js/documents.js @@ -5,7 +5,9 @@ $.widget('oc.documentGrid', { context : '.documentslist', documents : {}, sessions : {}, - members : {} + members : {}, + errorMessage : '', + errorHint : '' }, _create : function (){ @@ -80,10 +82,25 @@ $.widget('oc.documentGrid', { var that = this; var def = new $.Deferred(); $.getJSON(OC.generateUrl('apps/richdocuments/ajax/documents/list')) - .done(function (data) { - that.options.documents = data.documents; - that.options.sessions = data.sessions; - that.options.members = data.members; + .done(function (result) { + if (!result || result.status === 'error') { + documentsMain.loadError = true; + if (result && result.message) { + that.options.errorMessage = result.message; + } + else { + that.options.errorMessage = t('richdocuments', 'Failed to load the document, please contact your administrator.'); + } + + if (result && result.hint) { + that.options.errorHint = result.hint; + } + } + else { + that.options.documents = result.documents; + that.options.sessions = result.sessions; + that.options.members = result.members; + } def.resolve(); }) .fail(function(data){ @@ -102,6 +119,15 @@ $.widget('oc.documentGrid', { $(this.options.context + ' .document:not(.template,.progress)').remove(); + if (documentsMain.loadError) { + $(this.options.context).after('
' + this.options.errorMessage + '
' + + this.options.errorHint + + '