Use new owncloud9 addMenuEntry plugin
... to add new odf files from main 'Files' app
This commit is contained in:
Родитель
10ae3039ca
Коммит
bb01949a9a
|
@ -49,6 +49,7 @@ if (isset($request->server['REQUEST_URI'])) {
|
|||
|
||||
if (preg_match('%index.php/apps/files(/.*)?%', $url)) {
|
||||
\OCP\Util::addScript('richdocuments', 'viewer/viewer');
|
||||
\OCP\Util::addStyle('richdocuments', 'viewer/odfviewer');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -255,11 +255,15 @@ class DocumentController extends Controller {
|
|||
*/
|
||||
public function create(){
|
||||
$mimetype = $this->request->post['mimetype'];
|
||||
$filename = $this->request->post['filename'];
|
||||
$dir = $this->request->post['dir'];
|
||||
|
||||
$view = new View('/' . $this->uid . '/files');
|
||||
$dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/');
|
||||
if (!$view->is_dir($dir)){
|
||||
$dir = '/';
|
||||
if (!$dir){
|
||||
$dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/');
|
||||
if (!$view->is_dir($dir)){
|
||||
$dir = '/';
|
||||
}
|
||||
}
|
||||
|
||||
$basename = $this->l10n->t('New Document.odt');
|
||||
|
@ -276,7 +280,11 @@ class DocumentController extends Controller {
|
|||
break;
|
||||
}
|
||||
|
||||
$path = Helper::getNewFileName($view, $dir . '/' . $basename);
|
||||
if (!$filename){
|
||||
$path = Helper::getNewFileName($view, $dir . '/' . $basename);
|
||||
} else {
|
||||
$path = $dir . '/' . $filename;
|
||||
}
|
||||
|
||||
$content = '';
|
||||
if (class_exists('\OC\Files\Type\TemplateManager')){
|
||||
|
@ -321,7 +329,8 @@ class DocumentController extends Controller {
|
|||
'status' => 'success',
|
||||
'fileid' => $info['fileid'],
|
||||
'urlsrc' => $this->getWopiSrcUrl($discovery_parsed, $mimetype, 'edit'),
|
||||
'lolang' => $this->settings->getUserValue($this->uid, 'core', 'lang', 'en')
|
||||
'lolang' => $this->settings->getUserValue($this->uid, 'core', 'lang', 'en'),
|
||||
'data' => \OCA\Files\Helper::formatFileInfo($info)
|
||||
);
|
||||
} else {
|
||||
$response = array(
|
||||
|
|
|
@ -8,3 +8,15 @@
|
|||
-moz-box-shadow: 0px 4px 10px #000;
|
||||
-webkit-box-shadow: 0px 4px 10px #000;
|
||||
}
|
||||
|
||||
.icon-filetype-document{
|
||||
background-image: url('../../../../core/img/filetypes/x-office-document.svg')
|
||||
}
|
||||
|
||||
.icon-filetype-spreadsheet{
|
||||
background-image: url('../../../../core/img/filetypes/x-office-spreadsheet.svg');
|
||||
}
|
||||
|
||||
.icon-filetype-presentation{
|
||||
background-image: url('../../../../core/img/filetypes/x-office-presentation.svg');
|
||||
}
|
|
@ -113,3 +113,63 @@ $(document).ready(function() {
|
|||
|
||||
$('#odf_close').live('click', odfViewer.onClose);
|
||||
});
|
||||
|
||||
(function(OCA){
|
||||
OCA.FilesLOMenu = {
|
||||
attach: function(newFileMenu) {
|
||||
var self = this;
|
||||
|
||||
newFileMenu.addMenuEntry({
|
||||
id: 'add-odt',
|
||||
displayName: '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: '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: '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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче