1 package de.webman.generator; 2 3 import com.teamkonzept.lib.*; 4 import com.teamkonzept.lib.templates.TemplateTypes; 5 import com.teamkonzept.web.*; 6 7 import com.oroinc.text.regex.*; 8 import org.w3c.dom.*; 9 import de.webman.util.legacy.Legacy; 10 11 16 public class GenDocumentStatics implements TemplateTypes 17 { 18 19 22 private GeneratorContext context; 23 24 25 private TKHashtable genDocumentHash = new TKHashtable(); 26 private TKHashtable expandedGenDocs = new TKHashtable(); 27 28 private static boolean initialized = false; 29 static protected final String PAT_PRE_TAG = "TKK[_:]"; 30 public static Pattern patPostCompileTKTag; 31 32 33 public GenDocumentStatics (GeneratorContext context) 34 { 35 this.context = context != null ? context : GeneratorContext.setup (); 36 39 } 40 41 public void putExpandedGenDoc(String path, Object value) 42 { 43 expandedGenDocs.put(path, value); 44 } 45 46 50 public Object getDocumentExpanded(String path) 51 { 52 return expandedGenDocs.get(path); 53 } 54 55 public void putGeneratedDocument(String id, GenDocument value) 56 { 57 genDocumentHash.put(id, value); 58 } 59 60 63 public GenDocument getGeneratedDocument(String id) 64 { 65 return (GenDocument)genDocumentHash.get(id); 66 } 67 68 public final void fillReferenceIntoTemplate( 69 TemplateBasic t, 70 DOMTemplateData domData, 71 String url, 72 GenNode destNode, 73 GenNode srcNode, 74 GenDocument destDoc, 75 String integrationName, 76 SiteReference ref, 77 String tmplBase, 78 String ownUrl, 79 String rootDir, 80 boolean isPreview 81 ) 82 { 83 if (t.getType().equals(JSP_TEMPLATE)) 84 { 85 Element el = null; 86 el = domData.getReferenceElement(integrationName); 87 el.setAttribute("REF", url); 88 if (destNode != null) 89 { 90 el.setAttribute("REF_NODE_PATH", destNode.getPath() ); 91 el.setAttribute("REF_NODE", destNode.getNodeName() ); 92 el.setAttribute("REF_DESCRIPTION", destNode.getDescription() ); 93 } 94 int sepIdx = url.lastIndexOf( '/' ); 95 el.setAttribute( "REF_PATH", ( sepIdx > 0 ? url.substring( 0, sepIdx ) : "." ) ); 96 if (sepIdx > 0) el.setAttribute( "REF_DOC", url.substring( sepIdx+1 ) ); 97 if( destDoc != null ) 98 { 99 111 if( ref.getComponentType() == SiteReference.COMPONENT_TYPE_FREE ) 112 destDoc.generateDOMContents( el, domData, true ); 113 114 else destDoc.generateDOMContents( el, domData, false ); 115 } 116 } 117 else 118 { 119 t.set( integrationName+".REF", url ); 120 if (destNode != null) 121 { 122 t.set( integrationName+".REF_NODE_PATH", destNode.getPath() ); 123 t.set( integrationName+".REF_NODE", destNode.getNodeName() ); 124 t.set( integrationName+".REF_DESCRIPTION", destNode.getDescription() ); 125 } 126 int sepIdx = url.lastIndexOf( '/' ); 127 t.set( integrationName+".REF_PATH", ( sepIdx > 0 ? url.substring( 0, sepIdx ) : "." ) ); 128 if (sepIdx > 0) t.set( integrationName+".REF_DOC", url.substring( sepIdx+1 ) ); 129 130 if( destDoc != null ) 131 { 132 t.set (integrationName+".REF_INCLUDE", 133 new GenDocumentHandle 134 (context,isPreview,false,ownUrl,destNode,srcNode, 135 ref.getDestinationShortName(),tmplBase,rootDir)); 136 137 t.set (integrationName+".REF_DISPLACE", 138 new GenDocumentHandle 139 (context,isPreview,true,ownUrl,destNode,srcNode, 140 ref.getDestinationShortName(),tmplBase,rootDir)); 141 142 if( ref.getComponentType() == SiteReference.COMPONENT_TYPE_FREE ) 143 destDoc.generateContents( t, integrationName+".", true ); 144 else 145 destDoc.generateContents( t, integrationName+".", false ); 146 } 147 } 148 } 149 150 static void initStatic() { 151 152 if( initialized ) return; 153 PatternCompiler compiler = TKReg.getCompiler(); 154 try 155 { 156 patPostCompileTKTag = 157 compiler.compile("</?"+PAT_PRE_TAG, Perl5Compiler.CASE_INSENSITIVE_MASK); 158 159 } catch(MalformedPatternException e) 160 { 161 patPostCompileTKTag = null; 162 } 163 initialized = true; 164 } 165 166 static { 167 initStatic(); 168 } 169 }
| Popular Tags
|