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

📄 cmstemplatebean.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*
 * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/frontend/templateone/CmsTemplateBean.java,v $
 * Date   : $Date: 2006/03/27 14:52:51 $
 * Version: $Revision: 1.43 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (c) 2005 Alkacon Software GmbH (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, 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.frontend.templateone;

import org.opencms.file.CmsFile;
import org.opencms.file.CmsFolder;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.i18n.CmsMessages;
import org.opencms.jsp.util.CmsTemplateContentListItem;
import org.opencms.loader.CmsLoaderException;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.xml.content.CmsXmlContent;
import org.opencms.xml.content.CmsXmlContentFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
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.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;

import org.apache.commons.logging.Log;

/**
 * Provides methods to create the HTML for the frontend output in the main JSP template one.<p>
 * 
 * @author Andreas Zahner 
 * 
 * @version $Revision: 1.43 $ 
 * 
 * @since 6.0.0 
 */
public class CmsTemplateBean extends CmsTemplateBase {

    /** File name of the website area configuration file. */
    public static final String FILE_CONFIG_COMMON = "configuration_common";

    /** File name of the CSS style sheet to use. */
    public static final String FILE_CSS = "style.css";

    /** File name of the accessible CSS style sheet to use. */
    public static final String FILE_CSS_ACCESSIBLE = "style_accessible.css";

    /** File name of the head links configuration file. */
    public static final String FILE_LINKS_HEAD = "configuration_links";

    /** Folder path to the included JSP elements. */
    public static final String FOLDER_ELEMENTS = "../elements/";

    /** Name of the resource bundle containing the localized messages. */
    public static final String MESSAGE_BUNDLE = "templateone";

    /** Name of the frontend module in OpenCms. */
    public static final String MODULE_NAME = "org.opencms.frontend.templateone";

    /** Request parameter name to show the accessible version of a page. */
    public static final String PARAM_ACCESSIBLE = "accessible";

    /** Request parameter name to show the common version of a page. */
    public static final String PARAM_COMMON = "common";

    /** Request parameter name for the help page URI. */
    public static final String PARAM_HELPURI = "helpuri";

    /** Request parameter name to determine the displayed version of a page. */
    public static final String PARAM_LAYOUT = "layout";

    /** Request parameter name for the login page URI. */
    public static final String PARAM_LOGINURI = "loginuri";

    /** Request parameter name to determine the part of a JSP element to include. */
    public static final String PARAM_PART = "part";

    /** Request parameter name to show the print version of a page. */
    public static final String PARAM_PRINT = "print";

    /** Request parameter name for the current site. */
    public static final String PARAM_SITE = "site";

    /** Request parameter name for the uri. */
    public static final String PARAM_URI = "uri";

    /** Name of the property key to set the configuration path for the template. */
    public static final String PROPERTY_CONFIGPATH = "style_main_configpath";

    /** Name of the property key to set the extension module for the template. */
    public static final String PROPERTY_EXTENSIONMODULE = "style_main_extensionmodule";

    /** Name of the property key to set the head default link. */
    public static final String PROPERTY_HEAD_DEFAULTLINK = "style_head_links_defaultlink";

    /** Name of the property key to set the head element URI. */
    public static final String PROPERTY_HEAD_ELEMENTURI = "style_head_elementuri";

    /** Name of the property key to set the head image height. */
    public static final String PROPERTY_HEAD_IMGHEIGHT = "style_head_img_height";

    /** Name of the property key to set the head image link. */
    public static final String PROPERTY_HEAD_IMGLINK = "style_head_img_link";

    /** Name of the property key to set the head image uri. */
    public static final String PROPERTY_HEAD_IMGURI = "style_head_img_uri";

    /** Name of the property key to set the path to the layout file for the center layout. */
    public static final String PROPERTY_LAYOUT_CENTER = "layout.center";

    /** Name of the property key to set the path to the layout file for the right layout. */
    public static final String PROPERTY_LAYOUT_RIGHT = "layout.right";

    /** Name of the property key to set the left navigation include element uri. */
    public static final String PROPERTY_NAVLEFT_ELEMENTURI = "style_navleft_element_uri";

    /** Name of the property key to set the resource path for the template. */
    public static final String PROPERTY_RESOURCEPATH = "style_main_resourcepath";

    /** Name of the property key to determine if the head navigation row is shown. */
    public static final String PROPERTY_SHOW_HEADNAV = "style_show_head_nav";

    /** Name of the property key to determine if the left navigation is shown. */
    public static final String PROPERTY_SHOW_NAVLEFT = "style_show_navleft";

    /** Name of the property key to show the head image row. */
    public static final String PROPERTY_SHOWHEADIMAGE = "style_show_head_img";

    /** Name of the property key to show the head links row. */
    public static final String PROPERTY_SHOWHEADLINKS = "style_show_head_links";

    /** Name of the property key to set the side element uri. */
    public static final String PROPERTY_SIDE_URI = "style_side_uri";

    /** Name of the property key to set the start folder for navigation and search results. */
    public static final String PROPERTY_STARTFOLDER = "style_main_startfolder";

    /** Property value "none" for overriding certain properties. */
    public static final String PROPERTY_VALUE_NONE = CmsTemplateContentListItem.PROPERTY_VALUE_NONE;

    /** Resource type name for the microsite folders specifying a configurable subsite. */
    public static final String RESOURCE_TYPE_MICROSITE_NAME = "microsite";

    /** The log object for this class. */
    private static final Log LOG = CmsLog.getLog(CmsTemplateBean.class);

    /** Stores the global website area configuration. */
    private CmsXmlContent m_globalConfiguration;

    /** The current layout to parse. */
    private String m_layout;

    /** The default values for building lists of XMLContents. */
    private Map m_listDefaults;

    /** Stores the localized resource Strings. */
    private CmsMessages m_messages;

    /** Stores all properties for the requested resource. */
    private Map m_properties;

    /** Stores the substituted path to the modules resources. */
    private String m_resPath;

    /** Flag determining if the accessible version of the page should be shown. */
    private boolean m_showAccessibleVersion;

    /** Flag determining if the head dhtml navigation should be shown. */
    private boolean m_showHeadNavigation;

    /** Flag determining if the print version should be shown. */
    private boolean m_showPrintVersion;

    /** Stores the path to the start folder for navigation and search. */
    private String m_startFolder;

    /**
     * Empty constructor, required for every JavaBean.<p>
     */
    public CmsTemplateBean() {

        super();
    }

    /**
     * Constructor, with parameters.<p>
     * 
     * Use this constructor for the template.<p>
     * 
     * @param context the JSP page context object
     * @param req the JSP request 
     * @param res the JSP response 
     */
    public CmsTemplateBean(PageContext context, HttpServletRequest req, HttpServletResponse res) {

        super();
        init(context, req, res);
    }

    /**
     * Returns the initialized xmlcontent configuration file.<p>
     * 
     * @param fileName the absolute path to the configuration file
     * @param cms the CmsObject to access the VFS
     * @return the initialized xmlcontent configuration file
     */
    protected static CmsXmlContent getConfigurationFile(String fileName, CmsObject cms) {

        CmsXmlContent configuration = null;
        try {
            CmsFile configFile = cms.readFile(fileName, CmsResourceFilter.IGNORE_EXPIRATION);
            configuration = CmsXmlContentFactory.unmarshal(cms, configFile);
        } catch (Exception e) {
            // problem getting properties, log error
            if (LOG.isInfoEnabled()) {
                LOG.info(Messages.get().getBundle().key(
                    Messages.LOG_XMLCONTEN_CONFIG_NOT_FOUND_2,
                    fileName,
                    cms.getRequestContext().getUri()));
            }
        }
        return configuration;
    }

    /**
     * Builds the main html output for the template foot and includes all subelements depending on the settings.<p>
     *
     * @throws IOException if writing the output fails
     * @throws JspException if including an element fails
     */
    public void buildHtmlBodyEnd() throws IOException, JspException {

        m_properties.put(PARAM_LAYOUT, getLayout());
        // close content column
        JspWriter out = getJspContext().getOut();
        String elementName = FOLDER_ELEMENTS + "body_end.jsp";
        out.print(getTemplateParts().includePart(elementName, "1", getLayout(), this));
        if (!showPrintVersion()) {
            // build the side info box
            include(getExtensionModuleFileUri("elements/info_side.jsp"), null, m_properties);
        }

        // close main content row
        out.print(getTemplateParts().includePart(elementName, "2", getLayout(), this));

        if (!showPrintVersion()) {
            // build the foot links row
            getProperties().put(PARAM_HELPURI, getConfigurationValue("help.uri", PROPERTY_VALUE_NONE));
            getProperties().put(PARAM_LOGINURI, getConfigurationValue("login.uri", PROPERTY_VALUE_NONE));
            include(FOLDER_ELEMENTS + "foot_links.jsp", null, m_properties);
            boolean showMenus = Boolean.valueOf(getConfigurationValue("headnav.menus", CmsStringUtil.TRUE)).booleanValue();
            if (showHeadNavigation() && showMenus) {
                // create the head navigation dhtml menus
                if (getProperties().get(CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH) == null) {
                    getProperties().put(PARAM_SITE, getRequestContext().getSiteRoot());
                    getProperties().put(CmsTemplateNavigation.PARAM_STARTFOLDER, getStartFolder());
                    getProperties().put(CmsTemplateNavigation.PARAM_HEADNAV_FOLDER, getNavigationStartFolder());
                    getProperties().put(
                        CmsTemplateNavigation.PARAM_HEADNAV_MENUDEPTH,
                        getConfigurationValue("headnav.menudepth", "1"));
                    getProperties().put(
                        CmsTemplateNavigation.PARAM_SHOWMENUS,

⌨️ 快捷键说明

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