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

📄 cmspropertytemplateone.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        CmsProperty currentProperty = (CmsProperty)getActiveProperties().get(propertyName);
        if (currentProperty != null) {
            propValue = currentProperty.getValue();
            if (CmsStringUtil.isEmpty(propValue)) {
                if (CmsTemplateBean.PROPERTY_HEAD_IMGURI.equals(propertyName)
                    || CmsTemplateBean.PROPERTY_HEAD_IMGLINK.equals(propertyName)) {
                    String tmp = getDefault(propertyName);
                    if (!CmsStringUtil.isEmpty(tmp)) {
                        propValue = tmp;
                    }
                }
            } else {
                propValue = propValue.trim();
            }
        }

        propValue = CmsEncoder.escapeXml(propValue);
        result.append("<input type=\"text\" style=\"width: 99%\" class=\"maxwidth\" ");
        result.append("name=\"");
        result.append(PREFIX_VALUE);
        result.append(propertyName);
        result.append("\" id=\"");
        result.append(PREFIX_VALUE);
        result.append(propertyName);
        result.append("\" value=\"");
        result.append(propValue);
        result.append("\"");
        result.append(disabled);
        result.append(">");
        result.append("<input type=\"hidden\" name=\"");
        result.append(PREFIX_HIDDEN);
        result.append(propertyName);
        result.append("\" id=\"");
        result.append(PREFIX_HIDDEN);
        result.append(propertyName);
        result.append("\" value=\"");
        result.append(propValue);
        result.append("\">");
        result.append("</td>\n");
        result.append("<td>");
        result.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
        result.append("\t<tr>\n");
        result.append("<td>&nbsp;&nbsp;</td>");
        result.append("<td><a href=\"#\" onclick=\"javascript:top.openTreeWin('copy', true, 'main', '");
        result.append(PREFIX_VALUE);
        result.append(propertyName);
        result.append("', document);\" class=\"button\" title=\"");
        result.append(messages.key(Messages.GUI_BUTTON_SEARCH_0));
        result.append("\"><img class=\"button\" src=\"");
        result.append(getSkinUri());
        result.append("/buttons/folder.png\" border=\"0\"></a></td>");
        result.append("</tr>\n");
        result.append("</table>\n");
        result.append("</td>\n");
        result.append("</tr>");

        return result;
    }

    /**
     * Builds the html for a single selectbox property row to select the list layout.<p>
     * 
     * @param listType determines the content list type, "center" or "right"
     * @param propertyName the name of the property
     * @param propertyTitle the nice name of the property
     * @param editable indicates if the properties are editable
     * 
     * @return the html for a single text input property row
     */
    private StringBuffer buildPropertySelectbox(
        String listType,
        String propertyName,
        String propertyTitle,
        boolean editable) {

        StringBuffer result = new StringBuffer(128);
        result.append(buildTableRowStart(key(propertyTitle)));
        String disabled = "";
        if (!editable) {
            disabled = " disabled=\"disabled\"";
        }
        String propValue = "";
        // get property object from active properties
        CmsProperty currentProperty = (CmsProperty)getActiveProperties().get(propertyName);
        String inheritedValue = "";
        if (currentProperty != null) {
            // property value is directly set on resource
            propValue = currentProperty.getValue();
            inheritedValue = getDefault(propertyName);
        } else {
            // property is not set on resource
            propValue = getDefault(propertyName);
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(propValue)) {
                propValue = "";
            }
            inheritedValue = propValue;
        }

        List resources = getConfigurationFiles(listType);
        List options = new ArrayList(resources.size() + 1);
        List values = new ArrayList(resources.size() + 1);
        int selectedIndex = 0;

        // add the "none" option manually to selectbox
        options.add(key(KEY_PREFIX + "nolayout"));
        if ("".equals(propValue)
            || ("".equals(inheritedValue))
            || (CmsTemplateBean.PROPERTY_VALUE_NONE.equals(inheritedValue))) {
            // value is not set anywhere or is inherited from ancestor folder
            values.add("");
        } else {
            values.add(CmsTemplateBean.PROPERTY_VALUE_NONE);
        }

        for (int i = 0; i < resources.size(); i++) {
            // loop all found resources defining the layout
            CmsResource res = (CmsResource)resources.get(i);
            String path = getCms().getSitePath(res);
            // determine description to show for layout
            String description = "";
            try {
                description = getCms().readPropertyObject(path, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false).getValue(
                    null);
                if (CmsStringUtil.isEmpty(description)) {
                    description = getCms().readPropertyObject(path, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue(
                        path);
                }
            } catch (CmsException e) {
                // should never happen
                if (LOG.isErrorEnabled()) {
                    LOG.error(e);
                }
            }
            // try to find a localized key for the description property value
            String localized = key(description);
            if (localized.startsWith(CmsMessages.UNKNOWN_KEY_EXTENSION)) {
                localized = description;
            }
            options.add(localized);
            // check if this item is selected
            if (path.equals(propValue)) {
                selectedIndex = i + 1;
            }
            // determine value to add
            if (path.equals(inheritedValue)) {
                // the current path is like inherited path, so do not write property in this case
                path = "";
            }
            values.add(path);
        }
        // create select tag attributes
        StringBuffer attrs = new StringBuffer(4);
        attrs.append("name=\"").append(PREFIX_VALUE).append(propertyName).append("\"");
        attrs.append(" class=\"maxwidth\"");
        attrs.append(disabled);
        // create the select box
        result.append(buildSelect(attrs.toString(), options, values, selectedIndex));

        // build the hidden field with old property value
        result.append("<input type=\"hidden\" name=\"");
        result.append(PREFIX_HIDDEN);
        result.append(propertyName);
        result.append("\" id=\"");
        result.append(PREFIX_HIDDEN);
        result.append(propertyName);
        result.append("\" value=\"");
        result.append(propValue);
        result.append("\">");
        result.append("</td>\n");
        result.append("</tr>");

        return result;
    }

    /**
     * Builds the HTML for a complete Row with three radio Buttons.<p>
     * 
     * The propertyName will be translated in workplace.properties
     * 
     * Schema: 
     * Radio 1: Default (embedded)
     * Radio 2: Individual or Enable (depends on parameter mode)
     * Radio 3: Disable (embedded)
     * 
     * @param propertyName the name of the current property
     * @param mode the switch mode for the nice name
     * @param JSToggleFunction the javascript function for onclick handling
     * @param editable indicates if the properties are editable
     * 
     * @return the HTML for the row with three radio buttons
     */
    private StringBuffer buildRadioButtons(String propertyName, String mode, String JSToggleFunction, boolean editable) {

        StringBuffer result = new StringBuffer(256);
        // propertyName will be translated in workplace.properties
        result.append(buildTableRowStart(key(KEY_PREFIX + propertyName), 2));
        result.append("\t<table border=\"0\">\n");
        result.append("\t<tr>\n");
        result.append("\t<td>\n");
        result.append(buildPropertyRadioEntry(
            propertyName,
            PARAM_DEFAULT,
            key(KEY_PREFIX + "radio.default"),
            JSToggleFunction,
            editable));
        result.append("</td>\n");
        result.append("\t<td>\n");
        result.append(buildPropertyRadioEntry(
            propertyName,
            PARAM_TRUE,
            key(KEY_PREFIX + "radio." + mode),
            JSToggleFunction,
            editable));
        result.append("</td>\n");
        result.append("\t<td>\n");
        result.append(buildPropertyRadioEntry(
            propertyName,
            PARAM_FALSE,
            key(KEY_PREFIX + "radio.disable"),
            JSToggleFunction,
            editable));
        result.append("</td>\n");
        result.append("</tr>\n");
        result.append("</table>\n");
        result.append(buildTableRowEnd());

        return result;
    }

    /**
     * Builds the HTML for the start of a table row for a single property with colspan.<p>
     * 
     * Use this e.g. when the checkbox on the right side is not needed
     * 
     * @param propertyName the name of the current property
     * @param colspan the number of colspans
     * @return the HTML code for the start of a table row
     */
    private StringBuffer buildTableRowStart(String propertyName, int colspan) {

        StringBuffer result = new StringBuffer(96);
        result.append("<tr>\n");
        result.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">");
        result.append(propertyName);
        result.append("</td>\n");
        result.append("\t<td class=\"maxwidth\" colspan=\"");
        result.append(String.valueOf(colspan));
        result.append("\">");

        return result;
    }

    /**
     * Returns the layout configuration files for the specified list type.<p>
     *
     * @param listType the type of the layout list, "center" or "right"
     * @return the layout configuration files for the specified list type
     */
    private List getConfigurationFiles(String listType) {

        List result = new ArrayList();
        String configFolder;
        if (listType.equals(CmsTemplateContentListItem.DISPLAYAREA_CENTER)) {
            configFolder = VFS_PATH_CONFIGFILES_CENTER;
        } else {
            configFolder = VFS_PATH_CONFIGFILES_RIGHT;
        }
        try {
            // first get the default layout files for the list type
            result = getCms().readResources(configFolder, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);

            // add eventual individual layout files for the list type in the microsite 
            String configPath = getCms().readPropertyObject(
                getParamResource(),
                CmsTemplateBean.PROPERTY_CONFIGPATH,
                true).getValue();
            if (CmsStringUtil.isNotEmpty(configPath)) {
                int type = OpenCms.getResourceManager().getResourceType(CmsLayoutXmlContentHandler.CONFIG_RESTYPE_NAME).getTypeId();
                CmsResourceFilter filter = CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(type);
                Iterator i = getCms().readResources(configPath, filter, false).iterator();
                while (i.hasNext()) {
                    CmsResource res = (CmsResource)i.next();
                    // read column property
                    String column = getCms().readPropertyObject(
                        getCms().getSitePath(res),
                        CmsLayoutXmlContentHandler.PROPERTY_LAYOUT_COLUMN,
                        false).getValue();
                    if (listType.equals(column)) {
                        // add resource to list
                        result.add(res);
                    }
                }
            }
        } catch (CmsException e) {
            // error reading resources
            if (LOG.isErrorEnabled()) {
                LOG.error(e);
            }
        }
        return result;
    }
}

⌨️ 快捷键说明

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