|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface I_CmsLinkSubstitutionHandler
Allows to configure customized link substitution behavior.
This handler is plugged into
CmsLinkManager.substituteLink(org.opencms.file.CmsObject, String, String, boolean)
,
which is the central method to calculate links for the use on web pages.
This method is also used by the <cms:link />
tag.
Moreover, this handler is plugged into
CmsLinkManager.getRootPath(CmsObject, String, String)
,
which basically is the revered method that gets a VFS root path from a link.
For the implementation, you must implement the methods in this interface so that:
String path; // assume we have a valid VFS resource root path CmsObject cms; // assume we have a valid OpenCms user context CmsLinkManager lm = OpenCms.getLinkManager(); String link = lm.substituteLinkForRootPath(cms, path); String rootPath = lm.getRootPath(cms, link); link.equals(rootPath); // this must be true!Using this handler, you can completely customize the behavior of the link substitution.
The default implementation of this interface is CmsDefaultLinkSubstitutionHandler
.
for the method where this handler is used to create a link from a VFS root path
,
for the method where this handler is used to create VFS root path from a link
,
for the default implementation of this interface
Method Summary | |
---|---|
java.lang.String |
getLink(CmsObject cms,
java.lang.String link,
java.lang.String siteRoot,
boolean forceSecure)
Returns a link from the URI stored in the provided OpenCms user context to the VFS resource indicated by the given link and siteRoot ,
for use on web pages. |
java.lang.String |
getRootPath(CmsObject cms,
java.lang.String targetUri,
java.lang.String basePath)
Returns the resource root path in the OpenCms VFS for the given target URI link, or null in
case the link points to an external site. |
Method Detail |
---|
java.lang.String getLink(CmsObject cms, java.lang.String link, java.lang.String siteRoot, boolean forceSecure)
link
and siteRoot
,
for use on web pages.The result should be an absolute link that contains the configured context path and servlet name, and in the case of the "online" project it will also be rewritten according to to the configured static export settings.
In case link
is a relative URI, the current URI contained in the provided
OpenCms user context cms
is normally used to make the relative link
absolute.
The provided siteRoot
is assumed to be the "home" of the link.
In case the current site of the given OpenCms user context cms
is different from the
provided siteRoot
, the full server prefix is appended to the result link.
A server prefix is also added if
CmsDefaultLinkSubstitutionHandler
, which can be fully customized using this handler interface.
cms
- the current OpenCms user contextlink
- the link to process which is assumed to point to a VFS resource, with optional parameterssiteRoot
- the site root of the link
forceSecure
- if true
generates always an absolute URL (with protocol and server name) for secure links
link
and siteRoot
for the reverse function, which creates a VFS
java.lang.String getRootPath(CmsObject cms, java.lang.String targetUri, java.lang.String basePath)
null
in
case the link points to an external site.The default implementation applies the following transformations to the link:
/opencms/opencms
,
this prefix is removed from the result
basePath
as starting point.
http://www.mysite.de/
),
which points to a configured site in OpenCms, the server schema is replaced with
the root path of the site.
null
is returned.
CmsDefaultLinkSubstitutionHandler
, which can be fully customized using this handler interface.
cms
- the current users OpenCms contexttargetUri
- the target URI linkbasePath
- path to use as base in case the target URI is relative (can be null
)
null
in
case the link points to an external sitefor the reverse function, which creates a link
form a VFS resource path
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |