forked from liferay/liferay-portal
/
import_portlet_validation.jsp
127 lines (108 loc) · 5.49 KB
/
import_portlet_validation.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<%--
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<%@ include file="/init.jsp" %>
<%
String redirect = ParamUtil.getString(request, "redirect");
%>
<liferay-portlet:resourceURL copyCurrentRenderParameters="<%= false %>" id="exportImport" var="importPortletURL">
<portlet:param name="p_p_isolated" value="true" />
<portlet:param name="redirect" value="<%= redirect %>" />
<portlet:param name="portletResource" value="<%= portletResource %>" />
<portlet:param name="groupId" value="<%= String.valueOf(scopeGroupId) %>" />
<portlet:param name="validate" value="<%= String.valueOf(Boolean.FALSE) %>" />
</liferay-portlet:resourceURL>
<aui:form action="<%= importPortletURL %>" cssClass="lfr-export-dialog" method="post" name="fm1">
<div class="lfr-dynamic-uploader">
<div class="lfr-upload-container" id="<portlet:namespace />fileUpload"></div>
</div>
<%
FileEntry fileEntry = ExportImportHelperUtil.getTempFileEntry(scopeGroupId, themeDisplay.getUserId(), ExportImportHelper.TEMP_FOLDER_NAME + selPortlet.getPortletId());
%>
<aui:button-row>
<aui:button cssClass='<%= fileEntry == null ? "btn-lg hide" : "btn-lg" %>' name="continueButton" type="submit" value="continue" />
</aui:button-row>
<%
Date expirationDate = new Date(System.currentTimeMillis() + PropsValues.SESSION_TIMEOUT * Time.MINUTE);
Ticket ticket = TicketLocalServiceUtil.addTicket(user.getCompanyId(), User.class.getName(), user.getUserId(), TicketConstants.TYPE_IMPERSONATE, null, expirationDate, new ServiceContext());
%>
<aui:script use="liferay-upload">
var liferayUpload = new Liferay.Upload(
{
boundingBox: '#<portlet:namespace />fileUpload',
<%
DecimalFormatSymbols decimalFormatSymbols = DecimalFormatSymbols.getInstance(locale);
%>
decimalSeparator: '<%= decimalFormatSymbols.getDecimalSeparator() %>',
deleteFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>" name="exportImport"><portlet:param name="mvcRenderCommandName" value="exportImport" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.DELETE_TEMP %>" /><portlet:param name="redirect" value="<%= redirect %>" /><portlet:param name="portletResource" value="<%= portletResource %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= Group.class.getName() %>" />',
fileDescription: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
maxFileSize: '<%= PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE) %> B',
metadataContainer: '#<portlet:namespace />commonFileMetadataContainer',
metadataExplanationContainer: '#<portlet:namespace />metadataExplanationContainer',
multipleFiles: false,
namespace: '<portlet:namespace />',
'strings.dropFileText': '<liferay-ui:message key="drop-a-lar-file-here-to-import" />',
'strings.fileCannotBeSavedText': '<liferay-ui:message key="the-file-x-cannot-be-imported" />',
'strings.pendingFileText': '<liferay-ui:message key="this-file-was-previously-uploaded-but-not-actually-imported" />',
'strings.uploadsCompleteText': '<liferay-ui:message key="the-file-is-ready-to-be-imported" />',
tempFileURL: {
method: Liferay.Service.bind('/layout/get-temp-file-names'),
params: {
folderName: '<%= HtmlUtil.escapeJS(ExportImportHelper.TEMP_FOLDER_NAME + selPortlet.getPortletId()) %>',
groupId: <%= scopeGroupId %>
}
},
uploadFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>" name="exportImport"><portlet:param name="mvcRenderCommandName" value="exportImport" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.ADD_TEMP %>" /><portlet:param name="redirect" value="<%= redirect %>" /><portlet:param name="plid" value="<%= String.valueOf(plid) %>" /> <portlet:param name="groupId" value="<%= String.valueOf(themeDisplay.getScopeGroupId()) %>" /><portlet:param name="portletResource" value="<%= portletResource %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= Group.class.getName() %>" />'
}
);
var continueButton = A.one('#<portlet:namespace />continueButton');
liferayUpload._uploader.on(
'alluploadscomplete',
function(event) {
toggleContinueButton();
}
);
Liferay.on(
'tempFileRemoved',
function(event) {
toggleContinueButton();
}
);
function toggleContinueButton() {
var uploadedFiles = liferayUpload._fileListContent.all('.upload-file.upload-complete');
if (uploadedFiles.size() == 1) {
continueButton.show();
}
else {
continueButton.hide();
}
}
</aui:script>
</aui:form>
<aui:script sandbox="<%= true %>">
$('#<portlet:namespace />continueButton').on(
'click',
function(event) {
event.preventDefault();
$('#<portlet:namespace />fm1').ajaxSubmit(
{
success: function(responseData) {
$('#<portlet:namespace />exportImportOptions').html(responseData);
}
}
);
}
);
</aui:script>