//
return getPluginName();
}
WikiContext context = doc.getContext();
Boolean wysiwygVariable = (Boolean)context.getVariable( RenderingManager.WYSIWYG_EDITOR_MODE );
boolean wysiwygEditorMode = false;
if( wysiwygVariable != null )
{
wysiwygEditorMode = wysiwygVariable.booleanValue();
}
try
{
//
// Determine whether we should emit the actual code for this plugin or
// whether we should execute it. For some plugins we always execute it,
// since they can be edited visually.
//
// FIXME: The plugin name matching should not be done here, but in a per-editor resource
if( wysiwygEditorMode
&& !m_pluginName.matches( EMITTABLE_PLUGINS ) )
{
result = PLUGIN_START + m_pluginName + SPACE;
// convert newlines to <br> in case the plugin has a body.
String cmdLine = ( (String)m_params.get( CMDLINE ) ).replaceAll( LINEBREAK, ELEMENT_BR );
result = result + cmdLine + PLUGIN_END;
}
else
{
Boolean b = (Boolean)context.getVariable( RenderingManager.VAR_EXECUTE_PLUGINS );
if( b != null && !b.booleanValue() ) return BLANK;
WikiEngine engine = context.getEngine();
HashMap<String,Object> parsedParams = new HashMap<String,Object>();
//
// Parse any variable instances from the string
//
for( Map.Entry e : m_params.entrySet() )
{
Object val = e.getValue();
if( val instanceof String )
{
val = engine.getVariableManager().expandVariables( context, (String)val );
}
parsedParams.put( (String)e.getKey(), val );
}
result = engine.getPluginManager().execute( context,
m_pluginName,
parsedParams );
}
}
catch( Exception e )
{
if( wysiwygEditorMode )
{
result = "";
}
else
{
// log.info("Failed to execute plugin",e);
ResourceBundle rb = context.getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
Object[] args = { e.getMessage() };
result = JSPWikiMarkupParser.makeError(
MessageFormat.format( rb.getString( "plugin.error.insertionfailed" ), args ) ).getText();
}
}