/** * Returns the path to the cascading stylesheets.<p> * * @param filename the name of the stylesheet * @return the path to the cascading stylesheets */ public String getStyleUri(String filename) { return getStyleUri(getJsp(), filename); }
/** * @see org.opencms.workplace.tools.I_CmsToolHandler#getParameters(org.opencms.workplace.CmsWorkplace) */ public Map getParameters(CmsWorkplace wp) { Map parameters = new HashMap(); parameters.put(CmsDialog.PARAM_CLOSELINK, CmsToolManager.linkForToolPath(wp.getJsp(), CLOSELINK)); return parameters; }
/** * Returns the path to the cascading stylesheets.<p> * * @param filename the name of the stylesheet * @return the path to the cascading stylesheets */ public String getStyleUri(String filename) { return getStyleUri(getJsp(), filename); }
/** * Returns true if the currently processed element is an included sub element.<p> * * @return true if the currently processed element is an included sub element */ public boolean isSubElement() { return !getJsp().getRequestContext().getUri().equals(getJsp().info("opencms.request.element.uri")); }
/** * Returns true if the currently processed element is an included sub element.<p> * * @return true if the currently processed element is an included sub element */ public boolean isSubElement() { return !getJsp().getRequestContext().getUri().equals(getJsp().info("opencms.request.element.uri")); }
/** * Returns the default html for a workplace page, including setting of DOCTYPE and * inserting a header with the content-type, allowing the selection of an individual style sheet.<p> * * @param segment the HTML segment (START / END) * @param title the title of the page, if null no title tag is inserted * @param stylesheet the used style sheet, if null the default stylesheet 'workplace.css' is inserted * @return the default html for a workplace page */ public String pageHtmlStyle(int segment, String title, String stylesheet) { if (segment == HTML_START) { StringBuffer result = new StringBuffer(512); result.append("<!DOCTYPE html>\n"); result.append("<html>\n<head>\n"); if (title != null) { result.append("<title>"); result.append(title); result.append("</title>\n"); } result.append("<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset="); result.append(getEncoding()); result.append("\">\n"); result.append("<link rel=\"stylesheet\" type=\"text/css\" href=\""); result.append(getStyleUri(getJsp(), stylesheet == null ? "workplace.css" : stylesheet)); result.append("\">\n"); return result.toString(); } else { return "</html>"; } }
/** * Returns the default html for a workplace page, including setting of DOCTYPE and * inserting a header with the content-type, allowing the selection of an individual style sheet.<p> * * @param segment the HTML segment (START / END) * @param title the title of the page, if null no title tag is inserted * @param stylesheet the used style sheet, if null the default stylesheet 'workplace.css' is inserted * @return the default html for a workplace page */ public String pageHtmlStyle(int segment, String title, String stylesheet) { if (segment == HTML_START) { StringBuffer result = new StringBuffer(512); result.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"); result.append("<html>\n<head>\n"); if (title != null) { result.append("<title>"); result.append(title); result.append("</title>\n"); } result.append("<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset="); result.append(getEncoding()); result.append("\">\n"); result.append("<link rel=\"stylesheet\" type=\"text/css\" href=\""); result.append(getStyleUri(getJsp(), stylesheet == null ? "workplace.css" : stylesheet)); result.append("\">\n"); return result.toString(); } else { return "</html>"; } }
/** * Returns all present request parameters as String.<p> * * The String is formatted as a parameter String (<code>param1=val1&param2=val2</code>) with UTF-8 encoded values.<p> * * @return all present request parameters as String */ public String allParamsAsRequest() { StringBuffer retValue = new StringBuffer(512); HttpServletRequest request = getJsp().getRequest(); Iterator paramNames = request.getParameterMap().keySet().iterator(); while (paramNames.hasNext()) { String paramName = (String)paramNames.next(); String paramValue = request.getParameter(paramName); retValue.append(paramName + "=" + CmsEncoder.encode(paramValue, getCms().getRequestContext().getEncoding())); if (paramNames.hasNext()) { retValue.append("&"); } } return retValue.toString(); }
/** * Sends a http redirect to the specified URI in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @throws IOException in case redirection fails */ public void sendCmsRedirect(String location) throws IOException { // TOOD: IBM Websphere v5 has problems here, use forward instead (which has other problems) getJsp().getResponse().sendRedirect(OpenCms.getSystemInfo().getOpenCmsContext() + location); }
/** * Sends a http redirect to the specified URI in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @throws IOException in case redirection fails */ public void sendCmsRedirect(String location) throws IOException { // TOOD: IBM Websphere v5 has problems here, use forward instead (which has other problems) getJsp().getResponse().sendRedirect(OpenCms.getSystemInfo().getOpenCmsContext() + location); }
/** * Returns all present request parameters as String.<p> * * The String is formatted as a parameter String (<code>param1=val1&param2=val2</code>) with UTF-8 encoded values.<p> * * @return all present request parameters as String */ public String allParamsAsRequest() { StringBuffer retValue = new StringBuffer(512); HttpServletRequest request = getJsp().getRequest(); Iterator<String> paramNames = request.getParameterMap().keySet().iterator(); while (paramNames.hasNext()) { String paramName = paramNames.next(); String paramValue = request.getParameter(paramName); retValue.append( paramName + "=" + CmsEncoder.encode(paramValue, getCms().getRequestContext().getEncoding())); if (paramNames.hasNext()) { retValue.append("&"); } } return retValue.toString(); }
/** * Forwards to the specified location in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @param params the map of parameters to use for the forwarded request * * @throws IOException in case the forward fails * @throws ServletException in case the forward fails */ public void sendForward(String location, Map params) throws IOException, ServletException { setForwarded(true); // params must be arrays of String, ensure this is the case params = CmsRequestUtil.createParameterMap(params); CmsRequestUtil.forwardRequest(getJsp().link(location), params, getJsp().getRequest(), getJsp().getResponse()); }
/** * Forwards to the specified location in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @param params the map of parameters to use for the forwarded request * * @throws IOException in case the forward fails * @throws ServletException in case the forward fails */ public void sendForward(String location, Map<String, String[]> params) throws IOException, ServletException { setForwarded(true); // params must be arrays of String, ensure this is the case Map<String, String[]> parameters = CmsRequestUtil.createParameterMap(params); CmsRequestUtil.forwardRequest( getJsp().link(location), parameters, getJsp().getRequest(), getJsp().getResponse()); }
/** * Redirects to the given page with the given parameters.<p> * * @param wp the workplace object * @param pagePath the path to the page to redirect to * @param params the parameters to send * * @throws IOException in case of errors during forwarding * @throws ServletException in case of errors during forwarding */ public void jspForwardPage(CmsWorkplace wp, String pagePath, Map params) throws IOException, ServletException { Map newParams = createToolParams(wp, pagePath, params); if (pagePath.indexOf("?") > 0) { pagePath = pagePath.substring(0, pagePath.indexOf("?")); } wp.setForwarded(true); // forward to the requested page uri CmsRequestUtil.forwardRequest( wp.getJsp().link(pagePath), CmsRequestUtil.createParameterMap(newParams), wp.getJsp().getRequest(), wp.getJsp().getResponse()); }
/** * Redirects to the given page with the given parameters.<p> * * @param wp the workplace object * @param pagePath the path to the page to redirect to * @param params the parameters to send * * @throws IOException in case of errors during forwarding * @throws ServletException in case of errors during forwarding */ public void jspForwardPage(CmsWorkplace wp, String pagePath, Map<String, String[]> params) throws IOException, ServletException { Map<String, String[]> newParams = createToolParams(wp, pagePath, params); if (pagePath.indexOf("?") > 0) { pagePath = pagePath.substring(0, pagePath.indexOf("?")); } wp.setForwarded(true); // forward to the requested page uri CmsRequestUtil.forwardRequest( wp.getJsp().link(pagePath), CmsRequestUtil.createParameterMap(newParams), wp.getJsp().getRequest(), wp.getJsp().getResponse()); }
/** * Creates a parameter map from the given url and additional parameters.<p> * * @param wp the workplace context * @param url the url to create the parameter map for (extracting query params) * @param params additional parameter map * * @return the new parameter map */ private Map createToolParams(CmsWorkplace wp, String url, Map params) { Map newParams = new HashMap(); // add query parameters to the parameter map if required if (url.indexOf("?") > 0) { String query = url.substring(url.indexOf("?")); Map reqParameters = CmsRequestUtil.createParameterMap(query); newParams.putAll(reqParameters); } if (params != null) { newParams.putAll(params); } // put close link if not set if (!newParams.containsKey(CmsDialog.PARAM_CLOSELINK)) { Map argMap = resolveAdminTool(getCurrentRoot(wp).getKey(), getCurrentToolPath(wp)).getHandler().getParameters( wp); newParams.put(CmsDialog.PARAM_CLOSELINK, linkForToolPath(wp.getJsp(), getCurrentToolPath(wp), argMap)); } return newParams; }
newParams.put( CmsDialog.PARAM_CLOSELINK, new String[] {linkForToolPath(wp.getJsp(), getCurrentToolPath(wp), argMap)});
resolver.setJspPageContext(wp.getJsp().getJspContext()); resolver.setMessages(wp.getMessages()); if (m_textShown == null) {
/** * Returns the necessary html code for a link to this tool.<p> * * @param wp the jsp page to write the code to * * @return html code */ public String buttonHtml(CmsWorkplace wp) { if (!m_handler.isVisible(wp)) { return ""; } String link = CmsToolManager.linkForToolPath( wp.getJsp(), getHandler().getPath(), getHandler().getParameters(wp)); String onClic = "openPage('" + link + "');"; return A_CmsHtmlIconButton.defaultButtonHtml( CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT, getId(), m_handler.getShortName(), m_handler.isEnabled(wp) ? m_handler.getHelpText() : m_handler.getDisabledHelpText(), m_handler.isEnabled(wp), m_handler.getIconPath(), m_handler.getConfirmationMessage(), onClic); }
/** * Returns the necessary html code for a link to this tool.<p> * * @param wp the jsp page to write the code to * * @return html code */ public String buttonHtml(CmsWorkplace wp) { if (!m_handler.isVisible(wp)) { return ""; } String link = CmsToolManager.linkForToolPath( wp.getJsp(), getHandler().getPath(), getHandler().getParameters(wp)); String onClic = "openPage('" + link + "');"; return A_CmsHtmlIconButton.defaultButtonHtml( CmsHtmlIconButtonStyleEnum.BIG_ICON_TEXT, getId(), m_handler.getShortName(), m_handler.isEnabled(wp) ? m_handler.getHelpText() : m_handler.getDisabledHelpText(), m_handler.isEnabled(wp), m_handler.getIconPath(), m_handler.getConfirmationMessage(), onClic); }