Class A_CmsAjaxGallery

  • Direct Known Subclasses:
    CmsAjaxDownloadGallery, CmsAjaxImageGallery, CmsAjaxLinkGallery

    public abstract class A_CmsAjaxGallery
    extends CmsDialog
    Provides the general helper methods to generate the content of a gallery dialog used in the XML content editors, WYSIWYG editors and context menu. It

    It is also used for AJAX requests to dynamically switch galleries or categories and get additional information for the currently active item of the dialog.

    Extend this class for every gallery type (e.g. image gallery or download gallery) to build.

    Since:
    7.5.0
    • Constructor Detail

      • A_CmsAjaxGallery

        public A_CmsAjaxGallery​(javax.servlet.jsp.PageContext context,
                                javax.servlet.http.HttpServletRequest req,
                                javax.servlet.http.HttpServletResponse res)
        Public constructor with JSP variables.

        Parameters:
        context - the JSP page context
        req - the JSP request
        res - the JSP response
    • Method Detail

      • createInstance

        public static A_CmsAjaxGallery createInstance​(java.lang.String galleryTypeName,
                                                      CmsJspActionElement jsp)
        Creates a new gallery instance of the given gallery type name.

        Parameters:
        galleryTypeName - the gallery type name to create the instance for
        jsp - an initialized JSP action element
        Returns:
        a new gallery instance of the given gallery type name
      • getGalleries

        public static java.util.List<CmsResourcegetGalleries​(int galleryTypeId,
                                                               CmsObject cms)
        Returns a list of galleries which have the required gallery type id.

        Parameters:
        galleryTypeId - type id of the gallery
        cms - the initialized CmsObject for the current user
        Returns:
        a list of galleries
      • initGallery

        public static void initGallery​(CmsDialog wp)
        Initializes the gallery dialog before redirecting.

        Parameters:
        wp - the workplace object
      • displayDialog

        public void displayDialog()
        Called from the JSP that is used for the AJAX requests to OpenCms.

      • getGalleries

        public java.util.List<CmsResourcegetGalleries()
        Returns a list of galleries which have the required gallery type id.

        Returns:
        a list of galleries
      • getGalleryItems

        public java.util.List<CmsResourcegetGalleryItems()
        Returns a list of gallery items (resources) for the currently selected gallery and resource type id.

        Returns:
        a list of gallery items (resources)
      • getGalleryItemsTypeId

        public abstract int getGalleryItemsTypeId()
        Returns the type id of the gallery items that should be listed.

        In case of downloadgallery use '-1' to list all resources excluding folders.

        Returns:
        the type id of the gallery items that should be listed
      • getGalleryTypeId

        public abstract int getGalleryTypeId()
        Returns the type id of this gallery instance.

        Returns:
        the type id of this gallery instance
      • getGalleryTypeName

        public abstract java.lang.String getGalleryTypeName()
        Returns the type name of this gallery instance.

        Returns:
        the type name of this gallery instance
      • getGalleryTypeParams

        public java.lang.String getGalleryTypeParams()
        Returns the (optional) parameters of this gallery instance.

        Returns:
        the (optional) parameters of this gallery instance
      • getParamDialogMode

        public java.lang.String getParamDialogMode()
        Returns the current mode of the dialog.

        This is necessary to distinguish between widget mode, view mode and editor mode.

        Returns:
        the current mode of the dialog
      • getParamFieldId

        public java.lang.String getParamFieldId()
        Returns the input field ID when in widget mode.

        Returns:
        the input field ID
      • getParamGalleryPath

        public java.lang.String getParamGalleryPath()
        Returns the path of the gallery to display.

        Returns:
        the path of the gallery to display
      • getParamPropertyValue

        public java.lang.String getParamPropertyValue()
        Returns the property value parameter.

        Returns:
        the property value parameter
      • init

        public void init()
        Initialization method that is called after the gallery instance has been created.

        It can be overwritten in the inherited class, e.g. CmsAjaxImageGallery.init().

      • isModeEditor

        public boolean isModeEditor()
        Returns if the dialog mode is the "editor" mode.

        Returns:
        true if the dialog mode is the "editor" mode, otherwise false
      • isModeView

        public boolean isModeView()
        Returns if the dialog mode is the "view" mode.

        Returns:
        true if the dialog mode is the "view" mode, otherwise false
      • isModeWidget

        public boolean isModeWidget()
        Returns if the dialog mode is the "widget" mode.

        Returns:
        true if the dialog mode is the "editor" mode, otherwise false
      • setParamDialogMode

        public void setParamDialogMode​(java.lang.String dialogMode)
        Sets the current mode of the dialog.

        This is necessary to distinguish between widget mode and editor mode.

        Parameters:
        dialogMode - the current mode of the dialog
      • setParamFieldId

        public void setParamFieldId​(java.lang.String fieldId)
        Sets the input field ID if in widget mode.

        Parameters:
        fieldId - the input field ID
      • setParamGalleryPath

        public void setParamGalleryPath​(java.lang.String galleryPath)
        Sets the path of the gallery to display.

        Parameters:
        galleryPath - the path of the gallery to display
      • setParamPropertyValue

        public void setParamPropertyValue​(java.lang.String paramPropertyValue)
        Sets the property value parameter.

        Parameters:
        paramPropertyValue - the property value parameter to set
      • setResourceType

        public void setResourceType​(CmsResourceTypeFolderExtended type)
        Sets the extended folder resource type this gallery is based on.

        Parameters:
        type - the extended folder resource type this gallery is based on
      • buildJsonActiveItem

        protected void buildJsonActiveItem​(java.lang.String itemUrl)
        Builds the Javascript to set the currently active item object.

        Parameters:
        itemUrl - the URL of the currently selected item
      • buildJsonCategoryList

        protected void buildJsonCategoryList()
        Builds the JSON code for the category list as JSON array.

      • buildJsonGalleryItem

        protected void buildJsonGalleryItem​(java.lang.String galleryUrl)
        Creates a JSON object with the information found on the given gallery URL.

        Parameters:
        galleryUrl - the given gallery URL
      • buildJsonGalleryList

        protected void buildJsonGalleryList()
        Builds the JSON code for the gallery list as JSON array.

      • buildJsonItemCommonPart

        protected void buildJsonItemCommonPart​(JSONObject jsonObj,
                                               CmsResource res,
                                               java.lang.String sitePath)
        Fills the JSON object with the information used for all resource types.

        • sitepath: site path to the resource.
        • linkpath: substituted url of the resource.
        • title: title property of the resource.
        • size: size of the resource in kb.
        • datecreated: the creation date of the resource.
        • datelastmodified: the modification date.
        • state: the state of the resource, new or changed.
        • lockedby: indicates if the resource is locked by another user.
        • editable: editable flag to determine if item is editable and can be lockes by the user.
        • writepermission: flag to indicate if the user has write permissions for given resource.
        • directpublish: flag to indicate if the user has write direct publish permission for given resource.
        • description: description property of the resource.
        Parameters:
        jsonObj - containing information used by all possible resource
        res - the resource to create the object from
        sitePath - site path to the object
      • buildJsonItemObject

        protected JSONObject buildJsonItemObject​(CmsResource res)
        Returns a JSON object containing information of the given resource for usage in the gallery.

        The content of the JSON object consists of a common and a specific part of the given resource.

        Parameters:
        res - the resource to create the object from
        Returns:
        the JSON object containing information from the given resource
      • buildJsonItemSpecificPart

        protected abstract void buildJsonItemSpecificPart​(JSONObject jsonObj,
                                                          CmsResource res,
                                                          java.lang.String sitePath)
        Fills the JSON object with the specific information used for this resource type.

        Parameters:
        jsonObj - containing information used by all possible resource
        res - the resource to create the object from
        sitePath - site path to the object
      • buildJsonResourceItems

        protected void buildJsonResourceItems​(java.util.List<CmsResource> resourceitems,
                                              java.lang.String parentFolder)
        Builds the JSON code to create items for the folder.

        Parameters:
        resourceitems - the file resource to build the displayed items
        parentFolder - the parent folder of the collected files (for a gallery)
      • changeItemLinkUrl

        protected void changeItemLinkUrl​(java.lang.String itemUrl)
        Changes the content of the CmsResource.

        This function should be overwritten in CmsAjaxLinkGallery.

        Parameters:
        itemUrl - the item URL
      • changeItemTitle

        protected void changeItemTitle​(java.lang.String itemUrl)
        Changes the title property value of the given item.

        Parameters:
        itemUrl - the item URL on which the title is changed
      • getCategoryItems

        protected java.util.List<CmsResourcegetCategoryItems()
        Returns the resource items for the selected category.

        Returns:
        the resource items for the selected category
      • writeTitleProperty

        protected void writeTitleProperty​(CmsResource res)
        Changes the value of the property title for the specified resource.

        Parameters:
        res - the resource to change the property value