cmslinkgallery.java

来自「找了很久才找到到源代码」· Java 代码 · 共 745 行 · 第 1/3 页

JAVA
745
字号
                    changePointer(res);

                    // build the html

                    // file target
                    String pointer = new String(getCms().readFile(res).getContents());
                    if (CmsStringUtil.isEmptyOrWhitespaceOnly(pointer)) {
                        pointer = getJsp().link(getCms().getSitePath(res));
                    }
                    String title = getPropertyValue(res, CmsPropertyDefinition.PROPERTY_TITLE);
                    String description = getJsp().property(
                        CmsPropertyDefinition.PROPERTY_DESCRIPTION,
                        getParamResourcePath());
                    String keywords = getJsp().property(CmsPropertyDefinition.PROPERTY_KEYWORDS, getParamResourcePath());
                    String lastmodified = getMessages().getDateTime(res.getDateLastModified());

                    html.append("<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" style=\"align: middle; width:100%; background-color: ThreeDFace; margin: 0;\">\n");

                    // Link href input field
                    String link = new StringBuffer(key(Messages.GUI_INPUT_LINKTO_0)).append(
                        " (<a href=\"#\" onclick=\"javascript:window.open('").append(
                        getJsp().link(getCms().getSitePath(res))).append("','_preview','')\">").append(
                        key(Messages.GUI_BUTTON_PREVIEW_0)).append("</a>)").toString();
                    html.append(previewRow(link, pointer, VALUE_EDITPROPERTY_LINK));
                    // file title
                    html.append(previewRow(key(Messages.GUI_INPUT_TITLE_0), title, VALUE_EDITPROPERTY_TITLE));
                    // file name
                    html.append(previewRow(key(Messages.GUI_LABEL_NAME_0), res.getName(), false));
                    // file last modified date
                    html.append(previewRow(key(Messages.GUI_INPUT_DATELASTMODIFIED_0), lastmodified, false));
                    // file description if existing
                    if (CmsStringUtil.isNotEmpty(description)) {
                        html.append(previewRow(key(Messages.GUI_INPUT_DESCRIPTION_0), description));
                    }
                    // file keywords if existing
                    if (CmsStringUtil.isNotEmpty(keywords)) {
                        html.append(previewRow(key(Messages.GUI_INPUT_KEYWORDS_0), keywords));
                    }

                    // hidden value change submit form, controlled by javascript 
                    html.append("<form name=\"pointerchange\" action=\"").append(getJsp().link("gallery_preview.jsp")).append(
                        "\" target=\"gallery_preview\" method=\"post\" class=\"nomargin\">\n");
                    html.append("\t<input type=\"hidden\" id=\"").append(PARAM_EDITPROPERTY).append("\" name=\"").append(
                        PARAM_EDITPROPERTY).append("\"/>\n");
                    html.append("\t<input type=\"hidden\" id=\"").append(PARAM_EDITPROPERTY_VALUE).append("\" name=\"").append(
                        PARAM_EDITPROPERTY_VALUE).append("\"/>\n");
                    html.append("\t<input type=\"hidden\" id=\"").append(PARAM_ACTION).append("\" name=\"").append(
                        PARAM_ACTION).append("\" value=\"").append(DIALOG_EDITPROPERTY).append("\"/>\n");
                    html.append("\t<input type=\"hidden\" id=\"").append(PARAM_RESOURCEPATH).append("\" name=\"").append(
                        PARAM_RESOURCEPATH).append("\"pointerPropertyValue\" value=\"").append(
                        this.getParamResourcePath()).append("\"/>\n");

                    html.append("</form>\n");

                }
            }
        } catch (CmsException e) {
            // reading the resource or property value failed
            LOG.error(e.getLocalizedMessage(), e);
        }
        return html.toString();
    }

    /**
     * Builds the javascript for submitting the property changes for the current pointer in the
     * preview frame.<p>
     * 
     * @return the javascript for submitting the property changes for the current pointer in the
     *      preview frame
     */
    public String dialogScriptSubmit() {

        if (useNewStyle()) {
            return super.dialogScriptSubmit();
        }
        StringBuffer result = new StringBuffer(512);
        result.append("function submitAction(submitFieldId) {\n");
        result.append("\tdocument.pointerchange.").append(PARAM_EDITPROPERTY).append(".value = submitFieldId;\n");
        result.append("\tdocument.pointerchange.").append(PARAM_EDITPROPERTY_VALUE).append(
            ".value = document.getElementById(submitFieldId).value;\n");
        //        result.append("top.setTimeOut('')")
        result.append("\tdocument.pointerchange.submit();\n");
        result.append("\ttop.setTimeout('top.gallery_fs.gallery_head.displayGallery()', 1000);\n");
        result.append("\ttop.setTimeout('top.preview_fs.gallery_buttonbar.location.reload()', 1000);\n");
        result.append("}\n");

        return result.toString();
    }

    /**
     * @see org.opencms.workplace.galleries.A_CmsGallery#getGalleryItemsTypeId()
     */
    public int getGalleryItemsTypeId() {

        return CmsResourceTypePointer.getStaticTypeId();
    }

    /**
     * @see org.opencms.workplace.galleries.A_CmsGallery#getHeadFrameSetHeight()
     */
    public String getHeadFrameSetHeight() {

        return "450";
    }

    /**
     * Returns the order of the implemented gallery, used to sort the gallery buttons in the editors.<p>
     * 
     * @return the order of the implemented gallery
     */
    public Integer getOrder() {

        return ORDER_GALLERY;
    }

    /**
     * Returns the property to edit on the previewed resource parameter value.<p>
     * 
     * @return the parameter value
     */
    public String getParamEditProperty() {

        return m_paramEditProperty;
    }

    /**
     * Returns the property value to edit on the previewed resource parameter value.<p>
     * 
     * @return the parameter value
     */
    public String getParamEditPropertyValue() {

        return m_paramEditPropertyValue;
    }

    /**
     * Returns the url for the new CmsResourceTypePointer dialog.<p>
     * 
     * @return the url for the wizard dialog
     */
    public String getWizardUrl() {

        StringBuffer wizardUrl = new StringBuffer(8);
        wizardUrl.append(getJsp().link(
            PATH_DIALOGS
                + OpenCms.getWorkplaceManager().getExplorerTypeSetting(CmsResourceTypePointer.getStaticTypeName()).getNewResourceUri()));
        wizardUrl.append("?action=newform&");
        wizardUrl.append(CmsNewResourceUpload.PARAM_REDIRECTURL);
        wizardUrl.append("=");
        wizardUrl.append(PATH_GALLERIES);
        wizardUrl.append("gallery_list.jsp&");
        wizardUrl.append(CmsNewResourceUpload.PARAM_TARGETFRAME);
        wizardUrl.append("=gallery_list&");
        wizardUrl.append(CmsNewResource.PARAM_CURRENTFOLDER);
        wizardUrl.append("=");

        return wizardUrl.toString();
    }

    /**
     * Generates a HTML table row with two columns that contain the name on the left side and an a text input on the right side.<p>
     * 
     * The first column includes the given display String, the second column includes an input field with the 
     * id attribute set to <code>column1</code> preset with <code>column2</code>.<p>
     * 
     * @param column1 the string value for the first column
     * 
     * @param column2 the string value for the second column 
     * 
     * @return a HTML table row with two columns
     */
    public String previewRow(String column1, String column2) {

        return previewRow(column1, column2, true);

    }

    /**
     * Generates a HTML table row with two columns that contain the name on the left side and an a text input or 
     * plain text (based upon the boolean argument flag) on the right side.<p>
     * 
     * The first column includes the given display String, the second column includes an input field with the 
     * id attribute set to <code>column1</code> preset with <code>column2</code>.<p>
     * 
     * @param column1 the string value for the first column
     * @param column2 the string value for the second column 
     * @param inputField if <code>true</code> the <tt>column1</tt> parameter is used as <tt>id</tt> attribute for the input field
     * 
     * @return a HTML table row with two columns
     */
    public String previewRow(String column1, String column2, boolean inputField) {

        String result;
        if (inputField) {
            result = previewRow(column1, column2, column1);
        } else {
            StringBuffer previewRow = new StringBuffer();
            previewRow.append("<tr align=\"left\">\n");
            previewRow.append("<td>\n<b><nobr>");
            previewRow.append(column1);
            previewRow.append("&nbsp;</nobr></b>\n</td>\n");
            previewRow.append("<td>\n");
            previewRow.append(column2);
            previewRow.append("</td>\n");
            // this column is for edit button that is not available here: 
            previewRow.append("<td>&nbsp;</td>\n");
            // this is glue or the button would be stretched
            previewRow.append("<td class=\"maxwidth\">&nbsp;</td>\n");
            previewRow.append("</tr>\n");
            result = previewRow.toString();
        }
        return result;
    }

    /**
     * Sets the value of the request parameter <code>{@link #PARAM_EDITPROPERTY}</code>.<p>
     * 
     * @param paramEditProperty the value of the request parameter <code>{@link #PARAM_EDITPROPERTY}</code> to set
     */
    public void setParamEditProperty(String paramEditProperty) {

        m_paramEditProperty = paramEditProperty;
    }

    /**
     * Sets the value of the request parameter <code>{@link #PARAM_EDITPROPERTY_VALUE}</code>.<p>
     * 
     * @param paramEditPropertyValue the value of the request parameter <code>{@link #PARAM_EDITPROPERTY_VALUE}</code> to set
     */
    public void setParamEditPropertyValue(String paramEditPropertyValue) {

        m_paramEditPropertyValue = paramEditPropertyValue;
    }

    /**
     * @see org.opencms.workplace.galleries.A_CmsGallery#wizardButton()
     */
    public String wizardButton() {

        return button("javascript:wizard();", null, "upload.png", Messages.GUI_TITLE_NEW_0, 0);
    }

    /**
     * @see org.opencms.workplace.galleries.A_CmsGallery#buildGalleryItemListCustomEndCols(org.opencms.file.CmsResource, java.lang.String)
     */
    protected String buildGalleryItemListCustomEndCols(CmsResource res, String tdClass) {

        StringBuffer result = new StringBuffer(64);
        result.append("\t<td class=\"");

⌨️ 快捷键说明

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