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

📄 a_cmsgallery.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        } catch (CmsException e) {
            // error reading resources with filter
            LOG.error(e);
        }

        // if the current site is NOT the root site - add all other galleries from the system path
        if (!getCms().getRequestContext().getSiteRoot().equals("")) {
            List systemGalleries = null;
            try {
                // get the galleries in the /system/ folder
                systemGalleries = getCms().readResources(
                    CmsWorkplace.VFS_PATH_SYSTEM,
                    CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(galleryTypeId));
            } catch (CmsException e) {
                // error reading resources with filter
                LOG.error(e);
            }

            if (systemGalleries != null && systemGalleries.size() > 0) {
                // add the found system galleries to the result
                galleries.addAll(systemGalleries);
            }
        }

        // return the found galleries
        return galleries;
    }

    /**
     * Returns a list of gallery items (resources) for the currently selected gallery and resource type id.<p>
     * 
     * @return a list of gallery items (resources)
     */
    public List getGalleryItems() {

        if (m_galleryItems == null) {
            // gallery items have not been read yet
            int resTypeId = getGalleryItemsTypeId();
            if (CmsStringUtil.isNotEmpty(getParamGalleryPath())) {
                try {
                    // set last used gallery in settings to current gallery
                    getSettings().setLastUsedGallery(getGalleryTypeId(), getParamGalleryPath());
                    CmsResourceFilter filter;
                    if (resTypeId == -1) {
                        // filter all resources that are files
                        filter = CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireFile();
                    } else {
                        // filter all resources of the required type
                        filter = CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(resTypeId);
                    }
                    m_galleryItems = getCms().readResources(getParamGalleryPath(), filter, false);
                } catch (CmsException e) {
                    // error reading reaources
                    LOG.error(e);
                } catch (NullPointerException e) {
                    // ignore this exception    
                }
            }
        }
        List items = m_galleryItems;
        // apply search filter, if necessary
        if (CmsStringUtil.isNotEmpty(getParamSearchWord())) {
            items = getSearchHits(m_galleryItems);
        }
        return items;
    }

    /**
     * Returns the type id of the gallery items that should be listed.<p>
     * 
     * In case of downloadgallery use '-1' to list all resources excluding folders.<p>
     * 
     * @return the type id of the gallery items that should be listed
     */
    public abstract int getGalleryItemsTypeId();

    /**
     * Returns the resource type id of this gallery instance.<p>
     *
     * @return the resource type id of this gallery instance
     */
    public int getGalleryTypeId() {

        return m_galleryTypeId;
    }

    /**
     * Returns the resource type name of this gallery instance.<p>
     * 
     * @return the resource type name of this gallery instance
     */
    public String getGalleryTypeName() {

        return m_galleryTypeName;
    }

    /**
     * Returns the (optional) parameters of this gallery instance.<p>
     * 
     * @return the (optional) parameters of this gallery instance
     */
    public String getGalleryTypeParams() {

        return m_galleryTypeParams;
    }

    /**
     * Returns the height of the head frameset.<p>
     * 
     * @return the height of the head frameset
     */
    public String getHeadFrameSetHeight() {

        return "280";
    }

    /**
     * Returns the key title of the current gallery view.<p>
     * 
     * @return the key title of the current gallery view
     */
    public String getKeyTitle() {

        return key(Messages.getTitleGalleryKey(getGalleryTypeName()));
    }

    /**
     * Returns the error message if no gallery could be found.<p>
     * 
     * @return the error message if no gallery could be found
     */
    public String getNoGalleryErrorMsg() {

        return key(Messages.getGalleryNotFoundKey(getGalleryTypeName()));
    }

    /**
     * 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 new Integer(Integer.MAX_VALUE);
    }

    /**
     * Returns the current mode of the dialog.<p>
     * 
     * This is necessary to distinguish between widget mode, view mode and editor mode.<p>
     *
     * @return the current mode of the dialog
     */
    public String getParamDialogMode() {

        if (m_paramDialogMode == null) {
            return "";
        }
        return m_paramDialogMode;
    }

    /**
     * Returns the input field ID when in widget mode.<p>
     *
     * @return the input field ID
     */
    public String getParamFieldId() {

        return m_paramFieldId;
    }

    /**
     * Returns the path of the gallery to display.<p>
     *
     * @return the path of the gallery to display
     */
    public String getParamGalleryPath() {

        if (CmsStringUtil.isEmpty(m_paramGalleryPath)) {
            m_paramGalleryPath = "";
        }
        return m_paramGalleryPath;
    }

    /**
     * Returns the current page to display in the item list.<p>
     *
     * @return the current page to display in the item list
     */
    public String getParamPage() {

        return m_paramPage;
    }

    /**
     * Returns the property value parameter.<p>
     *
     * @return the property value parameter
     */
    public String getParamPropertyValue() {

        return m_paramPropertyValue;
    }

    /**
     * Returns the resource path.<p>
     *
     * @return the resource path
     */
    public String getParamResourcePath() {

        return m_paramResourcePath;
    }

    /**
     * Returns the search word to look up in the gallery items.<p>
     * 
     * @return the search word to look up in the gallery items
     */
    public String getParamSearchWord() {

        if (CmsStringUtil.isEmpty(m_paramSearchWord)) {
            m_paramSearchWord = "";
        }
        return m_paramSearchWord;
    }

    /**
     * Returns the style for the body tag of the preview frame.<p> 
     * 
     * @return the style for the body tag of the preview frame
     */
    public String getPreviewBodyStyle() {

        return new String(" class=\"dialog\" style=\"background-color: ThreeDFace;\" unselectable=\"on\"");
    }

    /**
     * Returns the style for the div tag of the preview frame.<p>
     * 
     * @return the style for the div tag of the preview frame
     */
    public String getPreviewDivStyle() {

        return new String("style=\"text-align: center; width: 100%; margin-top: 5px\"");
    }

    /**
     * Returns the extended folder resource type this gallery is based on.<p>
     * 
     * @return the extended folder resource type this gallery is based on
     */
    public CmsResourceTypeFolderExtended getResourceType() {

        return m_resourceType;
    }

    /**
     * Returns the url for the upload applet or JSP dialog.<p>
     * 
     * @return the url for the upload applet or JSP dialog
     */
    public String getWizardUrl() {

        StringBuffer wizardUrl = new StringBuffer(16);
        wizardUrl.append(getJsp().link(
            PATH_DIALOGS + OpenCms.getWorkplaceManager().getExplorerTypeSetting("upload").getNewResourceUri()));
        wizardUrl.append("?");
        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();
    }

    /**
     * Initialization method that is called after the gallery instance has been created.<p>
     */
    public void init() {

        // default gallery does not require initialization
    }

    /**
     * Generates a preview button for the gallery button bar.<p>
     * 
     * Overwrite this method if neccessary in the specified gallery class.<p>
     * 
     * @return a preview button for the gallery button bar
     */
    public String previewButton() {

        StringBuffer previewButton = new StringBuffer(8);
        previewButton.append(buttonBarSeparator(5, 5));
        previewButton.append(button(
            getJsp().link(getCms().getSitePath(getCurrentResource())),
            "_preview",
            "preview.png",
            Messages.GUI_BUTTON_PREVIEW_0,
            0));
        return previewButton.toString();
    }

    /**
     * Generates a HTML table row with two columns.<p>
     * 
     * The first column includes the given key as localized string, the second column
     * includes the value of the given property.<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) {

        StringBuffer previewRow = new StringBuffer();
        previewRow.append("<tr align=\"left\">");
        previewRow.append("<td><b>");
        previewRow.append(column1);
        previewRow.append("</b></td>");
        previewRow.append("<td>");
        previewRow.append(column2);
        previewRow.append("</td>");
        previewRow.append("</tr>");

        return previewRow.toString();

    }

    /**
     * Generates a publish button for the gallery button bar.<p>
     * 
     * This button is disabled if the current user has no publish rights.<p>
     * 
     * @return a publish button for the gallery button bar
     */
    public String publishButton() {

        if (getCms().hasPublishPermissions(getParamResourcePath())) {
            return button(
                "javascript:publishResource(\'" + getParamResourcePath() + "\');",
                null,
                "publish.png",
                Messages.GUI_MESSAGEBOX_TITLE_PUBLISHRESOURCE_0,
                0);
        }
        return button(null, null, "publish_in.png", "", 0);
    }

    /**
     * Builds the HTML for the search button.<p>
     * 
     * @return the HTML for the search button
     */
    public String searchButton() {

        return button("javascript:displayGallery();", null, "search.png", Messages.GUI_INPUT_SEARCH_0, 0);
    }

    /**
     * Sets the current resource.<p>
     * 
     * @param currentResource the current resource to set
     */
    public void setCurrentResource(CmsResource currentResource) {

        m_currentResource = currentResource;
    }

    /**
     * Sets the current mode of the dialog.<p>
     * 
     * This is necessary to distinguish between widget mode and editor mode.<p>
     *
     * @param dialogMode the current mode of the dialog
     */
    public void setParamDialogMode(String dialogMode) {

        m_paramDialogMode = dialogMode;
    }

    /**
     * Sets the input field ID if in widget mode.<p>
     *
     * @param fieldId the input field ID
     */
    public void setParamFieldId(String fieldId) {

⌨️ 快捷键说明

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