cloudsuite: Add buttons to create new spreadsheet and new presentation.

pull/1/head
Jan Holesovsky 9 years ago
parent 37f61b4056
commit e6593def87

@ -77,17 +77,34 @@ class DocumentController extends Controller{
* @NoAdminRequired
*/
public function create(){
$mimetype = $this->request->post['mimetype'];
$view = new View('/' . $this->uid . '/files');
$dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/');
if (!$view->is_dir($dir)){
$dir = '/';
}
$path = Helper::getNewFileName($view, $dir . '/New Document.odt');
$basename = $this->l10n->t('New Document.odt');
switch ($mimetype) {
case 'application/vnd.oasis.opendocument.spreadsheet':
$basename = $this->l10n->t('New Spreadsheet.ods');
break;
case 'application/vnd.oasis.opendocument.presentation':
$basename = $this->l10n->t('New Presentation.odp');
break;
default:
// to be safe
$mimetype = 'application/vnd.oasis.opendocument.text';
break;
}
$path = Helper::getNewFileName($view, $dir . '/' . $basename);
$content = '';
if (class_exists('\OC\Files\Type\TemplateManager')){
$manager = \OC_Helper::getFileTemplateManager();
$content = $manager->getTemplate('application/vnd.oasis.opendocument.text');
$content = $manager->getTemplate($mimetype);
}
if (!$content){

@ -34,26 +34,29 @@
box-sizing: border-box;
display: inline-block;
position: relative;
height: 100px;
height: 46px;
width: 200px;
background-repeat: no-repeat;
background-size: 32px;
background-position: 50%;
background-position: 3%;
}
.add-document a.add {
border-bottom: 1px solid #fff;
}
.add-document .add,
.add-document .add-odt,
.add-document .add-ods,
.add-document .add-odp,
.add-document .upload {
opacity: .7;
border: 1px solid #e8e8e8;
}
.add-document .upload {
margin-top: 4px;
}
.add-document .add:hover,
.add-document .add:focus,
margin-top: 12px;
}
.add-document .add-odt:hover,
.add-document .add-ods:hover,
.add-document .add-odp:hover,
.add-document .add-odt:focus,
.add-document .add-ods:focus,
.add-document .add-odp:focus,
.add-document #upload:hover .upload,
.add-document .upload:focus {
opacity: 1;

@ -374,8 +374,22 @@ var documentsMain = {
});
},
onCreate: function(event){
onCreateODT: function(event){
event.preventDefault();
documentsMain.create('application/vnd.oasis.opendocument.text');
},
onCreateODS: function(event){
event.preventDefault();
documentsMain.create('application/vnd.oasis.opendocument.spreadsheet');
},
onCreateODP: function(event){
event.preventDefault();
documentsMain.create('application/vnd.oasis.opendocument.presentation');
},
create: function(mimetype){
var docElem = $('.documentslist .template').clone();
docElem.removeClass('template');
docElem.addClass('document');
@ -383,7 +397,7 @@ var documentsMain = {
docElem.show();
$.post(
OC.generateUrl('apps/documents/ajax/documents/create'),
{},
{ mimetype : mimetype },
function(response){
if (response && response.fileid){
documentsMain.prepareSession();
@ -692,7 +706,9 @@ $(document).ready(function() {
}
});
$('.add-document').on('click', '.add', documentsMain.onCreate);
$('.add-document').on('click', '.add-odt', documentsMain.onCreateODT);
$('.add-document').on('click', '.add-ods', documentsMain.onCreateODS);
$('.add-document').on('click', '.add-odp', documentsMain.onCreateODP);
var file_upload_start = $('#file_upload_start');
if (typeof supportAjaxUploadWithProgress !== 'undefined' && supportAjaxUploadWithProgress()) {

@ -21,7 +21,7 @@ class Helper {
while ($view->file_exists($path)){
$fileNum += 1;
$path = preg_replace('/(\.odt|' . $prepend . '\(\d+\)\.odt)$/', $prepend . '(' . $fileNum . ').odt', $path);
$path = preg_replace('/(\.|' . $prepend . '\(\d+\)\.)([^.]*)$/', $prepend . '(' . $fileNum . ').$2', $path);
};
return $path;

@ -11,9 +11,15 @@ script('files', 'jquery.fileupload');
<div id="documents-content">
<ul class="documentslist">
<li class="add-document">
<a class="icon-add add svg" target="_blank" href="">
<label><?php p($l->t('New document')) ?></label>
<a class="icon-add add-odt svg" target="_blank" href="">
<label><?php p($l->t('New Document')) ?></label>
</a>
<a class="icon-add add-ods svg" target="_blank" href="">
<label><?php p($l->t('New Spreadsheet')) ?></label>
</a>
<a class="icon-add add-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']))) ?>">
<form data-upload-id="1"
id="data-upload-form"

Loading…
Cancel
Save