Class CmsTemplateContextManager

    • Method Detail

      • hasPropertyPrefix

        public static boolean hasPropertyPrefix​(java.lang.String propertyValue)
        Checks if the property value starts with the prefix which marks a dynamic template provider.

        propertyValue - the property value to check
        true if the value has the format of a dynamic template provider
      • isProvider

        public static boolean isProvider​(java.lang.String templatePath)
        Checks if a template property value refers to a template context provider.

        templatePath - the template property value
        true if this value refers to a template context provider
      • removePropertyPrefix

        public static java.lang.String removePropertyPrefix​(java.lang.String propertyValue)
        Removes the prefix which marks a property value as a dynamic template provider.

        propertyValue - the value from which to remove the prefix
        the string with the prefix removed
      • getContextInfoBean

        public 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.

        cms - the current CMS context
        request - the current request
        the bean with the template context information
      • getProviderKey

        public java.lang.String getProviderKey​(I_CmsTemplateContextProvider provider)
        Gets the key of a cached template provider (consisting of class name and parameters) that can later be used as an argument to getTemplateContextProvider.

        If the provider is not already cached, returns null.

        provider - the template provider
        the cache key
      • getTemplateContext

        public CmsTemplateContext getTemplateContext​(java.lang.String providerName,
                                                     CmsObject cms,
                                                     javax.servlet.http.HttpServletRequest request,
                                                     CmsResource resource)
        Gets the template context to use.

        providerName - the name of the template context provider
        cms - the current CMS context
        request - the current request
        resource - the current resource
        the current template context
      • getTemplateContextProvider

        public I_CmsTemplateContextProvider getTemplateContextProvider​(java.lang.String providerName)
        Retrieves an instance of a template context provider given its name (optionally prefixed by the 'dynamic:' prefix).

        providerName - the name of the provider
        an instance of the provider class
      • readPropertyFromTemplate

        public 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.

        cms - the CMS context to use
        res - the resource from whose template or template context provider the property should be read
        propertyName - the property name
        fallbackValue - the fallback value
        the property value
      • shouldShowType

        public 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.

        contextKey - the key of the template context
        typeName - the type name
        true if the context does not prohibit showing the type
      • safeGetAllowedContextMap

        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.

        the forbidden context map