Package com.jalios.jcms.policy
Class BasicWysiwygPolicyFilter
- java.lang.Object
-
- com.jalios.jcms.policy.AbstractPolicyFilter
-
- com.jalios.jcms.policy.BasicWysiwygPolicyFilter
-
- All Implemented Interfaces:
PluginComponent
,PolicyFilter
,WysiwygPolicyFilter
,java.lang.Comparable
public class BasicWysiwygPolicyFilter extends AbstractPolicyFilter implements WysiwygPolicyFilter, PluginComponent
This class allow users to customize behaviour of widgets by re-writing call-back methods.- Since:
- jcms-5.5.0
- Version:
- $Revision: 101645 $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REVISION
-
Fields inherited from class com.jalios.jcms.policy.AbstractPolicyFilter
order
-
-
Constructor Summary
Constructors Constructor Description BasicWysiwygPolicyFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
afterClean(java.lang.String unsafeStr, java.lang.String safeStr, java.util.Map<java.lang.String,java.lang.Object> contextMap)
This method is called after cleaning process of a HTML input received from the user.java.lang.String
afterRendering(java.lang.String text, java.util.Locale userLocale)
This method is called after wysiwyg renderingvoid
beforeClean(java.lang.String unsafeStr, java.util.Map<java.lang.String,java.lang.Object> contextMap)
This method is called before cleaning process of a HTML input received from the user.java.lang.String
beforeRendering(java.lang.String text, java.util.Locale userLocale)
This method is called before wysiwyg renderingboolean
init(Plugin plugin)
Initialize the component with the given plugin configurationorg.jsoup.nodes.Document
processJHTML(org.jsoup.nodes.Document document, java.util.Locale userLocale, WysiwygRenderingHints hints)
This method is called during JHTML processingjava.util.List<WysiwygConfigurationUpdate>
updateWysiwygConfiguration(java.lang.String configId)
Returns the list of updates to perform to the wysiwyg configuration defined by the given id.-
Methods inherited from class com.jalios.jcms.policy.AbstractPolicyFilter
compareTo, equals, getOrder, setOrder
-
-
-
-
Field Detail
-
REVISION
public static final java.lang.String REVISION
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public boolean init(Plugin plugin)
Description copied from interface:PluginComponent
Initialize the component with the given plugin configuration- Specified by:
init
in interfacePluginComponent
- Parameters:
plugin
- the calling plugin- Returns:
- true if the component has been correctly initialized.
- Since:
- jcms-5.7.1
- See Also:
PluginComponent.init(Plugin)
-
beforeRendering
public java.lang.String beforeRendering(java.lang.String text, java.util.Locale userLocale)
Description copied from interface:WysiwygPolicyFilter
This method is called before wysiwyg rendering- Specified by:
beforeRendering
in interfaceWysiwygPolicyFilter
- Parameters:
text
- the text to be rendered.userLocale
- an optionalLocale
of the user for which the text will be generated- Returns:
- the text.
- See Also:
WysiwygPolicyFilter.beforeRendering(String, Locale)
-
afterRendering
public java.lang.String afterRendering(java.lang.String text, java.util.Locale userLocale)
Description copied from interface:WysiwygPolicyFilter
This method is called after wysiwyg rendering- Specified by:
afterRendering
in interfaceWysiwygPolicyFilter
- Parameters:
text
- the text after the rendering.userLocale
- an optionalLocale
of the user for which the text will be generated- Returns:
- the text.
- See Also:
WysiwygPolicyFilter.afterRendering(String, Locale)
-
processJHTML
public org.jsoup.nodes.Document processJHTML(org.jsoup.nodes.Document document, java.util.Locale userLocale, WysiwygRenderingHints hints)
Description copied from interface:WysiwygPolicyFilter
This method is called during JHTML processing- Specified by:
processJHTML
in interfaceWysiwygPolicyFilter
- Parameters:
document
- the JSoup document of the HTML to be rendered.userLocale
- an optionalLocale
of the user for which the text will be generatedhints
- the rendering options to use.- Returns:
- the document.
- See Also:
WysiwygPolicyFilter.processJHTML(Document, Locale, WysiwygRenderingHints)
-
beforeClean
public void beforeClean(java.lang.String unsafeStr, java.util.Map<java.lang.String,java.lang.Object> contextMap)
Description copied from interface:WysiwygPolicyFilter
This method is called before cleaning process of a HTML input received from the user.In current implementation, the following informations can be retrieved or modified from the context map :
-
Data instance on which cleaning is performed (can be null) :
Data data = (Data) contextMap.get(WysiwygManager.CLEANHTML_CTXT_DATA)
-
Data's field name on which cleaning is performed, as described in type xml, eg "myWysiwygField" (can be null) :
String fieldName = (String) contextMap.get(WysiwygManager.CLEANHTML_CTXT_FIELDNAME)
-
The JSoup Safelist that will be used for the cleaning process :
Safelist safelist = (org.jsoup.safety.Safelist) contextMap.get(WysiwygManager.CLEANHTML_CTXT_SAFELIST)
Your WysiwygPolicyFilter implementation can set a custom Safelist for this key if you want to apply a stricter or relaxed policy in some circumstances.
Set tonull
to cancel the cleaning process (ie HTML parsing and cleaning), in such case, methodWysiwygPolicyFilter.afterClean(String, String, Map)
will still be invoked.
- Specified by:
beforeClean
in interfaceWysiwygPolicyFilter
- Parameters:
unsafeStr
- the input received from the usercontextMap
- the map providing information on cleaning context, NEVER null- See Also:
WysiwygPolicyFilter.beforeClean(String, Map)
-
Data instance on which cleaning is performed (can be null) :
-
afterClean
public java.lang.String afterClean(java.lang.String unsafeStr, java.lang.String safeStr, java.util.Map<java.lang.String,java.lang.Object> contextMap)
Description copied from interface:WysiwygPolicyFilter
This method is called after cleaning process of a HTML input received from the user.In current implementation, the following informations can be retrieved or modified from the context map :
-
Data instance on which cleaning is performed (can be null) :
Data data = (Data) contextMap.get(WysiwygManager.CLEANHTML_CTXT_DATA);
-
Data's field name on which cleaning is performed, as described in type xml, eg "myWysiwygField" (can be null) :
String fieldName = (String) contextMap.get(WysiwygManager.CLEANHTML_CTXT_FIELDNAME);
-
The JSoup Safelist that was used for the cleaning process :
Safelist safelist = (org.jsoup.safety.Safelist) contextMap.get(WysiwygManager.CLEANHTML_CTXT_SAFELIST);
Can be null if a custom WysiwygPolicyFilter has cancelled the cleaning process. -
The JSoup Document instance that was created by parsing input :
Document dirtyDoc = (org.jsoup.nodes.Document) contextMap.get(WysiwygManager.CLEANHTML_CTXT_DIRTYDOC);
Can be null if a custom WysiwygPolicyFilter has cancelled the cleaning process. -
The JSoup Document instance that was created by cleaned the dirty document :
Document cleanDoc = (org.jsoup.nodes.Document) contextMap.get(WysiwygManager.CLEANHTML_CTXT_CLEANDOC);
Can be null if a custom WysiwygPolicyFilter has cancelled the cleaning process.
- Specified by:
afterClean
in interfaceWysiwygPolicyFilter
- Parameters:
unsafeStr
- the input received from the usersafeStr
- the input cleaned by JCMS (unless it was cancelled inWysiwygPolicyFilter.beforeClean(String, Map)
)contextMap
- the map providing information on cleaning context, NEVER null- Returns:
- the cleaned HTML
- See Also:
WysiwygPolicyFilter.afterClean(String, String, Map)
-
Data instance on which cleaning is performed (can be null) :
-
updateWysiwygConfiguration
public java.util.List<WysiwygConfigurationUpdate> updateWysiwygConfiguration(java.lang.String configId)
Description copied from interface:WysiwygPolicyFilter
Returns the list of updates to perform to the wysiwyg configuration defined by the given id.- Specified by:
updateWysiwygConfiguration
in interfaceWysiwygPolicyFilter
- Parameters:
configId
- configuration id- Returns:
- List of
WysiwygConfigurationUpdate
- See Also:
WysiwygPolicyFilter.updateWysiwygConfiguration(String)
-
-