1 4 package com.openedit.modules.location; 5 6 import com.openedit.WebPageRequest; 7 import com.openedit.page.Page; 8 import com.openedit.util.PathUtilities; 9 import com.openedit.web.Crumb; 10 11 15 public class LocationModule 16 { 17 public void loadPaths( WebPageRequest inContext) throws Exception 18 { 19 20 Page page = inContext.getPage(); 21 String path = PathUtilities.extractDirectoryPath(page.getPath()); 22 24 String csspath = path.replace('/','-'); 26 if( csspath.startsWith("-")) 27 { 28 csspath = csspath.substring(1); 29 } 30 if( csspath.endsWith("-")) 31 { 32 csspath = csspath.substring(0,csspath.length() -1); 33 } 34 35 inContext.putPageValue("cssdirectory",csspath); 36 37 String name = PathUtilities.extractPageName( page.getPath() ); 38 String csspage = csspath + "-" + name; 39 inContext.putPageValue("cssaddress",csspage); 40 41 42 } 43 44 45 53 public void checkCrumb(WebPageRequest inContext) throws Exception 54 { 55 56 Page content = (Page)inContext.getPageValue("content"); 59 60 String crumb = inContext.getRequestParameter("crumb"); 61 if (crumb == null) 62 { 63 crumb = content.get("crumb"); 64 } 65 Crumb oldCrumb = (Crumb)inContext.getSessionValue("crumb"); 67 if (crumb != null) 69 { 70 Crumb newCrumb = new Crumb(); 71 newCrumb.setPath(inContext.getPathUrl()); 72 newCrumb.setText(crumb); 73 74 Crumb home = new Crumb(); 75 home.setPath("/index.html"); 76 home.setText("Home"); 77 newCrumb.setParent(home); 78 oldCrumb = newCrumb; 80 } 81 inContext.putSessionValue("crumb",oldCrumb); 82 83 String addcrumb = inContext.getRequestParameter("addcrumb"); 84 if ( addcrumb == null ) 85 { 86 addcrumb = content.get("addcrumb"); 87 } 88 if (addcrumb != null) 89 { 90 Crumb newCrumb = new Crumb(); 92 newCrumb.setPath(inContext.getPathUrl()); newCrumb.setText(addcrumb); 94 if (oldCrumb != null) 95 { 96 if (oldCrumb.isFinal()) 97 { 98 oldCrumb = oldCrumb.getParent(); 99 } 100 newCrumb.setParent(oldCrumb); newCrumb.setFinal(true); 102 } 103 inContext.putSessionValue("crumb",newCrumb); 104 } 105 } 106 107 108 109 } | Popular Tags |