1 28 29 30 package com.opencms.workplace; 31 32 import org.opencms.db.CmsUserSettings; 33 import org.opencms.file.CmsObject; 34 import org.opencms.main.CmsException; 35 36 import com.opencms.template.A_CmsXmlContent; 37 38 import java.util.Hashtable ; 39 40 import org.w3c.dom.Element ; 41 import org.w3c.dom.Node ; 42 import org.w3c.dom.NodeList ; 43 44 54 55 public class CmsContextmenue extends A_CmsWpElement implements I_CmsWpElement { 56 57 58 59 private Hashtable m_storage = new Hashtable (); 60 61 78 79 public Object handleSpecialWorkplaceTag(CmsObject cms, Element n, A_CmsXmlContent doc, 80 Object callingObject, Hashtable parameters, CmsXmlLanguageFile lang) throws CmsException { 81 82 String name = n.getAttribute("name"); 84 String output = "++ missing context ++"; 85 if(name != null) { 86 87 String currentLocale = null; 89 90 CmsUserSettings settings = new CmsUserSettings(cms); 91 currentLocale = settings.getLocale().toString(); 92 StringBuffer result = new StringBuffer (); 94 95 output = (String )m_storage.get(currentLocale + name + cms.getRequestContext().getUri()); 97 if(output == null) { 98 99 CmsXmlWpTemplateFile context = getContextmenueDefinitions(cms); 101 102 context.setData("name", name); 104 result.append(context.getProcessedDataValue("CONTEXTHEAD", callingObject, 105 parameters)); 106 NodeList nl = n.getChildNodes(); 107 108 for(int i = 0;i < nl.getLength();i++) { 110 Node actualNode = nl.item(i); 111 if(actualNode.getNodeType() != Node.TEXT_NODE) { 112 Element e = (Element )actualNode; 113 114 if(e.getTagName().toLowerCase().equals("contextspacer")) { 116 117 result.append(context.getProcessedDataValue("CONTEXTSPACER", 119 callingObject, parameters)); 120 } 121 else { 122 if(e.getTagName().toLowerCase().equals("contextentry")) { 123 124 context.setData("name", lang.getLanguageValue(e.getAttribute("name"))); 126 context.setData("href", e.getAttribute("href")); 127 result.append(context.getProcessedDataValue("CONTEXTENTRY", 128 callingObject, parameters)); 129 } 130 else { 131 if(e.getTagName().toLowerCase().equals("contextdisabled")) { 132 133 context.setData("name", lang.getLanguageValue(e.getAttribute("name"))); 135 result.append(context.getProcessedDataValue("CONTEXTDISABLED", callingObject, parameters)); 136 } 137 } 138 } 139 } 140 } 141 result.append(context.getProcessedDataValue("CONTEXTFOOT", callingObject, 142 parameters)); 143 output = result.toString(); 144 m_storage.put(currentLocale + name + cms.getRequestContext().getUri(), output); 145 } 146 } 147 148 return output; 150 } 151 } 152 | Popular Tags |