mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
* added share-link feature to filemanager context menu
This commit is contained in:
parent
1159df66cf
commit
91ecb5defc
@ -206,6 +206,14 @@ class filemanager_ui
|
|||||||
'order' => 10,
|
'order' => 10,
|
||||||
'onExecute' => 'javaScript:app.filemanager.copy_link'
|
'onExecute' => 'javaScript:app.filemanager.copy_link'
|
||||||
),
|
),
|
||||||
|
'sharelink' => array(
|
||||||
|
'caption' => lang('Share link'),
|
||||||
|
'group' => $group + 0.5,
|
||||||
|
'icon' => 'share',
|
||||||
|
'allowOnMultiple' => false,
|
||||||
|
'order' => 11,
|
||||||
|
'onExecute' => 'javaScript:app.filemanager.share_link'
|
||||||
|
),
|
||||||
'documents' => filemanager_merge::document_action(
|
'documents' => filemanager_merge::document_action(
|
||||||
$GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir'],
|
$GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir'],
|
||||||
++$group, 'Insert in document', 'document_',
|
++$group, 'Insert in document', 'document_',
|
||||||
@ -1476,6 +1484,14 @@ class filemanager_ui
|
|||||||
$arr['props'] = $props;
|
$arr['props'] = $props;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'sharelink':
|
||||||
|
|
||||||
|
$share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array() );
|
||||||
|
$arr["share_link"] = $link = Vfs\Sharing::share2link($share);
|
||||||
|
$arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet');
|
||||||
|
break;
|
||||||
|
|
||||||
// Upload, then link
|
// Upload, then link
|
||||||
case 'link':
|
case 'link':
|
||||||
// First upload
|
// First upload
|
||||||
|
@ -299,6 +299,10 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finish callback for file a file dialog, to get the overwrite / rename prompt
|
* Finish callback for file a file dialog, to get the overwrite / rename prompt
|
||||||
*
|
*
|
||||||
@ -1139,6 +1143,66 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a share-link for the given file or directory
|
||||||
|
* @param {object} _action egw actions
|
||||||
|
* @param {object} _senders selected nm row
|
||||||
|
* @returns {Boolean} returns false if not successful
|
||||||
|
*/
|
||||||
|
|
||||||
|
share_link: function(_action, _senders){
|
||||||
|
var data = egw.dataGetUIDdata(_senders[0].id)
|
||||||
|
var path = this.id2path(_senders[0].id);
|
||||||
|
|
||||||
|
var request = egw.json('filemanager_ui::ajax_action', ['sharelink', path],
|
||||||
|
this._share_link_callback, this, true, this
|
||||||
|
).sendRequest();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* share-link callback
|
||||||
|
*/
|
||||||
|
|
||||||
|
_share_link_callback: function(_data) {
|
||||||
|
if (_data.msg || _data.share_link) window.egw_refresh(_data.msg, this.appname);
|
||||||
|
console.log("_data", _data);
|
||||||
|
|
||||||
|
var copy_link_to_clipboard = null;
|
||||||
|
|
||||||
|
var copy_link_to_clipboard = function(evt){
|
||||||
|
var $target = jQuery(evt.target);
|
||||||
|
$target.select();
|
||||||
|
|
||||||
|
console.log("share_link click");
|
||||||
|
|
||||||
|
try {
|
||||||
|
successful = document.execCommand('copy');
|
||||||
|
if (successful)
|
||||||
|
{
|
||||||
|
egw.message('Share link copied into clipboard');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
egw.message('Failed to copy the link!');
|
||||||
|
|
||||||
|
};
|
||||||
|
jQuery("body").on("click", "[name=share_link]", copy_link_to_clipboard);
|
||||||
|
|
||||||
|
var dialog = et2_createWidget("dialog",{
|
||||||
|
callback: function( button_id, value){
|
||||||
|
jQuery("body").off("click", "[name=share_link]", copy_link_to_clipboard);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
title: "Share",
|
||||||
|
template: _data.template,
|
||||||
|
value: { content:{ "share_link": _data.share_link } }
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function copies the selected file/folder entry as webdav link into clipboard
|
* This function copies the selected file/folder entry as webdav link into clipboard
|
||||||
*
|
*
|
||||||
|
9
filemanager/templates/default/share_dialog.xet
Normal file
9
filemanager/templates/default/share_dialog.xet
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
|
||||||
|
<!-- $Id$ -->
|
||||||
|
<overlay>
|
||||||
|
<template id="filemanager.share_dialog" template="" lang="" group="0" version="1.9.003">
|
||||||
|
<textbox id="share_link" no_lang="1" width="250px"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</overlay>
|
Loading…
Reference in New Issue
Block a user