001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://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: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://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.file.types.CmsResourceTypeFunctionConfig; 031import org.opencms.util.CmsUUID; 032import org.opencms.xml.content.CmsXmlContentProperty; 033 034import java.util.Arrays; 035import java.util.Collection; 036import java.util.Collections; 037import java.util.HashMap; 038import java.util.List; 039import java.util.Map; 040import java.util.Set; 041 042/** 043 * A bean containing formatter configuration data as strings.<p> 044 */ 045public class CmsFunctionFormatterBean extends CmsFormatterBean { 046 047 /** The standard function formatter structure id. */ 048 private CmsUUID m_functionFormatterId; 049 050 /** The request parameters to add for the included JSP. */ 051 private Map<String, String[]> m_parameters = new HashMap<>(); 052 053 /** The real path of the configured jsp. */ 054 private String m_realJspRootPath; 055 056 /** 057 * Constructor for creating a new formatter configuration with resource structure id.<p> 058 * 059 * @param containerTypes the formatter container types 060 * @param jspRootPath the formatter JSP VFS root path 061 * @param jspStructureId the structure id of the formatter JSP 062 * @param functionFormatterId the standard function formatter structure id 063 * @param minWidth the formatter min width 064 * @param maxWidth the formatter max width 065 * @param location the location where this formatter was defined, should be an OpenCms VFS resource path 066 * @param cssHeadIncludes the CSS head includes 067 * @param inlineCss the in-line CSS 068 * @param javascriptHeadIncludes the JavaScript headincludes 069 * @param inlineJavascript the in-line JavaScript 070 * @param niceName the configuration display name 071 * @param description the description text for the formatter 072 * @param id the configuration id 073 * @param settings the settings configuration 074 * @param isAllowsSettingsInEditor whether this formatter allows settings to be edited in the content editor 075 * @param isStrictContainers <code>true</code> if this formatter will always render all nested containers 076 * @param parameters the request parameters to add for the included JSP 077 */ 078 public CmsFunctionFormatterBean( 079 Set<String> containerTypes, 080 String jspRootPath, 081 CmsUUID jspStructureId, 082 CmsUUID functionFormatterId, 083 int minWidth, 084 int maxWidth, 085 String location, 086 List<String> cssHeadIncludes, 087 String inlineCss, 088 List<String> javascriptHeadIncludes, 089 String inlineJavascript, 090 String niceName, 091 String description, 092 String id, 093 Map<String, CmsXmlContentProperty> settings, 094 boolean isAllowsSettingsInEditor, 095 boolean isStrictContainers, 096 Map<String, String[]> parameters) { 097 098 super( 099 containerTypes, 100 jspRootPath, 101 jspStructureId, 102 minWidth, 103 maxWidth, 104 true, // preview 105 false, // searchContent 106 location, 107 cssHeadIncludes, 108 inlineCss, 109 javascriptHeadIncludes, 110 inlineJavascript, 111 niceName, 112 description, 113 Arrays.asList(CmsResourceTypeFunctionConfig.TYPE_NAME), 114 10099, // rank 115 id, 116 settings, 117 true, //isFromConfigFile 118 true, // isAutoEnabled 119 false, // detailType 120 null, // isDisplay 121 isAllowsSettingsInEditor, 122 isStrictContainers, 123 false, // nestedFormatterSettings 124 Collections.<CmsMetaMapping> emptyList(), 125 Collections.emptyMap(), 126 false); 127 m_realJspRootPath = jspRootPath; 128 m_functionFormatterId = functionFormatterId; 129 if (parameters != null) { 130 m_parameters.putAll(parameters); 131 } 132 } 133 134 /** 135 * @see org.opencms.xml.containerpage.CmsFormatterBean#getJspRootPath() 136 * 137 * This is not the configured JSP, but the formatter JSP for the function_config type itself. 138 */ 139 @Override 140 public String getJspRootPath() { 141 142 return CmsResourceTypeFunctionConfig.FORMATTER_PATH; 143 } 144 145 /** 146 * @see org.opencms.xml.containerpage.CmsFormatterBean#getJspStructureId() 147 * 148 * This is not the configured JSP, but the formatter JSP for the function_config type itself. 149 */ 150 @Override 151 public CmsUUID getJspStructureId() { 152 153 return m_functionFormatterId; 154 } 155 156 /** 157 * Gets the parameters the dynamic function should set for the included JSP.<p> 158 * 159 * @return the map of parameters to add for the included JSP 160 */ 161 public Map<String, String[]> getParameters() { 162 163 return Collections.unmodifiableMap(m_parameters); 164 } 165 166 /** 167 * @see org.opencms.xml.containerpage.I_CmsFormatterBean#getRank() 168 */ 169 @Override 170 public int getRank() { 171 172 return 1000; 173 } 174 175 /** 176 * Gets the <em>actual</em> JSP id of the function.<p> 177 * 178 * @return the JSP structure id 179 */ 180 public CmsUUID getRealJspId() { 181 182 return super.getJspStructureId(); 183 } 184 185 /** 186 * Gets the root path of the configured JSP.<p> 187 * 188 * @return the root path of the configured JSP 189 */ 190 public String getRealJspRootPath() { 191 192 return m_realJspRootPath; 193 } 194 195 /** 196 * @see org.opencms.xml.containerpage.I_CmsFormatterBean#getResourceTypeNames() 197 */ 198 @Override 199 public Collection<String> getResourceTypeNames() { 200 201 return Collections.singletonList(CmsResourceTypeFunctionConfig.TYPE_NAME); 202 } 203 204}