
META-INF.resources.document_library.upload_multiple_file_entries.jsp Maven / Gradle / Ivy
The newest version!
<%--
/**
* 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="/document_library/init.jsp" %>
<%
String redirect = ParamUtil.getString(request, "redirect");
long repositoryId = ParamUtil.getLong(request, "repositoryId");
if (repositoryId <= 0) {
// only passes in groupId
repositoryId = ParamUtil.getLong(request, "groupId");
}
long folderId = ParamUtil.getLong(request, "folderId");
String headerTitle = portletName.equals(DLPortletKeys.MEDIA_GALLERY_DISPLAY) ? LanguageUtil.get(request, "add-multiple-media") : LanguageUtil.get(request, "add-multiple-documents");
boolean portletTitleBasedNavigation = GetterUtil.getBoolean(portletConfig.getInitParameter("portlet-title-based-navigation"));
if (portletTitleBasedNavigation) {
portletDisplay.setShowBackIcon(true);
portletDisplay.setURLBack(redirect);
renderResponse.setTitle(headerTitle);
}
%>
>
<%
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());
%>
new Liferay.Upload(
{
boundingBox: '# fileUpload',
<%
DecimalFormatSymbols decimalFormatSymbols = DecimalFormatSymbols.getInstance(locale);
%>
decimalSeparator: '<%= decimalFormatSymbols.getDecimalSeparator() %>',
deleteFile: ' &ticketKey=<%= ticket.getKey() %> ',
fileDescription: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
maxFileSize: '<%= PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE) %> B',
metadataContainer: '# commonFileMetadataContainer',
metadataExplanationContainer: '# metadataExplanationContainer',
namespace: ' ',
tempFileURL: {
method: Liferay.Service.bind('/dlapp/get-temp-file-names'),
params: {
folderId: <%= folderId %>,
folderName: '<%= EditFileEntryMVCActionCommand.TEMP_FOLDER_NAME %>',
groupId: <%= scopeGroupId %>
}
},
tempRandomSuffix: '<%= TempFileEntryUtil.TEMP_RANDOM_SUFFIX %>',
uploadFile: ' &ticketKey=<%= ticket.getKey() %> '
}
);
Liferay.provide(
window,
' updateMultipleFiles',
function() {
var A = AUI();
var Lang = A.Lang;
var commonFileMetadataContainer = A.one('# commonFileMetadataContainer');
var selectedFileNameContainer = A.one('# selectedFileNameContainer');
var inputTpl = '';
var values = A.all('input[name= selectUploadedFile]:checked').val();
var buffer = [];
var dataBuffer = [];
var length = values.length;
for (var i = 0; i < length; i++) {
dataBuffer[0] = i;
dataBuffer[1] = values[i];
buffer[i] = Lang.sub(inputTpl, dataBuffer);
}
selectedFileNameContainer.html(buffer.join(''));
commonFileMetadataContainer.plug(A.LoadingMask);
commonFileMetadataContainer.loadingmask.show();
A.io.request(
document. fm2.action,
{
after: {
failure: function(event, id, obj) {
var selectedItems = A.all('# fileUpload li.selected');
selectedItems.removeClass('selectable').removeClass('selected').addClass('upload-error');
selectedItems.append(' ');
selectedItems.all('input').remove(true);
commonFileMetadataContainer.loadingmask.hide();
},
success: function(event, id, obj) {
var jsonArray = this.get('responseData');
for (var i = 0; i < jsonArray.length; i++) {
var item = jsonArray[i];
var checkBox = A.one('input[data-fileName="' + item.originalFileName + '"]');
var li = checkBox.ancestor();
checkBox.remove(true);
li.removeClass('selectable').removeClass('selected');
var cssClass = null;
var childHTML = null;
if (item.added) {
cssClass = 'file-saved';
var originalFileName = item.originalFileName;
var pos = originalFileName.indexOf('<%= TempFileEntryUtil.TEMP_RANDOM_SUFFIX %>');
if (pos != -1) {
originalFileName = originalFileName.substr(0, pos);
}
if (originalFileName === item.fileName) {
childHTML = ' ';
}
else {
childHTML = ' ';
}
}
else {
cssClass = 'upload-error';
childHTML = ' ';
}
li.addClass(cssClass);
li.append(childHTML);
}
if (commonFileMetadataContainer.io) {
commonFileMetadataContainer.io.start();
}
else {
commonFileMetadataContainer.load('<%= uploadMultipleFileEntries %>');
}
Liferay.fire('filesSaved');
commonFileMetadataContainer.unplug(A.LoadingMask);
}
},
dataType: 'JSON',
form: {
id: document. fm2
}
}
);
},
['aui-base']
);
<%
DLBreadcrumbUtil.addPortletBreadcrumbEntries(folderId, request, renderResponse);
PortalUtil.addPortletBreadcrumbEntry(request, LanguageUtil.get(request, "add-multiple-file-entries"), currentURL);
%>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy