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

📄 cmscommentimages.java

📁 找了很久才找到到源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                description = getCms().readPropertyObject(res, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false).getValue();
            } catch (CmsException e) {
                // log, should never happen
                if (LOG.isErrorEnabled()) {
                    LOG.error(e.getLocalizedMessage(getLocale()));
                }
            }
            result.append("\t\t<tr>\n\t\t\t<td style=\"white-space: nowrap; vertical-align: top;\" unselectable=\"on\">");
            result.append(key(Messages.GUI_LABEL_DESCRIPTION_0));
            result.append(":</td>\n\t\t\t<td style=\"vertical-align: top; height: 110px;\">");
            result.append("<textarea rows=\"8\" class=\"maxwidth\" style=\"overflow: auto;\" name=\"");
            result.append(PREFIX_DESCRIPTION);
            result.append(propertySuffix);
            result.append("\">");
            if (CmsStringUtil.isNotEmpty(description)) {
                result.append(CmsEncoder.escapeXml(description));
            }
            result.append("</textarea>");
            result.append("</td>\n\t\t</tr>\n");

            result.append("\t\t</table>\n");

            result.append("</td>\n</tr>\n");
            result.append("</table>\n");
            result.append(dialogBlockEnd());

            if (i.hasNext()) {
                // append spacer if another entry follows
                result.append(dialogSpacer());
            }
        }

        result.append("</div>");

        return result.toString();
    }

    /**
     * Returns the image resources of the gallery folder which are edited in the dialog form.<p>
     * 
     * @return the images of the gallery folder which are edited in the dialog form
     */
    protected List getImages() {

        // get all image resources of the folder
        CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION.addRequireType(CmsResourceTypeImage.getStaticTypeId());
        try {
            return getCms().readResources(getParamResource(), filter, false);
        } catch (CmsException e) {
            // log, should never happen
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(getLocale()));
            }
            return new ArrayList(0);
        }
    }

    /**
     * Returns the initialized image scaler object used to generate thumbnails for the dialog form.<p>
     * 
     * @return the initialized image scaler object used to generate thumbnails for the dialog form
     */
    protected CmsImageScaler getImageScaler() {

        if (m_imageScaler == null) {
            // not initialized, create image scaler with default settings
            m_imageScaler = new CmsImageScaler();
            m_imageScaler.setWidth(THUMB_WIDTH);
            m_imageScaler.setHeight(THUMB_HEIGHT);
            m_imageScaler.setRenderMode(Simapi.RENDER_SPEED);
            m_imageScaler.setColor(new Color(0, 0, 0));
            m_imageScaler.setType(1);
        }
        return m_imageScaler;
    }

    /**
     * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
     */
    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {

        // fill the parameter values in the get/set methods
        fillParamValues(request);

        // check the required permissions to rename the resource       
        if (!checkResourcePermissions(CmsPermissionSet.ACCESS_WRITE, false)) {
            // no write permissions for the resource, set cancel action to close dialog
            setParamAction(DIALOG_CANCEL);
        }

        // set the dialog type
        setParamDialogtype(DIALOG_TYPE);
        // set the action for the JSP switch 
        if (DIALOG_TYPE.equals(getParamAction())) {
            setAction(ACTION_COMMENTIMAGES);
        } else if (DIALOG_LOCKS_CONFIRMED.equals(getParamAction())) {
            setAction(ACTION_LOCKS_CONFIRMED);
        } else if (DIALOG_CANCEL.equals(getParamAction())) {
            setAction(ACTION_CANCEL);
        } else {
            setAction(ACTION_DEFAULT);
            // build title for comment images dialog
            Object[] args = new Object[] {getParamResource()};
            setParamTitle(key(Messages.GUI_COMMENTIMAGES_TITLE_1, args));
        }
    }

    /**
     * Performs the comment images operation.<p>
     * 
     * @return true, if the resources were successfully processed, otherwise false
     * @throws CmsException if commenting is not successful
     */
    protected boolean performDialogOperation() throws CmsException {

        // lock the image gallery folder
        checkLock(getParamResource());

        Iterator i = getImages().iterator();
        // loop over all image resources to change the properties
        while (i.hasNext()) {
            CmsResource res = (CmsResource)i.next();
            String imageName = res.getName();
            String propertySuffix = "" + imageName.hashCode();

            // update the title property
            CmsProperty titleProperty = getCms().readPropertyObject(res, CmsPropertyDefinition.PROPERTY_TITLE, false);
            String newValue = getJsp().getRequest().getParameter(PREFIX_TITLE + propertySuffix);
            writeProperty(res, CmsPropertyDefinition.PROPERTY_TITLE, newValue, titleProperty);

            // update the description property
            CmsProperty descProperty = getCms().readPropertyObject(
                res,
                CmsPropertyDefinition.PROPERTY_DESCRIPTION,
                false);
            newValue = getJsp().getRequest().getParameter(PREFIX_DESCRIPTION + propertySuffix);
            writeProperty(res, CmsPropertyDefinition.PROPERTY_DESCRIPTION, newValue, descProperty);
        }

        return true;
    }

    /**
     * Writes a property value for a resource, if the value was changed.<p>
     * 
     * @param res the resource to write the property to
     * @param propName the name of the property definition
     * @param propValue the new value of the property
     * @param currentProperty the old property object
     * @throws CmsException if something goes wrong
     */
    protected void writeProperty(CmsResource res, String propName, String propValue, CmsProperty currentProperty)
    throws CmsException {

        // check if current property is not the null property
        if (currentProperty.isNullProperty()) {
            // create new property object
            currentProperty = new CmsProperty();
            currentProperty.setName(propName);
        }

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(propValue)) {
            // parameter is empty, determine the value to delete
            boolean writeProperty = false;
            if (currentProperty.getStructureValue() != null) {
                currentProperty.setStructureValue(CmsProperty.DELETE_VALUE);
                currentProperty.setResourceValue(null);
                writeProperty = true;
            } else if (currentProperty.getResourceValue() != null) {
                currentProperty.setResourceValue(CmsProperty.DELETE_VALUE);
                currentProperty.setStructureValue(null);
                writeProperty = true;
            }
            if (writeProperty) {
                // write the updated property object
                getCms().writePropertyObject(getCms().getSitePath(res), currentProperty);
            }
        } else {
            // parameter is not empty, check if the value has changed
            if (!propValue.equals(currentProperty.getValue())) {
                if ((currentProperty.getStructureValue() == null) && (currentProperty.getResourceValue() == null)) {
                    // new property, determine setting from OpenCms workplace configuration
                    if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
                        currentProperty.setStructureValue(propValue);
                        currentProperty.setResourceValue(null);
                    } else {
                        currentProperty.setResourceValue(propValue);
                        currentProperty.setStructureValue(null);
                    }
                } else if (currentProperty.getStructureValue() != null) {
                    // structure value has to be updated
                    currentProperty.setStructureValue(propValue);
                    currentProperty.setResourceValue(null);
                } else {
                    // resource value has to be updated
                    currentProperty.setResourceValue(propValue);
                    currentProperty.setStructureValue(null);
                }
                // write the updated property object
                getCms().writePropertyObject(getCms().getSitePath(res), currentProperty);
            }
        }
    }

}

⌨️ 快捷键说明

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