001/*
002 *  Copyright 2010 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.cms.transformation.html;
017
018/**
019 * This class represent a enhancement to html 
020 */
021public class HTMLEnhancer
022{
023    private String _htmleditor2HtmlXSLT;
024    private String _html2HTMLEditorXSLT;
025    private String _html2HTMLXSLT;
026    private String _html2outgoingReferencesXSLT;
027    private String _html2HTMLHandler;
028    private String _htmleditor2HTMLHandler;
029    private String _html2HTMLEditorHandler;
030    
031    /**
032     * Create a HTML enhancer
033     * @param pluginName The name of the plugin declaring the enhancer
034     * @param htmleditor2HtmlXSLT The fullpath to the xslt file or relative to the current plugin
035     * @param html2HTMLEditorXSLT The fullpath to the xslt file or relative to the current plugin
036     * @param html2HTMLXSLT The fullpath to the xslt file or relative to the current plugin
037     * @param html2outgoingReferencesXSLT The fullpath to the xslt file or relative to the current plugin
038     * @param html2HTMLHandler The role of a component that implements EnhancementHandler
039     * @param htmleditor2HTMLHandler The role of a component that implements HTMLEditionHandler
040     * @param html2HTMLEditorHandler The role of a component that implements HTMLEditionHandler
041     */
042    public HTMLEnhancer(String pluginName, String htmleditor2HtmlXSLT, String html2HTMLEditorXSLT, String html2HTMLXSLT, String html2outgoingReferencesXSLT, String html2HTMLHandler, String htmleditor2HTMLHandler, String html2HTMLEditorHandler)
043    {
044        if (htmleditor2HtmlXSLT != null && htmleditor2HtmlXSLT.indexOf("://") == -1 && !htmleditor2HtmlXSLT.startsWith("/"))
045        {
046            _htmleditor2HtmlXSLT = "plugin:" + pluginName + "://" + htmleditor2HtmlXSLT;
047        }
048        else
049        {
050            _htmleditor2HtmlXSLT = htmleditor2HtmlXSLT;
051        }
052
053        if (html2HTMLEditorXSLT != null && html2HTMLEditorXSLT.indexOf("://") == -1 && !html2HTMLEditorXSLT.startsWith("/"))
054        {
055            _html2HTMLEditorXSLT = "plugin:" + pluginName + "://" + html2HTMLEditorXSLT;
056        }
057        else
058        {
059            _html2HTMLEditorXSLT = html2HTMLEditorXSLT;
060        }
061
062        if (html2HTMLXSLT != null && html2HTMLXSLT.indexOf("://") == -1 && !html2HTMLXSLT.startsWith("/"))
063        {
064            _html2HTMLXSLT = "plugin:" + pluginName + "://" + html2HTMLXSLT;
065        }
066        else
067        {
068            _html2HTMLXSLT = html2HTMLXSLT;
069        }
070        
071        if (html2outgoingReferencesXSLT != null && html2outgoingReferencesXSLT.indexOf("://") == -1 && !html2outgoingReferencesXSLT.startsWith("/"))
072        {
073            _html2outgoingReferencesXSLT = "plugin:" + pluginName + "://" + html2outgoingReferencesXSLT;
074        }
075        else
076        {
077            _html2outgoingReferencesXSLT = html2outgoingReferencesXSLT;
078        }
079        
080        _html2HTMLHandler = html2HTMLHandler;
081        _htmleditor2HTMLHandler = htmleditor2HTMLHandler;
082        _html2HTMLEditorHandler = html2HTMLEditorHandler;
083    }
084    
085    /**
086     * Get the xslt to use when transforming from htmleditor to html
087     * @return The fullpath to a xslt file
088     */
089    public String getHTMLEditor2HtmlX()
090    {
091        return _htmleditor2HtmlXSLT;
092    }
093
094    /**
095     * Get the xslt to use when transforming from html to htmleditor 
096     * @return The fullpath to a xslt file
097     */
098    public String getHtml2HTMLEditorXSLT()
099    {
100        return _html2HTMLEditorXSLT;
101    }
102
103    /**
104     * Get the xslt to use when transforming from html to outgoing references 
105     * @return The fullpath to a xslt file
106     */
107    public String getHtml2outgoingReferencesXSLT()
108    {
109        return _html2outgoingReferencesXSLT;
110    }
111
112    /**
113     * Get the xslt to use when transforming from html to html
114     * @return The fullpath to a xslt file
115     */
116    public String getHtml2HTMLXSLT()
117    {
118        return _html2HTMLXSLT;
119    }
120    
121    /**
122     * Get the component role to use when transforming from html to html
123     * @return The component role
124     */
125    public String getHtml2HTMLHandler()
126    {
127        return _html2HTMLHandler;
128    }
129
130    /**
131     * Get the component role to use when transforming from htmleditor to html
132     * @return The component role
133     */
134    public String getHtmleditor2HTMLHandler()
135    {
136        return _htmleditor2HTMLHandler;
137    }
138
139    /**
140     * Get the component role to use when transforming from html to htmleditor
141     * @return The component role
142     */
143    public String getHtml2HTMLEditorHandler()
144    {
145        return _html2HTMLEditorHandler;
146    }
147}