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.docbook; 017 018/** 019 * This class represent a enhancement to docbook 020 */ 021public class DocbookEnhancer 022{ 023 private String _htmleditor2DocbookXSLT; 024 private String _docbook2HTMLEditorXSLT; 025 private String _docbook2outgoingReferencesXSLT; 026 private String _docbook2HTMLXSLT; 027 private String _docbook2MDXSLT; 028 private String _docbook2HTMLHandler; 029 private String _docbook2MDHandler; 030 private String _htmleditor2docbookHandler; 031 private String _docbook2htmleditorHandler; 032 033 /** 034 * Create a docbook enhancer 035 * @param pluginName The name of the plugin declaring the enhancer 036 * @param htmleditor2DocbookXSLT The fullpath to the xslt file or relative to the current plugin 037 * @param docbook2HTMLEditorXSLT The fullpath to the xslt file or relative to the current plugin 038 * @param docbook2HTMLXSLT The fullpath to the xslt file or relative to the current plugin 039 * @param docbook2MDXSLT The fullpath to the xslt file or relative to the current plugin 040 * @param docbook2outgoingReferencesXSLT The fullpath to the xslt file or relative to the current plugin 041 * @param docbook2MDHandler The role of a component that implements EnhancementTransformer 042 * @param docbook2HTMLHandler The role of a component that implements EnhancementTransformer 043 * @param htmleditor2DocbookHandler The role of a component that implements EnhancementTransformer 044 * @param docbook2htmleditorHandler The role of a component that implements EnhancementTransformer 045 */ 046 public DocbookEnhancer(String pluginName, String htmleditor2DocbookXSLT, String docbook2HTMLEditorXSLT, String docbook2HTMLXSLT, String docbook2MDXSLT, String docbook2outgoingReferencesXSLT, String docbook2HTMLHandler, String docbook2MDHandler, String htmleditor2DocbookHandler, String docbook2htmleditorHandler) 047 { 048 if (htmleditor2DocbookXSLT != null && htmleditor2DocbookXSLT.indexOf("://") == -1 && !htmleditor2DocbookXSLT.startsWith("/")) 049 { 050 _htmleditor2DocbookXSLT = "plugin:" + pluginName + "://" + htmleditor2DocbookXSLT; 051 } 052 else 053 { 054 _htmleditor2DocbookXSLT = htmleditor2DocbookXSLT; 055 } 056 057 _docbook2HTMLEditorXSLT = _absolutize(docbook2HTMLEditorXSLT, pluginName); 058 _docbook2HTMLXSLT = _absolutize(docbook2HTMLXSLT, pluginName); 059 _docbook2MDXSLT = _absolutize(docbook2MDXSLT, pluginName); 060 _docbook2outgoingReferencesXSLT = _absolutize(docbook2outgoingReferencesXSLT, pluginName); 061 062 _docbook2HTMLHandler = docbook2HTMLHandler; 063 _docbook2MDHandler = docbook2MDHandler; 064 _htmleditor2docbookHandler = htmleditor2DocbookHandler; 065 _docbook2htmleditorHandler = docbook2htmleditorHandler; 066 } 067 068 private String _absolutize(String url, String pluginName) 069 { 070 if (url != null && url.indexOf("://") == -1 && !url.startsWith("/")) 071 { 072 return "plugin:" + pluginName + "://" + url; 073 } 074 else 075 { 076 return url; 077 } 078 } 079 080 /** 081 * Get the xslt to use when transforming from htmleditor to docbook 082 * @return The fullpath to a xslt file 083 */ 084 public String getHTMLEditor2DocbookXSLT() 085 { 086 return _htmleditor2DocbookXSLT; 087 } 088 089 /** 090 * Get the xslt to use when transforming from docbook to htmleditor 091 * @return The fullpath to a xslt file 092 */ 093 public String getDocbook2HTMLEditorXSLT() 094 { 095 return _docbook2HTMLEditorXSLT; 096 } 097 098 /** 099 * Get the xslt to use when transforming from docbook to html 100 * @return The fullpath to a xslt file 101 */ 102 public String getDocbook2HTMLXSLT() 103 { 104 return _docbook2HTMLXSLT; 105 } 106 107 /** 108 * Get the xslt to use when transforming from docbook to markdown 109 * @return The fullpath to a xslt file 110 */ 111 public String getDocbook2MDXSLT() 112 { 113 return _docbook2MDXSLT; 114 } 115 116 /** 117 * Get the xslt to use when transforming from docbook to html 118 * @return The fullpath to a xslt file 119 */ 120 public String getDocbook2outgoingReferencesXSLT() 121 { 122 return _docbook2outgoingReferencesXSLT; 123 } 124 125 /** 126 * Get the component role to use when transforming from docbook to html 127 * @return The component role 128 */ 129 public String getDocbook2HTMLHandler() 130 { 131 return _docbook2HTMLHandler; 132 } 133 134 /** 135 * Get the component role to use when transforming from docbook to markdown 136 * @return The component role 137 */ 138 public String getDocbook2MDHandler() 139 { 140 return _docbook2MDHandler; 141 } 142 143 /** 144 * Get the component role to use when transforming from htmleditor to docbook 145 * @return The component role 146 */ 147 public String getHTMLEditor2DocbookHandler() 148 { 149 return _htmleditor2docbookHandler; 150 } 151 152 /** 153 * Get the component role to use when transforming from docbook to htmleditor 154 * @return The component role 155 */ 156 public String getDocbook2HTMLEditorHandler() 157 { 158 return _docbook2htmleditorHandler; 159 } 160}