Fix collab editor does not get open when triggered from infolog

This commit is contained in:
Hadi Nategh 2017-11-16 18:22:01 +01:00
parent 6d378b8e73
commit a79875a63a
2 changed files with 32 additions and 22 deletions

View File

@ -1613,8 +1613,17 @@ class filemanager_ui
function editor($content=null)
{
$tmpl = new Etemplate('filemanager.editor');
$file_path = $_GET['path'];
$paths = explode('/webdav.php', $file_path);
$path = $_GET['path'];
if (!preg_match("/\/webdav.php\//", $path))
{
$download_url = Vfs::download_url($path);
}
else
{
$download_url = $path;
$paths = explode('/webdav.php', $path);
$path = $paths[1];
}
// Include css files used by wodocollabeditor
Api\Framework::includeCSS('/api/js/webodf/collab/app/resources/app.css');
Api\Framework::includeCSS('/api/js/webodf/collab/wodocollabpane.css');
@ -1623,10 +1632,10 @@ class filemanager_ui
if (!$content)
{
if ($file_path)
if ($download_url)
{
$content['es_id'] = md5 ($file_path);
$content['file_path'] = $paths[1];
$content['es_id'] = md5 ($download_url);
$content['file_path'] = $path;
}
else
{
@ -1635,7 +1644,7 @@ class filemanager_ui
}
$actions = self::getActions_edit();
if (!Api\Vfs::check_access($paths[1], Api\Vfs::WRITABLE))
if (!Api\Vfs::check_access($path, Api\Vfs::WRITABLE))
{
unset ($actions['save']);
unset ($actions['discard']);

View File

@ -296,25 +296,26 @@ app.classes.filemanager = app.classes.filemanager.extend({
mode: 'saveas',
button_caption:"",
button_label:_egwAction.id == 'saveas'?"save as":"save",
value: "doc.odt",
onchange: function (){
file_path = vfs_select.get_value();
if (vfs_select.get_value())
{
// Add odt extension if not exist
if (!file_path.match(/\.odt$/,'ig')) file_path += '.odt';
widgetFilePath.set_value(file_path);
self.editor.getDocumentAsByteArray(saveByteArrayLocally);
self.editor_leaveSession(function(){
var path = window.location.href.split('&path=');
window.location.href = path[0]+'&path='+self.editor_getFilePath();
});
egw.refresh('','filemanager');
}
}
value: "doc.odt"
};
// create file selector
var vfs_select = et2_createWidget('vfs-select', vfs_attrs, this.et2);
jQuery(vfs_select.getDOMNode()).on('change', function (){
file_path = vfs_select.get_value();
if (vfs_select.get_value())
{
// Add odt extension if not exist
if (!file_path.match(/\.odt$/,'ig')) file_path += '.odt';
widgetFilePath.set_value(file_path);
self.editor.getDocumentAsByteArray(saveByteArrayLocally);
self.editor_leaveSession(function(){
var path = window.location.href.split('&path=');
window.location.href = path[0]+'&path='+self.editor_getFilePath();
});
egw.refresh('','filemanager');
}
});
// start the file selector dialog
vfs_select.click();
}