org.opencms.workplace.help.CmsHelpTemplateBean Maven / Gradle / Ivy
Show all versions of opencms-test Show documentation
/*
* This library is part of OpenCms -
* the Open Source Content Management System
*
* Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH & Co. KG, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.workplace.help;
import org.opencms.configuration.CmsParameterConfiguration;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsProperty;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.CmsVfsResourceNotFoundException;
import org.opencms.file.types.CmsResourceTypeXmlPage;
import org.opencms.i18n.CmsEncoder;
import org.opencms.i18n.CmsLocaleManager;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.jsp.CmsJspNavElement;
import org.opencms.loader.CmsLoaderException;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.security.CmsRole;
import org.opencms.security.CmsRoleViolationException;
import org.opencms.staticexport.CmsLinkManager;
import org.opencms.util.CmsMacroResolver;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.workplace.CmsWorkplaceSettings;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import org.apache.commons.logging.Log;
/**
* The bean that provides methods to build the HTML for the single online help frames.
*
*
Things to know
*
* -
* Online help will only work with resources of type xmlpage.
*
-
* Content pages with a property "template-elements" set to a path of a ressource (jsp, page,...)
* will get the content produced by
{@link org.opencms.jsp.CmsJspActionElement#getContent(String)}
* appended after their own output. This allows to use jsp's in the online help template.
*
*
* @since 6.0.0
*/
public class CmsHelpTemplateBean extends CmsDialog {
/** File name of the default help file to load. */
public static final String DEFAULT_HELPFILE = "index.html";
/** File name of the help mappings properties file(s). */
public static final String HELPMAPPINGS_FILENAME = "mappings_"
+ "${"
+ CmsMacroResolver.KEY_REQUEST_LOCALE
+ "}.properties";
/** The name of the help module. */
public static final String MODULE_NAME = "org.opencms.workplace.help";
/** Request parameter name for the buildframe flag parameter. */
public static final String PARAM_BUILDFRAME = "buildframe";
/** Request parameter name for the helpresource uri. */
public static final String PARAM_HELPRESOURCE = "helpresource";
/** Request parameter name for the homelink in head frame. */
public static final String PARAM_HOMELINK = "homelink";
/** Request parameter name for the workplaceresource uri. */
public static final String PARAM_WORKPLACERESOURCE = "workplaceresource";
/** VFS path to the help folder, contains a macro for the Locale which has to be resolved. */
public static final String PATH_HELP = CmsWorkplace.VFS_PATH_LOCALES
+ "${"
+ CmsMacroResolver.KEY_REQUEST_LOCALE
+ "}/help/";
/** Value of the NavInfo property indicating the start folder of the help. */
public static final String PROPERTY_VALUE_HELPSTART = "help.start";
/** Relative RFS path of the help mappings property file(s). */
public static final String RFS_HELPMAPPINGS = "classes/"
+ MODULE_NAME.replace('.', '/')
+ "/"
+ HELPMAPPINGS_FILENAME;
/** Absolute path to used JSP templates. */
public static final String TEMPLATEPATH = CmsWorkplace.VFS_PATH_MODULES + MODULE_NAME + "/jsptemplates/";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsHelpTemplateBean.class);
/** The online project that is switched to whenever body content is processed that should not be exported. */
private CmsProject m_offlineProject;
/** The online project that is switched to whenever body content is processed that shall be exported. */
private CmsProject m_onlineProject;
/** Request parameter for the help build frameset flag. */
private String m_paramBuildframe;
/** Request parameter for the help resource to display. */
private String m_paramHelpresource;
/** Request parameter for the home link to use in the head frame. */
private String m_paramHomelink;
/** Request parameter for the current workplace resource. */
private String m_paramWorkplaceresource;
/**
* Public constructor with JSP action element.
*
* @param jsp an initialized JSP action element
*/
public CmsHelpTemplateBean(CmsJspActionElement jsp) {
super(jsp);
try {
m_onlineProject = getCms().readProject(CmsProject.ONLINE_PROJECT_ID);
m_offlineProject = jsp.getRequestContext().getCurrentProject();
} catch (CmsException e) {
// failed to get online project
m_onlineProject = getCms().getRequestContext().getCurrentProject();
}
}
/**
* Public constructor with JSP variables.
*
* @param context the JSP page context
* @param req the JSP request
* @param res the JSP response
*/
public CmsHelpTemplateBean(PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
}
/**
* Returns the java script method to open the online help window.
*
* @param locale the current users workplace Locale
* @return the java script method to open the online help window
*/
public static String buildOnlineHelpJavaScript(Locale locale) {
StringBuffer result = new StringBuffer(16);
// the online help invoker: opens documentation central in a new window.
result.append("function openOnlineHelp() {\n");
result.append("\twindow.open('http://documentation.opencms.org/central/','_blank');\n");
result.append("}\n");
String s = result.toString();
return s;
}
/**
* Returns the HTML for the end of the page.
*
* @return the HTML for the end of the page
*/
public String buildHtmlHelpEnd() {
StringBuffer result = new StringBuffer(4);
result.append("