Package com.ecyrd.jspwiki

Examples of com.ecyrd.jspwiki.WikiContext


        {
            // See similar note in PluginContent
            return m_varName;
        }
       
        WikiContext context = root.getContext();

        if( context == null )
            return "No WikiContext available: INTERNAL ERROR";
   
        Boolean wysiwygEditorMode = (Boolean)context.getVariable(RenderingManager.WYSIWYG_EDITOR_MODE);
       
        if( wysiwygEditorMode != null && wysiwygEditorMode.booleanValue() )
        {
            result = "[" + m_varName + "]";
        }
        else
        {
            try
            {
                result = context.getEngine().getVariableManager().parseAndGetValue( context, m_varName );
            }
            catch( NoSuchVariableException e )
            {
                result = JSPWikiMarkupParser.makeError("No such variable: "+e.getMessage()).getText();
            }
View Full Code Here


            //
           
            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();
            }
        }
View Full Code Here

    protected void setUp() throws Exception
    {
        Properties props = new Properties();
        props.load( TestEngine.findTestProperties() );
        testEngine = new TestEngine( props );
        WikiContext context = new WikiContext( testEngine, new WikiPage(testEngine,"dummyPage"));
        val = new InputValidator( TEST, context );
    }
View Full Code Here

    }

    private String render(String s) throws IOException
    {
        WikiPage dummyPage = new WikiPage(m_testEngine,"TestPage");
        WikiContext ctx = new WikiContext(m_testEngine,dummyPage);
       
        StringReader in = new StringReader(s);
       
        JSPWikiMarkupParser p = new JSPWikiMarkupParser( ctx, in );
        WikiDocument d = p.parse();
View Full Code Here

    private String translate( String src )
        throws IOException,
               NoRequiredPropertyException,
               ServletException
    {
        WikiContext context = new WikiContext( testEngine,
                                               new WikiPage(testEngine, "TestPage") );
       
        MarkupParser p = new JSPWikiMarkupParser( context, new StringReader(src) );
       
        WikiDocument dom = p.parse();
View Full Code Here

    }

    private String render(String s) throws IOException
    {
        WikiPage dummyPage = new WikiPage(m_testEngine,"TestPage");
        WikiContext ctx = new WikiContext(m_testEngine,dummyPage);

        StringReader in = new StringReader(s);

        JSPWikiMarkupParser p = new JSPWikiMarkupParser( ctx, in );
        WikiDocument d = p.parse();
View Full Code Here

        newPage = plugin.getNewEntryPage( m_testEngine, "TestBlog" );
        m_testEngine.saveText( newPage, "!Title2\r\n__Bar__" );

        RSSGenerator gen = m_testEngine.getRSSGenerator();

        WikiContext context = new WikiContext( m_testEngine, m_testEngine.getPage("TestBlog") );

        WeblogPlugin blogplugin = new WeblogPlugin();

        List entries = blogplugin.findBlogEntries( m_testEngine.getPageManager(),
                                                   "TestBlog",
View Full Code Here

        newPage = plugin.getNewEntryPage( m_testEngine, "TestBlog" );
        m_testEngine.saveText( newPage, "!Title2\r\n__Bar__" );

        RSSGenerator gen = m_testEngine.getRSSGenerator();

        WikiContext context = new WikiContext( m_testEngine, m_testEngine.getPage("TestBlog") );

        WeblogPlugin blogplugin = new WeblogPlugin();

        List entries = blogplugin.findBlogEntries( m_testEngine.getPageManager(),
                                                   "TestBlog",
View Full Code Here

        String txt = "It was the dawn of the third age of mankind, ten years after the Earth-Minbari War.";
        MockHttpServletRequest request = m_engine.newHttpRequest();
        request.getParameterMap().put( "page", new String[]{ "TestPage" } );
       
        WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
       
        m_engine.saveText( ctx, txt );

        m_engine.saveText( ctx, "The Babylon Project was a dream given form. Its goal: to prevent another war by creating a place where humans and aliens could work out their differences peacefully." );
    
View Full Code Here

*
* @throws Exception
*/
public void testSimple() throws Exception
{
    context = new WikiContext( engine, new WikiPage(engine,"TestPage01") );

    String res = manager.execute( context, "{INSERT com.ecyrd.jspwiki.plugin.RecentChangesPlugin}" );

    // we don't want to compare the complete html returned, but check if certain Strings are present and other
    // Strings are not present
View Full Code Here

TOP

Related Classes of com.ecyrd.jspwiki.WikiContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.