%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki"%>
<%@ page import="java.util.Properties"%>
<%@ page import="com.ecyrd.jspwiki.*" %>
<%@ page import="com.ecyrd.jspwiki.render.*" %>
<%@ page import="com.ecyrd.jspwiki.parser.JSPWikiMarkupParser" %>
<%@ page import="com.ecyrd.jspwiki.ui.*" %>
<%@ page import="org.apache.commons.lang.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%--
This provides the FCK editor for JSPWiki.
--%>
<% WikiContext context = WikiContext.findContext( pageContext );
context.setVariable( RenderingManager.WYSIWYG_EDITOR_MODE, Boolean.TRUE );
context.setVariable( WikiEngine.PROP_RUNFILTERS, "false" );
WikiPage wikiPage = context.getPage();
String originalCCLOption = (String)wikiPage.getAttribute( JSPWikiMarkupParser.PROP_CAMELCASELINKS );
wikiPage.setAttribute( JSPWikiMarkupParser.PROP_CAMELCASELINKS, "false" );
String usertext = EditorManager.getEditedText(pageContext);
TemplateManager.addResourceRequest( context, "script", "scripts/fckeditor/fckeditor.js" );
%>
<%
if( usertext == null )
{
usertext = context.getEngine().getPureText( context.getPage() );
}%>
<% if( usertext == null ) usertext = "";
WikiEngine engine = context.getEngine();
RenderingManager renderingManager = new RenderingManager();
// since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
Properties copyOfWikiProperties = new Properties();
copyOfWikiProperties.putAll( engine.getWikiProperties() );
copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
renderingManager.initialize( engine, copyOfWikiProperties );
String pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
// Disable the WYSIWYG_EDITOR_MODE and reset the other properties immediately
// after the XHTML for FCK has been rendered.
context.setVariable( RenderingManager.WYSIWYG_EDITOR_MODE, Boolean.FALSE );
context.setVariable( WikiEngine.PROP_RUNFILTERS, null );
wikiPage.setAttribute( JSPWikiMarkupParser.PROP_CAMELCASELINKS, originalCCLOption );
String templateDir = (String)copyOfWikiProperties.get( WikiEngine.PROP_TEMPLATEDIR );
String protocol = "http://";
if( request.isSecure() )
{
protocol = "https://";
}
%>