public abstract class AbstractSkinExtensionPlugin extends XWikiDefaultPlugin implements com.xpn.xwiki.internal.cache.rendering.RenderingCacheAware
Skin Extensions base plugin. It allows templates and document content to pull required clientside code in the generated XHTML (or whatever XML) content.
The API provides a method SkinExtensionPluginApi.use(String)
, which, when called, marks an extension as used
in the current result. Later on, all the used extensions are inserted in the content, by replacing the first
occurrence of the following string: <!-- canonical.plugin.classname -->, where the actual extension
type classname is used. For example, JS extensions are inserted in place of
<!-- com.xpn.xwiki.plugin.skinx.JsSkinExtensionPlugin -->.
SkinExtensionPluginApi
,
JsSkinExtensionPlugin
,
CssSkinExtensionPlugin
,
LinkExtensionPlugin
Modifier and Type | Field and Description |
---|---|
protected String |
contextKey
The name of the context key for the list of pulled extensions.
|
protected String |
parametersContextKey
The name of the context key for the additional parameters for pulled extensions.
|
protected static String |
QUERY_PARAMETER_DELIMITER
The URL delimiter part of query parameters.
|
Constructor and Description |
---|
AbstractSkinExtensionPlugin(String name,
String className,
XWikiContext context)
XWiki plugin constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
endParsing(String content,
XWikiContext context) |
abstract Set<String> |
getAlwaysUsedExtensions(XWikiContext context)
Returns the list of always used extensions of this type.
|
com.xpn.xwiki.internal.cache.rendering.CachedItem.UsedExtension |
getCacheResources(XWikiContext context) |
protected org.xwiki.model.reference.DocumentReferenceResolver<String> |
getCurrentDocumentReferenceResolver()
Used to resolve a document string reference to a Document Reference.
|
protected org.xwiki.model.reference.EntityReferenceSerializer<String> |
getDefaultEntityReferenceSerializer()
Used to convert a proper Document Reference to string (standard form).
|
String |
getImportString(XWikiContext context)
Composes and returns the links to the resources pulled in the current request.
|
String |
getLink(String resource,
Map<String,Object> parameters,
XWikiContext context)
Abstract method for obtaining a link that points to the actual pulled resource.
|
abstract String |
getLink(String resource,
XWikiContext context)
Abstract method for obtaining a link that points to the actual pulled resource.
|
protected Object |
getParameter(String parameterName,
String resource,
XWikiContext context)
Get a parameter value for a pulled resource.
|
protected Map<String,Object> |
getParametersForResource(String resource,
XWikiContext context)
Get the parameters for a pulled resource.
|
protected Map<String,Map<String,Object>> |
getParametersMap(XWikiContext context)
Get the map of additional parameters for each pulled resource (of the plugin's type) for the current request.
|
Api |
getPluginApi(XWikiPluginInterface plugin,
XWikiContext context) |
protected Set<String> |
getPulledResources(XWikiContext context)
Get the list of pulled resources (of the plugin's type) for the current request.
|
protected org.xwiki.skinx.internal.async.SkinExtensionAsync |
getSkinExtensionAsync() |
abstract boolean |
hasPageExtensions(XWikiContext context)
Determines if the requested document contains on page skin extension objects of this type.
|
protected void |
initializeRequestListIfNeeded(XWikiContext context)
Initializes the list of pulled extensions corresponding to this request, if it wasn't already initialized.
|
protected String |
parametersAsQueryString(String resource,
XWikiContext context)
This method converts the parameters for an extension to a query string that can be used with
getURL() and printed in the
XHTML result. |
void |
restoreCacheResources(XWikiContext context,
com.xpn.xwiki.internal.cache.rendering.CachedItem.UsedExtension extension) |
protected String |
sanitize(String value)
Prevent "HTML Injection" by making sure the rendered text does not escape the current element.
|
void |
use(String resource,
Map<String,Object> parameters,
XWikiContext context)
Mark a skin extension document as used in the current result, together with some parameters.
|
void |
use(String resource,
XWikiContext context)
Mark a resource as used in the current result.
|
beginParsing, beginRendering, commonTagsHandler, downloadAttachment, endRendering, endRenderingHandler, flushCache, flushCache, getClassName, getLocalization, getName, init, insidePREHandler, localizePlainOrKey, outsidePREHandler, setClassName, setName, startRenderingHandler, virtualInit
protected static final String QUERY_PARAMETER_DELIMITER
protected final String contextKey
protected final String parametersContextKey
public AbstractSkinExtensionPlugin(String name, String className, XWikiContext context)
name
- The name of the plugin, which can be used for retrieving the plugin API from velocity. Unused.className
- The canonical classname of the plugin. Unused.context
- The current request context.XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
public abstract String getLink(String resource, XWikiContext context)
<script src="/path/to/Document">
, while CSS
uses <link rel="stylesheet" href="/path/to/Document">
(the actual syntax is longer, this is
just a simplified example).resource
- the name of the wiki document holding the resource.context
- the current request context, needed to access the URLFactory.String
representation of the linking element that should be printed in the generated HTML.public String getLink(String resource, Map<String,Object> parameters, XWikiContext context)
<script src="/path/to/Document">
, while CSS
uses <link rel="stylesheet" href="/path/to/Document">
(the actual syntax is longer, this is
just a simplified example).resource
- the name of the wiki document holding the resource.parameters
- the parameters associated with the resource.context
- the current request context, needed to access the URLFactory.String
representation of the linking element that should be printed in the generated HTML.public abstract Set<String> getAlwaysUsedExtensions(XWikiContext context)
context
- The current request context.public abstract boolean hasPageExtensions(XWikiContext context)
context
- the current request contextpublic Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
getPluginApi
in interface XWikiPluginInterface
getPluginApi
in class XWikiDefaultPlugin
public void use(String resource, XWikiContext context)
resource
- The name of the resource to pull.context
- The current request context.use(String, Map, XWikiContext)
public void use(String resource, Map<String,Object> parameters, XWikiContext context)
resource
- The name of the resource to pull.parameters
- The parameters for this resource.context
- The current request context.use(String, XWikiContext)
protected Set<String> getPulledResources(XWikiContext context)
context
- The current request context.protected Map<String,Map<String,Object>> getParametersMap(XWikiContext context)
context
- The current request context.protected void initializeRequestListIfNeeded(XWikiContext context)
context
- The current context where this list is stored.public String getImportString(XWikiContext context)
context
- The current request context.protected Map<String,Object> getParametersForResource(String resource, XWikiContext context)
resource
- The resource for which to retrieve the parameters.context
- The current request context.protected Object getParameter(String parameterName, String resource, XWikiContext context)
parameterName
- the name of the parameter to retrieveresource
- the resource for which to retrieve the parametercontext
- the current request contextnull
is returned.protected String parametersAsQueryString(String resource, XWikiContext context)
getURL()
and printed in the
XHTML result. The parameters separator is the escaped &. The query string already starts with an
& if at least one parameter exists.resource
- The pulled resource whose parameters should be converted.context
- The current request context.protected String sanitize(String value)
value
- The string to sanitize.public String endParsing(String content, XWikiContext context)
At the end of the request, insert the links to the pulled resources in the response, in the place marked by an XML comment of the format <!-- canonical.plugin.classname -->.
endParsing
in interface XWikiPluginInterface
endParsing
in class XWikiDefaultPlugin
XWikiDefaultPlugin.endParsing(String, XWikiContext)
public com.xpn.xwiki.internal.cache.rendering.CachedItem.UsedExtension getCacheResources(XWikiContext context)
getCacheResources
in interface com.xpn.xwiki.internal.cache.rendering.RenderingCacheAware
public void restoreCacheResources(XWikiContext context, com.xpn.xwiki.internal.cache.rendering.CachedItem.UsedExtension extension)
restoreCacheResources
in interface com.xpn.xwiki.internal.cache.rendering.RenderingCacheAware
protected org.xwiki.model.reference.EntityReferenceSerializer<String> getDefaultEntityReferenceSerializer()
protected org.xwiki.model.reference.DocumentReferenceResolver<String> getCurrentDocumentReferenceResolver()
protected org.xwiki.skinx.internal.async.SkinExtensionAsync getSkinExtensionAsync()
Copyright © 2004–2021 XWiki. All rights reserved.