Package org.opencms.ade.containerpage
Class CmsElementUtil
- java.lang.Object
-
- org.opencms.ade.containerpage.CmsElementUtil
-
public class CmsElementUtil extends java.lang.Object
Utility class to generate the element data objects used within the container-page editor.- Since:
- 8.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_NESTING_LEVEL
The maximum number of nested container levels.
-
Constructor Summary
Constructors Constructor Description CmsElementUtil(CmsObject cms, java.lang.String currentPageUri, CmsUUID detailContentId, java.lang.String requestParameters, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
Creates a new instance.CmsElementUtil(CmsObject cms, java.lang.String currentPageUri, CmsUUID detailContentId, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale)
Creates a new instance.CmsElementUtil(CmsObject cms, java.lang.String currentPageUri, CmsContainerPageBean containerPage, CmsUUID detailContentId, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean isDragMode, java.util.Locale locale)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
checkGroupAllowed(java.lang.String containerType, CmsGroupContainerBean groupContainer)
Checks if a group element is allowed in a container with a given type.static CmsContainerBean
clientToServerContainer(CmsContainer container, java.util.List<CmsContainerElementBean> elements)
static java.util.function.Function<java.lang.String,java.lang.String>
createStringTemplateSource(I_CmsFormatterBean formatter, com.google.common.base.Supplier<CmsXmlContent> contentSupplier)
Helper method to create a string template source for a given formatter and content.java.lang.String
getContentByContainer(CmsFile elementFile, java.lang.String elementId, CmsContainer container)
Returns the HTML content for the given resource and container.CmsContainerElementData
getElementData(CmsResource page, CmsContainerElementBean element, java.util.Collection<CmsContainer> containers)
Returns the data for an element.CmsElementSettingsConfig
getElementSettingsConfig(CmsResource page, CmsContainerElementBean element, java.lang.String containerId, java.util.Collection<CmsContainer> containers)
Returns the formatter and settings config data for an element.static I_CmsFormatterBean
getFormatterForContainer(CmsObject cms, CmsContainerElementBean element, CmsContainer container, CmsADEConfigData config, CmsADESessionCache cache)
Returns the formatter bean for the given element and container.CmsResource
getPage()
Gets the container page.static boolean
isSystemSetting(java.lang.String name)
Checks if the given setting name is a system setting.CmsContainerElement
setElementInfo(CmsContainerElementBean elementBean, CmsContainerElement result)
Sets the data to the given container element.
-
-
-
Field Detail
-
MAX_NESTING_LEVEL
public static final int MAX_NESTING_LEVEL
The maximum number of nested container levels.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsElementUtil
public CmsElementUtil(CmsObject cms, java.lang.String currentPageUri, CmsContainerPageBean containerPage, CmsUUID detailContentId, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, boolean isDragMode, java.util.Locale locale) throws CmsException
Creates a new instance.Use this constructor to set the current container page state.
- Parameters:
cms
- the cms contextcurrentPageUri
- the current page uricontainerPage
- the container page bean with the current container statedetailContentId
- the detail content structure idreq
- the http requestres
- the http responseisDragMode
- if the page is in drag modelocale
- the content locale- Throws:
CmsException
- if something goes wrong
-
CmsElementUtil
public CmsElementUtil(CmsObject cms, java.lang.String currentPageUri, CmsUUID detailContentId, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale) throws CmsException
Creates a new instance.- Parameters:
cms
- the cms contextcurrentPageUri
- the current page uridetailContentId
- the detail content structure idreq
- the http requestres
- the http responselocale
- the content locale- Throws:
CmsException
- if something goes wrong
-
CmsElementUtil
public CmsElementUtil(CmsObject cms, java.lang.String currentPageUri, CmsUUID detailContentId, java.lang.String requestParameters, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Locale locale) throws CmsException
Creates a new instance.- Parameters:
cms
- the cms contextcurrentPageUri
- the current page uridetailContentId
- the detail content structure idrequestParameters
- the request parameters to use while rendering the elementsreq
- the http requestres
- the http responselocale
- the content locale- Throws:
CmsException
- if something goes wrong
-
-
Method Detail
-
checkGroupAllowed
public static boolean checkGroupAllowed(java.lang.String containerType, CmsGroupContainerBean groupContainer)
Checks if a group element is allowed in a container with a given type.- Parameters:
containerType
- the container type spec (comma separated)groupContainer
- the group- Returns:
- true if the group is allowed in the container
-
clientToServerContainer
public static CmsContainerBean clientToServerContainer(CmsContainer container, java.util.List<CmsContainerElementBean> elements)
-
createStringTemplateSource
public static java.util.function.Function<java.lang.String,java.lang.String> createStringTemplateSource(I_CmsFormatterBean formatter, com.google.common.base.Supplier<CmsXmlContent> contentSupplier)
Helper method to create a string template source for a given formatter and content.- Parameters:
formatter
- the formattercontentSupplier
- the content supplier- Returns:
- the string template provider
-
getFormatterForContainer
public static I_CmsFormatterBean getFormatterForContainer(CmsObject cms, CmsContainerElementBean element, CmsContainer container, CmsADEConfigData config, CmsADESessionCache cache)
Returns the formatter bean for the given element and container.- Parameters:
cms
- the cms contextelement
- the element to rendercontainer
- the containerconfig
- the configuration datacache
- the session cache- Returns:
- the formatter bean
-
isSystemSetting
public static final boolean isSystemSetting(java.lang.String name)
Checks if the given setting name is a system setting.- Parameters:
name
- the setting name- Returns:
- true if the name corresponds to a system setting
-
getContentByContainer
public java.lang.String getContentByContainer(CmsFile elementFile, java.lang.String elementId, CmsContainer container)
Returns the HTML content for the given resource and container.- Parameters:
elementFile
- the element resource fileelementId
- the element idcontainer
- the container- Returns:
- the HTML content
-
getElementData
public CmsContainerElementData getElementData(CmsResource page, CmsContainerElementBean element, java.util.Collection<CmsContainer> containers) throws CmsException
Returns the data for an element.- Parameters:
page
- the current container pageelement
- the resourcecontainers
- the containers on the current container page- Returns:
- the data for an element
- Throws:
CmsException
- if something goes wrong
-
getElementSettingsConfig
public CmsElementSettingsConfig getElementSettingsConfig(CmsResource page, CmsContainerElementBean element, java.lang.String containerId, java.util.Collection<CmsContainer> containers) throws CmsException
Returns the formatter and settings config data for an element.- Parameters:
page
- the current container pageelement
- the resourcecontainerId
- the parent container idcontainers
- the containers on the current container page- Returns:
- the data for an element
- Throws:
CmsException
- if something goes wrong
-
getPage
public CmsResource getPage()
Gets the container page.- Returns:
- the container page resource
-
setElementInfo
public CmsContainerElement setElementInfo(CmsContainerElementBean elementBean, CmsContainerElement result) throws CmsException
Sets the data to the given container element.- Parameters:
elementBean
- the element beanresult
- the container element to set the data to- Returns:
- the container element
- Throws:
CmsException
- if something goes wrong
-
-