001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-setup/org/opencms/setup/xml/CmsXmlAddImgGalleryContextMenues.java,v $
003: * Date : $Date: 2008-02-27 12:05:37 $
004: * Version: $Revision: 1.2 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.setup.xml;
033:
034: import org.opencms.configuration.CmsConfigurationManager;
035: import org.opencms.configuration.CmsWorkplaceConfiguration;
036: import org.opencms.configuration.I_CmsXmlConfiguration;
037: import org.opencms.file.CmsPropertyDefinition;
038: import org.opencms.util.CmsStringUtil;
039: import org.opencms.xml.CmsXmlUtils;
040:
041: import java.util.ArrayList;
042: import java.util.List;
043:
044: import org.dom4j.Document;
045: import org.dom4j.Node;
046:
047: /**
048: * Adds the new rename and comment context menues for image galleries.<p>
049: *
050: * @author Michael Moossen
051: *
052: * @version $Revision: 1.2 $
053: *
054: * @since 6.1.8
055: */
056: public class CmsXmlAddImgGalleryContextMenues extends A_CmsXmlWorkplace {
057:
058: /** List of xpaths to update. */
059: private List m_xpaths;
060:
061: /**
062: * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getName()
063: */
064: public String getName() {
065:
066: return "Add new Rename and Comment context menues for Image Galleries";
067: }
068:
069: /**
070: * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#executeUpdate(org.dom4j.Document, java.lang.String)
071: */
072: protected boolean executeUpdate(Document document, String xpath) {
073:
074: Node node = document.selectSingleNode(xpath);
075: if (xpath.indexOf(CmsWorkplaceConfiguration.N_ENTRY) > 0) {
076: if (node == null) {
077: String xp = CmsXmlUtils
078: .removeLastComplexXpathElement(xpath);
079: setMenuEntry(document, xp,
080: "explorer.context.renameimages",
081: "commons/renameimages.jsp",
082: "d d iiii aaai dddd", "85");
083: setMenuEntry(document, xp,
084: "explorer.context.commentimages",
085: "commons/commentimages.jsp",
086: "d d iiii aaai dddd", "90");
087: return true;
088: }
089: } else if (xpath.indexOf(CmsWorkplaceConfiguration.A_REFERENCE
090: + "=") > 0) {
091: if (node != null) {
092: CmsSetupXmlHelper.setValue(document, xpath + "/@"
093: + CmsWorkplaceConfiguration.A_REFERENCE,
094: "downloadgallery");
095: return true;
096: }
097: } else if (xpath.indexOf(CmsWorkplaceConfiguration.A_REFERENCE) > 0) {
098: if (node != null) {
099: CmsSetupXmlHelper.setValue(document, xpath, null);
100: return true;
101: }
102: } else {
103: if (node == null) {
104: CmsSetupXmlHelper.setValue(document, xpath + "/"
105: + CmsWorkplaceConfiguration.N_DEFAULTPROPERTIES
106: + "/@" + I_CmsXmlConfiguration.A_ENABLED,
107: Boolean.TRUE.toString());
108: CmsSetupXmlHelper.setValue(document, xpath + "/"
109: + CmsWorkplaceConfiguration.N_DEFAULTPROPERTIES
110: + "/@"
111: + CmsWorkplaceConfiguration.A_SHOWNAVIGATION,
112: Boolean.TRUE.toString());
113: CmsSetupXmlHelper.setValue(document, xpath + "/"
114: + CmsWorkplaceConfiguration.N_DEFAULTPROPERTIES
115: + "[1]/" + I_CmsXmlConfiguration.N_PROPERTY
116: + "/@" + I_CmsXmlConfiguration.A_NAME,
117: CmsPropertyDefinition.PROPERTY_TITLE);
118:
119: xpath += "/" + CmsWorkplaceConfiguration.N_CONTEXTMENU;
120: setMenuEntry(document, xpath, "explorer.context.lock",
121: "commons/lock.jsp", "d d aaaa dddd dddd", "10");
122: setMenuEntry(document, xpath,
123: "explorer.context.overridelock",
124: "commons/lockchange.jsp", "d d dddd dddd aaaa",
125: "20");
126: setMenuEntry(document, xpath,
127: "explorer.context.unlock",
128: "commons/unlock.jsp", "d d dddd aaaa dddd",
129: "30");
130: CmsSetupXmlHelper.setValue(document, xpath + "/"
131: + CmsWorkplaceConfiguration.N_SEPARATOR + "[@"
132: + I_CmsXmlConfiguration.A_ORDER + "='40']"
133: + "/@" + I_CmsXmlConfiguration.A_ORDER, "40");
134: setMenuEntry(document, xpath,
135: "explorer.context.copytoproject",
136: "commons/copytoproject.jsp",
137: "d a dddd dddd dddd", "50");
138: setMenuEntry(document, xpath,
139: "explorer.context.publish",
140: "commons/publishresource.jsp",
141: "d d aaaa aaaa dddd", "60");
142: CmsSetupXmlHelper.setValue(document, xpath + "/"
143: + CmsWorkplaceConfiguration.N_SEPARATOR + "[@"
144: + I_CmsXmlConfiguration.A_ORDER + "='70']"
145: + "/@" + I_CmsXmlConfiguration.A_ORDER, "70");
146: setMenuEntry(document, xpath,
147: "explorer.context.opengallery",
148: "commons/opengallery.jsp",
149: "d d iiii aaai dddd", "80");
150: CmsSetupXmlHelper.setValue(document, xpath + "/"
151: + CmsWorkplaceConfiguration.N_SEPARATOR + "[@"
152: + I_CmsXmlConfiguration.A_ORDER + "='100']"
153: + "/@" + I_CmsXmlConfiguration.A_ORDER, "100");
154: setMenuEntry(document, xpath, "explorer.context.copy",
155: "commons/copy.jsp", "d d iiii aaai dddd", "150");
156: setMenuEntry(document, xpath, "explorer.context.move",
157: "commons/move.jsp", "d d iiii aaai dddd", "170");
158: setMenuEntry(document, xpath,
159: "explorer.context.delete",
160: "commons/delete.jsp", "d d iiii aaai dddd",
161: "180");
162: setMenuEntry(document, xpath, "explorer.context.touch",
163: "commons/touch.jsp", "d d iiii aaai dddd",
164: "190");
165: setMenuEntry(document, xpath,
166: "explorer.context.availability",
167: "commons/availability.jsp",
168: "d d iiii aaai dddd", "200");
169: setMenuEntry(document, xpath,
170: "explorer.context.undochanges",
171: "commons/undochanges.jsp",
172: "d d iiid aaid dddd", "210");
173: setMenuEntry(document, xpath,
174: "explorer.context.undelete",
175: "commons/undelete.jsp", "d d ddda ddda dddd",
176: "220");
177: CmsSetupXmlHelper.setValue(document, xpath + "/"
178: + CmsWorkplaceConfiguration.N_SEPARATOR + "[@"
179: + I_CmsXmlConfiguration.A_ORDER + "='240']"
180: + "/@" + I_CmsXmlConfiguration.A_ORDER, "240");
181: setMenuEntry(document, xpath,
182: "explorer.context.access", "commons/chacc.jsp",
183: "a a iiii aaai dddd", "300");
184: setMenuEntry(document, xpath,
185: "explorer.context.secure",
186: "commons/secure.jsp", "d d iiii aaai dddd",
187: "302");
188: setMenuEntry(document, xpath, "explorer.context.type",
189: "commons/chtype.jsp", "d d iiii aaai dddd",
190: "305");
191: setMenuEntry(document, xpath, "explorer.context.chnav",
192: "commons/chnav.jsp", "d d iiii aaai dddd",
193: "310");
194: CmsSetupXmlHelper.setValue(document, xpath + "/"
195: + CmsWorkplaceConfiguration.N_SEPARATOR + "[@"
196: + I_CmsXmlConfiguration.A_ORDER + "='340']"
197: + "/@" + I_CmsXmlConfiguration.A_ORDER, "340");
198: setMenuEntry(document, xpath,
199: "explorer.context.property",
200: "commons/property.jsp", "", "360");
201: return true;
202: }
203: }
204: return false;
205: }
206:
207: /**
208: * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
209: */
210: protected String getCommonPath() {
211:
212: // /opencms/workplace/explorertypes
213: return new StringBuffer("/").append(
214: CmsConfigurationManager.N_ROOT).append("/").append(
215: CmsWorkplaceConfiguration.N_WORKPLACE).append("/")
216: .append(CmsWorkplaceConfiguration.N_EXPLORERTYPES)
217: .toString();
218: }
219:
220: /**
221: * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
222: */
223: protected List getXPathsToUpdate() {
224:
225: if (m_xpaths == null) {
226: // /opencms/workplace/explorertypes/explorertype[@name='imagegallery']/editoptions/contextmenu/entry[@uri='commons/${res}images.jsp']
227: StringBuffer xp = new StringBuffer(256);
228: xp.append("/").append(CmsConfigurationManager.N_ROOT);
229: xp.append("/")
230: .append(CmsWorkplaceConfiguration.N_WORKPLACE);
231: xp.append("/").append(
232: CmsWorkplaceConfiguration.N_EXPLORERTYPES);
233: xp.append("/").append(
234: CmsWorkplaceConfiguration.N_EXPLORERTYPE);
235: xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
236: xp.append("='").append("imagegallery");
237: xp.append("']/").append(
238: CmsWorkplaceConfiguration.N_EDITOPTIONS);
239: xp.append("/").append(
240: CmsWorkplaceConfiguration.N_CONTEXTMENU);
241: xp.append("/").append(CmsWorkplaceConfiguration.N_ENTRY);
242: xp.append("[@").append(I_CmsXmlConfiguration.A_URI);
243: xp.append("='commons/${res}images.jsp']");
244: m_xpaths = new ArrayList();
245: // ${res}: rename, comment
246: m_xpaths.add(CmsStringUtil.substitute(xp.toString(),
247: "${res}", "rename"));
248: m_xpaths.add(CmsStringUtil.substitute(xp.toString(),
249: "${res}", "comment"));
250: // /opencms/workplace/explorertypes/explorertype[@name='${etype}' and @reference='imagegallery']
251: xp = new StringBuffer(256);
252: xp.append("/").append(CmsConfigurationManager.N_ROOT);
253: xp.append("/")
254: .append(CmsWorkplaceConfiguration.N_WORKPLACE);
255: xp.append("/").append(
256: CmsWorkplaceConfiguration.N_EXPLORERTYPES);
257: xp.append("/").append(
258: CmsWorkplaceConfiguration.N_EXPLORERTYPE);
259: xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
260: xp.append("='").append("${etype}");
261: xp.append("' and @").append(
262: CmsWorkplaceConfiguration.A_REFERENCE);
263: xp.append("='").append("imagegallery");
264: xp.append("']");
265: // ???: linkgallery, htmlgallery, tablegallery
266: m_xpaths.add(CmsStringUtil.substitute(xp.toString(),
267: "${etype}", "linkgallery"));
268: m_xpaths.add(CmsStringUtil.substitute(xp.toString(),
269: "${etype}", "htmlgallery"));
270: m_xpaths.add(CmsStringUtil.substitute(xp.toString(),
271: "${etype}", "tablegallery"));
272:
273: xp = new StringBuffer(256);
274: xp.append("/").append(CmsConfigurationManager.N_ROOT);
275: xp.append("/")
276: .append(CmsWorkplaceConfiguration.N_WORKPLACE);
277: xp.append("/").append(
278: CmsWorkplaceConfiguration.N_EXPLORERTYPES);
279: xp.append("/").append(
280: CmsWorkplaceConfiguration.N_EXPLORERTYPE);
281: xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
282: xp.append("='").append("downloadgallery");
283: xp.append("']/");
284: // /opencms/workplace/explorertypes/explorertype[@name='downloadgallery']/editoptions
285: m_xpaths.add(xp.toString()
286: + CmsWorkplaceConfiguration.N_EDITOPTIONS);
287: // /opencms/workplace/explorertypes/explorertype[@name='downloadgallery']/@reference
288: xp = new StringBuffer(256);
289: xp.append("/");
290: xp.append(CmsConfigurationManager.N_ROOT);
291: xp.append("/");
292: xp.append(CmsWorkplaceConfiguration.N_WORKPLACE);
293: xp.append("/");
294: xp.append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
295: xp.append("/");
296: xp.append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
297: xp.append("[@");
298: xp.append(I_CmsXmlConfiguration.N_NAME);
299: xp.append("='");
300: xp.append("downloadgallery");
301: xp.append("']/@");
302: xp.append(CmsWorkplaceConfiguration.A_REFERENCE);
303: m_xpaths.add(xp.toString());
304: }
305: return m_xpaths;
306: }
307: }
|