Package org.opencms.search.galleries
Class CmsGalleryNameMacroResolver
java.lang.Object
org.opencms.util.CmsMacroResolver
org.opencms.search.galleries.CmsGalleryNameMacroResolver
- All Implemented Interfaces:
I_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
Modifier and TypeFieldDescriptionstatic final String
Macro prefix.static final Pattern
Pattern used to match the no_prefix macro.static final String
Macro name.static final String
Macro name.static final String
Macro name.static final String
Macro name.static final String
Prefix for the isDetailPage? macro.static final String
Prefix for the stringtemplate macro.static final String
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
ConstructorDescriptionCmsGalleryNameMacroResolver
(CmsObject cms, A_CmsXmlDocument content, Locale locale) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 String
getContainerPageProperty
(String propName) Gets the given property of the container page referencing this content.getMacroValue
(String macro) Resolves a single macro to the macro value, returnsnull
if the macro could not be resolved.resolveMacros
(String input) Resolves the macros in the given input.void
setStringTemplateSource
(Function<String, 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 Details
-
NO_PREFIX
Macro prefix.- See Also:
-
NO_PREFIX_PATTERN
Pattern used to match the no_prefix macro. -
PAGE_NAV
Macro name.- See Also:
-
PAGE_ROOTPATH
Macro name.- See Also:
-
PAGE_SITEPATH
Macro name.- See Also:
-
PAGE_TITLE
Macro name.- See Also:
-
PREFIX_ISDETAILPAGE
Prefix for the isDetailPage? macro.- See Also:
-
PREFIX_STRINGTEMPLATE
Prefix for the stringtemplate macro.- See Also:
-
PREFIX_VALUE
Macro prefix.- See Also:
-
-
Constructor Details
-
CmsGalleryNameMacroResolver
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 Details
-
getMacroValue
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:
-
resolveMacros
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:
-
setStringTemplateSource
-
getContainerPagePath
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
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
-