public class CmsTemplateContextManager extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTR_RPC_CONTEXT_OVERRIDE
Request attribute used to set the template context during RPC calls.
|
static java.lang.String |
ATTR_TEMPLATE_BEAN
A bean containing information about the selected template.
|
static java.lang.String |
ATTR_TEMPLATE_CONTEXT
The request attribute in which the template context is stored.
|
static java.lang.String |
ATTR_TEMPLATE_NAME
Attribute name which contains the template name for non-dynamically selected templates.
|
static java.lang.String |
ATTR_TEMPLATE_RESOURCE
Attribute name for the template resource.
|
static java.lang.String |
DYNAMIC_TEMPLATE_PREFIX
The prefix used in the template property to activate dynamic template selection.
|
Constructor and Description |
---|
CmsTemplateContextManager(CmsObject cms)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected CmsXmlContentProperty |
createTemplateContextsPropertyDefinition(I_CmsTemplateContextProvider contextProvider,
java.util.Locale locale)
Creates the setting definition for the templateContexts setting.
|
CmsTemplateContextInfo |
getContextInfoBean(CmsObject cms,
javax.servlet.http.HttpServletRequest request)
Creates a bean with information about the current template context, for use in the client-side code.
|
CmsTemplateContext |
getTemplateContext(java.lang.String providerName,
CmsObject cms,
javax.servlet.http.HttpServletRequest request,
CmsResource resource)
Gets the template context to use.
|
I_CmsTemplateContextProvider |
getTemplateContextProvider(CmsObject cms,
java.lang.String path)
Gets the template context provider for a given path.
|
I_CmsTemplateContextProvider |
getTemplateContextProvider(java.lang.String providerName)
Retrieves an instance of a template context provider given its name (optionally prefixed by the 'dynamic:' prefix).
|
static boolean |
hasPropertyPrefix(java.lang.String propertyValue)
Checks if the property value starts with the prefix which marks a dynamic template provider.
|
static boolean |
isProvider(java.lang.String templatePath)
Checks if a template property value refers to a template context provider.
|
java.lang.String |
readPropertyFromTemplate(CmsObject cms,
CmsResource res,
java.lang.String propertyName,
java.lang.String fallbackValue)
Utility method which either reads a property from the template used for a specific resource, or from the template context provider used for the resource if available.
|
static java.lang.String |
removePropertyPrefix(java.lang.String propertyValue)
Removes the prefix which marks a property value as a dynamic template provider.
|
protected java.util.Map<java.lang.String,CmsDefaultSet<java.lang.String>> |
safeGetAllowedContextMap()
Helper method for getting the forbidden contexts from the resource manager without a try-catch block.
|
boolean |
shouldShowType(java.lang.String contextKey,
java.lang.String typeName)
Helper method to check whether a given type should not be shown in a context.
|
public static final java.lang.String ATTR_TEMPLATE_BEAN
public static final java.lang.String ATTR_TEMPLATE_CONTEXT
public static final java.lang.String ATTR_TEMPLATE_NAME
public static final java.lang.String ATTR_TEMPLATE_RESOURCE
public static final java.lang.String DYNAMIC_TEMPLATE_PREFIX
public static final java.lang.String ATTR_RPC_CONTEXT_OVERRIDE
public CmsTemplateContextManager(CmsObject cms)
cms
- the CMS context to usepublic static boolean hasPropertyPrefix(java.lang.String propertyValue)
propertyValue
- the property value to checkpublic static boolean isProvider(java.lang.String templatePath)
templatePath
- the template property valuepublic static java.lang.String removePropertyPrefix(java.lang.String propertyValue)
propertyValue
- the value from which to remove the prefixpublic CmsTemplateContextInfo getContextInfoBean(CmsObject cms, javax.servlet.http.HttpServletRequest request)
cms
- the current CMS contextrequest
- the current requestpublic CmsTemplateContext getTemplateContext(java.lang.String providerName, CmsObject cms, javax.servlet.http.HttpServletRequest request, CmsResource resource)
providerName
- the name of the template context providercms
- the current CMS contextrequest
- the current requestresource
- the current resourcepublic I_CmsTemplateContextProvider getTemplateContextProvider(CmsObject cms, java.lang.String path) throws CmsException
cms
- the current CMS contextpath
- the path for which the template context provider should be determinedCmsException
- if something goes wrongpublic I_CmsTemplateContextProvider getTemplateContextProvider(java.lang.String providerName)
providerName
- the name of the providerpublic java.lang.String readPropertyFromTemplate(CmsObject cms, CmsResource res, java.lang.String propertyName, java.lang.String fallbackValue)
cms
- the CMS context to useres
- the resource from whose template or template context provider the property should be readpropertyName
- the property namefallbackValue
- the fallback valuepublic boolean shouldShowType(java.lang.String contextKey, java.lang.String typeName)
contextKey
- the key of the template contexttypeName
- the type nameprotected CmsXmlContentProperty createTemplateContextsPropertyDefinition(I_CmsTemplateContextProvider contextProvider, java.util.Locale locale)
contextProvider
- the context providerlocale
- the current localeprotected java.util.Map<java.lang.String,CmsDefaultSet<java.lang.String>> safeGetAllowedContextMap()