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

📄 cmspropertytemplateone.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/frontend/templateone/CmsPropertyTemplateOne.java,v $
 * Date   : $Date: 2006/07/20 10:35:10 $
 * Version: $Revision: 1.31 $
 *
 * 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.CmsProperty;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.types.CmsResourceTypeBinary;
import org.opencms.file.types.CmsResourceTypeImage;
import org.opencms.file.types.CmsResourceTypePlain;
import org.opencms.file.types.CmsResourceTypeXmlPage;
import org.opencms.frontend.templateone.modules.CmsLayoutXmlContentHandler;
import org.opencms.i18n.CmsEncoder;
import org.opencms.i18n.CmsMessages;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.jsp.util.CmsTemplateContentListItem;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.CmsDialogSelector;
import org.opencms.workplace.CmsWorkplace;
import org.opencms.workplace.I_CmsDialogHandler;
import org.opencms.workplace.commons.CmsPropertyCustom;
import org.opencms.workplace.explorer.CmsExplorerTypeSettings;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;

import org.apache.commons.logging.Log;

/**
 * This property dialog is shown specially by files using the OpenCms template one,
 * and for any folders except system folders.<p>
 * 
 * @author Armen Markarian 
 * @author Andreas Zahner 
 * 
 * @version $Revision: 1.31 $ 
 * 
 * @since 6.0.0 
 */
public class CmsPropertyTemplateOne extends CmsPropertyCustom implements I_CmsDialogHandler {

    /** 
     * Contains all properties to set with this customized dialog.<p>
     *  
     * Loop this to get the HTTP request data and set the property values.<p>
     */
    private static final String[] ALL_PROPERTIES = {

        CmsTemplateNavigation.PROPERTY_HEADNAV_USE,
        CmsTemplateBean.PROPERTY_SHOWHEADIMAGE,
        CmsTemplateBean.PROPERTY_HEAD_IMGURI,
        CmsTemplateBean.PROPERTY_HEAD_IMGLINK,
        CmsTemplateBean.PROPERTY_HEAD_ELEMENTURI,
        CmsTemplateBean.PROPERTY_SHOW_HEADNAV,
        CmsTemplateBean.PROPERTY_SHOW_NAVLEFT,
        CmsTemplateBean.PROPERTY_NAVLEFT_ELEMENTURI,
        CmsTemplateBean.PROPERTY_SIDE_URI,
        CmsTemplateBean.PROPERTY_CONFIGPATH,
        CmsTemplateBean.PROPERTY_LAYOUT_CENTER,
        CmsTemplateBean.PROPERTY_LAYOUT_RIGHT};

    /** 
     * String Array with default properties.<p>
     *  
     * Loop this to create form fields or get HTTP request data and set the property values.<p>
     */
    private static final String[] DEFAULT_PROPERTIES = {

    CmsPropertyDefinition.PROPERTY_TITLE, CmsPropertyDefinition.PROPERTY_DESCRIPTION};

    /** Mode used for switching between different radio types. */
    private static final String ENABLE = "enable";

    /** Mode used for switching between different radio types. */
    private static final String INDIVIDUAL = "individual";

    /** Prefix for the localized keys of the dialog. */
    private static final String KEY_PREFIX = "templateonedialog.";

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

    /** The module path. */
    private static final String MODULE_PATH = "/system/modules/org.opencms.frontend.templateone/";

    /** The default parameter value. */
    private static final String PARAM_DEFAULT = "";

    /** The false parameter value. */
    private static final String PARAM_FALSE = CmsStringUtil.FALSE;

    /** The true parameter value. */
    private static final String PARAM_TRUE = CmsStringUtil.TRUE;

    /** The path of the "template one" template. */
    private static final String TEMPLATE_ONE = "/system/modules/org.opencms.frontend.templateone/templates/main";

    /** The VFS path to the global configuration files for content lists. */
    private static final String VFS_PATH_CONFIGFILES = CmsWorkplace.VFS_PATH_SYSTEM + "shared/templateone/";

    /** The VFS path to the global configuration files for center content lists. */
    private static final String VFS_PATH_CONFIGFILES_CENTER = VFS_PATH_CONFIGFILES + "center/";

    /** The VFS path to the global configuration files for right content lists. */
    private static final String VFS_PATH_CONFIGFILES_RIGHT = VFS_PATH_CONFIGFILES + "right/";

    /**
     * Default constructor needed for dialog handler implementation.<p>
     * 
     * Do not use this constructor on JSP pages.<p>
     */
    public CmsPropertyTemplateOne() {

        super(null);
    }

    /**
     * Public constructor with JSP action element.<p>
     * 
     * @param jsp an initialized JSP action element
     */
    public CmsPropertyTemplateOne(CmsJspActionElement jsp) {

        super(jsp);
    }

    /**
     * Public constructor with JSP variables.<p>
     * 
     * @param context the JSP page context
     * @param req the JSP request
     * @param res the JSP response
     */
    public CmsPropertyTemplateOne(PageContext context, HttpServletRequest req, HttpServletResponse res) {

        super(new CmsJspActionElement(context, req, res));
    }

    /**
     * Performs the edit properties action, will be called by the JSP page.<p>
     * 
     * @param request the HttpServletRequest
     * @throws JspException if problems including sub-elements occur
     */
    public void actionEdit(HttpServletRequest request) throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
        try {
            // save the changes only if resource is properly locked
            if (isEditable()) {
                performEditOperation(request);
            }
        } catch (Throwable e) {
            // Cms checked error defining property, show error dialog
            includeErrorpage(this, e);
        }
    }

    /**
     * Build the html for a property checkbox.<p>
     * 
     * @param propertyName the property name
     * @param propertyValue the property value
     * @param propertyText the property text
     * 
     * @return the html for a property checkbox
     */
    public String buildCheckBox(String propertyName, String propertyValue, String propertyText) {

        StringBuffer checkbox = new StringBuffer();
        checkbox.append(buildTableRowStart(key(propertyText)));
        String checked = "";
        if (getActiveProperties().containsKey(propertyName)) {
            // the property is used, so create text field with checkbox and hidden field
            CmsProperty currentProperty = (CmsProperty)getActiveProperties().get(propertyName);

            String propValue = currentProperty.getValue();
            if (propValue != null) {
                propValue = propValue.trim();
            }
            propValue = CmsEncoder.escapeXml(propValue);
            if (propertyValue.equals(propValue)) {
                checked = " checked=\"checked\"";
            }
        } else {
            // check radio if param value is the default
            if (propertyValue.equals(PARAM_DEFAULT)) {
                checked = " checked=\"checked\"";
            }
        }
        checkbox.append("<input type=\"checkbox\" name=\"");
        checkbox.append(PREFIX_VALUE);
        checkbox.append(propertyName);
        checkbox.append("\" value=\"");
        checkbox.append(propertyValue);
        checkbox.append("\"");
        checkbox.append(checked);
        checkbox.append(">");
        checkbox.append(buildTableRowEnd());

        return checkbox.toString();
    }

    /**
     * Creates the HTML String for the edit properties form.<p>
     * 
     * @return the HTML output String for the edit properties form
     */
    public String buildEditForm() {

        CmsMessages messages = Messages.get().getBundle(getLocale());
        StringBuffer result = new StringBuffer();

        // check if the properties are editable
        boolean editable = isEditable();

        // create the column heads
        result.append("<table border=\"0\">\n");
        result.append("<tr>\n");
        result.append("\t<td class=\"textbold\">");
        result.append(messages.key(Messages.GUI_INPUT_PROPERTY_0));
        result.append("</td>\n");
        result.append("\t<td class=\"textbold maxwidth\">");
        result.append(messages.key(Messages.GUI_LABEL_VALUE_0));
        result.append("</td>\n");
        result.append("\t<td class=\"textbold\" style=\"white-space: nowrap;\">");
        result.append(messages.key(Messages.GUI_USED_PROPERTY_0));
        result.append("</td>\n");
        result.append("</tr>\n");
        result.append("<tr><td colspan=\"3\"><span style=\"height: 6px;\"></span></td></tr>\n");

        // create the text property input rows from m_defaultProperties
        for (int i = 0; i < DEFAULT_PROPERTIES.length; i++) {
            result.append(buildPropertyEntry(DEFAULT_PROPERTIES[i], key(KEY_PREFIX + DEFAULT_PROPERTIES[i]), editable));
        }

        // show navigation properties
        result.append(buildNavigationProperties(editable));

        // build head nav checkbox
        result.append(buildCheckBox(CmsTemplateNavigation.PROPERTY_HEADNAV_USE, PARAM_TRUE, KEY_PREFIX
            + CmsTemplateNavigation.PROPERTY_HEADNAV_USE));

        // build head image radio buttons        
        result.append(buildRadioButtons(
            CmsTemplateBean.PROPERTY_SHOWHEADIMAGE,
            INDIVIDUAL,
            "toggleHeadImageProperties",
            editable));

        // build image uri search input 
        result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_HEAD_IMGURI, KEY_PREFIX
            + CmsTemplateBean.PROPERTY_HEAD_IMGURI, editable, messages));
        // build image link search input 
        result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_HEAD_IMGLINK, KEY_PREFIX
            + CmsTemplateBean.PROPERTY_HEAD_IMGLINK, editable, messages));

        // build head element search input 
        result.append(buildPropertySearchEntry(CmsTemplateBean.PROPERTY_HEAD_ELEMENTURI, KEY_PREFIX
            + CmsTemplateBean.PROPERTY_HEAD_ELEMENTURI, editable, messages));

        // build head navigation radio buttons   
        result.append(buildRadioButtons(CmsTemplateBean.PROPERTY_SHOW_HEADNAV, ENABLE, null, editable));

⌨️ 快捷键说明

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