Package org.opencms.workplace.galleries
Class A_CmsAjaxGallery
java.lang.Object
org.opencms.workplace.CmsWorkplace
org.opencms.workplace.tools.CmsToolDialog
org.opencms.workplace.CmsDialog
org.opencms.workplace.galleries.A_CmsAjaxGallery
- Direct Known Subclasses:
CmsAjaxDownloadGallery
,CmsAjaxImageGallery
,CmsAjaxLinkGallery
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 Summary
Modifier and TypeFieldDescriptionstatic final String
Request parameter value for the action: change the item link url value.static final String
Request parameter value for the action: change the item title property value.static final String
Request parameter value for the action: get the currently active item object.static final String
Request parameter value for the action: get the category selection list.static final String
Request parameter value for the action: get the gallery selection list.static final String
Request parameter value for the action: get a specific gallery.static final String
Request parameter value for the action: get the items for a gallery or category.static final String
Request parameter value for the action: list gallery items.static final String
The list mode name "category" for getting the items.static final String
The list mode name "gallery" for getting the items.protected String
The optional parameters for the gallery from the XML configuration.static final String
Request parameter value for the dialog mode: editor.static final String
Request parameter value for the dialog mode: view.static final String
Request parameter value for the dialog mode: widget.static final String
Request parameter name for the dialog mode (widget or editor).static final String
Request parameter name for the edited resource.static final String
Request parameter name for the input field id.static final String
Request parameter name for the gallery path.static final String
Request parameter name for the active item path.static final String
Request parameter name for the dialog initialization parameters.static final String
Request parameter name for the startup folder.static final String
Request parameter name for the startup type.static final String
The galleries path in the workplace containing the JSPs.static final String
Value that is returned if no result was found.Fields inherited from class org.opencms.workplace.CmsDialog
ACTION_CANCEL, ACTION_CLOSEPOPUP, ACTION_CLOSEPOPUP_SAVE, ACTION_CONFIRMED, ACTION_CONTINUE, ACTION_DEFAULT, ACTION_LOCKS_CONFIRMED, ACTION_OK, ACTION_REPORT_BEGIN, ACTION_REPORT_END, ACTION_REPORT_UPDATE, ACTION_SET, ACTION_WAIT, ATTRIBUTE_THROWABLE, BUTTON_ADVANCED, BUTTON_BACK, BUTTON_CANCEL, BUTTON_CLOSE, BUTTON_CONTINUE, BUTTON_DETAILS, BUTTON_DISCARD, BUTTON_EDIT, BUTTON_OK, BUTTON_OK_NO_SUBMIT, BUTTON_SET, DIALOG_BACK, DIALOG_CANCEL, DIALOG_CONFIRMED, DIALOG_CONTINUE, DIALOG_INITIAL, DIALOG_LOCKS_CONFIRMED, DIALOG_OK, DIALOG_SET, DIALOG_WAIT, PARAM_ACTION, PARAM_ACTION_VALUE_FOR_CHANGED_INDEX, PARAM_CLOSELINK, PARAM_DIALOGTYPE, PARAM_ERRORSTACK, PARAM_FILE, PARAM_FRAMENAME, PARAM_ISPOPUP, PARAM_LOCK, PARAM_MESSAGE, PARAM_ORIGINALPARAMS, PARAM_PREACTIONDONE, PARAM_REDIRECT, PARAM_RESOURCE, PARAM_TARGET, PARAM_THREAD, PARAM_THREAD_HASNEXT, PARAM_TITLE, REPORT_BEGIN, REPORT_END, REPORT_UPDATE
Fields inherited from class org.opencms.workplace.tools.CmsToolDialog
PARAM_ADMIN_PROJECT, PARAM_BASE, PARAM_FORCE, PARAM_PATH, PARAM_ROOT, PARAM_STYLE, STYLE_NEW
Fields inherited from class org.opencms.workplace.CmsWorkplace
DEBUG, DEFAULT_DATE_STRING, DEFAULT_LANGUAGE, DEFAULT_LOCALE, DIALOG_PATH_COMMON, FILE_DIALOG_CLOSE, FILE_DIALOG_SCREEN_CONFIRM, FILE_DIALOG_SCREEN_ERROR, FILE_DIALOG_SCREEN_ERRORPAGE, FILE_DIALOG_SCREEN_WAIT, FILE_EXPLORER_FILELIST, FILE_REPORT_OUTPUT, HTML_END, HTML_START, INPUT_DEFAULT, INPUT_NONE, JSP_WORKPLACE_URI, PARAM_DIRECTPUBLISH, PARAM_MODELFILE, PARAM_NEWRESOURCETYPE, PARAM_PUBLISHSIBLINGS, PARAM_RELATEDRESOURCES, PARAM_RESOURCELIST, PARAM_SUBRESOURCES, PARAM_WP_EXPLORER_RESOURCE, PARAM_WP_PROJECT, PARAM_WP_SITE, PARAM_WP_START, PARAM_WP_VIEW, PATH_DIALOGS, PATH_WORKPLACE, REQUEST_ATTRIBUTE_MULTIPART, REQUEST_ATTRIBUTE_RELOADTREE, RES_PATH_FILETYPES, RFS_PATH_RESOURCES, SESSION_WORKPLACE_CLASS, VFS_DIR_DEFAULTBODIES, VFS_DIR_TEMPLATES, VFS_PATH_COMMONS, VFS_PATH_EDITORS, VFS_PATH_GALLERIES, VFS_PATH_LOCALES, VFS_PATH_MODELDIALOG, VFS_PATH_MODULES, VFS_PATH_NEWRESOURCEDIALOG, VFS_PATH_RESOURCES, VFS_PATH_SITES, VFS_PATH_SYSTEM, VFS_PATH_VIEWS, VFS_PATH_WORKPLACE, VIEW_ADMIN, VIEW_DIRECT_EDIT, VIEW_EXPLORER, VIEW_GALLERY, VIEW_LIST, VIEW_WORKPLACE
-
Constructor Summary
ConstructorDescriptionPublic empty constructor, required forcreateInstance(String, CmsJspActionElement)
.A_CmsAjaxGallery
(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Public constructor with JSP variables.Public constructor with JSP action element. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
buildJsonActiveItem
(String itemUrl) Builds the Javascript to set the currently active item object.protected void
Builds the JSON code for the category list as JSON array.protected void
buildJsonGalleryItem
(String galleryUrl) Creates a JSON object with the information found on the given gallery URL.protected void
Builds the JSON code for the gallery list as JSON array.protected void
buildJsonItemCommonPart
(JSONObject jsonObj, CmsResource res, String sitePath) Fills the JSON object with the information used for all resource types.protected JSONObject
Returns a JSON object containing information of the given resource for usage in the gallery.protected abstract void
buildJsonItemSpecificPart
(JSONObject jsonObj, CmsResource res, String sitePath) Fills the JSON object with the specific information used for this resource type.protected void
buildJsonResourceItems
(List<CmsResource> resourceitems, String parentFolder) Builds the JSON code to create items for the folder.protected void
changeItemLinkUrl
(String itemUrl) Changes the content of the CmsResource.protected void
changeItemTitle
(String itemUrl) Changes the title property value of the given item.static A_CmsAjaxGallery
createInstance
(String galleryTypeName, CmsJspActionElement jsp) Creates a new gallery instance of the given gallery type name.void
Called from the JSP that is used for the AJAX requests to OpenCms.protected List<CmsResource>
Returns the resource items for the selected category.Returns a list of galleries which have the required gallery type id.static List<CmsResource>
getGalleries
(int galleryTypeId, CmsObject cms) Returns a list of galleries which have the required gallery type id.Returns a list of gallery items (resources) for the currently selected gallery and resource type id.abstract int
Returns the type id of the gallery items that should be listed.abstract int
Returns the type id of this gallery instance.abstract String
Returns the type name of this gallery instance.Returns the (optional) parameters of this gallery instance.Returns the current mode of the dialog.Returns the input field ID when in widget mode.Returns the path of the gallery to display.Returns the list mode for getting the items, eitherLISTMODE_CATEGORY
orLISTMODE_GALLERY
.Returns the property value parameter.Returns the extended folder resource type this gallery is based on.void
init()
Initialization method that is called after the gallery instance has been created.static void
initGallery
(CmsDialog wp) Initializes the gallery dialog before redirecting.protected void
initWorkplaceRequestValues
(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request) Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.boolean
Returns if the dialog mode is the "editor" mode.boolean
Returns if the dialog mode is the "view" mode.boolean
Returns if the dialog mode is the "widget" mode.void
setParamDialogMode
(String dialogMode) Sets the current mode of the dialog.void
setParamFieldId
(String fieldId) Sets the input field ID if in widget mode.void
setParamGalleryPath
(String galleryPath) Sets the path of the gallery to display.void
setParamListMode
(String paramListMode) Sets the list mode for getting the items, eitherLISTMODE_CATEGORY
orLISTMODE_GALLERY
.void
setParamPropertyValue
(String paramPropertyValue) Sets the property value parameter.void
Sets the extended folder resource type this gallery is based on.protected void
Changes the value of the property title for the specified resource.Methods inherited from class org.opencms.workplace.CmsDialog
actionCloseDialog, appendDelimiter, buildAjaxResultContainer, buildAjaxWaitMessage, buildLockAdditionalOptions, buildLockConfirmationMessageJS, buildLockHeaderBox, checkResourcePermissions, checkResourcePermissions, computeCurrentFolder, dialog, dialogBlock, dialogBlockEnd, dialogBlockStart, dialogButtonRow, dialogButtonRowEnd, dialogButtonRowStart, dialogButtons, dialogButtonsClose, dialogButtonsClose, dialogButtonsCloseDetails, dialogButtonsHtml, dialogButtonsOk, dialogButtonsOk, dialogButtonsOkCancel, dialogButtonsOkCancel, dialogButtonsOkCancelAdvanced, dialogButtonsSetOkCancel, dialogContent, dialogContentEnd, dialogContentStart, dialogEnd, dialogHead, dialogHorizontalSpacer, dialogLockButtons, dialogRow, dialogRowEnd, dialogRowStart, dialogScriptSubmit, dialogSeparator, dialogSpacer, dialogStart, dialogStart, dialogSubheadline, dialogToggleStart, dialogWhiteBox, dialogWhiteBoxEnd, dialogWhiteBoxStart, getAction, getAdministrationBackLink, getCancelAction, getDialogRealUri, getDialogUri, getOnlineHelpUriCustom, getParamAction, getParamCloseLink, getParamDialogtype, getParamFramename, getParamIsPopup, getParamMessage, getParamOriginalParams, getParamPreActionDone, getParamRedirect, getParamResource, getParamTitle, getState, hasCorrectLockstate, hasSiblings, htmlStart, htmlStart, htmlStart, htmlStartStyle, includeErrorpage, initCmsDialog, isPopup, isPreEditor, openLaunchpad, openWorkplaceLink, pageHtml, pageHtml, setAction, setOnlineHelpUriCustom, setParamAction, setParamCloseLink, setParamDialogtype, setParamFramename, setParamIsPopup, setParamMessage, setParamOriginalParams, setParamPreActionDone, setParamRedirect, setParamResource, setParamTitle
Methods inherited from class org.opencms.workplace.tools.CmsToolDialog
computeUpLevelLink, dialogTitle, getAdminTool, getCurrentToolPath, getParamBase, getParamForce, getParamPath, getParamRoot, getParamStyle, getParentPath, getToolManager, iconsBlockArea, iconsBlockAreaEnd, iconsBlockAreaStart, initAdminTool, pageBody, pageHtmlStyle, setParamBase, setParamForce, setParamPath, setParamRoot, setParamStyle, useNewStyle
Methods inherited from class org.opencms.workplace.CmsWorkplace
addMessages, addMessages, allParamsAsHidden, allParamsAsRequest, allParamValues, bodyEnd, bodyStart, bodyStart, buildSelect, buildSelect, button, button, buttonBar, buttonBar, buttonBarHorizontalLine, buttonBarLabel, buttonBarLabel, buttonBarLine, buttonBarLineSpacer, buttonBarSeparator, buttonBarSpacer, buttonBarStartTab, canEditPermissionsForRoles, checkLock, checkLock, checkRole, decodeParamValue, fillParamValues, fillParamValues, generateCssStyle, generatePageEndExtended, generatePageEndSimple, generatePageStartExtended, generatePageStartSimple, getBroadcastMessageString, getCms, getEncoding, getExplorerFileListFullUri, getFrameSource, getJsp, getLocale, getMacroResolver, getMessages, getMultiPartFileItems, getParameterMap, getResourceUri, getResourceUri, getSession, getSettings, getSkinUri, getStartSiteRoot, getStartSiteRoot, getStaticResourceUri, getStaticResourceUri, getStyleUri, getStyleUri, getStyleUri, getTemporaryFileName, getWorkplaceExplorerLink, getWorkplaceExplorerLink, getWorkplaceSettings, htmlEnd, initMessages, initSettings, initTimeWarp, initUserSettings, initWorkplaceMembers, initWorkplaceMembers, initWorkplaceSettings, isForwarded, isHelpEnabled, isSubElement, isTemporaryFile, key, key, keyDefault, nullToEmpty, paramsAsHidden, paramsAsHidden, paramsAsParameterMap, paramsAsRequest, paramValues, resolveMacros, sendCmsRedirect, sendForward, setForwarded, shortKey, substituteSiteTitle, substituteSiteTitleStatic, switchToCurrentProject, switchToTempProject, updateUserPreferences
-
Field Details
-
DIALOG_CHANGEITEMLINKURL
Request parameter value for the action: change the item link url value.- See Also:
-
DIALOG_CHANGEITEMTITLE
Request parameter value for the action: change the item title property value.- See Also:
-
DIALOG_GETACTIVEITEM
Request parameter value for the action: get the currently active item object.- See Also:
-
DIALOG_GETCATEGORIES
Request parameter value for the action: get the category selection list.- See Also:
-
DIALOG_GETGALLERIES
Request parameter value for the action: get the gallery selection list.- See Also:
-
DIALOG_GETGALLERY
Request parameter value for the action: get a specific gallery.- See Also:
-
DIALOG_GETITEMS
Request parameter value for the action: get the items for a gallery or category.- See Also:
-
DIALOG_LIST
Request parameter value for the action: list gallery items.- See Also:
-
LISTMODE_CATEGORY
The list mode name "category" for getting the items.- See Also:
-
LISTMODE_GALLERY
The list mode name "gallery" for getting the items.- See Also:
-
MODE_EDITOR
Request parameter value for the dialog mode: editor.- See Also:
-
MODE_VIEW
Request parameter value for the dialog mode: view.- See Also:
-
MODE_WIDGET
Request parameter value for the dialog mode: widget.- See Also:
-
PARAM_DIALOGMODE
Request parameter name for the dialog mode (widget or editor).- See Also:
-
PARAM_EDITEDRESOURCE
Request parameter name for the edited resource.- See Also:
-
PARAM_FIELDID
Request parameter name for the input field id.- See Also:
-
PARAM_GALLERYPATH
Request parameter name for the gallery path.- See Also:
-
PARAM_ITEMPATH
Request parameter name for the active item path.- See Also:
-
PARAM_PARAMS
Request parameter name for the dialog initialization parameters.- See Also:
-
PARAM_STARTUPFOLDER
Request parameter name for the startup folder.- See Also:
-
PARAM_STARTUPTYPE
Request parameter name for the startup type.- See Also:
-
PATH_GALLERIES
The galleries path in the workplace containing the JSPs.- See Also:
-
RETURNVALUE_NONE
Value that is returned if no result was found.- See Also:
-
m_galleryTypeParams
The optional parameters for the gallery from the XML configuration.
-
-
Constructor Details
-
A_CmsAjaxGallery
public A_CmsAjaxGallery()Public empty constructor, required forcreateInstance(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 contextreq
- the JSP requestres
- the JSP response
-
-
Method Details
-
createInstance
Creates a new gallery instance of the given gallery type name.- Parameters:
galleryTypeName
- the gallery type name to create the instance forjsp
- an initialized JSP action element- Returns:
- a new gallery instance of the given gallery type name
-
getGalleries
Returns a list of galleries which have the required gallery type id.- Parameters:
galleryTypeId
- type id of the gallerycms
- the initialized CmsObject for the current user- Returns:
- a list of galleries
-
initGallery
Initializes the gallery dialog before redirecting.- Parameters:
wp
- the workplace object
-
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
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
Returns the type id of this gallery instance.- Returns:
- the type id of this gallery instance
-
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, eitherLISTMODE_CATEGORY
orLISTMODE_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
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
Returns if the dialog mode is the "editor" mode.- Returns:
true
if the dialog mode is the "editor" mode, otherwisefalse
-
isModeView
Returns if the dialog mode is the "view" mode.- Returns:
true
if the dialog mode is the "view" mode, otherwisefalse
-
isModeWidget
Returns if the dialog mode is the "widget" mode.- Returns:
true
if the dialog mode is the "editor" mode, otherwisefalse
-
setParamDialogMode
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
Sets the input field ID if in widget mode.- Parameters:
fieldId
- the input field ID
-
setParamGalleryPath
Sets the path of the gallery to display.- Parameters:
galleryPath
- the path of the gallery to display
-
setParamListMode
Sets the list mode for getting the items, eitherLISTMODE_CATEGORY
orLISTMODE_GALLERY
.- Parameters:
paramListMode
- the list mode for getting the items
-
setParamPropertyValue
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
Builds the Javascript to set the currently active item object.- Parameters:
itemUrl
- the URL of the currently selected item
-
buildJsonCategoryList
Builds the JSON code for the category list as JSON array. -
buildJsonGalleryItem
Creates a JSON object with the information found on the given gallery URL.- Parameters:
galleryUrl
- the given gallery URL
-
buildJsonGalleryList
Builds the JSON code for the gallery list as JSON array. -
buildJsonItemCommonPart
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 resourceres
- the resource to create the object fromsitePath
- 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 resourceres
- the resource to create the object fromsitePath
- site path to the object
-
buildJsonResourceItems
Builds the JSON code to create items for the folder.- Parameters:
resourceitems
- the file resource to build the displayed itemsparentFolder
- the parent folder of the collected files (for a gallery)
-
changeItemLinkUrl
Changes the content of the CmsResource.This function should be overwritten in
CmsAjaxLinkGallery
.- Parameters:
itemUrl
- the item URL
-
changeItemTitle
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 classCmsDialog
- Parameters:
settings
- the workplace settingsrequest
- the current request- See Also:
-
writeTitleProperty
Changes the value of the property title for the specified resource.- Parameters:
res
- the resource to change the property value
-