Class AmetysXSLTHelper
java.lang.Object
org.ametys.core.util.AmetysXSLTHelper
org.ametys.cms.transformation.xslt.AmetysXSLTHelper
- All Implemented Interfaces:
Contextualizable
,LogEnabled
,Serviceable
- Direct Known Subclasses:
AmetysXSLTHelper
Helper component to be used from XSL stylesheets.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static AmetysObjectResolver
The Ametys object resolverprotected static ContentHelper
Helper for contentprotected static Context
The avalon contextprotected static ContentTypeExtensionPoint
The content types extension pointprotected static Logger
The loggerprotected static RichTextHelper
The sax parserprotected static TagProviderExtensionPoint
The tags providerFields inherited from class org.ametys.core.util.AmetysXSLTHelper
_currentUserProvider, _groupManager, _i18nUtils, _jsonUtils, _LOGGER, _rightManager, _sourceResolver, _userHelper, _userManager, _versionHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static NodeList
_contentTags
(Content content) Returns all tags of the given content_getNodeValues
(ModelAwareDataHolder dataHolder, String dataPath, String lang) Get values of an attribute of a model aware data holder at the given path_getNodeValues
(ModelAwareDataHolder dataHolder, String dataPath, String lang, DataContext dataContext) Get values of an attribute of a model aware data holder at the given pathstatic Node
static Node
contentAttachments
(String contentId) static NodeList
contentAttribute
(String contentId, String dataPath) Get the attribute of a content at the given pathstatic NodeList
contentAttribute
(String contentId, String dataPath, String lang) Get the attribute of a content at the given pathstatic String
contentExcerpt
(String contentId, String attributePath, int limit) Get the excerpt of content from the given richtext attributestatic String
contentMetadata
(String contentId, String metadataName) Get the metadata of a contentstatic String
contentMetadata
(String contentId, String metadataName, String lang) Get the metadata of a contentstatic NodeList
contentMixinTypes
(String contentId) Get the mixins of a contentstatic NodeList
Returns all tags of the current content.static NodeList
contentTags
(String contentId) Returns all tags of the given contentstatic NodeList
contentTypes
(String contentId) Get the content types of a contentstatic NodeList
contentTypeTags
(String contentTypeId) Returns all tags of a content typevoid
contextualize
(Context context) void
enableLogging
(Logger logger) static Node
getContentView
(String contentId) Get the HTML view of a contentstatic Node
getContentView
(String contentId, int startHeadingsLevel) Get the HTML view of a content with offset on headingsstatic Node
getContentView
(String contentId, String viewName) Get the HTML view of a contentstatic Node
getContentView
(String contentId, String viewName, int startHeadingsLevel) Get the HTML view of a contentstatic Node
getContentView
(String contentId, String viewName, int startHeadingsLevel, String lang, boolean checkReadAccess) Get the HTML view of a content with offset on headingsstatic boolean
Determines if there is a non-empty value for the data at the given pathstatic boolean
isReferenceTableContent
(String contentId) Determines if the content of given id is a entry of reference tablestatic String
lang()
Returns the current language for rendering.void
service
(ServiceManager manager) static void
setCurrentContent
(String contentId) Set the content of given id in request attributestatic void
setCurrentContent
(String contentId, String versionLabel) Set the content of given id and version in request attributestatic MapElement
Get the color (main and text) of a tagstatic String
tagDescription
(String siteName, String tagName, String lang) Get the description of a tagstatic String
Get the label of a tagstatic String
Get the name of the parent of a tag.static String
Get the path of a tag.static String
tagVisibility
(String siteName, String tagName) Get the visibility of a tagMethods inherited from class org.ametys.core.util.AmetysXSLTHelper
_getResourceBase64, absoluteUriPrefix, absoluteUriPrefix, config, escapeJS, escapeURLforCSS, getAbsoluteUriPrefix, getUriPrefix, getValueFromJsonObject, getWorkspaceName, getWorkspacePrefix, groups, groups, groups, hasRight, isDeveloperMode, isPluginEnabled, pluginImageBase64, requestParameter, splitText, splitText, translate, translate, translate, uriPrefix, uriPrefix, user, user, user, userByMail, versions, workspaceName, workspacePrefix, workspaceTheme, workspaceThemeURL
-
Field Details
-
_ametysObjectResolver
The Ametys object resolver -
_cTypeExtensionPoint
The content types extension point -
_tagProviderExtPt
The tags provider -
_contentHelper
Helper for content -
_context
The avalon context -
_logger
The logger -
_richTextHelper
The sax parser
-
-
Constructor Details
-
AmetysXSLTHelper
public AmetysXSLTHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Overrides:
contextualize
in classAmetysXSLTHelper
- Throws:
ContextException
-
enableLogging
- Specified by:
enableLogging
in interfaceLogEnabled
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAmetysXSLTHelper
- Throws:
ServiceException
-
contentTypes
Get the content types of a content- Parameters:
contentId
- The content id- Returns:
- The content type or empty if the content does not exist
-
contentMixinTypes
Get the mixins of a content- Parameters:
contentId
- The content id- Returns:
- The content type or empty if the content does not exist
-
isReferenceTableContent
Determines if the content of given id is a entry of reference table- Parameters:
contentId
- the content id- Returns:
- true if the content type is a reference table
-
lang
Returns the current language for rendering.- Returns:
- the current language for rendering.
-
hasValue
Determines if there is a non-empty value for the data at the given path- Parameters:
contentId
- The content iddataPath
- the path of data- Returns:
- true if the data exists
-
contentAttribute
Get the attribute of a content at the given path- Parameters:
contentId
- The content iddataPath
- The data path- Returns:
- The value into a "value" node or null if an error occurred
-
contentAttribute
Get the attribute of a content at the given path- Parameters:
contentId
- The content iddataPath
- The data pathlang
- The language for localized attribute. Can be null for non-localized attribute or to get the values for all existing locales.- Returns:
- The value into a "value" node or null if an error occurred
-
_getNodeValues
protected static List<Node> _getNodeValues(ModelAwareDataHolder dataHolder, String dataPath, String lang) Get values of an attribute of a model aware data holder at the given path- Parameters:
dataHolder
- the data holderdataPath
- The data pathlang
- The language for localized attribute. Can be null for non-localized attribute or to get the values for all existing locales.- Returns:
- A Node for each values or null if an error occurred
-
_getNodeValues
protected static List<Node> _getNodeValues(ModelAwareDataHolder dataHolder, String dataPath, String lang, DataContext dataContext) Get values of an attribute of a model aware data holder at the given path- Parameters:
dataHolder
- the data holderdataPath
- The data pathlang
- The language for localized attribute. Can be null for non-localized attribute or to get the values for all existing locales.dataContext
- The data context- Returns:
- A Node for each values or null if an error occurred
-
contentMetadata
Get the metadata of a content- Parameters:
contentId
- The content idmetadataName
- The metadata name (/ for composite)lang
- The language for localized metadata. Can be null to get the current language.- Returns:
- The name or empty if the metadata or the content does not exist
-
contentMetadata
Get the metadata of a content- Parameters:
contentId
- The content idmetadataName
- The metadata name (/ for composite)- Returns:
- The name or empty if the metadata or the content does not exist
-
contentAttachments
- Returns:
- an Element containing the attachments of the current content as
Resource
s.
-
contentAttachments
- Parameters:
contentId
- the content ID.- Returns:
- an Element containing the attachments of the given content as
Resource
s.
-
setCurrentContent
Set the content of given id in request attribute- Parameters:
contentId
- the id of content
-
setCurrentContent
Set the content of given id and version in request attribute- Parameters:
contentId
- the id of contentversionLabel
- The version label
-
contentTags
Returns all tags of the current content.- Returns:
- a list of tags.
-
contentTags
Returns all tags of the given content- Parameters:
contentId
- The identifier of the content- Returns:
- a list of tags.
-
_contentTags
Returns all tags of the given content- Parameters:
content
- The content- Returns:
- a list of tags.
-
tagParent
Get the name of the parent of a tag.- Parameters:
siteName
- the site nametagName
- the tag's name- Returns:
- The id of parent or empty if not found
-
tagPath
Get the path of a tag. The path contains the tag's parents seprated by '/'.- Parameters:
siteName
- The site nametagName
- The unique tag's name- Returns:
- The tag's path or empty string if tag does not exist
-
tagLabel
Get the label of a tag- Parameters:
siteName
- the current sitetagName
- the name of the taglang
- the lang (if i18n tag)- Returns:
- the label of the tag or empty if it cannot be found
-
tagDescription
Get the description of a tag- Parameters:
siteName
- the current sitetagName
- the name of the taglang
- the lang (if i18n tag)- Returns:
- the label of the tag or empty if it cannot be found
-
tagVisibility
Get the visibility of a tag- Parameters:
siteName
- the current sitetagName
- the name of the tag- Returns:
- the lower-cased visibility of the tag ("public" or "private")
-
tagColor
Get the color (main and text) of a tag- Parameters:
siteName
- the current sitetagName
- the name of the tag- Returns:
- the the color (main and text) of a tag
-
contentTypeTags
Returns all tags of a content type- Parameters:
contentTypeId
- The id of the content type- Returns:
- a list of tags.
-
contentExcerpt
Get the excerpt of content from the given richtext attribute- Parameters:
contentId
- the id of contentattributePath
- the attribute path of rich text attributelimit
- the max length for content excerpt- Returns:
- the excerpt
-
getContentView
Get the HTML view of a content- Parameters:
contentId
- the id of content- Returns:
- the content html view wrapped into a <content> tag
-
getContentView
Get the HTML view of a content with offset on headings- Parameters:
contentId
- the id of contentstartHeadingsLevel
- The start level for headings (h1, h2, h3, ...). For example, set to 2 so that the highest level headings are <h2>. Set to 1 for no offset.- Returns:
- the content html view wrapped into a <content> tag
-
getContentView
Get the HTML view of a content- Parameters:
contentId
- the id of contentviewName
- The content view name- Returns:
- the content html view wrapped into a <content> tag
-
getContentView
Get the HTML view of a content- Parameters:
contentId
- the id of contentviewName
- The content view namestartHeadingsLevel
- The start level for headings (h1, h2, h3, ...). For example, set to 2 so that the highest level headings are <h2>. Set to 1 for no offset.- Returns:
- the content html view wrapped into a <content> tag
-
getContentView
public static Node getContentView(String contentId, String viewName, int startHeadingsLevel, String lang, boolean checkReadAccess) Get the HTML view of a content with offset on headings- Parameters:
contentId
- the id of contentviewName
- The content view namelang
- the language. Can be null. Useful only if the content has a multilingual title.startHeadingsLevel
- The start level for headings (h1, h2, h3, ...). For example, set to 2 so that the highest level headings are <h2>. Set to 1 for no offset.checkReadAccess
- Set totrue
to check the read access on content. Be careful, do not use withtrue
on a cacheable element.- Returns:
- the content html view wrapped into a <content> tag
-