⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmshelptemplatebean.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            result.append("<body>\n");
            result.append("<a name=\"top\"></a>\n");
            result.append("<table class=\"helpcontent\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
            result.append("<tr>\n");
            result.append("\t<td class=\"helpnav\">\n");
            result.append("\t\t<a class=\"navhelphead\" href=\"javascript:top.body.location.href=top.head.homeLink;\">");
            result.append(key(Messages.GUI_HELP_NAVIGATION_HEAD_0));
            result.append("</a>\n");
            result.append(buildHtmlHelpNavigation());
            result.append("</td>\n");
            result.append("\t<td class=\"helpcontent\">\n");
            result.append("\t\t<h1>");
            result.append(getJsp().property(
                CmsPropertyDefinition.PROPERTY_TITLE,
                getParamHelpresource(),
                key(Messages.GUI_HELP_FRAMESET_TITLE_0)));
            result.append("</h1>\n");
            // print navigation if property template-elements is set to sitemap
            result.append(getJsp().getContent(getParamHelpresource(), "body", getLocale()));
            try {
                // additionally allow appending content of dynamic pages whose path may be specified 
                // as value of property PROPERTY_TEMPLATE_ELEMENTS (currently sitemap.jsp and search.jsp are used)
                CmsProperty elements = getCms().readPropertyObject(
                    getParamHelpresource(),
                    CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS,
                    false);
                if (!elements.isNullProperty()) {
                    try {
                        // trigger an exception here as getContent won't throw anything!
                        getJsp().getCmsObject().readFile(elements.getValue());
                        // Ok, ressource exists: switsch from the online project to turn of static export links. 
                        String elementName = elements.getValue();
                        // check, wether the "dynamic resource" wants to be exported or not:
                        boolean export = false;
                        CmsProperty exportProp = getCms().readPropertyObject(
                            elementName,
                            CmsPropertyDefinition.PROPERTY_EXPORT,
                            true);

                        if (!exportProp.isNullProperty()) {
                            export = Boolean.valueOf(exportProp.getValue(CmsStringUtil.FALSE)).booleanValue();
                        }
                        if (!export) {
                            // switch back from online project to avoid export:
                            getJsp().getRequestContext().setCurrentProject(m_offlineProject);
                        }
                        result.append(getJsp().getContent(elements.getValue()));

                    } catch (Throwable t) {
                        CmsVfsResourceNotFoundException e2 = new CmsVfsResourceNotFoundException(
                            Messages.get().container(
                                Messages.GUI_HELP_ERR_CONTENT_APPEND_2,
                                this.getParamHelpresource(),
                                elements.getValue(),
                                CmsPropertyDefinition.PROPERTY_TEMPLATE_ELEMENTS),
                            t);
                        throw e2;
                    }
                }
            } catch (CmsException e1) {

                if (LOG.isErrorEnabled()) {
                    LOG.error(e1);
                }
                result.append("<br>\n<div class=\"dialogerror\">");
                // getLocale() does not work in this context!?!
                result.append(e1.getMessageContainer().key(Locale.GERMAN));
                result.append("</div>");
            }
            result.append("\t</td>\n");
            result.append("</tr>\n");
            result.append("</table>\n");
            result.append(buildHtmlHelpEnd());
            return result.toString();
        } finally {
            getJsp().getRequestContext().setCurrentProject(m_offlineProject);
        }
    }

    /**
     * Returns the HTML for the head frame of the online help.<p>
     * 
     * @return the HTML for the head frame of the online help
     */
    public String displayHead() {

        StringBuffer result = new StringBuffer(2048);

        int buttonStyle = getSettings().getUserSettings().getWorkplaceButtonStyle();

        // change to online project to allow exporting
        try {
            getJsp().getRequestContext().setCurrentProject(m_onlineProject);
            String resourcePath = getJsp().link("/system/modules/" + MODULE_NAME + "/resources/");

            result.append(buildHtmlHelpStart("workplace.css", false));
            result.append("<body class=\"buttons-head\" unselectable=\"on\">\n");
            result.append("<script type=\"text/javascript\" src=\"");
            result.append(getJsp().link("/system/modules/org.opencms.workplace.help/resources/search.js"));
            result.append("\"></script>\n");

            // store home link in JS variable to use it in body frame
            result.append("<script type=\"text/javascript\">\n<!--\n");
            result.append("\tvar homeLink = \"");
            result.append(getParamHomelink());
            result.append("\";\n\n");
            result.append("//-->\n</script>\n");

            // search form with invisible elements 

            // search index may be attached to resource /system/modules/org.opencms.workplace.help/elements/search.jsp,   
            // property search.index.
            String index = getJsp().property(
                "search.index",
                "/system/modules/org.opencms.workplace.help/elements/search.jsp",
                "German online help",
                false);
            StringBuffer submitAction = new StringBuffer();
            submitAction.append("parseSearchQuery(document.forms[\'searchform\'],\'");
            submitAction.append(
                Messages.get().getBundle(getLocale()).key(Messages.GUI_HELP_ERR_SEARCH_WORD_LENGTH_1, new Integer(3))).append(
                "\');");

            result.append("<form style=\"margin: 0;\" name=\"searchform\" method=\"post\" action=\"");
            String searchLink = getJsp().link(
                new StringBuffer("/system/modules/org.opencms.workplace.help/elements/search.jsp?").append(
                    CmsLocaleManager.PARAMETER_LOCALE).append("=").append(getLocale()).toString());
            result.append(searchLink);
            result.append("\" target=\"body\"");
            result.append(" onsubmit=\"");
            result.append(submitAction.toString());
            result.append("\">\n");
            result.append("  <input type=\"hidden\" name=\"action\" value=\"search\" />\n");
            result.append("  <input type=\"hidden\" name=\"query\" value=\"\" />\n");
            result.append("  <input type=\"hidden\" name=\"index\" value=\"" + index + "\" />\n");
            result.append("  <input type=\"hidden\" name=\"searchPage\" value=\"1\" />\n");

            result.append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
            result.append("<tr>\n");
            result.append("\t<td align=\"left\">\n");

            // display navigation buttons
            result.append(buttonBar(HTML_START));
            result.append(buttonBarStartTab(0, 5));
            result.append(button(
                "javascript:history.back();",
                null,
                "back.png",
                org.opencms.search.Messages.GUI_HELP_BUTTON_BACK_0,
                buttonStyle,
                resourcePath));
            result.append(button(
                "javascript:history.forward();",
                null,
                "next.png",
                org.opencms.search.Messages.GUI_HELP_BUTTON_NEXT_0,
                buttonStyle,
                resourcePath));

            result.append(button(
                "javascript:top.body.location.href='" + getParamHomelink() + "';",
                null,
                "contents.png",
                org.opencms.search.Messages.GUI_HELP_BUTTON_CONTENTS_0,
                buttonStyle,
                resourcePath));
            //search
            result.append("<td style=\"vertical-align: top;\">");
            result.append("<input type=\"text\" name=\"query2\" class=\"onlineform\" style=\"width: 120px\" value=\"");
            result.append("");
            result.append(" \">");
            result.append("</td>\n");

            result.append(button(
                new StringBuffer("javascript:").append(submitAction.toString()).toString(),
                null,
                null,
                org.opencms.search.Messages.GUI_HELP_BUTTON_SEARCH_0,
                2,
                null));

            result.append(buttonBar(HTML_END));

            result.append("</td>\n");
            result.append("\t<td align=\"right\" width=\"100%\">\n");

            // display close button
            result.append(buttonBar(HTML_START));
            result.append(buttonBarSeparator(5, 0));
            result.append(button(
                "javascript:top.close();",
                null,
                "close",
                org.opencms.search.Messages.GUI_HELP_BUTTON_CLOSE_0,
                buttonStyle,
                resourcePath));
            result.append(buttonBar(HTML_END));

            result.append("\t</td>\n");
            result.append("\t<td>&nbsp;</td>\n");
            result.append("<td>");

            // display logo
            result.append("<span style=\"display: block; width: 80px; height: 22px; background-image: url(\'");
            result.append(getSkinUri());
            result.append("commons/workplace.png");
            result.append("\'); \"></span>");
            result.append("</td>");
            result.append("</tr>\n");
            result.append("</table>\n");
            result.append("</form>\n");
            result.append(buildHtmlHelpEnd());

            return result.toString();
        } finally {
            // set back to offline project
            getJsp().getRequestContext().setCurrentProject(m_offlineProject);
        }
    }

    /**
     * Generates the HTML for the online help frameset or redirects to the help body, depending on the build frameset flag.<p>
     * 
     * @return the HTML for the online help frameset or an empty String (redirect)
     * @throws IOException if redirection fails
     */
    public String displayHelp() throws IOException {

        String result = "";
        // change to online project to allow static export / export links 
        try {
            getJsp().getRequestContext().setCurrentProject(m_onlineProject);

            if (isBuildFrameset()) {
                // build the online help frameset
                result = displayFrameset();
            } else {
                // redirect to the help body
                StringBuffer bodyLink = new StringBuffer(8);
                bodyLink.append(TEMPLATEPATH);
                bodyLink.append("help_body.jsp?");
                bodyLink.append(CmsHelpTemplateBean.PARAM_HELPRESOURCE);
                bodyLink.append("=");
                bodyLink.append(getJsp().getRequestContext().getUri());
                bodyLink.append("&");
                bodyLink.append(CmsLocaleManager.PARAMETER_LOCALE);
                bodyLink.append("=");
                bodyLink.append(getLocale());
                // add the other parameters too!
                String bodyLinkWithParams = attachRequestString(bodyLink.toString());
                String redirectLink = getJsp().link(bodyLinkWithParams);
                // set back to current project
                getJsp().getResponse().sendRedirect(redirectLink);
            }
            return result;
        } finally {
            getJsp().getRequestContext().setCurrentProject(m_onlineProject);
        }
    }

    /**
     * Returns the buildframe parameter indicating if the frameset should be generated.<p>
     *
     * @return the buildframe parameter indicating if the frameset should be generated
     */
    public String getParamBuildframe() {

        return m_paramBuildframe;
    }

    /**
     * Returns the helpresource parameter value.<p>
     *
     * @return the helpresource parameter value
     */
    public String getParamHelpresource() {

        if (m_paramHelpresource == null) {
            m_paramHelpresource = resolveMacros(PATH_HELP) + DEFAULT_HELPFILE;
        }

        return m_paramHelpresource;
    }

    /**
     * Returns the homelink parameter value.<p>
     *
     * @return the homelink parameter value
     */
    public String getParamHomelink() {

        return m_paramHomelink;
    }

    /**
     * Returns the workplaceresource parameter value.<p>
     *
     * @return the workplaceresource parameter value
     */
    public String getParamWorkplaceresource() {

        return m_paramWorkplaceresource;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -