Merge pull request #494 from owncloud/fix-486

Use closure for navigation.
This commit is contained in:
VicDeo 2015-06-17 09:20:11 +03:00
commit 28fb6a4412
6 changed files with 80 additions and 64 deletions

View File

@ -21,61 +21,72 @@
*
*/
OCP\App::register(array('order' => 70, 'id' => 'documents', 'name' => 'Documents'));
//OCP\App::registerAdmin('documents', 'settings');
\OCP\App::registerAdmin('documents', 'admin');
OCP\App::registerPersonal('documents', 'personal');
namespace OCA\Documents\AppInfo;
OCP\App::addNavigationEntry(array(
'id' => 'documents_index',
'order' => 2,
'href' => OCP\Util::linkTo('documents/', 'index.php'),
'icon' => OCP\Util::imagePath('documents', 'documents.svg'),
'name' => OCA\Documents\Config::getL10n()->t('Documents'))
);
use OCA\Documents\Filter\Office;
use OCA\Documents\Config;
$app = new Application();
$c = $app->getContainer();
\OCP\App::register(['order' => 70, 'id' => 'documents', 'name' => 'Documents']);
//\OCP\App::registerAdmin('documents', 'settings');
\OCP\App::registerAdmin('documents', 'admin');
\OCP\App::registerPersonal('documents', 'personal');
$navigationEntry = function () use ($c) {
return [
'id' => 'documents_index',
'order' => 2,
'href' => \OCP\Util::linkTo('documents/', 'index.php'),
'icon' => \OCP\Util::imagePath('documents', 'documents.svg'),
'name' => $c->query('L10N')->t('Documents')
];
};
$c->getServer()->getNavigationManager()->add($navigationEntry);
//Script for registering file actions
$url = OC::$server->getRequest()->server['REQUEST_URI'];
$url = \OC::$server->getRequest()->server['REQUEST_URI'];
if (preg_match('%index.php/apps/files(/.*)?%', $url)) {
OCP\Util::addScript('documents', 'viewer/viewer');
\OCP\Util::addScript('documents', 'viewer/viewer');
}
if (OCA\Documents\Config::getConverter() !== 'off'){
$docFilter = new OCA\Documents\Filter\Office(
array(
'read' =>
array (
'target' => 'application/vnd.oasis.opendocument.text',
'format' => 'odt:writer8',
'extension' => 'odt'
),
'write' =>
array (
'target' => 'application/msword',
'format' => 'doc',
'extension' => 'doc'
)
)
);
if (Config::getConverter() !== 'off'){
$docFilter = new Office(
[
'read' =>
[
'target' => 'application/vnd.oasis.opendocument.text',
'format' => 'odt:writer8',
'extension' => 'odt'
],
'write' =>
[
'target' => 'application/msword',
'format' => 'doc',
'extension' => 'doc'
]
]
);
$docxFilter = new OCA\Documents\Filter\Office(
array (
'read' =>
array (
'target' => 'application/vnd.oasis.opendocument.text',
'format' => 'odt:writer8',
'extension' => 'odt'
),
'write' =>
array (
'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'format' => 'docx',
'extension' => 'docx'
)
)
$docxFilter = new Office(
[
'read' =>
[
'target' => 'application/vnd.oasis.opendocument.text',
'format' => 'odt:writer8',
'extension' => 'odt'
],
'write' =>
[
'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'format' => 'docx',
'extension' => 'docx'
]
]
);
}
//Listen to delete file signal
OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Documents\Storage", "onDelete");
\OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Documents\Storage", "onDelete");

View File

@ -5,7 +5,7 @@ $(document).ready(function(){
var documentsSettings = {
save : function() {
$('#docs_apply').attr('disabled', true);
var data = {
var data = {
converter : $('[name="docs_converter"]:checked').val()
};

View File

@ -14,8 +14,8 @@ $(document).ready(function(){
$('#documents-default-path').blur(documentsSettings.save);
$('#documents-default-path').keypress(function( event ) {
if (event.which == 13) {
event.preventDefault();
documentsSettings.save();
event.preventDefault();
documentsSettings.save();
}
});
});

View File

@ -8,7 +8,7 @@ $(document).ready(function(){
$.post(OC.generateUrl('apps/documents/ajax/config/unstable'), data, documentsSettings.afterSave);
},
afterSave : function(){
documentsMain.useUnstable = $('#webodf-unstable').attr('checked')==="checked"
documentsMain.useUnstable = $('#webodf-unstable').attr('checked')==="checked";
}
};
$('#webodf-unstable').change(documentsSettings.save);

View File

@ -13,21 +13,25 @@ var odfViewer = {
],
register : function(response){
var i,
mimeRead,
mimeUpdate;
if (response && response.mimes){
jQuery.each(response.mimes, function(i, mime){
odfViewer.supportedMimesRead.push(mime);
odfViewer.supportedMimesUpdate.push(mime);
});
}
for (var i = 0; i < odfViewer.supportedMimesRead.length; ++i) {
var mime = odfViewer.supportedMimesRead[i];
OCA.Files.fileActions.register(mime, 'View', OC.PERMISSION_READ, '', odfViewer.onView);
OCA.Files.fileActions.setDefault(mime, 'View');
for (i = 0; i < odfViewer.supportedMimesRead.length; ++i) {
mimeRead = odfViewer.supportedMimesRead[i];
OCA.Files.fileActions.register(mimeRead, 'View', OC.PERMISSION_READ, '', odfViewer.onView);
OCA.Files.fileActions.setDefault(mimeRead, 'View');
}
for (var i = 0; i < odfViewer.supportedMimesUpdate.length; ++i) {
var mime = odfViewer.supportedMimesUpdate[i];
for (i = 0; i < odfViewer.supportedMimesUpdate.length; ++i) {
mimeUpdate = odfViewer.supportedMimesUpdate[i];
OCA.Files.fileActions.register(
mime,
mimeUpdate,
'Edit',
OC.PERMISSION_UPDATE,
OC.imagePath('core', 'actions/rename'),
@ -39,7 +43,7 @@ var odfViewer = {
dispatch : function(filename){
if (odfViewer.supportedMimesUpdate.indexOf(OCA.Files.fileActions.getCurrentMimeType()) !== -1
&& OCA.Files.fileActions.getCurrentPermissions() & OC.PERMISSION_UPDATE
&& OCA.Files.fileActions.getCurrentPermissions() & OC.PERMISSION_UPDATE
){
odfViewer.onEdit(filename);
} else {
@ -48,7 +52,8 @@ var odfViewer = {
},
onEdit : function(fileName, context){
var fileId = context.$file.attr('data-id');
var location,
fileId = context.$file.attr('data-id');
window.location = OC.linkTo('documents', 'index.php') + '#' + fileId;
},
@ -58,12 +63,13 @@ var odfViewer = {
if (odfViewer.isDocuments){
//Documents view
var location = filename;
location = filename;
} else {
//Public page, files app, etc
var dirName = $('#dir').val()!='/' ? $('#dir').val() + '/' : '/';
var location = OC.filePath('documents', 'ajax', 'download.php') + '?path=' + encodeURIComponent(dirName) + encodeURIComponent(filename)
+ '&requesttoken=' + encodeURIComponent(oc_requesttoken);
location = OC.filePath('documents', 'ajax', 'download.php') + '?path='
+ encodeURIComponent(dirName) + encodeURIComponent(filename)
+ '&requesttoken=' + encodeURIComponent(oc_requesttoken);
OC.addStyle('documents', '3rdparty/webodf/wodotexteditor');
}

View File

@ -42,8 +42,7 @@ define("owncloud/widgets/ocToolbar",
ocClose.startup();
});
return callback(ocToolbar);
}
;
};
// init
makeWidget(function (widget) {
return callback(widget);