1 package info.magnolia.module.admininterface.dialogpages; 2 3 import info.magnolia.cms.beans.config.ContentRepository; 4 import info.magnolia.cms.gui.control.Button; 5 import info.magnolia.cms.gui.misc.CssConstants; 6 import info.magnolia.cms.gui.misc.Sources; 7 import info.magnolia.cms.i18n.MessagesManager; 8 import info.magnolia.module.admininterface.DialogPageMVCHandler; 9 10 import java.io.IOException ; 11 import java.io.PrintWriter ; 12 import java.util.Date ; 13 14 import javax.servlet.http.HttpServletRequest ; 15 import javax.servlet.http.HttpServletResponse ; 16 17 import org.apache.commons.lang.StringUtils; 18 19 20 24 public class LinkBrowserDialogPage extends DialogPageMVCHandler { 25 26 public LinkBrowserDialogPage(String name, HttpServletRequest request, HttpServletResponse response) { 27 super(name, request, response); 28 } 29 30 33 private static final long serialVersionUID = 222L; 34 35 protected void draw(HttpServletRequest request, HttpServletResponse response) throws IOException { 36 PrintWriter out = response.getWriter(); 37 String repository = request.getParameter("repository"); if (StringUtils.isEmpty(repository)) { 39 repository = ContentRepository.WEBSITE; 40 } 41 42 String path = request.getParameter("path"); String pathOpen = request.getParameter("pathOpen"); String pathSelected = request.getParameter("pathSelected"); 46 StringBuffer html = new StringBuffer (); 47 html.append("<html><head>"); html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"); html.append(new Sources(request.getContextPath()).getHtmlJs()); 50 html.append(new Sources(request.getContextPath()).getHtmlCss()); 51 html.append("</head>"); html.append("<body class=\"mgnlBgDark\" onload=\"mgnlDialogLinkBrowserResize();\">"); 54 StringBuffer src = getIFrameSrc(request, repository, path, pathOpen, pathSelected); 55 56 html.append("<div id=\"mgnlTreeDiv\" class=\"mgnlDialogLinkBrowserTreeDiv\">"); html.append("<iframe id=\"mgnlDialogLinkBrowserIFrame\" name=\"mgnlDialogLinkBrowserIFrame\" SRC=\"" + src + "\" scrolling=\"no\" frameborder=\"0\" width=\"100%\" height=\"100\"></iframe>"); html.append("</div>"); 61 Button bOk = new Button(); 62 bOk.setLabel(MessagesManager.get(request, "buttons.ok")); bOk.setOnclick("mgnlDialogLinkBrowserWriteBack()"); 66 Button bCancel = new Button(); 67 bCancel.setLabel(MessagesManager.get(request, "buttons.cancel")); bCancel.setOnclick("window.close();"); 70 html.append("<div class=\"" + CssConstants.CSSCLASS_TABSETSAVEBAR + "\">"); html.append(bOk.getHtml()); 72 html.append(" "); html.append(bCancel.getHtml()); 74 html.append("</div>"); 76 html.append("</body></html>"); 78 out.println(html); 79 } 80 81 private StringBuffer getIFrameSrc(HttpServletRequest request, String repository, String path, String pathOpen, String pathSelected) { 82 StringBuffer src = new StringBuffer (); 83 src.append(request.getContextPath()); 84 src.append("/.magnolia/adminCentral/extractTree.html"); src.append("?&mgnlCK=" + new Date ().getTime()); src.append("&name=" + repository); src.append("&browseMode=true"); if (path != null) { 89 src.append("&path=" + path); } 91 if (pathOpen != null) { 92 src.append("&pathOpen=" + pathOpen); } 94 if (pathSelected != null) { 95 src.append("&pathSelected=" + pathSelected); } 97 return src; 98 } 99 } 100 | Popular Tags |