1 14 15 package webEditor.interfaces; 16 17 import java.io.*; 18 import java.util.Hashtable ; 19 import java.lang.reflect.*; 20 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 import org.w3c.dom.*; 24 25 import webEditor.core.*; 26 27 31 32 public class editMode { 33 34 37 private configuration initValues; 38 39 42 private String myDocName; 43 44 47 private presentation myEditor= null; 48 49 52 private page myPage= null; 53 54 57 private article myDocument= null; 58 59 63 public editMode (configuration initParam) { 64 this.initValues = initParam; 67 } 68 69 75 public void edition (HttpServletRequest request, PrintWriter out) 76 throws ServletException, 77 IOException { 78 79 String outputString = null; 80 this.myEditor = new presentation (this.initValues); 81 this.myDocument = new article (this.initValues); 82 this.myPage = new page (this.initValues); 83 84 this.myDocName = this.initValues.readValue("HTTP Parameters", "docID"); 85 String opCode = this.initValues.readValue ("HTTP Parameters", "code"); 86 87 if (this.myDocName == null) { 88 this.myDocName = "document.xml"; 90 } 91 String imgWrite = this.initValues.readValue 93 ("HTTP Parameters", "Write.x"); 94 if (imgWrite != null) { 95 opCode = "Write"; 96 } 97 98 99 if (opCode != null) { 100 try { 101 Method m = getClass().getMethod(opCode, new Class [0]); 103 m.invoke(this,new Object [0]); 104 } 105 catch (Exception e) { 106 out.println (opCode + " : Code not supported"); 107 } 108 } 109 110 Document doc = this.myDocument.docRead (this.myDocName); 111 112 String editionMode = this.initValues.readValue("directories", "editionMode"); 114 String browserType = this.initValues.readValue("HTTP Headers", "user-agent"); 115 if ( browserType == null ) { 116 browserType = this.initValues.readValue("HTTP Headers", "User-Agent"); 118 } 119 outputString = this.myEditor.showTextEditor (doc, editionMode, browserType); 120 121 out.println (outputString); 122 } 123 124 128 public void Write () 129 throws ServletException, IOException 130 { 131 Hashtable http_params = this.initValues.readCategory ("HTTP Parameters"); 133 134 Document doc = null; 135 if (this.myDocName.equals ("new")) { 136 this.myDocName = this.myDocument.newDocID (); 138 Hashtable dataStream = new Hashtable (); 139 dataStream.put ("docID" , this.myDocName); 140 141 String htmlDocName = this.myDocument.getHTMLname (this.myDocName); 142 dataStream.put ("HTMLname" , htmlDocName); 143 doc = this.myDocument.docRead ("document.xml"); 145 doc = this.myDocument.writeDoc (dataStream, doc, "root"); 146 this.myPage.insertDoc (this.myDocName); 148 } 149 else { 150 doc = this.myDocument.docRead (this.myDocName); 151 } 152 153 doc = this.myDocument.writeDoc (http_params, doc, "content"); 155 this.myDocument.saveFile (this.myDocName, doc); 156 String htmlContent = this.myEditor.showDoc (doc, "publish"); 158 this.myDocument.saveHtmlFile (this.myDocName, htmlContent); 159 } 160 161 } 162 | Popular Tags |