
META-INF.resources.edit_template.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 closeRedirect = ParamUtil.getString(request, "closeRedirect");
String portletResource = ParamUtil.getString(request, "portletResource");
String portletResourceNamespace = ParamUtil.getString(request, "portletResourceNamespace");
DDMTemplate template = (DDMTemplate)request.getAttribute(DDMWebKeys.DYNAMIC_DATA_MAPPING_TEMPLATE);
long templateId = BeanParamUtil.getLong(template, request, "templateId");
long groupId = BeanParamUtil.getLong(template, request, "groupId", PortalUtil.getScopeGroupId(request, refererPortletName));
long classNameId = BeanParamUtil.getLong(template, request, "classNameId");
long classPK = ParamUtil.getLong(request, "classPK");
long resourceClassNameId = BeanParamUtil.getLong(template, request, "resourceClassNameId");
boolean cacheable = BeanParamUtil.getBoolean(template, request, "cacheable", true);
boolean smallImage = BeanParamUtil.getBoolean(template, request, "smallImage");
DDMStructure structure = (DDMStructure)request.getAttribute(DDMWebKeys.DYNAMIC_DATA_MAPPING_STRUCTURE);
if ((structure == null) && (template != null)) {
structure = ddmDisplayContext.fetchStructure(template);
}
String type = BeanParamUtil.getString(template, request, "type", DDMTemplateConstants.TEMPLATE_TYPE_FORM);
String mode = BeanParamUtil.getString(template, request, "mode", DDMTemplateConstants.TEMPLATE_MODE_CREATE);
String language = BeanParamUtil.getString(template, request, "language", ddmDisplay.getDefaultTemplateLanguage());
String script = BeanParamUtil.getString(template, request, "script");
if (Validator.isNull(script) && type.equals(DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY)) {
TemplateHandler templateHandler = TemplateHandlerRegistryUtil.getTemplateHandler(classNameId);
if ((templateHandler == null) && (structure != null)) {
templateHandler = TemplateHandlerRegistryUtil.getTemplateHandler(structure.getClassNameId());
}
if (templateHandler != null) {
script = templateHandler.getTemplatesHelpContent(language);
}
else {
script = StringUtil.read(DDMWebConfigurationUtil.class.getClassLoader(), DDMWebConfigurationUtil.get(DDMWebConfigurationKeys.DYNAMIC_DATA_MAPPING_TEMPLATE_LANGUAGE_CONTENT, new Filter(language)));
}
}
DDMTemplateVersion templateVersion = null;
if (template != null) {
templateVersion = template.getLatestTemplateVersion();
}
String structureAvailableFields = ParamUtil.getString(request, "structureAvailableFields");
if (Validator.isNotNull(structureAvailableFields)) {
scopeAvailableFields = structureAvailableFields;
}
boolean showBackURL = ParamUtil.getBoolean(request, "showBackURL", true);
boolean showCacheableInput = ParamUtil.getBoolean(request, "showCacheableInput");
boolean showHeader = ParamUtil.getBoolean(request, "showHeader", true);
DDMNavigationHelper ddmNavigationHelper = ddmDisplay.getDDMNavigationHelper();
%>
<%
String[] imageExtensions = ddmDisplayContext.smallImageExtensions();
%>
<%= HtmlUtil.escape(StringUtil.merge(imageExtensions, StringPool.COMMA)) %>.
<%
long imageMaxSize = ddmDisplayContext.smallImageMaxSize();
%>
<%
String title = StringPool.BLANK;
if ((structure != null) || (template != null)) {
title = ddmDisplay.getEditTemplateTitle(structure, template, locale);
}
else {
title = ddmDisplay.getEditTemplateTitle(classNameId, locale);
}
%>
<%
portletDisplay.setShowBackIcon(true);
portletDisplay.setURLBack(PortalUtil.escapeRedirect(ddmDisplay.getEditTemplateBackURL(liferayPortletRequest, liferayPortletResponse, classNameId, classPK, resourceClassNameId, portletResource)));
renderResponse.setTitle(title);
%>
var toolbarChildren = [
{
icon: 'icon-time',
label: '<%= UnicodeLanguageUtil.get(request, "view-history") %>',
on: {
click: function(event) {
event.domEvent.preventDefault();
window.location.href = '<%= viewHistoryURL %>';
}
}
}
];
new A.Toolbar(
{
boundingBox: '# templateHistoryToolbar',
children: toolbarChildren
}
).render();
<%
for (String curLangType : ddmDisplay.getTemplateLanguageTypes()) {
StringBundler sb = new StringBundler(6);
sb.append(LanguageUtil.get(request, curLangType + "[stands-for]"));
sb.append(StringPool.SPACE);
sb.append(StringPool.OPEN_PARENTHESIS);
sb.append(StringPool.PERIOD);
sb.append(curLangType);
sb.append(StringPool.CLOSE_PARENTHESIS);
%>
<%
}
%>
" key="preview" />" class="lfr-ddm-small-image-preview" src="<%= HtmlUtil.escapeAttribute(template.getTemplateImageURL(themeDisplay)) %>" />
<%@ include file="/edit_template_form.jspf" %>
<%@ include file="/edit_template_display.jspf" %>
var container = A.one('# smallImageContainer');
var types = container.all('.lfr-ddm-small-image-type');
var values = container.all('.lfr-ddm-small-image-value');
var selectSmallImageType = function(index) {
types.attr('checked', false);
types.item(index).attr('checked', true);
values.attr('disabled', true);
values.item(index).attr('disabled', false);
};
container.delegate(
'change',
function(event) {
var index = types.indexOf(event.currentTarget);
selectSmallImageType(index);
},
'.lfr-ddm-small-image-type'
);
new A.Toggler(
{
animated: true,
content: '# smallImageContainer .lfr-ddm-small-image-content',
expanded: <%= smallImage %>,
header: '# smallImageContainer .lfr-ddm-small-image-header',
on: {
animatingChange: function(event) {
var instance = this;
var expanded = !instance.get('expanded');
A.one('# smallImage').attr('checked', expanded);
if (expanded) {
types.each(
function(item, index) {
if (item.get('checked')) {
values.item(index).attr('disabled', false);
}
}
);
}
else {
values.attr('disabled', true);
}
}
}
}
);
selectSmallImageType('<%= ((template != null) && Validator.isNotNull(template.getSmallImageURL())) ? 0 : 1 %>');
function openDDMStructureSelector() {
Liferay.Util.openDDMPortlet(
{
basePortletURL: '<%= PortletURLFactoryUtil.create(request, DDMPortletKeys.DYNAMIC_DATA_MAPPING, PortletRequest.RENDER_PHASE) %>',
classNameId: '<%= PortalUtil.getClassNameId(DDMStructure.class) %>',
classPK: 0,
eventName: ' selectStructure',
groupId: <%= groupId %>,
mvcPath: '/select_structure.jsp',
navigationStartsOn: '<%= DDMNavigationHelper.SELECT_STRUCTURE %>',
showAncestorScopes: true,
title: '<%= UnicodeLanguageUtil.get(request, "structures") %>'
},
function(event) {
if (document. fm. classPK.value != event.ddmstructureid) {
document. fm. classPK.value = event.ddmstructureid;
Liferay.fire(' refreshEditor');
}
}
);
}
Liferay.after(
' saveTemplate',
function() {
submitForm(document. fm);
}
);
function saveDraftTemplate() {
var form = AUI.$('# fm');
form.fm('status').val(<%= String.valueOf(WorkflowConstants.STATUS_DRAFT) %>);
Liferay.fire('<%= renderResponse.getNamespace() + "saveTemplate" %>');
}
function saveAndContinueTemplate() {
document. fm. saveAndContinue.value = '1';
Liferay.fire(' saveTemplate');
}
<%
String taglibOnClick = "Liferay.fire('" + liferayPortletResponse.getNamespace() + "saveTemplate');";
%>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy