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    
030    /**
031     * Create a HTML enhancer
032     * @param pluginName The name of the plugin declaring the enhancer
033     * @param htmleditor2HtmlXSLT The fullpath to the xslt file or relative to the current plugin
034     * @param html2HTMLEditorXSLT The fullpath to the xslt file or relative to the current plugin
035     * @param html2HTMLXSLT The fullpath to the xslt file or relative to the current plugin
036     * @param html2outgoingReferencesXSLT The fullpath to the xslt file or relative to the current plugin
037     * @param html2HTMLHandler The role of a component that implements EnhancementHandler
038     * @param htmleditor2HTMLHandler The role of a component that implements HTMLEditionHandler
039     */
040    public HTMLEnhancer(String pluginName, String htmleditor2HtmlXSLT, String html2HTMLEditorXSLT, String html2HTMLXSLT, String html2outgoingReferencesXSLT, String html2HTMLHandler, String htmleditor2HTMLHandler)
041    {
042        if (htmleditor2HtmlXSLT != null && htmleditor2HtmlXSLT.indexOf("://") == -1 && !htmleditor2HtmlXSLT.startsWith("/"))
043        {
044            _htmleditor2HtmlXSLT = "plugin:" + pluginName + "://" + htmleditor2HtmlXSLT;
045        }
046        else
047        {
048            _htmleditor2HtmlXSLT = htmleditor2HtmlXSLT;
049        }
050
051        if (html2HTMLEditorXSLT != null && html2HTMLEditorXSLT.indexOf("://") == -1 && !html2HTMLEditorXSLT.startsWith("/"))
052        {
053            _html2HTMLEditorXSLT = "plugin:" + pluginName + "://" + html2HTMLEditorXSLT;
054        }
055        else
056        {
057            _html2HTMLEditorXSLT = html2HTMLEditorXSLT;
058        }
059
060        if (html2HTMLXSLT != null && html2HTMLXSLT.indexOf("://") == -1 && !html2HTMLXSLT.startsWith("/"))
061        {
062            _html2HTMLXSLT = "plugin:" + pluginName + "://" + html2HTMLXSLT;
063        }
064        else
065        {
066            _html2HTMLXSLT = html2HTMLXSLT;
067        }
068        
069        if (html2outgoingReferencesXSLT != null && html2outgoingReferencesXSLT.indexOf("://") == -1 && !html2outgoingReferencesXSLT.startsWith("/"))
070        {
071            _html2outgoingReferencesXSLT = "plugin:" + pluginName + "://" + html2outgoingReferencesXSLT;
072        }
073        else
074        {
075            _html2outgoingReferencesXSLT = html2outgoingReferencesXSLT;
076        }
077        
078        _html2HTMLHandler = html2HTMLHandler;
079        _htmleditor2HTMLHandler = htmleditor2HTMLHandler;
080    }
081    
082    /**
083     * Get the xslt to use when transforming from htmleditor to html
084     * @return The fullpath to a xslt file
085     */
086    public String getHTMLEditor2HtmlX()
087    {
088        return _htmleditor2HtmlXSLT;
089    }
090
091    /**
092     * Get the xslt to use when transforming from html to htmleditor 
093     * @return The fullpath to a xslt file
094     */
095    public String getHtml2HTMLEditorXSLT()
096    {
097        return _html2HTMLEditorXSLT;
098    }
099
100    /**
101     * Get the xslt to use when transforming from html to outgoing references 
102     * @return The fullpath to a xslt file
103     */
104    public String getHtml2outgoingReferencesXSLT()
105    {
106        return _html2outgoingReferencesXSLT;
107    }
108
109    /**
110     * Get the xslt to use when transforming from html to html
111     * @return The fullpath to a xslt file
112     */
113    public String getHtml2HTMLXSLT()
114    {
115        return _html2HTMLXSLT;
116    }
117    
118    /**
119     * Get the component role to use when transforming from html to html
120     * @return The component role
121     */
122    public String getHtml2HTMLHandler()
123    {
124        return _html2HTMLHandler;
125    }
126
127    /**
128     * Get the component role to use when transforming from htmleditor to html
129     * @return The component role
130     */
131    public String getHtmleditor2HTMLHandler()
132    {
133        return _htmleditor2HTMLHandler;
134    }
135}