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
FieldsModifier and TypeFieldDescriptionprotected static AmetysObjectResolverThe Ametys object resolverprotected static ContentHelperHelper for contentprotected static ContextThe avalon contextprotected static ContentTypeExtensionPointThe content types extension pointprotected static LoggerThe loggerprotected static RichTextHelperThe sax parserprotected static SourceResolverThe source resolverprotected static TagProviderExtensionPointThe tags providerFields inherited from class org.ametys.core.util.AmetysXSLTHelper
_currentUserProvider, _groupManager, _i18nUtils, _jsonUtils, _LOGGER, _rightManager, _userHelper, _userManager, _versionHandler -
Constructor Summary
Constructors -
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 Nodestatic NodecontentAttachments(String contentId) static NodeListcontentAttribute(String contentId, String dataPath) Get the attribute of a content at the given pathstatic NodeListcontentAttribute(String contentId, String dataPath, String lang) Get the attribute of a content at the given pathstatic StringcontentExcerpt(String contentId, String attributePath, int limit) Get the excerpt of content from the given richtext attributestatic StringcontentMetadata(String contentId, String metadataName) Get the metadata of a contentstatic StringcontentMetadata(String contentId, String metadataName, String lang) Get the metadata of a contentstatic NodeListcontentMixinTypes(String contentId) Get the mixins of a contentstatic NodeListReturns all tags of the current content.static NodeListcontentTags(String contentId) Returns all tags of the given contentstatic NodeListcontentTypes(String contentId) Get the content types of a contentstatic NodeListcontentTypeTags(String contentTypeId) Returns all tags of a content typevoidcontextualize(Context context) voidenableLogging(Logger logger) static NodegetContentView(String contentId) Get the HTML view of a contentstatic NodegetContentView(String contentId, int startHeadingsLevel) Get the HTML view of a content with offset on headingsstatic NodegetContentView(String contentId, String viewName) Get the HTML view of a contentstatic NodegetContentView(String contentId, String viewName, int startHeadingsLevel) Get the HTML view of a contentstatic NodegetContentView(String contentId, String viewName, int startHeadingsLevel, String lang, boolean checkReadAccess) Get the HTML view of a content with offset on headingsstatic booleanDetermines if there is a value for the data at the given pathstatic booleanisReferenceTableContent(String contentId) Determines if the content of given id is a entry of reference tablestatic Stringlang()Returns the current language for rendering.voidservice(ServiceManager manager) static voidsetCurrentContent(String contentId) Set the content of given id in request attributestatic voidsetCurrentContent(String contentId, String versionLabel) Set the content of given id and version in request attributestatic MapElementGet the color (main and text) of a tagstatic StringtagDescription(String siteName, String tagName, String lang) Get the description of a tagstatic StringGet the label of a tagstatic StringGet the name of the parent of a tag.static StringGet the path of a tag.static StringtagVisibility(String siteName, String tagName) Get the visibility of a tagMethods inherited from class org.ametys.core.util.AmetysXSLTHelper
absoluteUriPrefix, absoluteUriPrefix, config, escapeJS, getAbsoluteUriPrefix, getUriPrefix, getValueFromJsonObject, getWorkspaceName, getWorkspacePrefix, groups, groups, groups, hasRight, isDeveloperMode, isPluginEnabled, 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 -
_sourceResolver
The source resolver -
_richTextHelper
The sax parser
-
-
Constructor Details
-
AmetysXSLTHelper
public AmetysXSLTHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Overrides:
contextualizein classAmetysXSLTHelper- Throws:
ContextException
-
enableLogging
- Specified by:
enableLoggingin interfaceLogEnabled
-
service
- Specified by:
servicein interfaceServiceable- Overrides:
servicein 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 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
Resources.
-
contentAttachments
- Parameters:
contentId- the content ID.- Returns:
- an Element containing the attachments of the given content as
Resources.
-
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 totrueto check the read access on content. Be careful, do not use withtrueon a cacheable element.- Returns:
- the content html view wrapped into a <content> tag
-