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
public class AmetysXSLTHelper extends AmetysXSLTHelper implements LogEnabled
Helper component to be used from XSL stylesheets.
-
-
Field Summary
Fields Modifier and Type Field Description protected static AmetysObjectResolver
_ametysObjectResolver
The Ametys object resolverprotected static ContentHelper
_contentHelper
Helper for contentprotected static Context
_context
The avalon contextprotected static ContentTypeExtensionPoint
_cTypeExtensionPoint
The content types extension pointprotected static Logger
_logger
The loggerprotected static SourceResolver
_sourceResolver
The source resolverprotected static TagProviderExtensionPoint
_tagProviderExtPt
The tags provider-
Fields inherited from class org.ametys.core.util.AmetysXSLTHelper
_currentUserProvider, _groupManager, _i18nUtils, _jsonUtils, _LOGGER, _rightManager, _userHelper, _userManager, _versionHandler
-
-
Constructor Summary
Constructors Constructor Description AmetysXSLTHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static NodeList
_contentTags(Content content)
Returns all tags of the given contentprotected static List<Node>
_getNodeValues(ModelAwareDataHolder dataHolder, String dataPath, String lang)
Get values of an attribute of a model aware data holder at the given pathprotected 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 pathstatic Node
contentAttachments()
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
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
contentTags()
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
hasValue(String contentId, String dataPath)
Determines if there is a 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 String
tagDescription(String siteName, String tagName, String lang)
Get the description of a tagstatic String
tagLabel(String siteName, String tagName, String lang)
Get the label of a tagstatic String
tagParent(String siteName, String tagName)
Get the name of the parent of a tag.static String
tagPath(String siteName, String tagName)
Get the path of a tag.static String
tagVisibility(String siteName, String tagName)
Get the visibility of a tag-
Methods inherited from class org.ametys.core.util.AmetysXSLTHelper
absoluteUriPrefix, absoluteUriPrefix, config, escapeJS, getAbsoluteUriPrefix, getUriPrefix, getValueFromJsonObject, getWorkspaceName, getWorkspacePrefix, groups, groups, groups, hasRight, isDeveloperMode, requestParameter, splitText, splitText, translate, translate, translate, uriPrefix, uriPrefix, user, user, user, userByMail, versions, workspaceName, workspacePrefix, workspaceTheme, workspaceThemeURL
-
-
-
-
Field Detail
-
_ametysObjectResolver
protected static AmetysObjectResolver _ametysObjectResolver
The Ametys object resolver
-
_cTypeExtensionPoint
protected static ContentTypeExtensionPoint _cTypeExtensionPoint
The content types extension point
-
_tagProviderExtPt
protected static TagProviderExtensionPoint _tagProviderExtPt
The tags provider
-
_contentHelper
protected static ContentHelper _contentHelper
Helper for content
-
_sourceResolver
protected static SourceResolver _sourceResolver
The source resolver
-
-
Constructor Detail
-
AmetysXSLTHelper
public AmetysXSLTHelper()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Overrides:
contextualize
in classAmetysXSLTHelper
- Throws:
ContextException
-
enableLogging
public void enableLogging(Logger logger)
- Specified by:
enableLogging
in interfaceLogEnabled
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAmetysXSLTHelper
- Throws:
ServiceException
-
contentTypes
public static NodeList contentTypes(String contentId)
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
public static NodeList contentMixinTypes(String contentId)
Get the mixins of a content- Parameters:
contentId
- The content id- Returns:
- The content type or empty if the content does not exist
-
isReferenceTableContent
public static boolean isReferenceTableContent(String contentId)
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
public static String lang()
Returns the current language for rendering.- Returns:
- the current language for rendering.
-
hasValue
public static boolean hasValue(String contentId, String dataPath)
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
public static NodeList contentAttribute(String contentId, String dataPath)
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
public static NodeList contentAttribute(String contentId, String dataPath, String lang)
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
public static String contentMetadata(String contentId, String metadataName, String lang)
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
public static String contentMetadata(String contentId, String metadataName)
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
public static Node contentAttachments()
- Returns:
- an Element containing the attachments of the current content as
Resource
s.
-
contentAttachments
public static Node contentAttachments(String contentId)
- Parameters:
contentId
- the content ID.- Returns:
- an Element containing the attachments of the given content as
Resource
s.
-
setCurrentContent
public static void setCurrentContent(String contentId)
Set the content of given id in request attribute- Parameters:
contentId
- the id of content
-
setCurrentContent
public static void setCurrentContent(String contentId, String versionLabel)
Set the content of given id and version in request attribute- Parameters:
contentId
- the id of contentversionLabel
- The version label
-
contentTags
public static NodeList contentTags()
Returns all tags of the current content.- Returns:
- a list of tags.
-
contentTags
public static NodeList contentTags(String contentId)
Returns all tags of the given content- Parameters:
contentId
- The identifier of the content- Returns:
- a list of tags.
-
_contentTags
protected static NodeList _contentTags(Content content)
Returns all tags of the given content- Parameters:
content
- The content- Returns:
- a list of tags.
-
tagParent
public static String tagParent(String siteName, String tagName)
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
public static String tagPath(String siteName, String tagName)
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
public static String tagLabel(String siteName, String tagName, String lang)
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
public static String tagDescription(String siteName, String tagName, String lang)
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
public static String tagVisibility(String siteName, String tagName)
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")
-
contentTypeTags
public static NodeList contentTypeTags(String contentTypeId)
Returns all tags of a content type- Parameters:
contentTypeId
- The id of the content type- Returns:
- a list of tags.
-
getContentView
public static Node getContentView(String contentId)
Get the HTML view of a content- Parameters:
contentId
- the id of content- Returns:
- the content html view wrapped into a <content> tag
-
getContentView
public static Node getContentView(String contentId, int startHeadingsLevel)
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
public static Node getContentView(String contentId, String viewName)
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
public static Node getContentView(String contentId, String viewName, int startHeadingsLevel)
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
-
-