1 28 29 30 package com.opencms.workplace; 31 32 import org.opencms.file.CmsObject; 33 import org.opencms.main.CmsException; 34 35 import com.opencms.core.I_CmsSession; 36 import com.opencms.legacy.CmsXmlTemplateLoader; 37 38 import java.util.Hashtable ; 39 40 49 50 public class CmsExplorerHead extends CmsWorkplaceDefault { 51 52 53 54 private final static String C_PARENT = "PARENT"; 55 56 57 58 private final static String C_PARENT_ENABLED = "PARENT_ENABLED"; 59 60 61 62 private final static String C_PARENT_DISABLED = "PARENT_DISABLED"; 63 64 65 66 private final static String C_PREVIOUS = "PREVIOUS"; 67 68 69 70 private final static String C_PREVIOUS_ENABLED = "PREVIOUS_ENABLED"; 71 72 73 74 private final static String C_PREVIOUS_DISABLED = "PREVIOUS_DISABLED"; 75 76 77 78 private final static String C_NEW = "NEW"; 79 80 81 82 private final static String C_NEW_ENABLED = "NEW_ENABLED"; 83 84 85 86 private final static String C_NEW_DISABLED = "NEW_DISABLED"; 87 88 89 90 private final static String C_FILELIST = "FILELIST"; 91 92 93 94 private final static String C_PREVIOUSLIST = "PREVIOUSLIST"; 95 96 97 98 private final static String C_STARTUP = "STARTUP"; 99 100 101 102 private final static String C_STARTUP_FILE = "STARTUP_FILE"; 103 104 105 106 private final static String C_STARTUP_FOLDER = "STARTUP_FOLDER"; 107 108 109 110 private final static String C_LINK_VALUE = "LINK_VALUE"; 111 112 134 135 public byte[] getContent(CmsObject cms, String templateFile, String elementName, 136 Hashtable parameters, String templateSelector) throws CmsException { 137 String viewfile = null; 138 String filelist = null; 139 String previous = null; 140 String url = null; 141 String currentFilelist = null; 142 String previousFilelist = null; 143 String newFilelist = null; 144 145 String template = null; 147 148 I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true); 150 String servlets = CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getServletUrl(); 151 CmsXmlWpTemplateFile xmlTemplateDocument = new CmsXmlWpTemplateFile(cms, templateFile); 152 153 viewfile = (String )parameters.get(CmsWorkplaceDefault.C_PARA_VIEWFILE); 156 if(viewfile != null) { 157 template = "viewfile"; 158 } 159 else { 160 161 url = (String )parameters.get(CmsWorkplaceDefault.C_PARA_URL); 164 if(url == null) { 165 xmlTemplateDocument.clearStartup(); 166 } 167 else { 168 169 if(url.endsWith("/")) { 171 172 xmlTemplateDocument.setData(C_FILELIST, url); 174 xmlTemplateDocument.setData(C_STARTUP, xmlTemplateDocument.getProcessedDataValue(C_STARTUP_FOLDER, this)); 175 currentFilelist = CmsWorkplaceAction.getCurrentFolder(CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getOriginalRequest()); 177 if(currentFilelist == null) { 178 currentFilelist = cms.getSitePath(cms.readFolder("/")); 179 } 180 session.putValue(CmsWorkplaceDefault.C_PARA_PREVIOUSLIST, currentFilelist); 181 CmsWorkplaceAction.setCurrentFolder(url, CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getOriginalRequest()); 183 session.putValue(CmsWorkplaceDefault.C_PARA_FOLDER, url); 184 } 185 else { 186 187 xmlTemplateDocument.setData(C_LINK_VALUE, servlets + url); 189 xmlTemplateDocument.setData(C_STARTUP, xmlTemplateDocument.getProcessedDataValue(C_STARTUP_FILE, this)); 190 191 } 193 } 194 195 previous = (String )parameters.get(CmsWorkplaceDefault.C_PARA_PREVIOUSLIST); 198 if(previous != null) { 199 session.putValue(CmsWorkplaceDefault.C_PARA_PREVIOUSLIST, previous); 200 } 201 202 previousFilelist = (String )session.getValue(CmsWorkplaceDefault.C_PARA_PREVIOUSLIST); 204 205 filelist = CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getParameter(CmsWorkplaceDefault.C_PARA_FILELIST); 208 if(filelist != null) { 209 CmsWorkplaceAction.setCurrentFolder(filelist, CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getOriginalRequest()); 211 } 212 213 currentFilelist = CmsWorkplaceAction.getCurrentFolder(CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getOriginalRequest()); 216 217 if(currentFilelist == null) { 219 currentFilelist = cms.getSitePath(cms.readFolder("/")); 220 } 221 if(!currentFilelist.equals("/")) { 222 223 newFilelist = currentFilelist.substring(0, currentFilelist.length() - 1); 225 226 int end = newFilelist.lastIndexOf("/"); 228 if(end > -1) { 229 newFilelist = newFilelist.substring(0, end + 1); 230 } 231 } 232 else { 233 newFilelist = currentFilelist; 234 } 235 236 xmlTemplateDocument.setData(C_FILELIST, newFilelist); 239 xmlTemplateDocument.setData(C_PREVIOUSLIST, previousFilelist); 240 241 if(currentFilelist.equals("/")) { 246 xmlTemplateDocument.setData(C_PARENT, xmlTemplateDocument.getProcessedDataValue(C_PARENT_DISABLED, this)); 247 } 248 else { 249 xmlTemplateDocument.setData(C_PARENT, xmlTemplateDocument.getProcessedDataValue(C_PARENT_ENABLED, this)); 250 } 251 252 if(previousFilelist == null) { 254 xmlTemplateDocument.setData(C_PREVIOUS, xmlTemplateDocument.getProcessedDataValue(C_PREVIOUS_DISABLED, this)); 255 } 256 else { 257 xmlTemplateDocument.setData(C_PREVIOUS, xmlTemplateDocument.getProcessedDataValue(C_PREVIOUS_ENABLED, this)); 258 } 259 260 if(cms.getRequestContext().currentProject().isOnlineProject()) { 263 xmlTemplateDocument.setData(C_NEW, xmlTemplateDocument.getProcessedDataValue(C_NEW_DISABLED, this)); 264 } 265 else { 266 xmlTemplateDocument.setData(C_NEW, xmlTemplateDocument.getProcessedDataValue(C_NEW_ENABLED, this)); 267 } 268 } 269 270 return startProcessing(cms, xmlTemplateDocument, "", parameters, template); 272 } 273 274 284 285 public boolean isCacheable(CmsObject cms, String templateFile, String elementName, 286 Hashtable parameters, String templateSelector) { 287 return false; 288 } 289 290 299 300 public String setValue(CmsObject cms, CmsXmlLanguageFile lang, Hashtable parameters) throws CmsException { 301 303 String currentFilelist = CmsWorkplaceAction.getCurrentFolder(CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getOriginalRequest()); 306 307 if(currentFilelist == null) { 309 currentFilelist = cms.getSitePath(cms.readFolder("/")); 310 } 311 return currentFilelist; 312 } 313 } 314 | Popular Tags |