1 22 23 package org.meshcms.taglib; 24 25 import java.io.*; 26 import java.util.*; 27 import javax.servlet.jsp.*; 28 import org.meshcms.core.*; 29 import org.meshcms.util.*; 30 31 45 public final class AdminMenu extends AbstractTag { 46 public static final String MODE_NORMAL = "normal"; 47 public static final String MODE_HIDDEN = "hidden"; 48 49 private String mode; 50 private String separator = " "; 51 private String style; 52 53 public void setMode(String mode) { 54 this.mode = mode; 55 } 56 57 public void setSeparator(String separator) { 58 if (separator != null) { 59 this.separator = separator; 60 } 61 } 62 63 public void setStyle(String style) { 64 this.style = style; 65 } 66 67 public void writeTag() throws IOException { 68 UserInfo userInfo = (UserInfo) pageContext.getAttribute("userInfo", 69 PageContext.SESSION_SCOPE); 70 Locale locale = WebUtils.getPageLocale(pageContext); 71 ResourceBundle bundle = ResourceBundle.getBundle("org/meshcms/webui/Locales", locale); 72 73 String a1 = "<a" + 74 (Utils.isNullOrEmpty(style) ? "" : " class=\"" + style + "\"") + 75 " HREF=\""; 76 String a2 = "\">"; 77 String a3 = "</a>"; 78 List l = new ArrayList(); 79 80 if (userInfo == null || userInfo.isGuest()) { 81 if (mode == null || mode.equals(MODE_NORMAL)) { 82 l.add(a1 + afp + "/login.jsp" + a2 + bundle.getString("adminLogin") + a3); 83 } 84 } else { 85 l.add(a1 + afp + "/index.jsp" + a2 + bundle.getString("homeTitle") + a3); 86 87 if (!isEdit) { 88 if (userInfo.canWrite(webSite, pagePath)) { 89 if (webSite.isVisuallyEditable(pagePath)) { 90 l.add(a1 + request.getRequestURI() + '?' + HitFilter.ACTION_NAME + 91 '=' + HitFilter.ACTION_EDIT + a2 + 92 bundle.getString("adminEditPage") + a3); 93 } 94 95 if (FileTypes.isPage(pagePath.getLastElement())) { 96 l.add(a1 + afp + "/editsrc.jsp?path=" + pagePath + a2 + 97 bundle.getString("adminEditText") + a3); 98 Path pathInMenu = webSite.getSiteMap().getPathInMenu(pagePath); 99 100 if (!pathInMenu.isRoot()) { 101 Path parentPath = pathInMenu.getParent(); 102 103 if (userInfo.canWrite(webSite, parentPath)) { 104 l.add(a1 + afp + "/createpage.jsp?popup=false&path=" + 105 parentPath + a2 + bundle.getString("adminNewPage") + a3); 106 } 107 } 108 109 if (webSite.isDirectory(pathInMenu)) { 110 l.add(a1 + afp + "/createpage.jsp?popup=false&path=" + 111 pathInMenu + a2 + bundle.getString("adminNewChildPage") + a3); 112 } 113 } 114 } 115 } 116 } 117 118 getOut().write(l.size() > 0 ? Utils.generateList(l, separator) : " "); 119 } 120 121 public String getMode() { 122 return mode; 123 } 124 125 public String getSeparator() { 126 return separator; 127 } 128 129 public String getStyle() { 130 return style; 131 } 132 } 133
| Popular Tags
|