Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
META-INF.resources.edit_article.jsp Maven / Gradle / Ivy
<%--
/**
* 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");
String portletResource = ParamUtil.getString(request, "portletResource");
long refererPlid = ParamUtil.getLong(request, "refererPlid");
String referringPortletResource = ParamUtil.getString(request, "referringPortletResource");
boolean changeStructure = GetterUtil.getBoolean(ParamUtil.getString(request, "changeStructure"));
JournalArticle article = journalDisplayContext.getArticle();
long groupId = BeanParamUtil.getLong(article, request, "groupId", scopeGroupId);
long folderId = BeanParamUtil.getLong(article, request, "folderId", JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID);
long classNameId = BeanParamUtil.getLong(article, request, "classNameId");
long classPK = BeanParamUtil.getLong(article, request, "classPK");
String articleId = BeanParamUtil.getString(article, request, "articleId");
double version = BeanParamUtil.getDouble(article, request, "version", JournalArticleConstants.VERSION_DEFAULT);
String ddmStructureKey = ParamUtil.getString(request, "ddmStructureKey");
String requestDDMFormValues = ParamUtil.getString(request, "ddmFormValues");
if (Validator.isNull(ddmStructureKey) && (article != null)) {
ddmStructureKey = article.getDDMStructureKey();
}
DDMStructure ddmStructure = null;
long ddmStructureId = ParamUtil.getLong(request, "ddmStructureId");
if (ddmStructureId > 0) {
ddmStructure = DDMStructureLocalServiceUtil.fetchStructure(ddmStructureId);
}
else if (Validator.isNotNull(ddmStructureKey)) {
ddmStructure = DDMStructureLocalServiceUtil.fetchStructure((article != null) ? article.getGroupId() : themeDisplay.getSiteGroupId(), PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey, true);
}
String ddmTemplateKey = ParamUtil.getString(request, "ddmTemplateKey");
if (Validator.isNull(ddmTemplateKey) && (article != null) && Objects.equals(article.getDDMStructureKey(), ddmStructureKey)) {
ddmTemplateKey = article.getDDMTemplateKey();
}
DDMTemplate ddmTemplate = null;
long ddmTemplateId = ParamUtil.getLong(request, "ddmTemplateId");
if (ddmTemplateId > 0) {
ddmTemplate = DDMTemplateLocalServiceUtil.fetchDDMTemplate(ddmTemplateId);
}
else if (Validator.isNotNull(ddmTemplateKey)) {
ddmTemplate = DDMTemplateLocalServiceUtil.fetchTemplate((article != null) ? article.getGroupId() : themeDisplay.getSiteGroupId(), PortalUtil.getClassNameId(DDMStructure.class), ddmTemplateKey, true);
}
if (ddmTemplate == null) {
List ddmTemplates = DDMTemplateServiceUtil.getTemplates(company.getCompanyId(), ddmStructure.getGroupId(), PortalUtil.getClassNameId(DDMStructure.class), ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class), true, WorkflowConstants.STATUS_APPROVED);
if (!ddmTemplates.isEmpty()) {
ddmTemplate = ddmTemplates.get(0);
}
}
boolean editingDDMStructureDefaultValues = false;
if (classNameId > JournalArticleConstants.CLASSNAME_ID_DEFAULT) {
editingDDMStructureDefaultValues = true;
}
String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getSiteDefault());
boolean changeableDefaultLanguage = journalWebConfiguration.changeableDefaultLanguage();
if (article != null) {
String articleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(article.getContent(), LocaleUtil.getSiteDefault());
if (!Objects.equals(defaultLanguageId, articleDefaultLanguageId)) {
changeableDefaultLanguage = true;
}
defaultLanguageId = articleDefaultLanguageId;
}
if (Validator.isNotNull(requestDDMFormValues)) {
defaultLanguageId = journalDisplayContext.getDefaultLanguageIdFromDDMFormValues(requestDDMFormValues);
}
if (editingDDMStructureDefaultValues) {
changeableDefaultLanguage = false;
}
boolean showHeader = ParamUtil.getBoolean(request, "showHeader", true);
request.setAttribute("edit_article.jsp-redirect", redirect);
request.setAttribute("edit_article.jsp-structure", ddmStructure);
request.setAttribute("edit_article.jsp-template", ddmTemplate);
request.setAttribute("edit_article.jsp-defaultLanguageId", defaultLanguageId);
request.setAttribute("edit_article.jsp-changeStructure", changeStructure);
%>
<%
portletDisplay.setShowBackIcon(true);
if (Validator.isNotNull(redirect)) {
portletDisplay.setURLBack(redirect);
}
else if ((classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) && (article != null)) {
PortletURL backURL = liferayPortletResponse.createRenderURL();
backURL.setParameter("groupId", String.valueOf(article.getGroupId()));
backURL.setParameter("folderId", String.valueOf(article.getFolderId()));
portletDisplay.setURLBack(backURL.toString());
}
String title = StringPool.BLANK;
if (editingDDMStructureDefaultValues) {
title = LanguageUtil.get(request, "structure-default-values");
}
else if ((article != null) && !article.isNew()) {
title = article.getTitle(locale);
}
else {
title = LanguageUtil.get(request, "new-web-content");
}
renderResponse.setTitle(title);
%>
<%
DDMFormValues ddmFormValues = journalDisplayContext.getDDMFormValues(ddmStructure);
Set availableLocalesSet = new HashSet<>();
if (Validator.isNotNull(requestDDMFormValues)) {
availableLocalesSet.addAll(journalDisplayContext.getAvailableLocalesFromDDMFormValues(requestDDMFormValues));
}
else {
availableLocalesSet.add(LocaleUtil.fromLanguageId(defaultLanguageId));
availableLocalesSet.addAll(journalDisplayContext.getAvailableArticleLocales());
if (ddmFormValues != null) {
availableLocalesSet.addAll(ddmFormValues.getAvailableLocales());
}
}
Locale[] availableLocales = availableLocalesSet.toArray(new Locale[0]);
%>
<%
long fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE);
if (fileMaxSize == 0) {
fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE);
}
%>
<%
boolean approved = false;
boolean pending = false;
long inheritedWorkflowDDMStructuresFolderId = JournalFolderLocalServiceUtil.getInheritedWorkflowFolderId(folderId);
boolean workflowEnabled = WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(themeDisplay.getCompanyId(), groupId, JournalFolder.class.getName(), folderId, ddmStructure.getStructureId()) || WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(themeDisplay.getCompanyId(), groupId, JournalFolder.class.getName(), inheritedWorkflowDDMStructuresFolderId, ddmStructure.getStructureId()) || WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(themeDisplay.getCompanyId(), groupId, JournalFolder.class.getName(), inheritedWorkflowDDMStructuresFolderId, JournalArticleConstants.DDM_STRUCTURE_ID_ALL);
if ((article != null) && (version > 0)) {
approved = article.isApproved();
if (workflowEnabled) {
pending = article.isPending();
}
}
%>
<%
boolean hasSavePermission = false;
if ((article != null) && !article.isNew()) {
hasSavePermission = JournalArticlePermission.contains(permissionChecker, article, ActionKeys.UPDATE);
}
else {
hasSavePermission = JournalFolderPermission.contains(permissionChecker, groupId, folderId, ActionKeys.ADD_ARTICLE);
}
String saveButtonLabel = "save";
if ((article == null) || article.isApproved() || article.isDraft() || article.isExpired() || article.isScheduled()) {
saveButtonLabel = "save-as-draft";
}
String publishButtonLabel = "publish";
if (workflowEnabled) {
publishButtonLabel = "submit-for-publication";
}
if (editingDDMStructureDefaultValues) {
publishButtonLabel = "save";
}
%>
new Liferay.Portlet.Journal(
{
article: {
editUrl: '<%= editArticleURL %>',
id: '<%= (article != null) ? HtmlUtil.escape(articleId) : StringPool.BLANK %>',
previewUrl: '<%= HtmlUtil.escapeJS(previewArticleContentURL.toString()) %>',
title: '<%= (article != null) ? HtmlUtil.escapeJS(article.getTitle(locale)) : StringPool.BLANK %>'
},
namespace: ' ',
'strings.addTemplate': ' ',
'strings.saveAsDraftBeforePreview': ' '
}
);