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

📄 cmscommentimages.java

📁 找了很久才找到到源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/commons/CmsCommentImages.java,v $
 * Date   : $Date: 2007-08-13 16:29:43 $
 * Version: $Revision: 1.5 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) 2002 - 2007 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.workplace.commons;

import com.alkacon.simapi.Simapi;

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.CmsResourceTypeImage;
import org.opencms.i18n.CmsEncoder;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.loader.CmsImageScaler;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.security.CmsPermissionSet;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.CmsDialog;
import org.opencms.workplace.CmsWorkplaceSettings;

import java.awt.Color;
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;

/**
 * Provides methods for the comment images dialog on image gallery folders.<p> 
 * 
 * The following files use this class:
 * <ul>
 * <li>/commons/commentimages.jsp
 * </ul>
 * <p>
 *
 * @author  Andreas Zahner 
 * 
 * @version $Revision: 1.5 $ 
 * 
 * @since 6.1.3
 */
public class CmsCommentImages extends CmsDialog {

    /** Value for the action: comment images. */
    public static final int ACTION_COMMENTIMAGES = 100;

    /** The dialog type. */
    public static final String DIALOG_TYPE = "commentimages";

    /** The input field prefix for description property fields. */
    public static final String PREFIX_DESCRIPTION = "desc_";

    /** The input field prefix for title property fields. */
    public static final String PREFIX_TITLE = "title_";

    /** The height of the dialog thumbnails. */
    public static final int THUMB_HEIGHT = 150;

    /** The width of the dialog thumbnails. */
    public static final int THUMB_WIDTH = 200;

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

    /** The image scaler object used in the dialog input form. */
    private CmsImageScaler m_imageScaler;

    /**
     * Public constructor with JSP action element.<p>
     * 
     * @param jsp an initialized JSP action element
     */
    public CmsCommentImages(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 CmsCommentImages(PageContext context, HttpServletRequest req, HttpServletResponse res) {

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

    /**
     * Performs the comment images action, will be called by the JSP page.<p>
     * 
     * @throws JspException if problems including sub-elements occur
     */
    public void actionCommentImages() throws JspException {

        // save initialized instance of this class in request attribute for included sub-elements
        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
        try {
            performDialogOperation();
            // if no exception is caused comment operation was successful
            actionCloseDialog();
        } catch (Throwable e) {
            // error during rename images, show error dialog
            includeErrorpage(this, e);
        }
    }

    /**
     * Returns the HTML for the dialog input form to comment the images.<p>
     * 
     * @return the HTML for the dialog input form to comment the images
     */
    public String buildDialogForm() {

        StringBuffer result = new StringBuffer(16384);
        Iterator i = getImages().iterator();

        result.append("<div style=\"height: 450px; padding: 4px; overflow: auto;\">");

        while (i.hasNext()) {
            CmsResource res = (CmsResource)i.next();
            String imageName = res.getName();
            String propertySuffix = "" + imageName.hashCode();
            result.append(dialogBlockStart(imageName));
            result.append("<table border=\"0\">\n");
            result.append("<tr>\n\t<td style=\"vertical-align: top;\">");
            // create image tag
            result.append("<img src=\"");
            StringBuffer link = new StringBuffer(256);
            link.append(getCms().getSitePath(res));
            link.append(getImageScaler().toRequestParam());
            result.append(getJsp().link(link.toString()));
            result.append("\" border=\"0\" alt=\"\" width=\"");
            result.append(getImageScaler().getWidth());
            result.append("\" height=\"");
            result.append(getImageScaler().getHeight());
            result.append("\">");

            result.append("</td>\n");
            result.append("\t<td class=\"maxwidth\" style=\"vertical-align: top;\">\n");

            result.append("\t\t<table border=\"0\">\n");

            // build title property input row
            String title = "";
            try {
                title = getCms().readPropertyObject(res, CmsPropertyDefinition.PROPERTY_TITLE, 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;\" unselectable=\"on\">");
            result.append(key(Messages.GUI_LABEL_TITLE_0));
            result.append(":</td>\n\t\t\t<td class=\"maxwidth\">");
            result.append("<input type=\"text\" class=\"maxwidth\" name=\"");
            result.append(PREFIX_TITLE);
            result.append(propertySuffix);
            result.append("\" value=\"");
            if (CmsStringUtil.isNotEmpty(title)) {
                result.append(CmsEncoder.escapeXml(title));
            }
            result.append("\">");
            result.append("</td>\n\t\t</tr>\n");

            // build description property input row
            String description = "";
            try {

⌨️ 快捷键说明

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