1 31 32 package org.opencms.setup.xml; 33 34 import org.opencms.configuration.CmsConfigurationManager; 35 import org.opencms.configuration.CmsWorkplaceConfiguration; 36 import org.opencms.configuration.I_CmsXmlConfiguration; 37 import org.opencms.file.types.CmsResourceTypeBinary; 38 import org.opencms.file.types.CmsResourceTypeImage; 39 import org.opencms.file.types.CmsResourceTypeJsp; 40 import org.opencms.file.types.CmsResourceTypePlain; 41 import org.opencms.file.types.CmsResourceTypePointer; 42 import org.opencms.file.types.CmsResourceTypeXmlPage; 43 import org.opencms.util.CmsStringUtil; 44 45 import java.util.ArrayList ; 46 import java.util.List ; 47 48 import org.dom4j.Document; 49 import org.dom4j.Node; 50 51 60 public class CmsXmlUpdateHistoryContextMenu extends A_CmsSetupXmlUpdate { 61 62 63 private List m_xpaths; 64 65 68 public String getName() { 69 70 return "Modify the History context menu"; 71 } 72 73 76 public String getXmlFilename() { 77 78 return CmsWorkplaceConfiguration.DEFAULT_XML_FILE_NAME; 79 } 80 81 84 protected boolean executeUpdate(Document document, String xpath) { 85 86 Node node = document.selectSingleNode(xpath); 87 if (xpath.indexOf(CmsWorkplaceConfiguration.N_TOOLMANAGER) < 0) { 88 if (node != null) { 89 CmsSetupXmlHelper.setValue( 90 document, 91 xpath + "/@" + I_CmsXmlConfiguration.A_URI, 92 "views/admin/admin-main.jsp?root=explorer&path=%2Fhistory"); 93 94 return true; 95 } 96 } else { 97 if (node == null) { 98 String xp = xpath 99 + "/" 100 + CmsWorkplaceConfiguration.N_ROOTS 101 + "/" 102 + CmsWorkplaceConfiguration.N_ROOT 103 + "[" 104 + CmsWorkplaceConfiguration.N_KEY 105 + "='admin']"; 106 107 CmsSetupXmlHelper.setValue(document, xp + "/" + CmsWorkplaceConfiguration.N_KEY, "admin"); 108 CmsSetupXmlHelper.setValue( 109 document, 110 xp + "/" + CmsWorkplaceConfiguration.N_URI, 111 "/system/workplace/admin/"); 112 CmsSetupXmlHelper.setValue( 113 document, 114 xp + "/" + I_CmsXmlConfiguration.N_NAME, 115 "${key.GUI_ADMIN_VIEW_ROOT_NAME_0}"); 116 CmsSetupXmlHelper.setValue( 117 document, 118 xp + "/" + CmsWorkplaceConfiguration.N_HELPTEXT, 119 "${key.GUI_ADMIN_VIEW_ROOT_HELP_0}"); 120 121 xp = CmsStringUtil.substitute(xp, "admin", "explorer"); 122 CmsSetupXmlHelper.setValue(document, xp + "/" + CmsWorkplaceConfiguration.N_KEY, "explorer"); 123 CmsSetupXmlHelper.setValue( 124 document, 125 xp + "/" + CmsWorkplaceConfiguration.N_URI, 126 "/system/workplace/explorer/"); 127 CmsSetupXmlHelper.setValue( 128 document, 129 xp + "/" + I_CmsXmlConfiguration.N_NAME, 130 "${key.GUI_EXPLORER_VIEW_ROOT_NAME_0}"); 131 CmsSetupXmlHelper.setValue( 132 document, 133 xp + "/" + CmsWorkplaceConfiguration.N_HELPTEXT, 134 "${key.GUI_EXPLORER_VIEW_ROOT_HELP_0}"); 135 136 return true; 137 } 138 } 139 return false; 140 } 141 142 145 protected String getCommonPath() { 146 147 return new StringBuffer ("/").append(CmsConfigurationManager.N_ROOT).append("/").append( 149 CmsWorkplaceConfiguration.N_WORKPLACE).toString(); 150 } 151 152 155 protected List getXPathsToUpdate() { 156 157 if (m_xpaths == null) { 158 StringBuffer xp = new StringBuffer (256); 160 xp.append("/").append(CmsConfigurationManager.N_ROOT); 161 xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE); 162 xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES); 163 xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPE); 164 xp.append("[@").append(I_CmsXmlConfiguration.N_NAME); 165 xp.append("='${etype}']/"); 166 xp.append(CmsWorkplaceConfiguration.N_EDITOPTIONS); 167 xp.append("/").append(CmsWorkplaceConfiguration.N_CONTEXTMENU); 168 xp.append("/").append(CmsWorkplaceConfiguration.N_ENTRY); 169 xp.append("[@").append(I_CmsXmlConfiguration.A_URI); 170 xp.append("='commons/history.jsp']"); 171 m_xpaths = new ArrayList (); 172 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "xmlcontent")); 174 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeXmlPage.getStaticTypeName())); 175 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePlain.getStaticTypeName())); 176 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeImage.getStaticTypeName())); 177 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeJsp.getStaticTypeName())); 178 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeBinary.getStaticTypeName())); 179 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePointer.getStaticTypeName())); 180 m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "XMLTemplate")); 181 xp = new StringBuffer (256); 183 xp.append("/").append(CmsConfigurationManager.N_ROOT); 184 xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE); 185 xp.append("/").append(CmsWorkplaceConfiguration.N_TOOLMANAGER); 186 m_xpaths.add(xp.toString()); 187 } 188 return m_xpaths; 189 } 190 191 } | Popular Tags |