diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java index db57dbfe6..fdeea0b45 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java @@ -239,8 +239,19 @@ public final class CMSConfig extends AbstractConfig { m_dhtmlEditorConfig = new DHTMLEditorConfigParameter ("com.arsdigita.cms.dhtml_editor_config", - Parameter.REQUIRED, - DHTMLEditor.Config.STANDARD); + Parameter.REQUIRED, + new DHTMLEditor.Config( "XinhaConfig", + "/assets/xinha/CCMcmsXinhaConfig.js") ); + // previous parameter definition: + // > DHTMLEditor.Config.STANDARD); < + // didn't work because of broken unmarshalling (cf. similiar problem + // with ResourceParameter and patch provided by Brad). It work for + // HTMLArea, because configuration was hard coded into xsl(!). + // Additionally, we would like to use a specific configuration for cms + // to include cms specific functions (like access to internal . + // content items for links and internal image assets, which may not + // be accessable by other modules which use DHTMLeditor. + // Would be bad style to configure a cms specific parameter in core. m_dhtmlEditorPlugins = new StringArrayParameter ("com.arsdigita.cms.dhtml_editor_plugins", @@ -629,13 +640,32 @@ public final class CMSConfig extends AbstractConfig { + /** + * Internal class representing a DHTMLEditor configuration parameter. It + * creates a new DHMTLEditor Config object (internal class in DHTMLEditor). + * + * XXX Method unmarshal is broken and currently does not work correctly. It + * does not process default values provided by using + * DHTMLEditor.Config.Standard (see parameter m_dhtmlEditorConfig above). + * May be a similiar problem as with ResourceParameter and default value, + * see patch provided by pbrucha. + * Best solution may be to remove this special parameter class and use a + * string parameter instead to directly create a DHTMLEditor.Config object. + * (pboy, 2010-09-02) + */ private class DHTMLEditorConfigParameter extends StringParameter { public DHTMLEditorConfigParameter(final String name, final int multiplicity, final Object defaultObj) { super(name, multiplicity, defaultObj); } - + + /** + * WARNING: Does not correctly process default values, see above! + * @param value + * @param errors + * @return + */ @Override protected Object unmarshal(String value, ErrorList errors) { return DHTMLEditor.Config.valueOf(value); diff --git a/ccm-cms/web/assets/Xinha/CCMcmsXinhaConfig.js b/ccm-cms/web/assets/Xinha/CCMcmsXinhaConfig.js new file mode 100644 index 000000000..040eab53d --- /dev/null +++ b/ccm-cms/web/assets/Xinha/CCMcmsXinhaConfig.js @@ -0,0 +1,22 @@ +/* This is the OpenCCM default Xinha configuration file. It provides basic funcionality * + * which might be used by any CCM module. A module may provide its own configuration * + * file during Xinha loading or may extend com.arsdigita.bebop.form.DHTMLEditor as * + * ccm-cms does (com.arsdigita.cms.CMSDHTMLEditor) to provide extensive configuration * + * options. */ +/* It is based on the original configuration file XinhaConfig.js (compressed version) */ +/* http://svn.xinha.webfactional.com/trunk/examples/XinhaConfig.js */ +xinha_init=null; +xinha_config=null; +xinha_init=xinha_init?xinha_init:function(){ +xinha_editors=xinha_editors?xinha_editors:["myTextArea","anotherOne"]; +xinha_plugins=xinha_plugins?xinha_plugins:["CharacterMap","ContextMenu","SmartReplace","Stylist","TableOperations"]; +if(!Xinha.loadPlugins(xinha_plugins,xinha_init)){ +return; +} +xinha_config=xinha_config?xinha_config():new Xinha.Config(); +xinha_config.pageStyleSheets=[_editor_url+"examples/full_example.css"]; +xinha_editors=Xinha.makeEditors(xinha_editors,xinha_config,xinha_plugins); +Xinha.startEditors(xinha_editors); +}; +Xinha.addOnloadHandler(xinha_init); + diff --git a/ccm-core/src/com/arsdigita/bebop/BebopConfig.java b/ccm-core/src/com/arsdigita/bebop/BebopConfig.java index 908783057..b9d07ee4c 100755 --- a/ccm-core/src/com/arsdigita/bebop/BebopConfig.java +++ b/ccm-core/src/com/arsdigita/bebop/BebopConfig.java @@ -42,12 +42,15 @@ public final class BebopConfig extends AbstractConfig { private final Parameter m_presenter; private final Parameter m_page; + /** Pointer to JTidy validation listener config file */ private final Parameter m_tidy; private final Parameter m_fancyErrors; private final Parameter m_dcpOnButtons; private final Parameter m_dcpOnLinks; private final Parameter m_enableTreeSelect; + /** List of supported DHTML editors, first one is default (Xinha) */ private final EnumerationParameter m_dhtmlEditor; + /** Path to DHTML editor source file, relativ to document root */ private final Parameter m_dhtmlEditorSrcFile; private final Parameter m_showClassName; @@ -59,6 +62,7 @@ public final class BebopConfig extends AbstractConfig { m_page = new ClassParameter ("waf.bebop.base_page", Parameter.REQUIRED, SimplePage.class); + /* Pointer to JTidy validation listener config file */ m_tidy = new StringParameter ("waf.bebop.tidy_config_file", Parameter.REQUIRED, "com/arsdigita/bebop/parameters/tidy.properties"); @@ -73,13 +77,16 @@ public final class BebopConfig extends AbstractConfig { Parameter.REQUIRED, Boolean.FALSE); - m_dhtmlEditor = new EnumerationParameter("waf.bebop.dhtml_editor", - Parameter.REQUIRED,BebopConstants.BEBOP_DHTMLEDITOR); - // HTMLArea for compatibility with old XSL - m_dhtmlEditor.put("HTMLArea", BebopConstants.BEBOP_DHTMLEDITOR); - m_dhtmlEditor.put("FCKeditor", BebopConstants.BEBOP_FCKEDITOR); + /** List of supported DHTML editors, first one is default (Xinha) */ + m_dhtmlEditor = new EnumerationParameter("waf.bebop.dhtml_editor", + Parameter.REQUIRED,BebopConstants.BEBOP_XINHAEDITOR); +// Parameter.REQUIRED,BebopConstants.BEBOP_DHTMLEDITOR); m_dhtmlEditor.put("Xinha", BebopConstants.BEBOP_XINHAEDITOR); + m_dhtmlEditor.put("FCKeditor", BebopConstants.BEBOP_FCKEDITOR); + // HTMLArea for backwards compatibility with old XSL. to be removed soon! + m_dhtmlEditor.put("HTMLArea", BebopConstants.BEBOP_DHTMLEDITOR); + // Xinha is now default! m_dhtmlEditorSrcFile = new StringParameter ("waf.bebop.dhtml_editor_src", Parameter.REQUIRED, "/assets/xinha/XinhaLoader.js"); @@ -140,10 +147,16 @@ public final class BebopConfig extends AbstractConfig { return ((Boolean) get(m_enableTreeSelect)).booleanValue(); } + /** + * Gets the DHTML editor to use + */ public final String getDHTMLEditor() { return (String) get(m_dhtmlEditor); } + /** + * Gets the location of DHTML editor's xource file + */ public final String getDHTMLEditorSrcFile() { return (String) get(m_dhtmlEditorSrcFile); } diff --git a/ccm-core/src/com/arsdigita/bebop/BebopConfig_parameter.properties b/ccm-core/src/com/arsdigita/bebop/BebopConfig_parameter.properties index 35087582a..f42f02df5 100755 --- a/ccm-core/src/com/arsdigita/bebop/BebopConfig_parameter.properties +++ b/ccm-core/src/com/arsdigita/bebop/BebopConfig_parameter.properties @@ -31,7 +31,7 @@ waf.bebop.dcp_on_links.format=[boolean] waf.bebop.dhtml_editor.title=DHTML editor implementation waf.bebop.dhtml_editor.purpose=Select which DHTML text input widget is used for DHTMLEditor Bebop component. waf.bebop.dhtml_editor.example=FCKeditor -waf.bebop.dhtml_editor.format=HTMLArea|FCKeditor|Xinha +waf.bebop.dhtml_editor.format=Xinha|FCKeditor|HTMLArea waf.bebop.dhtml_editor_src.title=Relative path to the source javascript file waf.bebop.dhtml_editor_src.purpose=Relative path to the source javascript file diff --git a/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java b/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java index f0d4249d2..5d2fa8fbf 100755 --- a/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java +++ b/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java @@ -32,11 +32,12 @@ import com.arsdigita.xml.Element; /** * Displays and manages a WYSIWYG HTML editor that takes advantage of * DHTML scripting features. - * This class can use the HTMLArea - * http://women.cs.uiuc.edu/htmlarea/ - * or FCKeditor http://www.fckeditor.net. + * This class can use: + * - FCKeditor + * - HTMLarea for backwards compatibility, development discontinued * Editor is choosen based on the config parameter waf.bebop.dhtml_editor, - * default is "HTMLArea" for compatibility reasons. + * default is "Xinha", which is the successor of HTNLarea * * @author Jim Parsons * @author Richard Li @@ -73,9 +74,19 @@ public class DHTMLEditor extends TextArea { * for a description of what this attribute does. */ public static final int SOFT = 2; + + /** + * Config objects for supported DHTMP editors + */ public static class Config { - public static final Config STANDARD = new Config("HTMLArea.Config", null); + + // WARNING: Processing of these default values by CMSConfig does NOT + // work correctly because of deviciencies in unmarshal method there. + + public static final Config STANDARD = + new Config("Xinha.Config", + "/assets/xinha/CCMcoreXinhaConfig.js"); /** Example FCKEditor configuration. */ public static final Config FCK_STANDARD = @@ -86,6 +97,10 @@ public class DHTMLEditor extends TextArea { new Config("FCKEditor.Config.StyleCMSAdmin", "/assets/fckeditor/config/fckconfigstylecmsadmin.js"); + /** Example old HTMLarea configuration. */ + public static final Config HTMLAREA = + new Config("HTMLArea.Config", null); + private String m_name; private String m_path; @@ -123,20 +138,34 @@ public class DHTMLEditor extends TextArea { return m_name + "," + m_path; } } - } + } //end config object(s) private Config m_config; private Set m_plugins; private Set m_hiddenButtons; + /** + * Constructor + * + * @param name + */ public DHTMLEditor(String name) { this(new StringParameter(name)); } + /** + * Constructor + * @param model + */ public DHTMLEditor(ParameterModel model) { this(model, Config.STANDARD); } + /** + * Constructor + * @param model + * @param config + */ public DHTMLEditor(ParameterModel model, Config config) { super(model); @@ -176,6 +205,7 @@ public class DHTMLEditor extends TextArea { public void addPlugin(String name) { m_plugins.add(name); } + /** * Prevent the specified button from being displayed in the editor toolbar. * @param name name of the button, as specified in the btnList of the htmlarea.js file diff --git a/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java b/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java index 45885d076..d45aeada2 100755 --- a/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java +++ b/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java @@ -70,7 +70,7 @@ public class ResourceParameter extends AbstractParameter { * * Developers note: * This makes the trick to use Parameter.java interface rsp AbstractParameter - * for other types of parameter as Strint. If you don't overwrite this + * for other types of parameter as String. If you don't overwrite this * method, you will always get a casting error, because the parameter * returns a string instead of the intended object! * diff --git a/ccm-core/web/assets/xinha/CCMcoreXinhaConfig.js b/ccm-core/web/assets/xinha/CCMcoreXinhaConfig.js new file mode 100644 index 000000000..040eab53d --- /dev/null +++ b/ccm-core/web/assets/xinha/CCMcoreXinhaConfig.js @@ -0,0 +1,22 @@ +/* This is the OpenCCM default Xinha configuration file. It provides basic funcionality * + * which might be used by any CCM module. A module may provide its own configuration * + * file during Xinha loading or may extend com.arsdigita.bebop.form.DHTMLEditor as * + * ccm-cms does (com.arsdigita.cms.CMSDHTMLEditor) to provide extensive configuration * + * options. */ +/* It is based on the original configuration file XinhaConfig.js (compressed version) */ +/* http://svn.xinha.webfactional.com/trunk/examples/XinhaConfig.js */ +xinha_init=null; +xinha_config=null; +xinha_init=xinha_init?xinha_init:function(){ +xinha_editors=xinha_editors?xinha_editors:["myTextArea","anotherOne"]; +xinha_plugins=xinha_plugins?xinha_plugins:["CharacterMap","ContextMenu","SmartReplace","Stylist","TableOperations"]; +if(!Xinha.loadPlugins(xinha_plugins,xinha_init)){ +return; +} +xinha_config=xinha_config?xinha_config():new Xinha.Config(); +xinha_config.pageStyleSheets=[_editor_url+"examples/full_example.css"]; +xinha_editors=Xinha.makeEditors(xinha_editors,xinha_config,xinha_plugins); +Xinha.startEditors(xinha_editors); +}; +Xinha.addOnloadHandler(xinha_init); +