public class AmetysXSLTHelper extends AmetysXSLTHelper
Modifier and Type | Field and 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 SourceResolver |
_sourceResolver |
private static UrlPreviewComponent |
_urlPreview |
_ametysObjectResolver, _contentHelper, _context, _cTypeExtensionPoint, _logger, _tagProviderExtPt
_currentUserProvider, _groupManager, _i18nUtils, _jsonUtils, _LOGGER, _rightManager, _userHelper, _versionHandler
Constructor and Description |
---|
AmetysXSLTHelper() |
Modifier and Type | Method and Description |
---|---|
private static String |
_convertTagName(String name) |
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 Map<String,MapElement.MapNode> |
_getParameterValue(String parameterPath,
ModelItem modelItem,
ModelAwareDataHolder dataHolder,
Object defaultValue) |
private static String |
_getResourceBase64(FileSource source)
Get the base 64 encoding for the given source
|
private static String |
_getResourceURL(Request request,
Site site,
String resourcePath) |
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 access
|
static NodeList |
breadcrumb()
Computes the breadcrumb of the current page.
|
static NodeList |
findContentsIdsByTag(String tag)
Returns the ids of the contents
|
static NodeList |
findContentsIdsByTag(String sitename,
String lang,
String tag)
Returns the ids of the contents
|
static NodeList |
findPagesIdsByTag(String tag)
Returns the ids of the pages
|
static NodeList |
findPagesIdsByTag(String sitename,
String lang,
String tag)
Returns the ids of the pages
|
static boolean |
hasRightOnPage(String rightId)
Returns true if the current user has the specified right on the current page
|
static boolean |
hasRightOnPage(String rightId,
String pageId)
Returns true if the current user has the specified right on the specified page
|
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.
|
static boolean |
isEditionMode()
Determines if we are in an edition mode
|
static 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 exists
|
static 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 elements
|
static boolean |
pageIsVisible(String sitename,
String lang,
String path)
Returns true if the given page is visible into navigation elements
|
static String |
pageLongTitle(String pageId)
Get the long title of a page
|
static String |
pageLongTitle(String sitename,
String lang,
String path)
Get the long title of a page
|
static String |
pageMetadata(String pageId,
String dataPath)
Get the data of a page at the given path
|
static String |
pageMetadata(String sitename,
String lang,
String path,
String dataPath)
Get the data of a page at the given path
|
static 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 page
|
static 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 content
|
static String |
renderingContext()
Returns the current
RenderingContext . |
static Node |
resourceByPath(String path)
Returns a DOM
Element representing a single file of the resources explorer. |
static Node |
resourcesById(String collectionId)
Returns a DOM
Element representing files and folder of the resources explorer,
under the ResourceCollection corresponding to the given id. |
static Node |
resourcesByPath(String path)
Returns a DOM
Element representing files and folder of the resources explorer,
under the ResourceCollection 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 a
Node . |
static String |
site()
Returns the current site
|
static String |
site(String pageId)
Returns the current site
|
static Node |
sitemap()
Return the current sitemap as a
Node . |
static Node |
sitemap(boolean includeInvisiblePages)
Return the current sitemap as a
Node . |
static Node |
sitemap(String pageId)
Return the subsitemap of the given page as a
Node . |
static Node |
sitemap(String pageId,
boolean includeInvisiblePages)
Return the subsitemap of the given page as a
Node . |
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 DOM
Element 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 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 site
|
static String |
zone(String defaultValue)
Return the name of the zone beeing handled
|
static String |
zoneItemId()
Returns the id of the current zone item id.
|
_contentTags, contentAttachments, contentAttachments, contentMetadata, contentMetadata, contentMixinTypes, contentTags, contentTags, contentTypes, contentTypeTags, contextualize, enableLogging, isReferenceTableContent, setCurrentContent, setCurrentContent, tagDescription, tagLabel, tagParent, tagPath, tagVisibility
absoluteUriPrefix, config, escapeJS, getAbsoluteUriPrefix, getUriPrefix, getValueFromJsonObject, getWorkspaceName, getWorkspacePrefix, groups, groups, groups, hasRight, isDeveloperMode, requestParameter, splitText, splitText, translate, translate, uriPrefix, urlEncode, user, user, user, userByMail, versions, workspaceName, workspacePrefix, workspaceTheme, workspaceThemeURL
static final int _PAGINATION_CURRENT
static final int _PAGINATION_SEPARATOR
static final int _PAGINATION_SPACE
private static final String __NAME_ATTRIBUTE
private static final String __TYPE_ATTRIBUTE
private static final String __REPEATER_ENTRY_TYPE
private static SiteManager _siteManager
private static RenderingContextHandler _renderingContextHandler
private static URIPrefixHandler _prefixHandler
private static SourceResolver _sourceResolver
private static ServiceExtensionPoint _serviceEP
private static PopulationContextHelper _populationContextHelper
private static UrlPreviewComponent _urlPreview
public AmetysXSLTHelper()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
service
in class AmetysXSLTHelper
ServiceException
public static String uriPrefix()
public static String siteUriPrefix()
public static String absoluteUriPrefix()
public static String absoluteSiteUriPrefix()
public static String absoluteSiteUriPrefix(String siteName)
siteName
- The site name. Can be null to get the current site.public static String template()
public static String lang()
public static String lang(String pageId)
pageId
- The page identifier to get sitemap onpublic static String skinURL(String path)
path
- the resource path.public static String skinImageURL(String path, int height, int width)
path
- the resource pathheight
- the height for the resource to getwidth
- the width for the resource to getpublic static String skinImageBase64(String path) throws IOException
path
- the path of the imageIOException
- if an error occurs while trying to get the filepublic static String skinBoundedImageURL(String path, int maxHeight, int maxWidth)
path
- the resource pathmaxHeight
- the maximum height for the resource to getmaxWidth
- the maximum width for the resource to getpublic static String templateURL(String path)
path
- the resource path.public static String pluginResourceURL(String plugin, String path)
plugin
- the plugin name.path
- the resource path.public static String pluginImageBase64(String plugin, String path) throws MalformedURLException, IOException
plugin
- the plugin's name.path
- the resource path.IOException
- if an error occurs when trying to get the fileMalformedURLException
- if the url is invalidprivate static String _getResourceURL(Request request, Site site, String resourcePath)
private static String _getResourceBase64(FileSource source)
source
- the sourcepublic static String renderingContext()
RenderingContext
.RenderingContext
.public static String zone(String defaultValue)
defaultValue
- If no page is handled currently, this value is returned (can be null, empty...)public static String siteParameter(String parameter)
parameter
- the parameter ID.public static String siteParameter(String siteName, String parameter)
siteName
- the site nameparameter
- the parameter ID.public static Node serviceParameters()
Node
.Node
.static Node _serviceParameters(ZoneItem zoneItem)
public static Node serviceParameter(String parameterPath)
parameterPath
- the parameter path.public static Node serviceParameter(String parameterPath, Object defaultValue)
parameterPath
- the parameter path.defaultValue
- the default value. Note that default value is ignored if the parameter is a composite parameter.static Node _serviceParameter(ZoneItem zoneItem, String parameterPath, Object defaultValue)
private static String _convertTagName(String name)
private static Map<String,MapElement.MapNode> _getParameterValue(String parameterPath, ModelItem modelItem, ModelAwareDataHolder dataHolder, Object defaultValue)
public static String site(String pageId)
pageId
- The identifier ot the pagepublic static Node sitemap()
Node
.
Invisible pages will not be displayedpublic static Node sitemap(boolean includeInvisiblePages)
Node
.includeInvisiblePages
- Should return child invisible pagespublic static Node sitemap(String pageId)
Node
.
Invisible child pages will not be returned;pageId
- The root pagepublic static Node sitemap(String pageId, boolean includeInvisiblePages)
Node
.pageId
- The root pageincludeInvisiblePages
- Should return child invisible pagespublic static NodeList breadcrumb()
public static Node resourcesById(String collectionId)
Element
representing files and folder of the resources explorer,
under the ResourceCollection
corresponding to the given id.collectionId
- the id of the root ResourceCollection
.public static Node resourcesByPath(String path)
Element
representing files and folder of the resources explorer,
under the ResourceCollection
corresponding to the given path. path
- the path of the root ResourceCollection
, relative to the current site's resource explorer.public static Node resourceByPath(String path)
Element
representing a single file of the resources explorer. path
- the path of the Resource
, relative to the current site's resource explorer.public static Node skinResources(String path) throws IOException
Element
representing files and folder of a skin directory. path
- the path of the root ResourceCollection
, relative to the current skin's 'resources' directory. Can be a file path to test its existance.IOException
- if an error occured while listing files.public static String pageSiteName(String pageId)
pageId
- The page id.public static String pageTitle(String sitename, String lang, String path)
sitename
- the site name.lang
- the sitemap name.path
- the page path.public static boolean pageExists(String sitename, String lang, String path)
sitename
- the site name.lang
- the sitemap name.path
- the page path.false
the page does not exist.public static String pageTitle(String pageId)
pageId
- The page id.public static String pageLongTitle(String sitename, String lang, String path)
sitename
- the site namelang
- the page's languagepath
- the page's pathpublic static String pageLongTitle(String pageId)
pageId
- The page idpublic static String pageMetadata(String sitename, String lang, String path, String dataPath)
sitename
- the site namelang
- the page's languagepath
- the page's pathdataPath
- The data path (use '/' as separator for composites and repeaters)public static String pageMetadata(String pageId, String dataPath)
pageId
- The page iddataPath
- The data path (use '/' as separator for composites and repeaters)private static String _getPageData(Page page, String dataPath)
public static boolean pageIsVisible(String pageId)
pageId
- the page id.public static boolean pageIsVisible(String sitename, String lang, String path)
sitename
- the site namelang
- the page's languagepath
- the page's pathpublic static boolean pageHasRestrictedAccess(String pageId)
pageId
- the page id.public static boolean hasRightOnPage(String rightId)
rightId
- Right Idpublic static boolean hasRightOnPage(String rightId, String pageId)
rightId
- Right IdpageId
- Page Idprivate static boolean _hasRightOnPage(String rightId, Page page)
rightId
- Right Idpage
- Pagepublic static boolean pageHasRestrictedAccess(String sitename, String lang, String path)
sitename
- the site namelang
- the page's languagepath
- the page's pathpublic static String pagePath()
public static String pagePath(String pageId)
pageId
- The id of pagepublic static String pageId()
public static String zoneItemId()
public static boolean isCacheable()
public static boolean isEditionMode()
public static NodeList accessibleReferencedPages(String contentId)
contentId
- The content's idpublic static NodeList referencedPages(String contentId)
contentId
- The content's idpublic static NodeList findContentsIdsByTag(String tag)
tag
- The tag idpublic static NodeList findContentsIdsByTag(String sitename, String lang, String tag)
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 idpublic static NodeList findPagesIdsByTag(String sitename, String lang, String tag)
sitename
- The site idlang
- The language codetag
- The tag idpublic static NodeList findPagesIdsByTag(String tag)
tag
- The tag idpublic static Node userByMail(String email) throws SAXException
email
- the concerned user's emailSAXException
- If an error occurred while saxing the userpublic static Node urlPreview(String url) throws SAXException
url
- the web linkSAXException
- If an error occurred while saxingpublic static AmetysNodeList pagination(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int nbLastPages)
<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>
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 separatorstatic int[] _pagination(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int nbLastPages)
private static int _paginationMiddle(int nbPages, int currentPage, int nbFirstPages, int nbCentralPages, int[] values, int cursorP, int offset)
private static int _paginationComputeOffsetAfterFirstSeparator(int nbPages, int currentPage, int nbCentralPages, int nbLastPages, int centerOfCentralPages, boolean firstSeparator, boolean secondSeparator, int cursor)
private static int _paginationLastPages(int nbPages, int currentPage, int displayedPages, int[] values, int cursorP, int offset)
private static int _paginationSecondSeparator(int nbPages, boolean secondSeparator, int currentPage, int nbLastPages, int[] values, int cursor, int offset)
private static int _paginationFirstSeparator(int nbPages, boolean firstSeparator, int currentPage, int[] values, int cursor)
private static int _paginationFirstPages(int nbPages, int nbFirstPages, int currentPage, int[] values, int cursorP)