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
  • Field Details

  • Constructor Details

    • A_CmsAjaxGallery

      Public empty constructor, required for createInstance(String, CmsJspActionElement).

    • A_CmsAjaxGallery

      Public constructor with JSP action element.

      Parameters:
      jsp - an initialized JSP action element
    • 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 Details

    • createInstance

      public static A_CmsAjaxGallery createInstance(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 List<CmsResource> getGalleries(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

      Returns a list of galleries which have the required gallery type id.

      Returns:
      a list of galleries
    • getGalleryItems

      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 String getGalleryTypeName()
      Returns the type name of this gallery instance.

      Returns:
      the type name of this gallery instance
    • getGalleryTypeParams

      Returns the (optional) parameters of this gallery instance.

      Returns:
      the (optional) parameters of this gallery instance
    • 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

      Returns the input field ID when in widget mode.

      Returns:
      the input field ID
    • getParamGalleryPath

      Returns the path of the gallery to display.

      Returns:
      the path of the gallery to display
    • getParamListMode

      Returns the list mode for getting the items, either LISTMODE_CATEGORY or LISTMODE_GALLERY.

      Returns:
      the list mode for getting the item
    • getParamPropertyValue

      Returns the property value parameter.

      Returns:
      the property value parameter
    • getResourceType

      Returns the extended folder resource type this gallery is based on.

      Returns:
      the extended folder resource type this gallery is based on
    • 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(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(String fieldId)
      Sets the input field ID if in widget mode.

      Parameters:
      fieldId - the input field ID
    • setParamGalleryPath

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

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

      public void setParamListMode(String paramListMode)
      Sets the list mode for getting the items, either LISTMODE_CATEGORY or LISTMODE_GALLERY.

      Parameters:
      paramListMode - the list mode for getting the items
    • setParamPropertyValue

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

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

      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(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(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, 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

      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, 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(List<CmsResource> resourceitems, 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(String itemUrl)
      Changes the content of the CmsResource.

      This function should be overwritten in CmsAjaxLinkGallery.

      Parameters:
      itemUrl - the item URL
    • changeItemTitle

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

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

      Returns the resource items for the selected category.

      Returns:
      the resource items for the selected category
    • initWorkplaceRequestValues

      protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
      Description copied from class: CmsWorkplace
      Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.

      Overrides:
      initWorkplaceRequestValues in class CmsDialog
      Parameters:
      settings - the workplace settings
      request - the current request
      See Also:
    • 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