Class AmetysXSLTHelper
- java.lang.Object
-
- org.ametys.core.util.AmetysXSLTHelper
-
- org.ametys.cms.transformation.xslt.AmetysXSLTHelper
-
- org.ametys.web.transformation.xslt.AmetysXSLTHelper
-
- All Implemented Interfaces:
Contextualizable
,LogEnabled
,Serviceable
- Direct Known Subclasses:
LinkDirectoryXSLTHelper
,OrgUnitXSLTHelper
,UgcXSLTHelper
,UserXSLTHelper
public class AmetysXSLTHelper extends AmetysXSLTHelper
Helper component to be used from XSL stylesheets.
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__NAME_ATTRIBUTE
private static String
__REPEATER_ENTRY_TYPE
private static String
__TYPE_ATTRIBUTE
(package private) static int
_PAGINATION_CURRENT
(package private) static int
_PAGINATION_SEPARATOR
(package private) static int
_PAGINATION_SPACE
private static PopulationContextHelper
_populationContextHelper
private static URIPrefixHandler
_prefixHandler
private static RenderingContextHandler
_renderingContextHandler
private static ServiceExtensionPoint
_serviceEP
private static SiteManager
_siteManager
private static UrlPreviewComponent
_urlPreview
private static ViewParametersManager
_viewParametersManager
-
Fields inherited from class org.ametys.cms.transformation.xslt.AmetysXSLTHelper
_ametysObjectResolver, _contentHelper, _context, _cTypeExtensionPoint, _logger, _sourceResolver, _tagProviderExtPt
-
Fields inherited from class org.ametys.core.util.AmetysXSLTHelper
_currentUserProvider, _groupManager, _i18nUtils, _jsonUtils, _LOGGER, _rightManager, _userHelper, _versionHandler
-
-
Constructor Summary
Constructors Constructor Description AmetysXSLTHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static String
_convertTagName(String name)
private static Content
_getContentFromRequest()
private static Page
_getPage(String id)
private static Page
_getPage(String sitename, String lang, String path)
private static String
_getPageData(Page page, String dataPath)
private static Page
_getPageFromRequest()
private static Map<String,MapElement.MapNode>
_getParameterValue(String parameterPath, ModelItem modelItem, ModelAwareDataHolder dataHolder, Object defaultValue)
private static String
_getResourceBase64(Source source)
Get the base 64 encoding for the given sourceprivate static String
_getResourceURL(Request request, Site site, String resourcePath)
private static Zone
_getZone(Page page, String zoneName)
private static Zone
_getZoneForParameter(Page page, String zoneName)
private static Zone
_getZoneFromRequest(Page page)
private static ZoneItem
_getZoneItem(String id)
private static ZoneItem
_getZoneItemFromRequest()
private static boolean
_hasParameterValueOrDefaultValue(String parameterPath, ModelAwareDataHolder dataHolder, Object defaultValue)
private static boolean
_hasRightOnPage(String rightId, Page page)
Returns true if the current user has the specified right on the specified page(package private) static int[]
_pagination(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int nbLastPages)
private static int
_paginationComputeOffsetAfterFirstSeparator(int nbPages, int currentPage, int nbCentralPages, int nbLastPages, int centerOfCentralPages, boolean firstSeparator, boolean secondSeparator, int cursor)
private static int
_paginationFirstPages(int nbPages, int nbFirstPages, int currentPage, int[] values, int cursorP)
private static int
_paginationFirstSeparator(int nbPages, boolean firstSeparator, int currentPage, int[] values, int cursor)
private static int
_paginationLastPages(int nbPages, int currentPage, int displayedPages, int[] values, int cursorP, int offset)
private static int
_paginationMiddle(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int[] values, int cursorP, int offset)
private static int
_paginationSecondSeparator(int nbPages, boolean secondSeparator, int currentPage, int nbLastPages, int[] values, int cursor, int offset)
(package private) static Node
_serviceParameter(ZoneItem zoneItem, String parameterPath, Object defaultValue)
(package private) static Node
_serviceParameters(ZoneItem zoneItem)
static String
absoluteSiteUriPrefix()
Returns the absolute URI prefix corresponding to the current site, depending on the rendering context.static String
absoluteSiteUriPrefix(String siteName)
Returns the absolute URI prefix corresponding to the given site, depending on the rendering context.static String
absoluteUriPrefix()
Returns the absolute URI prefix, depending on the rendering context.static NodeList
accessibleReferencedPages(String contentId)
Returns the id of pages referencing the content and for which the Front-office user can accessstatic NodeList
breadcrumb()
Computes the breadcrumb of the current page.static NodeList
contentViewParameter(String parameterPath)
Returns the value of the given parameter for the current content, or the empty node if the parameter does not exist.static NodeList
contentViewParameters()
Get the parameters of the current contentstatic NodeList
findContentsIdsByTag(String tag)
Returns the ids of the contentsstatic NodeList
findContentsIdsByTag(String sitename, String lang, String tag)
Returns the ids of the contentsstatic NodeList
findPagesIdsByTag(String tag)
Returns the ids of the pagesstatic NodeList
findPagesIdsByTag(String sitename, String lang, String tag)
Returns the ids of the pagesstatic boolean
hasRightOnPage(String rightId)
Returns true if the current user has the specified right on the current pagestatic boolean
hasRightOnPage(String rightId, String pageId)
Returns true if the current user has the specified right on the specified pagestatic boolean
isCacheable()
Determines if the current zone item or (if there is no current zone item) the current page is cacheable This method is only valid for a page.static boolean
isEditionMode()
Determines if we are in an edition modestatic String
lang()
Returns the current sitemap name.static String
lang(String pageId)
Returns the current sitemap name.static boolean
pageExists(String sitename, String lang, String path)
Determines if page existsstatic boolean
pageHasRestrictedAccess(String pageId)
Returns true if the given page has restricted access.static boolean
pageHasRestrictedAccess(String sitename, String lang, String path)
Returns true if the given page has restricted access.static String
pageId()
Returns the id of the current page.static boolean
pageIsVisible(String pageId)
Returns true if the given page is visible into navigation elementsstatic boolean
pageIsVisible(String sitename, String lang, String path)
Returns true if the given page is visible into navigation elementsstatic String
pageLongTitle(String pageId)
Get the long title of a pagestatic String
pageLongTitle(String sitename, String lang, String path)
Get the long title of a pagestatic String
pageMetadata(String pageId, String dataPath)
Get the data of a page at the given pathstatic String
pageMetadata(String sitename, String lang, String path, String dataPath)
Get the data of a page at the given pathstatic String
pagePath()
Returns the path of the current page, relative to the sitemap's root.static String
pagePath(String pageId)
Returns the path in sitemap of a pagestatic String
pageSiteName(String pageId)
Get the site name of a page.static String
pageTitle(String pageId)
Get the title of a page.static String
pageTitle(String sitename, String lang, String path)
Get the title of a page.static AmetysNodeList
pagination(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int nbLastPages)
Generates a XML structure to help to creates a complex pagination.static String
pluginImageBase64(String plugin, String path)
Computes the base 64 representation of the image at the specified path in the given plugin.static String
pluginResourceURL(String plugin, String path)
Computes the URI for the given resource in the given plugin.
If the URI is requested by the front-office, it will be absolutized.static NodeList
referencedPages(String contentId)
Returns the id of pages referencing the contentstatic String
renderingContext()
Returns the currentRenderingContext
.static Node
resourceByPath(String path)
Returns a DOMElement
representing a single file of the resources explorer.static Node
resourcesById(String collectionId)
Returns a DOMElement
representing files and folder of the resources explorer, under theResourceCollection
corresponding to the given id.static Node
resourcesByPath(String path)
Returns a DOMElement
representing files and folder of the resources explorer, under theResourceCollection
corresponding to the given path.void
service(ServiceManager manager)
static Node
serviceParameter(String parameterPath)
Returns the value of the given parameter for the current service, or the empty string if the parameter does not exist.static Node
serviceParameter(String parameterPath, Object defaultValue)
Returns the value of the given parameter for the current service, or the provided default value if the parameter does not exist.static Node
serviceParameters()
Get the service parameters as aNode
.static NodeList
serviceViewParameter(String parameterPath)
Returns the value of the given parameter for the current service, or the empty node if the parameter does not exist.static NodeList
serviceViewParameters()
Get the parameters of the current servicestatic String
site()
Returns the current sitestatic String
site(String pageId)
Returns the current sitestatic Node
sitemap()
Return the current sitemap as aNode
.static Node
sitemap(boolean includeInvisiblePages)
Return the current sitemap as aNode
.static Node
sitemap(String pageId)
Return the subsitemap of the given page as aNode
.static Node
sitemap(String pageId, boolean includeInvisiblePages)
Return the subsitemap of the given page as aNode
.static String
siteParameter(String parameter)
Return the value of a site parameter as a String.static String
siteParameter(String siteName, String parameter)
Return the value of a site parameter as a String.static String
siteUriPrefix()
Returns the URI prefix corresponding to the current site, depending on the rendering context.static String
skin()
Returns the current skin name.static String
skinBoundedImageURL(String path, int maxHeight, int maxWidth)
Computes the URI for the given image with a given heigth and width in the current site's skin.
If the URI is requested by the front-office, it will be absolutized.static String
skinImageBase64(String path)
Computes the base 64 representation of the image at the specified path.static String
skinImageURL(String path, int height, int width)
Computes the URI for the given image with a given heigth and width in the current site's skin.
If the URI is requested by the front-office, it will be absolutized.static Node
skinResources(String path)
Returns a DOMElement
representing files and folder of a skin directory.static String
skinURL(String path)
Computes the URI for the given resource in the current site's skin.
If the URI is requested by the front-office, it will be absolutized.static String
template()
Returns the current template name.static NodeList
templateParameter(String parameterPath)
Returns the value of the given parameter for the current page template, or the empty node if the parameter does not exist.static NodeList
templateParameter(String pageId, String parameterPath)
Returns the value of the given parameter for the given page template, or the empty node if the parameter does not exist.static NodeList
templateParameters()
Get the parameters' values of the current templatestatic String
templateURL(String path)
Computes the URI for the given resource in the current template.
If the URI is requested by the front-office, it will be absolutized.static String
uriPrefix()
Returns the current URI prefix, depending on the rendering context.static Node
urlPreview(String url)
Get the preview of a url (title, description, image, favico)static Node
userByMail(String email)
Return the given user by its email over all authorized population on current sitestatic String
zone(String defaultValue)
Return the name of the zone beeing handledstatic String
zoneItemId()
Returns the id of the current zone item id.static NodeList
zoneItemParameter(String parameterPath)
Returns the value of the given parameter for the current zone item, or the empty node if the parameter does not exist.static NodeList
zoneItemParameter(String zoneItemId, String parameterPath)
Returns the value of the given parameter for the given zone item, or the empty node if the parameter does not exist.static NodeList
zoneItemParameters()
Get the parameters of the current zone itemstatic NodeList
zoneItemParameters(String zoneItemId)
Get the parameters of a given zone itemstatic NodeList
zoneParameter(String parameterPath)
Returns the value of the given parameter for the current page and current zone, or the empty node if the parameter does not exist.static NodeList
zoneParameter(String zoneName, String parameterPath)
Returns the value of the given parameter for the current page and given zone, or the empty node if the parameter does not exist.static NodeList
zoneParameter(String pageId, String zoneName, String parameterPath)
Returns the value of the given parameter for the given page and given zone name, or the empty node if the parameter does not exist.static NodeList
zoneParameters()
Get the parameters of the current zonestatic NodeList
zoneParameters(String zoneName)
Get the parameters of a given zone-
Methods inherited from class org.ametys.cms.transformation.xslt.AmetysXSLTHelper
_contentTags, _getNodeValues, contentAttachments, contentAttachments, contentAttribute, contentAttribute, contentMetadata, contentMetadata, contentMixinTypes, contentTags, contentTags, contentTypes, contentTypeTags, contextualize, enableLogging, getContentView, getContentView, getContentView, getContentView, getContentView, hasValue, isReferenceTableContent, setCurrentContent, setCurrentContent, tagDescription, tagLabel, tagParent, tagPath, tagVisibility
-
Methods inherited from class org.ametys.core.util.AmetysXSLTHelper
absoluteUriPrefix, config, escapeJS, getAbsoluteUriPrefix, getUriPrefix, getValueFromJsonObject, getWorkspaceName, getWorkspacePrefix, groups, groups, groups, hasRight, isDeveloperMode, requestParameter, splitText, splitText, translate, translate, uriPrefix, user, user, user, userByMail, versions, workspaceName, workspacePrefix, workspaceTheme, workspaceThemeURL
-
-
-
-
Field Detail
-
_PAGINATION_CURRENT
static final int _PAGINATION_CURRENT
- See Also:
- Constant Field Values
-
_PAGINATION_SEPARATOR
static final int _PAGINATION_SEPARATOR
- See Also:
- Constant Field Values
-
_PAGINATION_SPACE
static final int _PAGINATION_SPACE
- See Also:
- Constant Field Values
-
__NAME_ATTRIBUTE
private static final String __NAME_ATTRIBUTE
- See Also:
- Constant Field Values
-
__TYPE_ATTRIBUTE
private static final String __TYPE_ATTRIBUTE
- See Also:
- Constant Field Values
-
__REPEATER_ENTRY_TYPE
private static final String __REPEATER_ENTRY_TYPE
- See Also:
- Constant Field Values
-
_siteManager
private static SiteManager _siteManager
-
_renderingContextHandler
private static RenderingContextHandler _renderingContextHandler
-
_prefixHandler
private static URIPrefixHandler _prefixHandler
-
_serviceEP
private static ServiceExtensionPoint _serviceEP
-
_populationContextHelper
private static PopulationContextHelper _populationContextHelper
-
_urlPreview
private static UrlPreviewComponent _urlPreview
-
_viewParametersManager
private static ViewParametersManager _viewParametersManager
-
-
Constructor Detail
-
AmetysXSLTHelper
public AmetysXSLTHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAmetysXSLTHelper
- Throws:
ServiceException
-
uriPrefix
public static String uriPrefix()
Returns the current URI prefix, depending on the rendering context.- Returns:
- the current URI prefix.
-
siteUriPrefix
public static String siteUriPrefix()
Returns the URI prefix corresponding to the current site, depending on the rendering context.- Returns:
- the URI prefix corresponding to the current site.
-
absoluteUriPrefix
public static String absoluteUriPrefix()
Returns the absolute URI prefix, depending on the rendering context.- Returns:
- the absolute URI prefix.
-
absoluteSiteUriPrefix
public static String absoluteSiteUriPrefix()
Returns the absolute URI prefix corresponding to the current site, depending on the rendering context.- Returns:
- the absolute URI prefix corresponding to the current site.
-
absoluteSiteUriPrefix
public static String absoluteSiteUriPrefix(String siteName)
Returns the absolute URI prefix corresponding to the given site, depending on the rendering context.- Parameters:
siteName
- The site name. Can be null to get the current site.- Returns:
- the absolute URI prefix corresponding to the current site.
-
template
public static String template()
Returns the current template name.- Returns:
- the current template name.
-
lang
public static String lang()
Returns the current sitemap name.- Returns:
- the current sitemap name.
-
lang
public static String lang(String pageId)
Returns the current sitemap name.- Parameters:
pageId
- The page identifier to get sitemap on- Returns:
- the current sitemap name.
-
skinURL
public static String skinURL(String path)
Computes the URI for the given resource in the current site's skin.
If the URI is requested by the front-office, it will be absolutized.- Parameters:
path
- the resource path.- Returns:
- the URI for the given resource.
-
skinImageURL
public static String skinImageURL(String path, int height, int width)
Computes the URI for the given image with a given heigth and width in the current site's skin.
If the URI is requested by the front-office, it will be absolutized.- Parameters:
path
- the resource pathheight
- the height for the resource to getwidth
- the width for the resource to get- Returns:
- the URI of the given resource
-
skinImageBase64
public static String skinImageBase64(String path) throws IOException
Computes the base 64 representation of the image at the specified path.- Parameters:
path
- the path of the image- Returns:
- the base 64-encoded image
- Throws:
IOException
- if an error occurs while trying to get the file
-
skinBoundedImageURL
public static String skinBoundedImageURL(String path, int maxHeight, int maxWidth)
Computes the URI for the given image with a given heigth and width in the current site's skin.
If the URI is requested by the front-office, it will be absolutized.- Parameters:
path
- the resource pathmaxHeight
- the maximum height for the resource to getmaxWidth
- the maximum width for the resource to get- Returns:
- the URI of the given resource
-
templateURL
public static String templateURL(String path)
Computes the URI for the given resource in the current template.
If the URI is requested by the front-office, it will be absolutized.- Parameters:
path
- the resource path.- Returns:
- the URI for the given resource.
-
pluginResourceURL
public static String pluginResourceURL(String plugin, String path)
Computes the URI for the given resource in the given plugin.
If the URI is requested by the front-office, it will be absolutized.- Parameters:
plugin
- the plugin name.path
- the resource path.- Returns:
- the URI for the given resource.
-
pluginImageBase64
public static String pluginImageBase64(String plugin, String path) throws MalformedURLException, IOException
Computes the base 64 representation of the image at the specified path in the given plugin.- Parameters:
plugin
- the plugin's name.path
- the resource path.- Returns:
- the base 64 encoding for the given resource.
- Throws:
IOException
- if an error occurs when trying to get the fileMalformedURLException
- if the url is invalid
-
_getResourceURL
private static String _getResourceURL(Request request, Site site, String resourcePath)
-
_getResourceBase64
private static String _getResourceBase64(Source source)
Get the base 64 encoding for the given source- Parameters:
source
- the source- Returns:
- the base 64 encoding of the source
-
renderingContext
public static String renderingContext()
Returns the currentRenderingContext
.- Returns:
- the current
RenderingContext
.
-
zone
public static String zone(String defaultValue)
Return the name of the zone beeing handled- Parameters:
defaultValue
- If no page is handled currently, this value is returned (can be null, empty...)- Returns:
- the name or the default value (so can be null or empty)
-
siteParameter
public static String siteParameter(String parameter)
Return the value of a site parameter as a String.- Parameters:
parameter
- the parameter ID.- Returns:
- the parameter value as a String.
-
siteParameter
public static String siteParameter(String siteName, String parameter)
Return the value of a site parameter as a String.- Parameters:
siteName
- the site nameparameter
- the parameter ID.- Returns:
- the parameter value as a String.
-
serviceParameters
public static Node serviceParameters()
Get the service parameters as aNode
.- Returns:
- the service parameters as a
Node
.
-
_serviceParameters
static Node _serviceParameters(ZoneItem zoneItem)
-
serviceParameter
public static Node serviceParameter(String parameterPath)
Returns the value of the given parameter for the current service, or the empty string if the parameter does not exist.- Parameters:
parameterPath
- the parameter path.- Returns:
- the value of the given parameter for the current service.
-
serviceParameter
public static Node serviceParameter(String parameterPath, Object defaultValue)
Returns the value of the given parameter for the current service, or the provided default value if the parameter does not exist.- Parameters:
parameterPath
- the parameter path.defaultValue
- the default value. Note that default value is ignored if the parameter is a composite parameter.- Returns:
- the value of the given parameter for the current service.
-
_serviceParameter
static Node _serviceParameter(ZoneItem zoneItem, String parameterPath, Object defaultValue)
-
_convertTagName
private static String _convertTagName(String name)
-
_getParameterValue
private static Map<String,MapElement.MapNode> _getParameterValue(String parameterPath, ModelItem modelItem, ModelAwareDataHolder dataHolder, Object defaultValue)
-
_hasParameterValueOrDefaultValue
private static boolean _hasParameterValueOrDefaultValue(String parameterPath, ModelAwareDataHolder dataHolder, Object defaultValue)
-
site
public static String site(String pageId)
Returns the current site- Parameters:
pageId
- The identifier ot the page- Returns:
- the current site
-
sitemap
public static Node sitemap()
Return the current sitemap as aNode
. Invisible pages will not be displayed- Returns:
- the current sitemap.
-
sitemap
public static Node sitemap(boolean includeInvisiblePages)
Return the current sitemap as aNode
.- Parameters:
includeInvisiblePages
- Should return child invisible pages- Returns:
- the current sitemap.
-
sitemap
public static Node sitemap(String pageId)
Return the subsitemap of the given page as aNode
. Invisible child pages will not be returned;- Parameters:
pageId
- The root page- Returns:
- The page as node.
-
sitemap
public static Node sitemap(String pageId, boolean includeInvisiblePages)
Return the subsitemap of the given page as aNode
.- Parameters:
pageId
- The root pageincludeInvisiblePages
- Should return child invisible pages- Returns:
- The page as node.
-
breadcrumb
public static NodeList breadcrumb()
Computes the breadcrumb of the current page.- Returns:
- a NodeList containing all ancestor pages, rooted at the sitemap.
-
resourcesById
public static Node resourcesById(String collectionId)
Returns a DOMElement
representing files and folder of the resources explorer, under theResourceCollection
corresponding to the given id.- Parameters:
collectionId
- the id of the rootResourceCollection
.- Returns:
- an Element containing files and folders.
-
resourcesByPath
public static Node resourcesByPath(String path)
Returns a DOMElement
representing files and folder of the resources explorer, under theResourceCollection
corresponding to the given path.
This path is intended to be relative to the current site's resource explorer.- Parameters:
path
- the path of the rootResourceCollection
, relative to the current site's resource explorer.- Returns:
- an Element containing files and folders or null if the specified resource does not exist.
-
resourceByPath
public static Node resourceByPath(String path)
Returns a DOMElement
representing a single file of the resources explorer.
This path is intended to be relative to the current site's resource explorer.- Parameters:
path
- the path of theResource
, relative to the current site's resource explorer.- Returns:
- an Element containing a file or null if the specified resource does not exist.
-
skinResources
public static Node skinResources(String path) throws IOException
Returns a DOMElement
representing files and folder of a skin directory.
This path is intended to be relative to the current skin's 'resources' directory.- Parameters:
path
- the path of the rootResourceCollection
, relative to the current skin's 'resources' directory. Can be a file path to test its existance.- Returns:
- an Element containing files and folders. node name is 'collection' or 'resource' with an attribute 'name'. Return null if the path does not exits.
- Throws:
IOException
- if an error occurred while listing files.
-
pageSiteName
public static String pageSiteName(String pageId)
Get the site name of a page.- Parameters:
pageId
- The page id.- Returns:
- The name or empty if the page does not exist.
-
pageTitle
public static String pageTitle(String sitename, String lang, String path)
Get the title of a page.- Parameters:
sitename
- the site name.lang
- the sitemap name.path
- the page path.- Returns:
- The name or empty if the meta or the page does not exist.
-
pageExists
public static boolean pageExists(String sitename, String lang, String path)
Determines if page exists- Parameters:
sitename
- the site name.lang
- the sitemap name.path
- the page path.- Returns:
false
the page does not exist.
-
pageTitle
public static String pageTitle(String pageId)
Get the title of a page.- Parameters:
pageId
- The page id.- Returns:
- The name or empty if the meta or the page does not exist.
-
pageLongTitle
public static String pageLongTitle(String sitename, String lang, String path)
Get the long title of a page- Parameters:
sitename
- the site namelang
- the page's languagepath
- the page's path- Returns:
- The name or empty if the meta or the page does not exist
-
pageLongTitle
public static String pageLongTitle(String pageId)
Get the long title of a page- Parameters:
pageId
- The page id- Returns:
- The name or empty if the meta or the page does not exist
-
pageMetadata
public static String pageMetadata(String sitename, String lang, String path, String dataPath)
Get the data of a page at the given path- Parameters:
sitename
- the site namelang
- the page's languagepath
- the page's pathdataPath
- The data path (use '/' as separator for composites and repeaters)- Returns:
- The value or empty if the data or the page does not exist
-
pageMetadata
public static String pageMetadata(String pageId, String dataPath)
Get the data of a page at the given path- Parameters:
pageId
- The page iddataPath
- The data path (use '/' as separator for composites and repeaters)- Returns:
- The value or empty if the data or the page does not exist
-
_getPageData
private static String _getPageData(Page page, String dataPath)
-
pageIsVisible
public static boolean pageIsVisible(String pageId)
Returns true if the given page is visible into navigation elements- Parameters:
pageId
- the page id.- Returns:
- true if the page is visible
-
pageIsVisible
public static boolean pageIsVisible(String sitename, String lang, String path)
Returns true if the given page is visible into navigation elements- Parameters:
sitename
- the site namelang
- the page's languagepath
- the page's path- Returns:
- true if the page is visible
-
pageHasRestrictedAccess
public static boolean pageHasRestrictedAccess(String pageId)
Returns true if the given page has restricted access.- Parameters:
pageId
- the page id.- Returns:
- true if the page exists and has restricted access.
-
hasRightOnPage
public static boolean hasRightOnPage(String rightId)
Returns true if the current user has the specified right on the current page- Parameters:
rightId
- Right Id- Returns:
- true if the current user has the specified right on the current page
-
hasRightOnPage
public static boolean hasRightOnPage(String rightId, String pageId)
Returns true if the current user has the specified right on the specified page- Parameters:
rightId
- Right IdpageId
- Page Id- Returns:
- true if the current user has the specified right on the specified page
-
_hasRightOnPage
private static boolean _hasRightOnPage(String rightId, Page page)
Returns true if the current user has the specified right on the specified page- Parameters:
rightId
- Right Idpage
- Page- Returns:
- true if the current user has the specified right on the specified page
-
pageHasRestrictedAccess
public static boolean pageHasRestrictedAccess(String sitename, String lang, String path)
Returns true if the given page has restricted access.- Parameters:
sitename
- the site namelang
- the page's languagepath
- the page's path- Returns:
- true if the page exists and has restricted access.
-
_getPageFromRequest
private static Page _getPageFromRequest()
-
pagePath
public static String pagePath()
Returns the path of the current page, relative to the sitemap's root.- Returns:
- the path of the current Page, or empty if there's no current page.
-
pagePath
public static String pagePath(String pageId)
Returns the path in sitemap of a page- Parameters:
pageId
- The id of page- Returns:
- the path of the Page, or empty if not exists
-
pageId
public static String pageId()
Returns the id of the current page.- Returns:
- the id of the current Page, or empty if there's no current page.
-
_getZoneFromRequest
private static Zone _getZoneFromRequest(Page page)
-
zoneItemId
public static String zoneItemId()
Returns the id of the current zone item id.- Returns:
- the id of the current zone item id, or empty if there's no current zone item.
-
_getZoneItem
private static ZoneItem _getZoneItem(String id)
-
_getZoneItemFromRequest
private static ZoneItem _getZoneItemFromRequest()
-
_getContentFromRequest
private static Content _getContentFromRequest()
-
isCacheable
public static boolean isCacheable()
Determines if the current zone item or (if there is no current zone item) the current page is cacheable This method is only valid for a page.- Returns:
- true if the current zone item or page is cacheable.
-
isEditionMode
public static boolean isEditionMode()
Determines if we are in an edition mode- Returns:
- true if we are in edition mode
-
accessibleReferencedPages
public static NodeList accessibleReferencedPages(String contentId)
Returns the id of pages referencing the content and for which the Front-office user can access- Parameters:
contentId
- The content's id- Returns:
- The pages' id
-
referencedPages
public static NodeList referencedPages(String contentId)
Returns the id of pages referencing the content- Parameters:
contentId
- The content's id- Returns:
- The pages' id
-
findContentsIdsByTag
public static NodeList findContentsIdsByTag(String tag)
Returns the ids of the contents- Parameters:
tag
- The tag id- Returns:
- Array of contents ids
-
findContentsIdsByTag
public static NodeList findContentsIdsByTag(String sitename, String lang, String tag)
Returns the ids of the contents- Parameters:
sitename
- site name. '+' for any site, '*'/null for any site, including contents without site, '^' for only contents without sitelang
- lang of the contentstag
- The tag id- Returns:
- Array of contents ids
-
findPagesIdsByTag
public static NodeList findPagesIdsByTag(String sitename, String lang, String tag)
Returns the ids of the pages- Parameters:
sitename
- The site idlang
- The language codetag
- The tag id- Returns:
- Array of pages ids
-
findPagesIdsByTag
public static NodeList findPagesIdsByTag(String tag)
Returns the ids of the pages- Parameters:
tag
- The tag id- Returns:
- Array of pages ids
-
userByMail
public static Node userByMail(String email) throws SAXException
Return the given user by its email over all authorized population on current site- Parameters:
email
- the concerned user's email- Returns:
- The informations about the given user
- Throws:
SAXException
- If an error occurred while saxing the user
-
urlPreview
public static Node urlPreview(String url) throws SAXException
Get the preview of a url (title, description, image, favico)- Parameters:
url
- the web link- Returns:
- the url preview
- Throws:
SAXException
- If an error occurred while saxing
-
pagination
public static AmetysNodeList pagination(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int nbLastPages)
Generates a XML structure to help to creates a complex pagination.
Example: pagination(39, 19, 2, 5, 2) will return<gotofirstpage enabled="true">1</gotofirstpage> <gotopreviouspage enabled="true">18</gotopreviouspage> <page>1</page> <page>2</page> <separator/> <page>17</page> <page>18</page> <current>19</current> <page>20</page> <page>21</page> <separator/> <page>38</page> <page>39</page> <gotonextpage enabled="true">20</gotonextpage> <gotolastpage enabled="true">39</gotonextpage>
Example: pagination(5, 2, 2, 5, 2) will return<gotofirstpage enabled="true">1</gotofirstpage> <gotopreviouspage enabled="true">1</gotopreviouspage> <page>1</page> <current>2</page> <page>3</page> <page>4</page> <page>5</page> <space/> <space/> <space/> <space/> <gotonextpage enabled="true">3</gotonextpage> <gotolastpage enabled="true">5</gotonextpage>
- Parameters:
nbPages
- The total number of pagescurrentPage
- The currently displayed page (1 based)nbFirstPages
- The max number of pages to display before the 1st separatornbCentralPages
- The max number of pages to display around the current pagenbLastPages
- The max number of pages to display after the 2nd separator- Returns:
- The xml described
-
_pagination
static int[] _pagination(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int nbLastPages)
-
_paginationMiddle
private static int _paginationMiddle(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int[] values, int cursorP, int offset)
-
_paginationComputeOffsetAfterFirstSeparator
private static int _paginationComputeOffsetAfterFirstSeparator(int nbPages, int currentPage, int nbCentralPages, int nbLastPages, int centerOfCentralPages, boolean firstSeparator, boolean secondSeparator, int cursor)
-
_paginationLastPages
private static int _paginationLastPages(int nbPages, int currentPage, int displayedPages, int[] values, int cursorP, int offset)
-
_paginationSecondSeparator
private static int _paginationSecondSeparator(int nbPages, boolean secondSeparator, int currentPage, int nbLastPages, int[] values, int cursor, int offset)
-
_paginationFirstSeparator
private static int _paginationFirstSeparator(int nbPages, boolean firstSeparator, int currentPage, int[] values, int cursor)
-
_paginationFirstPages
private static int _paginationFirstPages(int nbPages, int nbFirstPages, int currentPage, int[] values, int cursorP)
-
templateParameters
public static NodeList templateParameters()
Get the parameters' values of the current template- Returns:
- the values of template's parameters
-
templateParameter
public static NodeList templateParameter(String parameterPath)
Returns the value of the given parameter for the current page template, or the empty node if the parameter does not exist.- Parameters:
parameterPath
- the parameter path.- Returns:
- the value of the given parameter for the current page template.
-
templateParameter
public static NodeList templateParameter(String pageId, String parameterPath)
Returns the value of the given parameter for the given page template, or the empty node if the parameter does not exist.- Parameters:
pageId
- the page idparameterPath
- the parameter path.- Returns:
- the value of the given parameter for the given page template.
-
zoneParameters
public static NodeList zoneParameters()
Get the parameters of the current zone- Returns:
- the zone's parameters
-
zoneParameters
public static NodeList zoneParameters(String zoneName)
Get the parameters of a given zone- Parameters:
zoneName
- The zone's name. Can be null or empty to get the current zone.- Returns:
- the zone's parameters
-
zoneParameter
public static NodeList zoneParameter(String parameterPath)
Returns the value of the given parameter for the current page and current zone, or the empty node if the parameter does not exist.- Parameters:
parameterPath
- the parameter path.- Returns:
- the value of the given parameter for the current page and current zone.
-
zoneParameter
public static NodeList zoneParameter(String zoneName, String parameterPath)
Returns the value of the given parameter for the current page and given zone, or the empty node if the parameter does not exist.- Parameters:
zoneName
- the zone nameparameterPath
- the parameter path.- Returns:
- the value of the given parameter for the current page and given zone.
-
zoneParameter
public static NodeList zoneParameter(String pageId, String zoneName, String parameterPath)
Returns the value of the given parameter for the given page and given zone name, or the empty node if the parameter does not exist.- Parameters:
pageId
- the page idzoneName
- the zone nameparameterPath
- the parameter path.- Returns:
- the value of the given parameter for the given page and given zone name.
-
zoneItemParameters
public static NodeList zoneItemParameters()
Get the parameters of the current zone item- Returns:
- the zone items's parameters
-
zoneItemParameters
public static NodeList zoneItemParameters(String zoneItemId)
Get the parameters of a given zone item- Parameters:
zoneItemId
- The id of zone item. Can be null or empty to get the current zone item- Returns:
- the zone items's parameters
-
zoneItemParameter
public static NodeList zoneItemParameter(String parameterPath)
Returns the value of the given parameter for the current zone item, or the empty node if the parameter does not exist.- Parameters:
parameterPath
- the parameter path.- Returns:
- the value of the given parameter for the current zone item.
-
zoneItemParameter
public static NodeList zoneItemParameter(String zoneItemId, String parameterPath)
Returns the value of the given parameter for the given zone item, or the empty node if the parameter does not exist.- Parameters:
zoneItemId
- the zone item idparameterPath
- the parameter path.- Returns:
- the value of the given parameter for the given zone item.
-
serviceViewParameters
public static NodeList serviceViewParameters()
Get the parameters of the current service- Returns:
- the service's parameters
-
serviceViewParameter
public static NodeList serviceViewParameter(String parameterPath)
Returns the value of the given parameter for the current service, or the empty node if the parameter does not exist.- Parameters:
parameterPath
- the parameter path.- Returns:
- the value of the given parameter for the current service.
-
contentViewParameters
public static NodeList contentViewParameters()
Get the parameters of the current content- Returns:
- the content's parameters
-
contentViewParameter
public static NodeList contentViewParameter(String parameterPath)
Returns the value of the given parameter for the current content, or the empty node if the parameter does not exist.- Parameters:
parameterPath
- the parameter path.- Returns:
- the value of the given parameter for the current content.
-
_getZoneForParameter
private static Zone _getZoneForParameter(Page page, String zoneName)
-
-