Package org.opencms.search.galleries
Class CmsGalleryNameMacroResolver
- java.lang.Object
-
- org.opencms.util.CmsMacroResolver
-
- org.opencms.search.galleries.CmsGalleryNameMacroResolver
-
- All Implemented Interfaces:
I_CmsMacroResolver
public class CmsGalleryNameMacroResolver extends CmsMacroResolver
Macro resolver used to resolve macros for the gallery name mapping.This supports the following special macros:
- %(no_prefix:some more text): This will expand to "some more text" if, after expanding all other macros in the input string, there is at least one character before the occurence of this macro, and to an empty string otherwise.
- %(value:/Some/XPath): This will expand to the value under the given XPath in the XML content and locale with which the macro resolver was initialized. If no value is found under the XPath, the macro will expand to an empty string.
- %(page_nav): This will expand to the NavText property of the container page in which this element is referenced. If this element is referenced from multiple container pages with the same locale, this macro is expanded to an empty string.
- %(page_title): Same as %(page_nav), but uses the Title property instead of NavText.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NO_PREFIX
Macro prefix.static java.util.regex.Pattern
NO_PREFIX_PATTERN
Pattern used to match the no_prefix macro.static java.lang.String
PAGE_NAV
Macro name.static java.lang.String
PAGE_ROOTPATH
Macro name.static java.lang.String
PAGE_SITEPATH
Macro name.static java.lang.String
PAGE_TITLE
Macro name.static java.lang.String
PREFIX_ISDETAILPAGE
Prefix for the isDetailPage? macro.static java.lang.String
PREFIX_STRINGTEMPLATE
Prefix for the stringtemplate macro.static java.lang.String
PREFIX_VALUE
Macro prefix.-
Fields inherited from class org.opencms.util.CmsMacroResolver
KEY_ATTRIBUTE, KEY_CONTEXT_PATH, KEY_CURRENT_ORGUNIT_DESCRIPTION, KEY_CURRENT_ORGUNIT_FQN, KEY_CURRENT_TIME, KEY_CURRENT_USER_CITY, KEY_CURRENT_USER_COUNTRY, KEY_CURRENT_USER_DISPLAYNAME, KEY_CURRENT_USER_EMAIL, KEY_CURRENT_USER_FIRSTNAME, KEY_CURRENT_USER_FULLNAME, KEY_CURRENT_USER_INSTITUTION, KEY_CURRENT_USER_LASTLOGIN, KEY_CURRENT_USER_LASTNAME, KEY_CURRENT_USER_NAME, KEY_CURRENT_USER_STREET, KEY_CURRENT_USER_ZIP, KEY_LOCALIZED_PREFIX, KEY_OPENCMS, KEY_PAGE_CONTEXT, KEY_PARAM, KEY_PROJECT_ID, KEY_PROPERTY, KEY_PROPERTY_ELEMENT, KEY_RANDOM_ID, KEY_REQUEST_ENCODING, KEY_REQUEST_FOLDER, KEY_REQUEST_LOCALE, KEY_REQUEST_PARAM, KEY_REQUEST_SITEROOT, KEY_REQUEST_URI, KEY_SITEMAP_ATTRIBUTE, KEY_VALIDATION_PATH, KEY_VALIDATION_REGEX, KEY_VALIDATION_VALUE, m_additionalMacros, m_cms, m_jspPageContext, m_keepEmptyMacros, m_messages, m_parameterMap, m_resourceName, VALUE_NAMES
-
Fields inherited from interface org.opencms.util.I_CmsMacroResolver
MACRO_DELIMITER, MACRO_DELIMITER_OLD, MACRO_END, MACRO_END_OLD, MACRO_START, MACRO_START_OLD
-
-
Constructor Summary
Constructors Constructor Description CmsGalleryNameMacroResolver(CmsObject cms, A_CmsXmlDocument content, java.util.Locale locale)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
getContainerPagePath(boolean isSitePath)
Returns the site path of the page the resource is on, iff it is on exactly one page per locale.protected java.lang.String
getContainerPageProperty(java.lang.String propName)
Gets the given property of the container page referencing this content.java.lang.String
getMacroValue(java.lang.String macro)
Resolves a single macro to the macro value, returnsnull
if the macro could not be resolved.java.lang.String
resolveMacros(java.lang.String input)
Resolves the macros in the given input.void
setStringTemplateSource(java.util.function.Function<java.lang.String,java.lang.String> stringtemplateSource)
-
Methods inherited from class org.opencms.util.CmsMacroResolver
addDynamicMacro, addMacro, copyAndResolveMacro, copyAndResolveMacro, copyAndResolveMacro, formatMacro, getBundleMapFromResources, isKeepEmptyMacros, isMacro, isMacro, localizedKeyMacro, newInstance, newWorkplaceLocaleResolver, resolveMacros, resolveMacros, setAdditionalMacros, setCmsObject, setJspPageContext, setKeepEmptyMacros, setMessages, setParameterMap, setResourceName, stripMacro, toFunction
-
-
-
-
Field Detail
-
NO_PREFIX
public static final java.lang.String NO_PREFIX
Macro prefix.- See Also:
- Constant Field Values
-
NO_PREFIX_PATTERN
public static final java.util.regex.Pattern NO_PREFIX_PATTERN
Pattern used to match the no_prefix macro.
-
PAGE_NAV
public static final java.lang.String PAGE_NAV
Macro name.- See Also:
- Constant Field Values
-
PAGE_ROOTPATH
public static final java.lang.String PAGE_ROOTPATH
Macro name.- See Also:
- Constant Field Values
-
PAGE_SITEPATH
public static final java.lang.String PAGE_SITEPATH
Macro name.- See Also:
- Constant Field Values
-
PAGE_TITLE
public static final java.lang.String PAGE_TITLE
Macro name.- See Also:
- Constant Field Values
-
PREFIX_ISDETAILPAGE
public static final java.lang.String PREFIX_ISDETAILPAGE
Prefix for the isDetailPage? macro.- See Also:
- Constant Field Values
-
PREFIX_STRINGTEMPLATE
public static final java.lang.String PREFIX_STRINGTEMPLATE
Prefix for the stringtemplate macro.- See Also:
- Constant Field Values
-
PREFIX_VALUE
public static final java.lang.String PREFIX_VALUE
Macro prefix.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsGalleryNameMacroResolver
public CmsGalleryNameMacroResolver(CmsObject cms, A_CmsXmlDocument content, java.util.Locale locale)
Creates a new instance.- Parameters:
cms
- the CMS context to use for VFS operationscontent
- the content to use for macro value lookuplocale
- the locale to use for macro value lookup
-
-
Method Detail
-
getMacroValue
public java.lang.String getMacroValue(java.lang.String macro)
Description copied from interface:I_CmsMacroResolver
Resolves a single macro to the macro value, returnsnull
if the macro could not be resolved.- Specified by:
getMacroValue
in interfaceI_CmsMacroResolver
- Overrides:
getMacroValue
in classCmsMacroResolver
- Parameters:
macro
- the macro to resolve- Returns:
- the resolved macro or
null
if the macro could not be resolved - See Also:
CmsMacroResolver.getMacroValue(java.lang.String)
-
resolveMacros
public java.lang.String resolveMacros(java.lang.String input)
Description copied from class:CmsMacroResolver
Resolves the macros in the given input.Calls
until no more macros can be resolved in the input. This way "nested" macros in the input are resolved as well.CmsMacroResolver.resolveMacros(String)
- Specified by:
resolveMacros
in interfaceI_CmsMacroResolver
- Overrides:
resolveMacros
in classCmsMacroResolver
- Parameters:
input
- the input to resolve the macros in- Returns:
- the input with all macros resolved
- See Also:
CmsMacroResolver.resolveMacros(java.lang.String)
-
setStringTemplateSource
public void setStringTemplateSource(java.util.function.Function<java.lang.String,java.lang.String> stringtemplateSource)
-
getContainerPagePath
protected java.lang.String getContainerPagePath(boolean isSitePath)
Returns the site path of the page the resource is on, iff it is on exactly one page per locale.- Returns:
- the site path of the page the resource is on, iff it is on exactly one page per locale.
-
getContainerPageProperty
protected java.lang.String getContainerPageProperty(java.lang.String propName)
Gets the given property of the container page referencing this content.If more than one container page with the same locale reference this content, the empty string will be returned.
- Parameters:
propName
- the property name to look up- Returns:
- the value of the named property on the container page, or an empty string
-
-