Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2016-10-13 09:58:54 +0300
committerPranav Kant <pranavk@collabora.co.uk>2016-10-13 12:11:49 +0300
commit145854400e3e82c6a04d68e58e9661de7e3cace2 (patch)
tree8bd682b909aa683fee063c33fca539b7f5bc943c
parentf2e6c36060a2fdf2689c38cbda55c8ae99692cf0 (diff)
New 'Use OOXML by default' option in admin settings
-rw-r--r--appinfo/app.php8
-rw-r--r--appinfo/routes.php1
-rw-r--r--assets/docxtemplate.docxbin0 -> 12559 bytes
-rw-r--r--assets/odttemplate.odtbin8734 -> 8891 bytes
-rw-r--r--assets/pptxtemplate.pptxbin0 -> 31659 bytes
-rw-r--r--assets/xlsxtemplate.xlsxbin0 -> 8347 bytes
-rw-r--r--controller/documentcontroller.php12
-rw-r--r--controller/settingscontroller.php19
-rw-r--r--js/admin.js12
-rw-r--r--js/documents.js28
-rw-r--r--js/viewer/viewer.js148
-rw-r--r--templates/admin.php3
-rw-r--r--templates/documents.php6
13 files changed, 166 insertions, 71 deletions
diff --git a/appinfo/app.php b/appinfo/app.php
index b057f763..d7845a3a 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -51,5 +51,13 @@ $eventDispatcher->addListener(
}
);
+if (class_exists('\OC\Files\Type\TemplateManager')) {
+ $manager = \OC_Helper::getFileTemplateManager();
+
+ $manager->registerTemplate('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'apps/richdocuments/assets/docxtemplate.docx');
+ $manager->registerTemplate('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'apps/richdocuments/assets/xlsxtemplate.xlsx');
+ $manager->registerTemplate('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'apps/richdocuments/assets/pptxtemplate.pptx');
+}
+
//Listen to delete file signal
\OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Richdocuments\Storage", "onDelete");
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 3b5d539c..37d996ab 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -41,5 +41,6 @@ $application->registerRoutes($this, [
//settings
['name' => 'settings#setSettings', 'url' => 'ajax/admin.php', 'verb' => 'POST'],
['name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'],
+ ['name' => 'settings#getSettings', 'url' => 'ajax/settings.php', 'verb' => 'GET'],
]
]);
diff --git a/assets/docxtemplate.docx b/assets/docxtemplate.docx
new file mode 100644
index 00000000..900c5276
--- /dev/null
+++ b/assets/docxtemplate.docx
Binary files differ
diff --git a/assets/odttemplate.odt b/assets/odttemplate.odt
index fdab6778..34c424eb 100644
--- a/assets/odttemplate.odt
+++ b/assets/odttemplate.odt
Binary files differ
diff --git a/assets/pptxtemplate.pptx b/assets/pptxtemplate.pptx
new file mode 100644
index 00000000..49c772e9
--- /dev/null
+++ b/assets/pptxtemplate.pptx
Binary files differ
diff --git a/assets/xlsxtemplate.xlsx b/assets/xlsxtemplate.xlsx
new file mode 100644
index 00000000..7dbe3992
--- /dev/null
+++ b/assets/xlsxtemplate.xlsx
Binary files differ
diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php
index f4303475..20045d28 100644
--- a/controller/documentcontroller.php
+++ b/controller/documentcontroller.php
@@ -270,7 +270,8 @@ class DocumentController extends Controller {
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
'wopi_url' => $webSocket,
- 'edit_groups' => $this->appConfig->getAppValue('edit_groups')
+ 'edit_groups' => $this->appConfig->getAppValue('edit_groups'),
+ 'doc_format' => $this->appConfig->getAppValue('doc_format')
]);
$policy = new ContentSecurityPolicy();
@@ -308,6 +309,15 @@ class DocumentController extends Controller {
case 'application/vnd.oasis.opendocument.presentation':
$basename = $this->l10n->t('New Presentation.odp');
break;
+ case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
+ $basename = $this->l10n->t('New Document.docx');
+ break;
+ case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
+ $basename = $this->l10n->t('New Spreadsheet.xlsx');
+ break;
+ case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
+ $basename = $this->l10n->t('New Presentation.pptx');
+ break;
default:
// to be safe
$mimetype = 'application/vnd.oasis.opendocument.text';
diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php
index 8bf3289b..945b021b 100644
--- a/controller/settingscontroller.php
+++ b/controller/settingscontroller.php
@@ -44,6 +44,16 @@ class SettingsController extends Controller{
}
/**
+ * @NoAdminRequired
+ */
+ public function getSettings() {
+ return array(
+ 'doc_format' => $this->appConfig->getAppValue('doc_format'),
+ 'wopi_url' => $this->appConfig->getAppValue('wopi_url')
+ );
+ }
+
+ /**
* @NoCSRFRequired
*/
public function settingsIndex(){
@@ -63,13 +73,14 @@ class SettingsController extends Controller{
'admin',
[
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
- 'edit_groups' => $this->appConfig->getAppValue('edit_groups')
+ 'edit_groups' => $this->appConfig->getAppValue('edit_groups'),
+ 'doc_format' => $this->appConfig->getAppValue('doc_format')
],
'blank'
);
}
- public function setSettings($wopi_url, $edit_groups){
+ public function setSettings($wopi_url, $edit_groups, $doc_format){
if (!is_null($wopi_url)){
$this->appConfig->setAppValue('wopi_url', $wopi_url);
}
@@ -78,6 +89,10 @@ class SettingsController extends Controller{
$this->appConfig->setAppValue('edit_groups', $edit_groups);
}
+ if (!is_null($doc_format)){
+ $this->appConfig->setAppValue('doc_format', $doc_format);
+ }
+
$richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
$richMemCache->clear('discovery.xml');
diff --git a/js/admin.js b/js/admin.js
index 7a27eda0..223b1173 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -26,6 +26,13 @@ var documentsSettings = {
);
},
+ saveDocFormat: function(format) {
+ $.post(
+ OC.filePath('richdocuments', 'ajax', 'admin.php'),
+ { 'doc_format': format }
+ );
+ },
+
afterSave : function(response){
$('#wopi_apply').attr('disabled', false);
OC.msg.finishedAction('#documents-admin-msg', response);
@@ -45,6 +52,11 @@ var documentsSettings = {
$('#wopi_apply').on('click', documentsSettings.save);
documentsSettings.initEditGroups();
+ $(document).on('change', '.doc-format-ooxml', function() {
+ var ooxml = this.checked;
+ documentsSettings.saveDocFormat(ooxml ? 'ooxml' : 'odf');
+ });
+
$(document).on('change', '#edit_group_select', function() {
var element = $(this).parent().find('input.edit-groups-enable');
var groups = $(this).val();
diff --git a/js/documents.js b/js/documents.js
index 7179389c..809c2b0b 100644
--- a/js/documents.js
+++ b/js/documents.js
@@ -712,6 +712,21 @@ var documentsMain = {
documentsMain.create('application/vnd.oasis.opendocument.presentation');
},
+ onCreateDOCX: function(event){
+ event.preventDefault();
+ documentsMain.create('application/vnd.openxmlformats-officedocument.wordprocessingml.document');
+ },
+
+ onCreateXLSX: function(event){
+ event.preventDefault();
+ documentsMain.create('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ },
+
+ onCreatePPTX: function(event){
+ event.preventDefault();
+ documentsMain.create('application/vnd.openxmlformats-officedocument.presentationml.presentation');
+ },
+
create: function(mimetype){
var docElem = $('.documentslist .template').clone();
docElem.removeClass('template');
@@ -970,7 +985,7 @@ FileList.generatePreviewUrl = function(urlSpec) {
urlSpec.y = Math.ceil(urlSpec.y);
urlSpec.forceIcon = 0;
return OC.generateUrl('/core/preview.png?') + $.param(urlSpec);
-}
+};
FileList.isFileNameValid = function (name) {
var trimmedName = name.trim();
@@ -980,14 +995,14 @@ FileList.isFileNameValid = function (name) {
throw t('files', 'File name cannot be empty.');
}
return true;
-}
+};
FileList.setViewerMode = function(){
};
FileList.findFile = function(fileName){
fullPath = escapeHTML(FileList.getCurrentDirectory + '/' + fileName);
- return !!$('.documentslist .document:not(.template,.progress) a[original-title="' + fullPath + '"]').length
-}
+ return !!$('.documentslist .document:not(.template,.progress) a[original-title="' + fullPath + '"]').length;
+};
$(document).ready(function() {
@@ -1030,10 +1045,13 @@ $(document).ready(function() {
$('.add-document').on('click', '.add-odt', documentsMain.onCreateODT);
$('.add-document').on('click', '.add-ods', documentsMain.onCreateODS);
$('.add-document').on('click', '.add-odp', documentsMain.onCreateODP);
+ $('.add-document').on('click', '.add-docx', documentsMain.onCreateDOCX);
+ $('.add-document').on('click', '.add-xlsx', documentsMain.onCreateXLSX);
+ $('.add-document').on('click', '.add-pptx', documentsMain.onCreatePPTX);
OC.Upload._isReceivedSharedFile = function () {
return false;
- }
+ };
var file_upload_start = $('#file_upload_start');
if (typeof supportAjaxUploadWithProgress !== 'undefined' && supportAjaxUploadWithProgress()) {
diff --git a/js/viewer/viewer.js b/js/viewer/viewer.js
index 27318ca7..9ec81bd6 100644
--- a/js/viewer/viewer.js
+++ b/js/viewer/viewer.js
@@ -96,6 +96,88 @@ var odfViewer = {
onClose: function() {
FileList.setViewerMode(false);
$('#loleafletframe').remove();
+ },
+
+ registerFilesMenu: function(response) {
+ var ooxml = response.doc_format === 'ooxml';
+
+ var docExt, spreadsheetExt, presentationExt;
+ var docMime, spreadsheetMime, presentationMime;
+ if (ooxml) {
+ docExt = 'docx';
+ spreadsheetExt = 'xlsx';
+ presentationExt = 'pptx';
+ docMime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
+ spreadsheetMime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
+ presentationMime = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
+ } else {
+ docExt = 'odt';
+ spreadsheetExt = 'ods';
+ presentationExt = 'odp';
+ docMime = 'application/vnd.oasis.opendocument.text';
+ spreadsheetMime = 'application/vnd.oasis.opendocument.spreadsheet';
+ presentationMime = 'application/vnd.oasis.opendocument.presentation';
+ }
+
+ (function(OCA){
+ OCA.FilesLOMenu = {
+ attach: function(newFileMenu) {
+ var self = this;
+
+ newFileMenu.addMenuEntry({
+ id: 'add-' + docExt,
+ displayName: t('richdocuments', 'Document'),
+ templateName: 'New Document.' + docExt,
+ iconClass: 'icon-filetype-document',
+ fileType: 'x-office-document',
+ actionHandler: function(filename) {
+ self._createDocument(docMime, filename);
+ }
+ });
+
+ newFileMenu.addMenuEntry({
+ id: 'add-' + spreadsheetExt,
+ displayName: t('richdocuments', 'Spreadsheet'),
+ templateName: 'New Spreadsheet.' + spreadsheetExt,
+ iconClass: 'icon-filetype-spreadsheet',
+ fileType: 'x-office-spreadsheet',
+ actionHandler: function(filename) {
+ self._createDocument(spreadsheetMime, filename);
+ }
+ });
+
+ newFileMenu.addMenuEntry({
+ id: 'add-' + presentationExt,
+ displayName: t('richdocuments', 'Presentation'),
+ templateName: 'New Presentation.' + presentationExt,
+ iconClass: 'icon-filetype-presentation',
+ fileType: 'x-office-presentation',
+ actionHandler: function(filename) {
+ self._createDocument(presentationMime, filename);
+ }
+ });
+ },
+
+ _createDocument: function(mimetype, filename) {
+ OCA.Files.Files.isFileNameValid(filename);
+ filename = FileList.getUniqueName(filename);
+
+ $.post(
+ OC.generateUrl('apps/richdocuments/ajax/documents/create'),
+ { mimetype : mimetype, filename: filename, dir: $('#dir').val() },
+ function(response){
+ if (response && response.status === 'success'){
+ FileList.add(response.data, {animate: true, scrollTo: true});
+ } else {
+ OC.dialogs.alert(response.data.message, t('core', 'Could not create file'));
+ }
+ }
+ );
+ }
+ };
+ })(OCA);
+
+ OC.Plugins.register('OCA.Files.NewFileMenu', OCA.FilesLOMenu);
}
};
@@ -109,67 +191,13 @@ $(document).ready(function() {
{},
odfViewer.register
);
+
+ $.get(
+ OC.filePath('richdocuments', 'ajax', 'settings.php'),
+ {},
+ odfViewer.registerFilesMenu
+ );
}
$('#odf_close').live('click', odfViewer.onClose);
});
-
-(function(OCA){
- OCA.FilesLOMenu = {
- attach: function(newFileMenu) {
- var self = this;
-
- newFileMenu.addMenuEntry({
- id: 'add-odt',
- displayName: t('richdocuments', 'Document'),
- templateName: 'New Document.odt',
- iconClass: 'icon-filetype-document',
- fileType: 'x-office-document',
- actionHandler: function(filename) {
- self._createDocument('application/vnd.oasis.opendocument.text', filename);
- }
- });
-
- newFileMenu.addMenuEntry({
- id: 'add-ods',
- displayName: t('richdocuments', 'Spreadsheet'),
- templateName: 'New Spreadsheet.ods',
- iconClass: 'icon-filetype-spreadsheet',
- fileType: 'x-office-spreadsheet',
- actionHandler: function(filename) {
- self._createDocument('application/vnd.oasis.opendocument.spreadsheet', filename);
- }
- });
-
- newFileMenu.addMenuEntry({
- id: 'add-odp',
- displayName: t('richdocuments', 'Presentation'),
- templateName: 'New Presentation.odp',
- iconClass: 'icon-filetype-presentation',
- fileType: 'x-office-presentation',
- actionHandler: function(filename) {
- self._createDocument('application/vnd.oasis.opendocument.presentation', filename);
- }
- });
- },
-
- _createDocument: function(mimetype, filename) {
- OCA.Files.Files.isFileNameValid(filename);
- filename = FileList.getUniqueName(filename);
-
- $.post(
- OC.generateUrl('apps/richdocuments/ajax/documents/create'),
- { mimetype : mimetype, filename: filename, dir: $('#dir').val() },
- function(response){
- if (response && response.status === 'success'){
- FileList.add(response.data, {animate: true, scrollTo: true});
- } else {
- OC.dialogs.alert(response.data.message, t('core', 'Could not create file'));
- }
- }
- );
- }
- };
-})(OCA);
-
-OC.Plugins.register('OCA.Files.NewFileMenu', OCA.FilesLOMenu);
diff --git a/templates/admin.php b/templates/admin.php
index 8738a8a7..412c47d6 100644
--- a/templates/admin.php
+++ b/templates/admin.php
@@ -12,4 +12,7 @@ script('richdocuments', 'admin');
<input type="checkbox" class="edit-groups-enable" id="edit_groups_enable-richdocuments" data-appid="richdocuments" />
<label for="edit_groups_enable-richdocuments"><?php p($l->t('Enable edit for specific groups')) ?></label>
<input type="hidden" id="edit_group_select" value="<?php p($_['edit_groups'])?>" title="<?php p($l->t('All')); ?>" style="width: 200px">
+ <br/>
+ <input type="checkbox" class="doc-format-ooxml" id="doc_format_ooxml_enable-richdocuments" <?php p($_['doc_format'] === 'ooxml' ? 'checked' : '') ?> data-appid="richdocuments" />
+ <label for="doc_format_ooxml_enable-richdocuments"><?php p($l->t('Use OOXML by default for new files')) ?></label>
</div>
diff --git a/templates/documents.php b/templates/documents.php
index 75594590..898e2219 100644
--- a/templates/documents.php
+++ b/templates/documents.php
@@ -9,13 +9,13 @@ script('files', 'jquery.fileupload');
<div id="documents-content">
<ul class="documentslist">
<li class="add-document">
- <a class="icon-add add-odt svg" target="_blank" href="">
+ <a class="icon-add add-<?php p($_['doc_format'] === 'ooxml' ? 'docx' : 'odt') ?> svg" target="_blank" href="">
<label><?php p($l->t('New Document')) ?></label>
</a>
- <a class="icon-add add-ods svg" target="_blank" href="">
+ <a class="icon-add add-<?php p($_['doc_format'] === 'ooxml' ? 'xlsx' : 'ods') ?> svg" target="_blank" href="">
<label><?php p($l->t('New Spreadsheet')) ?></label>
</a>
- <a class="icon-add add-odp svg" target="_blank" href="">
+ <a class="icon-add add-<?php p($_['doc_format'] === 'ooxml' ? 'pptx' : 'odp') ?> svg" target="_blank" href="">
<label><?php p($l->t('New Presentation')) ?></label>
</a>
<div id="upload" title="<?php p($l->t('Upload (max. %s)', array($_['uploadMaxHumanFilesize']))) ?>">