public abstract class CmsEditor extends CmsEditorBase
The editor classes have to extend this class and implement action methods for common editor actions.
限定符和类型 | 字段和说明 |
---|---|
static int |
ACTION_CHANGE_BODY
Value for the action: change the body.
|
static int |
ACTION_DELETELOCALE
Value for the action: delete the current locale.
|
static int |
ACTION_EXIT
Value for the action: exit.
|
static int |
ACTION_PREVIEW
Value for the action: show a preview.
|
static int |
ACTION_SAVE
Value for the action: save.
|
static int |
ACTION_SAVEACTION
Constant value for the customizable action button.
|
static int |
ACTION_SAVEEXIT
Value for the action: save and exit.
|
static int |
ACTION_SHOW
Value for the action: show the editor.
|
static int |
ACTION_SHOW_ERRORMESSAGE
Value for the action: an error occurred.
|
static java.lang.String |
EDITOR_CHANGE_ELEMENT
Value for the action parameter: change the element.
|
static java.lang.String |
EDITOR_CLEANUP
Value for the action parameter: cleanup content.
|
static java.lang.String |
EDITOR_CLOSEBROWSER
Value for the action parameter: close browser window (accidentally).
|
static java.lang.String |
EDITOR_DELETELOCALE
Value for the action parameter: delete the current locale.
|
static java.lang.String |
EDITOR_EXIT
Value for the action parameter: exit editor.
|
static java.lang.String |
EDITOR_PREVIEW
Value for the action parameter: show a preview.
|
static java.lang.String |
EDITOR_SAVE
Value for the action parameter: save content.
|
static java.lang.String |
EDITOR_SAVEACTION
Value for the customizable action button.
|
static java.lang.String |
EDITOR_SAVEEXIT
Value for the action parameter: save and exit.
|
static java.lang.String |
EDITOR_SHOW
Value for the action parameter: show the editor.
|
static java.lang.String |
EDITOR_SHOW_ERRORMESSAGE
Value for the action parameter: an error occurred.
|
static java.lang.String |
EMPTY_LOCALE
Marker for empty locale in locale selection.
|
static java.lang.String |
PARAM_BACKLINK
Parameter name for the request parameter "backlink".
|
static java.lang.String |
PARAM_CONTENT
Parameter name for the request parameter "content".
|
static java.lang.String |
PARAM_DIRECTEDIT
Parameter name for the request parameter "directedit".
|
static java.lang.String |
PARAM_EDITASTEXT
Parameter name for the request parameter "editastext".
|
static java.lang.String |
PARAM_EDITORMODE
Parameter name for the request parameter "editormode".
|
static java.lang.String |
PARAM_ELEMENTLANGUAGE
Parameter name for the request parameter "element language".
|
static java.lang.String |
PARAM_LOADDEFAULT
Parameter name for the request parameter "loaddefault".
|
static java.lang.String |
PARAM_MODIFIED
Parameter name for the request parameter "modified".
|
static java.lang.String |
PARAM_OLDELEMENTLANGUAGE
Parameter name for the request parameter "old element language".
|
static java.lang.String |
PARAM_TEMPFILE
Parameter name for the request parameter "tempfile".
|
static java.lang.String |
PATH_EDITORS
Stores the VFS editor path.
|
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_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
PARAM_ADMIN_PROJECT, PARAM_BASE, PARAM_FORCE, PARAM_PATH, PARAM_ROOT, PARAM_STYLE, STYLE_NEW
DEBUG, 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, PARAM_WP_EXPLORER_RESOURCE, PARAM_WP_PROJECT, PARAM_WP_SITE, 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_MODULES, VFS_PATH_RESOURCES, VFS_PATH_SYSTEM, VFS_PATH_VIEWS, VFS_PATH_WORKPLACE, VIEW_DIRECT_EDIT, VIEW_WORKPLACE
构造器和说明 |
---|
CmsEditor(CmsJspActionElement jsp)
Public constructor.
|
限定符和类型 | 方法和说明 |
---|---|
abstract void |
actionClear(boolean forceUnlock)
Unlocks the edited resource when in direct edit mode or when the resource was not modified.
|
protected void |
actionClose()
Closes the editor and forwards to the workplace or the resource depending on the editor mode.
|
abstract void |
actionExit()
Performs the exit editor action.
|
abstract void |
actionSave()
Performs the save content action.
|
java.lang.String |
buildSelectElementLanguage(java.lang.String attributes,
java.lang.String resourceName,
java.util.Locale selectedLocale)
Builds the html String for the element language selector.
|
java.lang.String |
button(java.lang.String href,
java.lang.String target,
java.lang.String image,
java.lang.String label,
int type,
boolean useCustomImage)
Generates a button for the OpenCms editor.
|
java.lang.String |
buttonActionCancel()
Returns the editor action for a "cancel" button.
|
java.lang.String |
buttonActionDirectEdit(java.lang.String jsFunction,
int type)
Builds the html to display the special action button for the direct edit mode of the editor.
|
void |
checkLock(java.lang.String resource,
CmsLockType type)
Checks the lock state of the resource and locks it if the autolock feature is enabled.
|
protected void |
clearEditorSessionInfo()
Clears the editor session info bean.
|
protected void |
commitTempFile()
Writes the content of a temporary file back to the original file.
|
protected java.lang.String |
createTempFile()
Creates a temporary file which is needed while working in an editor with preview option.
|
protected java.lang.String |
decodeContent(java.lang.String content)
Decodes the given content the same way the client would do it.
|
protected java.lang.String |
decodeParamValue(java.lang.String paramName,
java.lang.String paramValue)
Decodes an individual parameter value, ensuring the content is always decoded in UTF-8.
|
java.lang.String |
deleteLocaleButton(java.lang.String href,
java.lang.String target,
java.lang.String image,
java.lang.String label,
int type)
Generates a button for delete locale.
|
protected void |
deleteTempFile()
Deletes a temporary file from the OpenCms VFS, needed when exiting an editor.
|
protected java.lang.String |
encodeContent(java.lang.String content)
Encodes the given content so that it can be transfered to the client.
|
protected CmsObject |
getCloneCms()
Returns a cloned cms instance that prevents the time range resource filter check.
|
CmsEditorDisplayOptions |
getEditorDisplayOptions()
Returns the instantiated editor display option class from the workplace manager.
|
abstract java.lang.String |
getEditorResourceUri()
Returns the URI to the editor resource folder where button images and javascripts are located.
|
protected CmsEditorSessionInfo |
getEditorSessionInfo()
Returns the editor session info bean.
|
protected java.lang.String |
getFileEncoding()
Returns the encoding parameter.
|
protected java.lang.String |
getFileEncoding(CmsObject cms,
java.lang.String filename)
Helper method to determine the encoding of the given file in the VFS,
which must be set using the "content-encoding" property.
|
java.lang.String |
getOpenCmsContext()
Returns the OpenCms request context path.
|
java.lang.String |
getParamBacklink()
Returns the back link when closing the editor.
|
java.lang.String |
getParamContent()
Returns the content of the editor.
|
java.lang.String |
getParamDirectedit()
Returns the direct edit flag parameter.
|
java.lang.String |
getParamEditastext()
Returns the edit as text parameter.
|
java.lang.String |
getParamEditormode()
Returns the editor mode parameter.
|
java.lang.String |
getParamElementlanguage()
Returns the current element language.
|
java.lang.String |
getParamLoaddefault()
Returns the "loaddefault" parameter to determine if the default editor should be loaded.
|
java.lang.String |
getParamModified()
Returns the modified parameter indicating if the resource has been saved.
|
java.lang.String |
getParamOldelementlanguage()
Returns the old element language.
|
java.lang.String |
getParamTempfile()
Returns the name of the temporary file.
|
java.lang.String |
getPicsUri()
Returns the path to the images used by this editor.
|
protected abstract void |
initContent()
Initializes the editor content when openening the editor for the first time.
|
protected void |
initMessages()
Initializes the message object.
|
protected void |
initSessionInfo()
Initializes the editor session info bean.
|
protected void |
setFileEncoding(java.lang.String value)
Sets the encoding parameter.
|
void |
setParamBacklink(java.lang.String backLink)
Sets the back link when closing the editor.
|
void |
setParamContent(java.lang.String content)
Sets the content of the editor.
|
void |
setParamDirectedit(java.lang.String direct)
Sets the direct edit flag parameter.
|
void |
setParamEditastext(java.lang.String editAsText)
Sets the edit as text parameter.
|
void |
setParamEditormode(java.lang.String mode)
Sets the editor mode parameter.
|
void |
setParamElementlanguage(java.lang.String elementLanguage)
Sets the current element language.
|
void |
setParamLoaddefault(java.lang.String loadDefault)
Sets the "loaddefault" parameter to determine if the default editor should be loaded.
|
void |
setParamModified(java.lang.String modified)
Sets the modified parameter indicating if the resource has been saved.
|
void |
setParamOldelementlanguage(java.lang.String oldElementLanguage)
Sets the old element language.
|
void |
setParamTempfile(java.lang.String fileName)
Sets the name of the temporary file.
|
protected void |
showErrorPage(java.lang.Exception exception)
Shows the selected error page in case of an exception.
|
protected void |
showErrorPage(java.lang.Object editor,
java.lang.Exception exception)
Shows the selected error page in case of an exception.
|
initTimeWarp
actionCloseDialog, appendDelimiter, buildAjaxResultContainer, buildAjaxWaitMessage, buildLockAdditionalOptions, buildLockConfirmationMessageJS, buildLockDialog, buildLockDialog, 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, initWorkplaceRequestValues, isPopup, isPreEditor, pageHtml, pageHtml, setAction, setOnlineHelpUriCustom, setParamAction, setParamCloseLink, setParamDialogtype, setParamFramename, setParamIsPopup, setParamMessage, setParamOriginalParams, setParamPreActionDone, setParamRedirect, setParamResource, setParamTitle
computeUpLevelLink, dialogTitle, getAdminTool, getCurrentToolPath, getParamBase, getParamForce, getParamPath, getParamRoot, getParamStyle, getParentPath, getToolManager, iconsBlockArea, iconsBlockAreaEnd, iconsBlockAreaStart, initAdminTool, pageBody, pageHtmlStyle, setParamBase, setParamForce, setParamPath, setParamRoot, setParamStyle, useNewStyle
addMessages, addMessages, allParamsAsHidden, allParamsAsRequest, allParamValues, bodyEnd, bodyStart, bodyStart, buildSelect, buildSelect, button, button, buttonBar, buttonBar, buttonBarHorizontalLine, buttonBarLabel, buttonBarLabel, buttonBarLine, buttonBarLineSpacer, buttonBarSeparator, buttonBarSpacer, buttonBarStartTab, checkLock, checkRole, fillParamValues, fillParamValues, getBroadcastMessageString, getCms, getEncoding, getExplorerFileListFullUri, getFrameSource, getJsp, getLocale, getMacroResolver, getMessages, getMultiPartFileItems, getParameterMap, getResourceUri, getResourceUri, getSession, getSettings, getSkinUri, getStartSiteRoot, getStyleUri, getStyleUri, getStyleUri, getTemporaryFileName, htmlEnd, initSettings, initUserSettings, initWorkplaceMembers, initWorkplaceSettings, isForwarded, isHelpEnabled, isSubElement, isTemporaryFile, key, key, keyDefault, nullToEmpty, paramsAsHidden, paramsAsHidden, paramsAsParameterMap, paramsAsRequest, paramValues, resolveMacros, sendCmsRedirect, sendForward, setForwarded, shortKey, substituteSiteTitle, switchToCurrentProject, switchToTempProject
public static final int ACTION_CHANGE_BODY
public static final int ACTION_DELETELOCALE
public static final int ACTION_EXIT
public static final int ACTION_PREVIEW
public static final int ACTION_SAVE
public static final int ACTION_SAVEACTION
public static final int ACTION_SAVEEXIT
public static final int ACTION_SHOW
public static final int ACTION_SHOW_ERRORMESSAGE
public static final java.lang.String EDITOR_CHANGE_ELEMENT
public static final java.lang.String EDITOR_CLEANUP
public static final java.lang.String EDITOR_CLOSEBROWSER
public static final java.lang.String EDITOR_DELETELOCALE
public static final java.lang.String EDITOR_EXIT
public static final java.lang.String EDITOR_PREVIEW
public static final java.lang.String EDITOR_SAVE
public static final java.lang.String EDITOR_SAVEACTION
public static final java.lang.String EDITOR_SAVEEXIT
public static final java.lang.String EDITOR_SHOW
public static final java.lang.String EDITOR_SHOW_ERRORMESSAGE
public static final java.lang.String EMPTY_LOCALE
public static final java.lang.String PARAM_BACKLINK
public static final java.lang.String PARAM_CONTENT
public static final java.lang.String PARAM_DIRECTEDIT
public static final java.lang.String PARAM_EDITASTEXT
public static final java.lang.String PARAM_EDITORMODE
public static final java.lang.String PARAM_ELEMENTLANGUAGE
public static final java.lang.String PARAM_LOADDEFAULT
public static final java.lang.String PARAM_MODIFIED
public static final java.lang.String PARAM_OLDELEMENTLANGUAGE
public static final java.lang.String PARAM_TEMPFILE
public static final java.lang.String PATH_EDITORS
public CmsEditor(CmsJspActionElement jsp)
jsp
- an initialized JSP action elementpublic abstract void actionClear(boolean forceUnlock)
forceUnlock
- if true, the resource will be unlocked anywaypublic abstract void actionExit() throws CmsException, java.io.IOException, javax.servlet.ServletException, javax.servlet.jsp.JspException
CmsException
- if something goes wrongjava.io.IOException
- if a forward failsjavax.servlet.ServletException
- if a forward failsjavax.servlet.jsp.JspException
- if including an element failspublic abstract void actionSave() throws java.io.IOException, javax.servlet.jsp.JspException
java.io.IOException
- if a redirection failsjavax.servlet.jsp.JspException
- if including an element failspublic java.lang.String buildSelectElementLanguage(java.lang.String attributes, java.lang.String resourceName, java.util.Locale selectedLocale)
attributes
- optional attributes for the <select> tagresourceName
- the name of the resource to editselectedLocale
- the currently selected Localepublic java.lang.String button(java.lang.String href, java.lang.String target, java.lang.String image, java.lang.String label, int type, boolean useCustomImage)
href
- the href link for the button, if none is given the button will be disabledtarget
- the href link target for the button, if none is given the target will be same windowimage
- the image name for the button, skin path will be automatically added as prefixlabel
- the label for the text of the buttontype
- 0: image only (default), 1: image and text, 2: text onlyuseCustomImage
- if true, the button has to be placed in the editors "custom pics" folderpublic java.lang.String buttonActionCancel()
This overwrites the cancel method of the CmsDialog class.
Always use this value, do not write anything directly in the html page.
public java.lang.String buttonActionDirectEdit(java.lang.String jsFunction, int type)
jsFunction
- the JavaScript function which will be executed on the mouseup eventtype
- 0: image only (default), 1: image and text, 2: text onlypublic void checkLock(java.lang.String resource, CmsLockType type) throws CmsException
CmsWorkplace
checkLock
在类中 CmsWorkplace
resource
- the resource name which is checkedtype
- indicates the mode CmsLockType.EXCLUSIVE
or CmsLockType.TEMPORARY
CmsException
- if reading or locking the resource failsCmsWorkplace.checkLock(String, CmsLockType)
public java.lang.String deleteLocaleButton(java.lang.String href, java.lang.String target, java.lang.String image, java.lang.String label, int type)
href
- the href link for the button, if none is given the button will be disabledtarget
- the href link target for the button, if none is given the target will be same windowimage
- the image name for the button, skin path will be automatically added as prefixlabel
- the label for the text of the buttontype
- 0: image only (default), 1: image and text, 2: text onlypublic CmsEditorDisplayOptions getEditorDisplayOptions()
This is a convenience method to be used on editor JSPs.
public abstract java.lang.String getEditorResourceUri()
public java.lang.String getOpenCmsContext()
This is a convenience method to use in the editor.
public java.lang.String getParamBacklink()
public java.lang.String getParamContent()
public java.lang.String getParamDirectedit()
public java.lang.String getParamEditastext()
public java.lang.String getParamEditormode()
public java.lang.String getParamElementlanguage()
public java.lang.String getParamLoaddefault()
public java.lang.String getParamModified()
public java.lang.String getParamOldelementlanguage()
public java.lang.String getParamTempfile()
public java.lang.String getPicsUri()
public void setParamBacklink(java.lang.String backLink)
backLink
- the back linkpublic void setParamContent(java.lang.String content)
content
- the content of the editorpublic void setParamDirectedit(java.lang.String direct)
direct
- the direct edit flag parameterpublic void setParamEditastext(java.lang.String editAsText)
editAsText
- "true"
if the resource should be handled like a text filepublic void setParamEditormode(java.lang.String mode)
mode
- the editor mode parameterpublic void setParamElementlanguage(java.lang.String elementLanguage)
elementLanguage
- the current element languagepublic void setParamLoaddefault(java.lang.String loadDefault)
loadDefault
- the "loaddefault" parameterpublic void setParamModified(java.lang.String modified)
modified
- the modified parameter indicating if the resource has been savedpublic void setParamOldelementlanguage(java.lang.String oldElementLanguage)
oldElementLanguage
- the old element languagepublic void setParamTempfile(java.lang.String fileName)
fileName
- the name of the temporary fileprotected void actionClose() throws java.io.IOException, javax.servlet.jsp.JspException, javax.servlet.ServletException
java.io.IOException
- if forwarding failsjavax.servlet.ServletException
- if forwarding failsjavax.servlet.jsp.JspException
- if including a JSP failsprotected void clearEditorSessionInfo()
protected void commitTempFile() throws CmsException
CmsException
- if something goes wrongprotected java.lang.String createTempFile() throws CmsException
CmsException
- if something goes wrongprotected java.lang.String decodeContent(java.lang.String content)
Content is decoded as if it was encoded using the JavaScript "encodeURIComponent()" function.
content
- the content to decodeprotected java.lang.String decodeParamValue(java.lang.String paramName, java.lang.String paramValue)
For editors the content is always encoded using the JavaScript encodeURIComponent() method on the client, which always encodes in UTF-8.
decodeParamValue
在类中 CmsWorkplace
paramName
- the name of the parameterparamValue
- the unencoded value of the parameterprotected void deleteTempFile()
protected java.lang.String encodeContent(java.lang.String content)
Content is encoded so that it is compatible with the JavaScript "decodeURIComponent()" function.
content
- the content to encodeprotected CmsObject getCloneCms() throws CmsException
Use it always for unmarshalling and file writing.
CmsException
- if something goes wrongprotected CmsEditorSessionInfo getEditorSessionInfo()
protected java.lang.String getFileEncoding()
protected java.lang.String getFileEncoding(CmsObject cms, java.lang.String filename)
cms
- the CmsObjectfilename
- the name of the file which is to be checkedprotected abstract void initContent()
protected void initMessages()
CmsWorkplace
By default the CmsWorkplaceMessages
are initialized.
You SHOULD override this method for setting the bundles you really need,
using the
or CmsWorkplace.addMessages(CmsMessages)
method.CmsWorkplace.addMessages(String)
initMessages
在类中 CmsWorkplace
CmsWorkplace.initMessages()
protected void initSessionInfo()
protected void setFileEncoding(java.lang.String value)
value
- the encoding value to setprotected void showErrorPage(java.lang.Exception exception) throws javax.servlet.jsp.JspException
exception
- the current exceptionjavax.servlet.jsp.JspException
- if inclusion of the error page failsprotected void showErrorPage(java.lang.Object editor, java.lang.Exception exception) throws javax.servlet.jsp.JspException
editor
- initialized instance of the editor classexception
- the current exceptionjavax.servlet.jsp.JspException
- if inclusion of the error page fails