| 1 31 32 package org.opencms.setup.xml; 33 34 import org.opencms.configuration.CmsConfigurationManager; 35 import org.opencms.configuration.CmsVfsConfiguration; 36 import org.opencms.configuration.I_CmsXmlConfiguration; 37 import org.opencms.widgets.CmsHtmlWidget; 38 39 import java.util.ArrayList ; 40 import java.util.List ; 41 42 import org.dom4j.Document; 43 import org.dom4j.Node; 44 45 54 public class CmsXmlReplaceHtmlAreaWidgets extends A_CmsSetupXmlUpdate { 55 56 57 private List m_xpaths; 58 59 62 public String getName() { 63 64 return "Replace HtmlArea widget entries"; 65 } 66 67 70 public String getXmlFilename() { 71 72 return CmsVfsConfiguration.DEFAULT_XML_FILE_NAME; 73 } 74 75 78 protected boolean executeUpdate(Document document, String xpath) { 79 80 Node node = document.selectSingleNode(xpath); 82 if (node != null) { 83 if (xpath.equals(getXPathsToUpdate().get(0))) { 84 CmsSetupXmlHelper.setValue( 85 document, 86 xpath + "/@" + I_CmsXmlConfiguration.A_CLASS, 87 CmsHtmlWidget.class.getName()); 88 } else if (xpath.equals(getXPathsToUpdate().get(1))) { 89 CmsSetupXmlHelper.setValue( 90 document, 91 xpath + "/@" + CmsVfsConfiguration.A_DEFAULTWIDGET, 92 CmsHtmlWidget.class.getName()); 93 } 94 return true; 95 } 96 return false; 97 } 98 99 102 protected String getCommonPath() { 103 104 StringBuffer xp = new StringBuffer (256); 106 xp.append("/").append(CmsConfigurationManager.N_ROOT); 107 xp.append("/").append(CmsVfsConfiguration.N_VFS); 108 xp.append("/").append(CmsVfsConfiguration.N_XMLCONTENT); 109 return xp.toString(); 110 } 111 112 115 protected List getXPathsToUpdate() { 116 117 if (m_xpaths == null) { 118 StringBuffer xp = new StringBuffer (256); 120 xp.append("/").append(CmsConfigurationManager.N_ROOT); 121 xp.append("/").append(CmsVfsConfiguration.N_VFS); 122 xp.append("/").append(CmsVfsConfiguration.N_XMLCONTENT); 123 xp.append("/").append(CmsVfsConfiguration.N_WIDGETS); 124 xp.append("/").append(CmsVfsConfiguration.N_WIDGET); 125 xp.append("[@").append(I_CmsXmlConfiguration.A_CLASS); 126 xp.append("='org.opencms.widgets.CmsHtmlAreaWidget']"); 127 m_xpaths = new ArrayList (); 128 m_xpaths.add(xp.toString()); 129 xp = new StringBuffer (256); 131 xp.append("/").append(CmsConfigurationManager.N_ROOT); 132 xp.append("/").append(CmsVfsConfiguration.N_VFS); 133 xp.append("/").append(CmsVfsConfiguration.N_XMLCONTENT); 134 xp.append("/").append(CmsVfsConfiguration.N_SCHEMATYPES); 135 xp.append("/").append(CmsVfsConfiguration.N_SCHEMATYPE); 136 xp.append("[@").append(CmsVfsConfiguration.A_DEFAULTWIDGET); 137 xp.append("='org.opencms.widgets.CmsHtmlAreaWidget']"); 138 m_xpaths.add(xp.toString()); 139 } 140 return m_xpaths; 141 } 142 } | Popular Tags |