Permalink
Browse files

The return of the "HTML Snippet" code in info panel for shared links.

  • Loading branch information...
1 parent 746d548 commit 7c3195bc59420c4af4ff111172ce5de1004a6af1 @cdujeu cdujeu committed Jul 1, 2016
@@ -14,6 +14,7 @@
<global_param name="SHARE_FORCE_PASSWORD" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Do not allow users to create public links, only private links (password-protected)]" label="CONF_MESSAGE[Set password mandatory]" type="boolean" default="false" expose="true"/>
<global_param name="EMAIL_INVITE_EXTERNAL" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Use external mailer for invitations]" label="CONF_MESSAGE[Force External Mailer]" type="boolean" default="false" expose="true"/>
<global_param name="CREATE_QRCODE" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Create and display QRCode for shared link]" label="CONF_MESSAGE[Create QRCode]" type="boolean" default="false" expose="true"/>
+ <global_param name="INFOPANEL_DISPLAY_HTML_EMBED" group="CONF_MESSAGE[Link Generation]" description="CONF_MESSAGE[Display pasteable HTML snippet in right-hand information panel]" label="CONF_MESSAGE[Display HTML Embed code]" type="boolean" default="false" expose="true"/>
<global_param name="AVOID_SHARED_FOLDER_SAME_LABEL" group="CONF_MESSAGE[Internal Sharing]" description="CONF_MESSAGE[Disallow users to create shared folders if a workspace already exists with the same label]" label="CONF_MESSAGE[Avoid labels duplication]" type="boolean" default="false"/>
<global_param name="SHARED_USERS_TMP_PREFIX" group="CONF_MESSAGE[Internal Sharing]" description="CONF_MESSAGE[Mandatory prefix for users created temporary users login]" label="CONF_MESSAGE[Tmp users prefix]" type="string" expose="true"/>
<global_param name="FORK_EVENT_FORWARDING" group="CONF_MESSAGE[Internal Sharing]" type="boolean" label="CONF_MESSAGE[Fork Events Forwarding]" description="CONF_MESSAGE[If you detect performances issues while modifiyng files under deep trees, try activating that one. Please be sure of what you do, this may trigger a whole lot of php processes on the server.]" default="false"/>
@@ -40,22 +40,21 @@
}
}
- var InfoPanel = React.createClass({
+ var InfoPanelInputRow = React.createClass({
propTypes: {
- node:React.PropTypes.instanceOf(AjxpNode),
- pydio:React.PropTypes.instanceOf(Pydio)
+ inputTitle: React.PropTypes.string,
+ inputValue: React.PropTypes.string,
+ inputClassName: React.PropTypes.string,
+ getMessage: React.PropTypes.func,
+ inputCopyMessage: React.PropTypes.object
},
getInitialState: function(){
- return {
- status:'loading',
- copyMessage:null,
- model : new ReactModel.Share(this.props.pydio, this.props.node)
- };
+ return {copyMessage: null};
},
+
componentDidMount:function(){
- this.state.model.observe("status_changed", this.modelUpdated);
this.attachClipboard();
},
componentDidUpdate:function(){
@@ -71,30 +70,132 @@
}
this._clip = new Clipboard(this.refs['copy-button'].getDOMNode(), {
text: function(trigger) {
- var linkData = this.state.model.getPublicLinks()[0];
- return linkData['public_link'];
+ return this.props.inputValue;
}.bind(this)
});
this._clip.on('success', function(){
- this.setState({copyMessage:this.getMessage('192')}, this.clearCopyMessage);
+ this.setState({copyMessage:this.props.getMessage(this.props.inputCopyMessage)}, this.clearCopyMessage);
}.bind(this));
this._clip.on('error', function(){
var copyMessage;
if( global.navigator.platform.indexOf("Mac") === 0 ){
- copyMessage = this.getMessage('144');
+ copyMessage = this.props.getMessage('144');
}else{
- copyMessage = this.getMessage('143');
+ copyMessage = this.props.getMessage('143');
}
this.refs['input'].getDOMNode().focus();
this.setState({copyMessage:copyMessage}, this.clearCopyMessage);
}.bind(this));
},
+
clearCopyMessage:function(){
global.setTimeout(function(){
this.setState({copyMessage:''});
}.bind(this), 3000);
},
+ render: function(){
+
+ let select = function(e){
+ e.currentTarget.select();
+ };
+
+ let copyMessage = null;
+ if(this.state.copyMessage){
+ var setHtml = function(){
+ return {__html:this.state.copyMessage};
+ }.bind(this);
+ copyMessage = <div className="copy-message" dangerouslySetInnerHTML={setHtml()}/>;
+ }
+ return (
+ <div className="infoPanelRow">
+ <div className="infoPanelLabel">{this.props.getMessage(this.props.inputTitle)}</div>
+ <div className="infoPanelValue" style={{position:'relative'}}>
+ <input
+ ref="input"
+ type="text"
+ className={this.props.inputClassName}
+ readOnly={true}
+ onClick={select}
+ value={this.props.inputValue}
+ />
+ <span ref="copy-button" title={this.props.getMessage('191')} className="copy-button icon-paste"/>
+ {copyMessage}
+ </div>
+ </div>
+ );
+
+ }
+
+ });
+
+ var TemplatePanel = React.createClass({
+
+ propTypes: {
+ node:React.PropTypes.instanceOf(AjxpNode),
+ pydio:React.PropTypes.instanceOf(Pydio),
+ getMessage:React.PropTypes.func,
+ publicLink:React.PropTypes.string
+ },
+
+ getInitialState:function(){
+ return {show: false};
+ },
+
+ generateTplHTML: function(){
+
+ let editors = this.props.pydio.Registry.findEditorsForMime(this.props.node.getAjxpMime(), true);
+ if(!editors.length){
+ return null;
+ }
+
+ let tplString ;
+ let messKey = "61";
+ let newlink = this.props.publicLink + (this.props.publicLink.indexOf('?') !== -1 ? '&' : '?') + 'dl=true&ct=true';
+ let template = global.pydio.UI.getSharedPreviewTemplateForEditor(editors[0], this.props.node);
+ if(template){
+ tplString = template.evaluate({WIDTH:480, HEIGHT:260, DL_CT_LINK:newlink});
+ }else{
+ tplString = newlink;
+ messKey = "60";
+ }
+ return {messageKey:messKey, templateString:tplString};
+
+ },
+
+ render : function(){
+ let data = this.generateTplHTML();
+ if(!data){
+ return null;
+ }
+ return <InfoPanelInputRow
+ inputTitle={data.messageKey}
+ inputValue={data.templateString}
+ inputClassName="share_info_panel_link"
+ getMessage={this.props.getMessage}
+ inputCopyMessage="192"
+ />;
+ }
+
+ });
+
+ var InfoPanel = React.createClass({
+
+ propTypes: {
+ node:React.PropTypes.instanceOf(AjxpNode),
+ pydio:React.PropTypes.instanceOf(Pydio)
+ },
+
+ getInitialState: function(){
+ return {
+ status:'loading',
+ model : new ReactModel.Share(this.props.pydio, this.props.node)
+ };
+ },
+ componentDidMount:function(){
+ this.state.model.observe("status_changed", this.modelUpdated);
+ },
+
modelUpdated: function(){
if(this.isMounted()){
this.setState({status:this.state.model.getStatus()});
@@ -113,32 +214,17 @@
if(this.state.model.hasPublicLink()){
var linkData = this.state.model.getPublicLinks()[0];
var isExpired = linkData["is_expired"];
- var select = function(e){
- e.currentTarget.select();
- };
- if(this.state.copyMessage){
- var setHtml = function(){
- return {__html:this.state.copyMessage};
- }.bind(this);
- var copyMessage = <div className="copy-message" dangerouslySetInnerHTML={setHtml()}/>;
+
+ var linkField = (<InfoPanelInputRow
+ inputTitle="121"
+ inputValue={linkData['public_link']}
+ inputClassName={"share_info_panel_link" + (isExpired?" share_info_panel_link_expired":"")}
+ getMessage={this.getMessage}
+ inputCopyMessage="192"
+ />);
+ if(this.props.node.isLeaf() && this.props.pydio.getPluginConfigs("action.share").get("INFOPANEL_DISPLAY_HTML_EMBED")){
+ var templateField = <TemplatePanel {...this.props} getMessage={this.getMessage} publicLink={linkData.public_link} />;
}
- var linkField = (
- <div className="infoPanelRow">
- <div className="infoPanelLabel">{this.getMessage('121')}</div>
- <div className="infoPanelValue" style={{position:'relative'}}>
- <input
- ref="input"
- type="text"
- className={"share_info_panel_link" + (isExpired?" share_info_panel_link_expired":"")}
- readOnly={true}
- onClick={select}
- value={linkData['public_link']}
- />
- <span ref="copy-button" title={this.getMessage('191')} className="copy-button icon-paste"/>
- {copyMessage}
- </div>
- </div>
- );
}
var users = this.state.model.getSharedUsers();
var sharedUsersEntries = [], remoteUsersEntries = [];
@@ -196,6 +282,7 @@
return (
<div>
{linkField}
+ {templateField}
{sharedUsersBlock}
</div>
);
@@ -154,14 +154,15 @@ public static function loadMinisite($data, $hash = '', $error = null)
if(isSet($_GET["dl"]) && isSet($_GET["file"]) && (!isSet($data["DOWNLOAD_DISABLED"]) || $data["DOWNLOAD_DISABLED"] === false)){
$repoObject = UsersService::getRepositoryWithPermission($loggedUser, $repository);
- PluginsService::getInstance(Context::emptyContext());
+ $dlContext = Context::contextWithObjects($loggedUser, $repoObject);
+ PluginsService::getInstance($dlContext);
$errMessage = null;
try {
$params = $_GET;
$ACTION = "download";
if(isset($_GET["ct"])){
$mime = pathinfo($params["file"], PATHINFO_EXTENSION);
- $editors = PluginsService::getInstance(Context::emptyContext())->searchAllManifests("//editor[contains(@mimes,'$mime') and @previewProvider='true']", "node", true, true, false);
+ $editors = PluginsService::getInstance($dlContext)->searchAllManifests("//editor[contains(@mimes,'$mime') and @previewProvider='true']", "node", true, true, false);
if (count($editors)) {
foreach ($editors as $editor) {
$xPath = new DOMXPath($editor->ownerDocument);
@@ -176,11 +177,11 @@ public static function loadMinisite($data, $hash = '', $error = null)
}
}
}
- $ctx = Context::emptyContext();
- $req = Controller::executableRequest($ctx, $ACTION, $params);
+ $req = Controller::executableRequest($dlContext, $ACTION, $params);
$response = Controller::run($req);
$emitter = new \Pydio\Core\Http\Middleware\SapiMiddleware();
$emitter->emitResponse($req, $response);
+ return;
} catch (\Exception $e) {
$errMessage = $e->getMessage();
}
@@ -225,14 +225,14 @@ Class.create("SMPlayer", AbstractEditor, {
crtRoot = crtRoot.replace(rgxtrim, '');
return new Template('<link rel="stylesheet" type="text/css" href="'+crtRoot+'/plugins/editor.soundmanager/sm/shared/mp3-player-button.css" />\n\
-&lt;script type="text/javascript" src="'+crtRoot+'/plugins/editor.soundmanager/sm/shared/soundmanager2.js"&gt;&lt;/script&gt;\n\
-&lt;script type="text/javascript" src="'+crtRoot+'/plugins/editor.soundmanager/sm/shared/mp3-player-button.js"&gt;&lt;/script&gt;\n\
-&lt;script&gt;\n \
+<script type="text/javascript" src="'+crtRoot+'/plugins/editor.soundmanager/sm/shared/soundmanager2.js"></script>;\n\
+<script type="text/javascript" src="'+crtRoot+'/plugins/editor.soundmanager/sm/shared/mp3-player-button.js"></script>\n\
+<script>\n \
soundManager.setup({\n\
url: "'+crtRoot+'/plugins/editor.soundmanager/sm/swf/",\n\
debugMode : false\n\
});\n\
-&lt;/script&gt;\n\
+</script>\n\
<a href="#{DL_CT_LINK}&fake=ext.'+getAjxpMimeType(node)+'" class="sm2_button">'+node.getLabel()+'</a> '+node.getLabel());
},
@@ -83,7 +83,7 @@ Class.create("VideoPreviewer", AbstractEditor, {
else if(mime == "ogv") cType = "video/ogg";
else if(mime == "webm") cType = "video/webm";
return new Template('<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">\n\
-&lt;script src="http://vjs.zencdn.net/c/video.js"&gt;&lt;/script&gt;\n\
+<script src="http://vjs.zencdn.net/c/video.js"></script>\n\
<video id="my_video_1" class="video-js vjs-default-skin" controls\n\
preload="auto" width="#{WIDTH}" height="#{HEIGHT}" data-setup="{}">\n\
<source src="#{DL_CT_LINK}" type="'+cType+'">\n\
@@ -91,6 +91,13 @@ Class.create("PydioUI", {
}
},
+ getSharedPreviewTemplateForEditor: function(editorData, node){
+ if(Class.getByName(editorData.editorClass).prototype.getSharedPreviewTemplate) {
+ return Class.getByName(editorData.editorClass).prototype.getSharedPreviewTemplate(node);
+ }
+ return null;
+ },
+
registerAsMessageBoxReference: function(element){
this._messageBoxReference = element;
},

0 comments on commit 7c3195b

Please sign in to comment.