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.file.types.CmsResourceTypeFolderExtended; 38 39 import java.util.Collections ; 40 import java.util.List ; 41 42 import org.dom4j.Document; 43 import org.dom4j.Node; 44 45 54 public class CmsXmlAddImgGalleryParam extends A_CmsSetupXmlUpdate { 55 56 57 private List m_xpaths; 58 59 62 public String getName() { 63 64 return "Add new Image Gallery parameter"; 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); 81 if (node == null) { 82 if (xpath.equals(getXPathsToUpdate().get(0))) { 83 CmsSetupXmlHelper.setValue( 84 document, 85 xpath + "/@" + I_CmsXmlConfiguration.A_NAME, 86 CmsResourceTypeFolderExtended.CONFIGURATION_FOLDER_CLASS_PARAMS); 87 CmsSetupXmlHelper.setValue(document, xpath, "w:120,h:90,c:dddddd,t:1,r:2"); 88 } 89 return true; 90 } 91 return false; 92 } 93 94 97 protected String getCommonPath() { 98 99 StringBuffer xp = new StringBuffer (256); 101 xp.append("/").append(CmsConfigurationManager.N_ROOT); 102 xp.append("/").append(CmsVfsConfiguration.N_VFS); 103 xp.append("/").append(CmsVfsConfiguration.N_RESOURCES); 104 xp.append("/").append(CmsVfsConfiguration.N_RESOURCETYPES); 105 xp.append("/").append(CmsVfsConfiguration.N_TYPE); 106 xp.append("[@").append(I_CmsXmlConfiguration.A_CLASS); 107 xp.append("='").append(CmsResourceTypeFolderExtended.class.getName()); 108 return xp.append("']").toString(); 109 } 110 111 114 protected List getXPathsToUpdate() { 115 116 if (m_xpaths == null) { 117 StringBuffer xp = new StringBuffer (256); 119 xp.append("/").append(CmsConfigurationManager.N_ROOT); 120 xp.append("/").append(CmsVfsConfiguration.N_VFS); 121 xp.append("/").append(CmsVfsConfiguration.N_RESOURCES); 122 xp.append("/").append(CmsVfsConfiguration.N_RESOURCETYPES); 123 xp.append("/").append(CmsVfsConfiguration.N_TYPE); 124 xp.append("[@").append(I_CmsXmlConfiguration.A_CLASS); 125 xp.append("='").append(CmsResourceTypeFolderExtended.class.getName()); 126 xp.append("']/").append(I_CmsXmlConfiguration.N_PARAM); 127 xp.append("[@").append(I_CmsXmlConfiguration.A_NAME); 128 xp.append("='").append(CmsResourceTypeFolderExtended.CONFIGURATION_FOLDER_CLASS_PARAMS); 129 xp.append("']"); 130 m_xpaths = Collections.singletonList(xp.toString()); 131 } 132 return m_xpaths; 133 } 134 135 } | Popular Tags |