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

📄 cmspropertydelete.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

    /**
     * Builds a HTML list of Resources that use the specified property.<p>
     *  
     * @throws CmsException if operation was not successful
     * 
     * @return the HTML String for the Resource list
     */
    public String buildResourceList() throws CmsException {

        List resourcesWithProperty = getCms().readResourcesWithProperty(getParamPropertyName());

        return buildResourceList(resourcesWithProperty, false);
    }

    /**
     * Builds a HTML list of Resources.<p>
     * 
     * Columns: Type, Name, Uri, Value of the property, locked by(optional).<p>
     *  
     * @param resourceList a list of resources
     * @param lockInfo a boolean to decide if the locked info should be shown or not
     * @throws CmsException if operation was not successful
     * 
     * @return the HTML String for the Resource list
     */
    public String buildResourceList(List resourceList, boolean lockInfo) throws CmsException {

        // reverse the resource list
        Collections.reverse(resourceList);
        CmsMessages messages = Messages.get().getBundle(getLocale());
        StringBuffer result = new StringBuffer();
        result.append("<table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"1\">\n");
        result.append("<tr>\n");
        // Type        
        result.append("\t<td style=\"width:5%;\" class=\"textbold\">");
        result.append(messages.key(Messages.GUI_INPUT_TYPE_0));
        result.append("</td>\n");
        // Uri
        result.append("\t<td style=\"width:40%;\" class=\"textbold\">");
        result.append(messages.key(Messages.GUI_INPUT_ADRESS_0));
        result.append("</td>\n");
        // Name
        result.append("\t<td style=\"width:25%;\" class=\"textbold\">");
        result.append(messages.key(Messages.GUI_INPUT_TITLE_0));
        result.append("</td>\n");
        if (!lockInfo) {
            // Property value
            result.append("\t<td style=\"width:30%;\" class=\"textbold\">");
            result.append(messages.key(Messages.GUI_INPUT_PROPERTYVALUE_0));
            result.append("</td>\n");
        }
        if (lockInfo) {
            // Property value
            result.append("\t<td style=\"width:30%;\" class=\"textbold\">");
            result.append(messages.key(Messages.GUI_EXPLORER_LOCKEDBY_0));
            result.append("</td>\n");
            result.append("</tr>\n");
        }
        result.append("</tr>\n");
        result.append("<tr><td colspan=\"4\"><span style=\"height: 6px;\">&nbsp;</span></td></tr>\n");

        getCms().getRequestContext().saveSiteRoot();
        getCms().getRequestContext().setSiteRoot("/");
        try {
            Iterator i = resourceList.iterator();
            while (i.hasNext()) {
                CmsResource resource = (CmsResource)i.next();
                String filetype = OpenCms.getResourceManager().getResourceType(resource.getTypeId()).getTypeName();
                result.append("<tr>\n");
                // file type
                result.append("\t<td>");
                result.append("<img src=\"");
                result.append(getSkinUri());
                result.append("filetypes/");
                result.append(filetype);
                result.append(".gif\">");
                result.append("</td>\n");
                // file address
                result.append("\t<td>");
                result.append(resource.getRootPath());
                result.append("</td>\n");
                // title
                result.append("\t<td>");
                result.append(getJsp().property(CmsPropertyDefinition.PROPERTY_TITLE, resource.getRootPath(), ""));
                result.append("</td>\n");
                // current value of the property
                if (!lockInfo) {
                    result.append("\t<td>");
                    result.append(getJsp().property(getParamPropertyName(), resource.getRootPath()));
                    result.append("</td>\n");
                }
                // locked by user
                if (lockInfo) {
                    CmsLock lock = getCms().getLock(resource);
                    result.append("\t<td>");
                    result.append(getCms().readUser(lock.getUserId()).getName());
                    result.append("</td>\n");
                }
                result.append("</tr>\n");
            }
            result.append("</table>\n");
        } finally {
            getCms().getRequestContext().restoreSiteRoot();
        }

        return result.toString();
    }

    /**
     * Builds the html for the property definition select box.<p>
     * 
     * @param attributes optional attributes for the &lt;select&gt; tag
     * @return the html for the property definition select box
     */
    public String buildSelectProperty(String attributes) {

        return CmsPropertyChange.buildSelectProperty(getCms(), Messages.get().getBundle(getLocale()).key(
            Messages.GUI_PLEASE_SELECT_0), attributes, "");
    }

    /**
     * Returns the value of the propertyname parameter.<p>
     *
     * @return the value of the propertyname parameter
     */
    public String getParamPropertyName() {

        return m_paramPropertyName;
    }

    /**
     * Sets the value of the propertyname parameter.<p>
     *
     * @param paramPropertyName the value of the propertyname parameter
     */
    public void setParamPropertyName(String paramPropertyName) {

        m_paramPropertyName = paramPropertyName;
    }

    /**
     * @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);
        // set the dialog type
        setParamDialogtype(DIALOG_TYPE);
        // set the action for the JSP switch 
        if (DIALOG_OK.equals(getParamAction())) {
            setAction(ACTION_OK);
            setParamTitle(Messages.get().getBundle(getLocale()).key(Messages.GUI_TITLE_PROPERTYDELETE_0) + ": " + getParamPropertyName());
        } else if (DIALOG_CANCEL.equals(getParamAction())) {
            setAction(ACTION_CANCEL);
        } else if (DIALOG_DELETE_CASCADE.equals(getParamAction())) {
            setAction(ACTION_DELETE_CASCADE);
        } else {
            setAction(ACTION_DEFAULT);
            // build title for change property value dialog     
            setParamTitle(Messages.get().getBundle(getLocale()).key(Messages.GUI_TITLE_PROPERTYDELETE_0));
        }
    }

    /**
     * Returns a list of resources that are locked by another user as the current user.<p>
     * 
     * @param resourceList the list of all (mixed) resources
     * 
     * @return a list of resources that are locked by another user as the current user
     * @throws CmsException if the getLock operation fails
     */
    private List getResourcesLockedByOtherUser(List resourceList) throws CmsException {

        List lockedResourcesByOtherUser = new ArrayList();
        Iterator i = resourceList.iterator();
        while (i.hasNext()) {
            CmsResource resource = (CmsResource)i.next();
            // get the lock state for the resource
            CmsLock lock = getCms().getLock(resource);
            // add this resource to the list if this is locked by another user
            if (lock.getType() != CmsLock.TYPE_UNLOCKED
                && !lock.getUserId().equals(getCms().getRequestContext().currentUser().getId())) {
                lockedResourcesByOtherUser.add(resource);
            }
        }

        return lockedResourcesByOtherUser;
    }
}

⌨️ 快捷键说明

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