001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.xml.containerpage; 029 030import org.opencms.ade.configuration.formatters.CmsSettingConfiguration; 031import org.opencms.ade.configuration.plugins.CmsTemplatePlugin; 032import org.opencms.file.types.CmsResourceTypeFunctionConfig; 033import org.opencms.util.CmsUUID; 034 035import java.util.Arrays; 036import java.util.Collection; 037import java.util.Collections; 038import java.util.HashMap; 039import java.util.List; 040import java.util.Map; 041import java.util.Set; 042 043/** 044 * A bean containing formatter configuration data as strings.<p> 045 */ 046public class CmsFunctionFormatterBean extends CmsFormatterBean { 047 048 /** The standard function formatter structure id. */ 049 private CmsUUID m_functionFormatterId; 050 051 /** The request parameters to add for the included JSP. */ 052 private Map<String, String[]> m_parameters = new HashMap<>(); 053 054 /** The real path of the configured jsp. */ 055 private String m_realJspRootPath; 056 057 /** 058 * Constructor for creating a new formatter configuration with resource structure id.<p> 059 * 060 * @param containerTypes the formatter container types 061 * @param jspRootPath the formatter JSP VFS root path 062 * @param jspStructureId the structure id of the formatter JSP 063 * @param key the key 064 * @param aliasKeys the alias keys 065 * @param functionFormatterId the standard function formatter structure id 066 * @param minWidth the formatter min width 067 * @param maxWidth the formatter max width 068 * @param location the location where this formatter was defined, should be an OpenCms VFS resource path 069 * @param cssHeadIncludes the CSS head includes 070 * @param inlineCss the in-line CSS 071 * @param javascriptHeadIncludes the JavaScript headincludes 072 * @param inlineJavascript the in-line JavaScript 073 * @param plugins the template plugins 074 * @param niceName the configuration display name 075 * @param description the description text for the formatter 076 * @param id the configuration id 077 * @param settingConfig the settings configuration 078 * @param isAllowsSettingsInEditor whether this formatter allows settings to be edited in the content editor 079 * @param isStrictContainers <code>true</code> if this formatter will always render all nested containers 080 * @param parameters the request parameters to add for the included JSP 081 */ 082 public CmsFunctionFormatterBean( 083 Set<String> containerTypes, 084 String jspRootPath, 085 CmsUUID jspStructureId, 086 String key, 087 Set<String> aliasKeys, 088 CmsUUID functionFormatterId, 089 int minWidth, 090 int maxWidth, 091 String location, 092 List<String> cssHeadIncludes, 093 String inlineCss, 094 List<String> javascriptHeadIncludes, 095 String inlineJavascript, 096 List<CmsTemplatePlugin> plugins, 097 String niceName, 098 String description, 099 String id, 100 CmsSettingConfiguration settingConfig, 101 boolean isAllowsSettingsInEditor, 102 boolean isStrictContainers, 103 Map<String, String[]> parameters) { 104 105 super( 106 containerTypes, 107 jspRootPath, 108 jspStructureId, 109 key, 110 aliasKeys, 111 minWidth, 112 maxWidth, 113 true, // preview 114 false, // searchContent 115 location, 116 cssHeadIncludes, 117 inlineCss, 118 javascriptHeadIncludes, 119 inlineJavascript, 120 plugins, 121 niceName, 122 description, 123 Arrays.asList(CmsResourceTypeFunctionConfig.TYPE_NAME), 124 10099, // rank 125 id, 126 settingConfig, 127 true, //isFromConfigFile 128 true, // isAutoEnabled 129 false, // detailType 130 null, // isDisplay 131 isAllowsSettingsInEditor, 132 isStrictContainers, 133 false, // nestedFormatterSettings 134 Collections.<CmsMetaMapping> emptyList(), 135 Collections.emptyMap(), 136 false, 137 null); // contentExtractionPolicy 138 m_realJspRootPath = jspRootPath; 139 m_functionFormatterId = functionFormatterId; 140 if (parameters != null) { 141 m_parameters.putAll(parameters); 142 } 143 } 144 145 /** 146 * @see org.opencms.xml.containerpage.CmsFormatterBean#getJspRootPath() 147 * 148 * This is not the configured JSP, but the formatter JSP for the function_config type itself. 149 */ 150 @Override 151 public String getJspRootPath() { 152 153 return CmsResourceTypeFunctionConfig.FORMATTER_PATH; 154 } 155 156 /** 157 * @see org.opencms.xml.containerpage.CmsFormatterBean#getJspStructureId() 158 * 159 * This is not the configured JSP, but the formatter JSP for the function_config type itself. 160 */ 161 @Override 162 public CmsUUID getJspStructureId() { 163 164 return m_functionFormatterId; 165 } 166 167 /** 168 * Gets the parameters the dynamic function should set for the included JSP.<p> 169 * 170 * @return the map of parameters to add for the included JSP 171 */ 172 public Map<String, String[]> getParameters() { 173 174 return Collections.unmodifiableMap(m_parameters); 175 } 176 177 /** 178 * @see org.opencms.xml.containerpage.I_CmsFormatterBean#getRank() 179 */ 180 @Override 181 public int getRank() { 182 183 return 1000; 184 } 185 186 /** 187 * Gets the <em>actual</em> JSP id of the function.<p> 188 * 189 * @return the JSP structure id 190 */ 191 public CmsUUID getRealJspId() { 192 193 return super.getJspStructureId(); 194 } 195 196 /** 197 * Gets the root path of the configured JSP.<p> 198 * 199 * @return the root path of the configured JSP 200 */ 201 public String getRealJspRootPath() { 202 203 return m_realJspRootPath; 204 } 205 206 /** 207 * @see org.opencms.xml.containerpage.I_CmsFormatterBean#getResourceTypeNames() 208 */ 209 @Override 210 public Collection<String> getResourceTypeNames() { 211 212 return Collections.singletonList(CmsResourceTypeFunctionConfig.TYPE_NAME); 213 } 214 215}