📄 cmseditor.java
字号:
// set link to the specified back link target
target = getParamBacklink();
} else {
// set link to the edited resource
target = getParamResource();
}
} else {
// in workplace mode, show explorer view
target = OpenCms.getLinkManager().substituteLink(getCms(), CmsFrameset.JSP_WORKPLACE_URI);
}
return "onclick=\"top.location.href='" + getJsp().link(target) + "';\"";
}
/**
* Builds the html to display the special action button for the direct edit mode of the editor.<p>
*
* @param jsFunction the JavaScript function which will be executed on the mouseup event
* @param type 0: image only (default), 1: image and text, 2: text only
* @return the html to display the special action button
*/
public String buttonActionDirectEdit(String jsFunction, int type) {
// get the action class from the OpenCms runtime property
I_CmsEditorActionHandler actionClass = OpenCms.getWorkplaceManager().getEditorActionHandler();
String url;
String name;
boolean active = false;
if (actionClass != null) {
// get button parameters and state from action class
url = actionClass.getButtonUrl(getJsp(), getParamResource());
name = actionClass.getButtonName();
active = actionClass.isButtonActive(getJsp(), getParamResource());
} else {
// action class not defined, display inactive button
url = getSkinUri() + "buttons/publish_in.png";
name = Messages.GUI_EXPLORER_CONTEXT_PUBLISH_0;
}
String image = url.substring(url.lastIndexOf("/") + 1);
if (url.endsWith(".gif")) {
image = image.substring(0, image.length() - 4);
}
if (active) {
// create the link for the button
return button("javascript:" + jsFunction, null, image, name, type, url.substring(
0,
url.lastIndexOf("/") + 1));
} else {
// create the inactive button
return button(null, null, image, name, type, url.substring(0, url.lastIndexOf("/") + 1));
}
}
/**
* @see org.opencms.workplace.CmsWorkplace#checkLock(java.lang.String, int)
*/
public void checkLock(String resource, int mode) throws CmsException {
CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL);
if (!getCms().getLock(res).isNullLock()) {
setParamModified(Boolean.TRUE.toString());
}
super.checkLock(resource, mode);
}
/**
* Generates a button for delete locale.<p>
*
* @param href the href link for the button, if none is given the button will be disabled
* @param target the href link target for the button, if none is given the target will be same window
* @param image the image name for the button, skin path will be automattically added as prefix
* @param label the label for the text of the button
* @param type 0: image only (default), 1: image and text, 2: text only
*
* @return a button for the OpenCms workplace
*/
public String deleteLocaleButton(String href, String target, String image, String label, int type) {
String filename = getParamResource();
try {
CmsResource res = getCms().readResource(filename);
String temporaryFilename = CmsResource.getFolderPath(filename)
+ CmsWorkplace.TEMP_FILE_PREFIX
+ res.getName();
if (getCms().existsResource(temporaryFilename)) {
res = getCms().readResource(temporaryFilename);
}
CmsFile file = CmsFile.upgrade(res, getCms());
CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file);
int locales = xmlContent.getLocales().size();
// there are less than 2 locales, so disable the delete locale button
if (locales < 2) {
href = null;
target = null;
image += "_in";
}
} catch (CmsException e) {
// to nothing here in case the resource could not be opened
if (LOG.isErrorEnabled()) {
LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, filename), e);
}
}
return button(href, target, image, label, type, getSkinUri() + "buttons/");
}
/**
* Returns the instanciated editor display option class from the workplace manager.<p>
*
* This is a convenience method to be used on editor JSPs.<p>
*
* @return the instanciated editor display option class
*/
public CmsEditorDisplayOptions getEditorDisplayOptions() {
return OpenCms.getWorkplaceManager().getEditorDisplayOptions();
}
/**
* Returns the URI to the editor resource folder where button images and javascripts are located.<p>
*
* @return the URI to the editor resource folder
*/
public abstract String getEditorResourceUri();
/**
* Returns the OpenCms request context path.<p>
*
* This is a convenience method to use in the editor.<p>
*
* @return the OpenCms request context path
*/
public String getOpenCmsContext() {
return OpenCms.getSystemInfo().getOpenCmsContext();
}
/**
* Returns the back link when closing the editor.<p>
*
* @return the back link
*/
public String getParamBacklink() {
if (m_paramBackLink == null) {
m_paramBackLink = "";
}
return m_paramBackLink;
}
/**
* Returns the content of the editor.<p>
* @return the content of the editor
*/
public String getParamContent() {
if (m_paramContent == null) {
m_paramContent = "";
}
return m_paramContent;
}
/**
* Returns the direct edit flag parameter.<p>
*
* @return the direct edit flag parameter
*/
public String getParamDirectedit() {
return m_paramDirectedit;
}
/**
* Returns the edit as text parameter.<p>
*
* @return the edit as text parameter
*/
public String getParamEditastext() {
return m_paramEditAsText;
}
/**
* Returns the editor mode parameter.<p>
*
* @return the editor mode parameter
*/
public String getParamEditormode() {
return m_paramEditormode;
}
/**
* Returns the current element language.<p>
*
* @return the current element language
*/
public String getParamElementlanguage() {
return m_paramElementlanguage;
}
/**
* Returns the "loaddefault" parameter to determine if the default editor should be loaded.<p>
*
* @return the "loaddefault" parameter
*/
public String getParamLoaddefault() {
return m_paramLoadDefault;
}
/**
* Returns the modified parameter indicating if the resource has been saved.<p>
*
* @return the modified parameter indicating if the resource has been saved
*/
public String getParamModified() {
return m_paramModified;
}
/**
* Returns the old element language.<p>
*
* @return the old element language
*/
public String getParamOldelementlanguage() {
return m_paramOldelementlanguage;
}
/**
* Returns the name of the temporary file.<p>
*
* @return the name of the temporary file
*/
public String getParamTempfile() {
return m_paramTempFile;
}
/**
* Returns the path to the images used by this editor.<p>
*
* @return the path to the images used by this editor
*/
public String getPicsUri() {
if (m_picsUri == null) {
m_picsUri = getEditorResourceUri() + "pics/";
}
return m_picsUri;
}
/**
* Sets the back link when closing the editor.<p>
*
* @param backLink the back link
*/
public void setParamBacklink(String backLink) {
m_paramBackLink = backLink;
}
/**
* Sets the content of the editor.<p>
*
* @param content the content of the editor
*/
public void setParamContent(String content) {
if (content == null) {
content = "";
}
m_paramContent = content;
}
/**
* Sets the direct edit flag parameter.<p>
*
* @param direct the direct edit flag parameter
*/
public void setParamDirectedit(String direct) {
m_paramDirectedit = direct;
}
/**
* Sets the edit as text parameter.<p>
*
* @param editAsText <code>"true"</code> if the resource should be handled like a text file
*/
public void setParamEditastext(String editAsText) {
m_paramEditAsText = editAsText;
}
/**
* Sets the editor mode parameter.<p>
*
* @param mode the editor mode parameter
*/
public void setParamEditormode(String mode) {
m_paramEditormode = mode;
}
/**
* Sets the current element language.<p>
*
* @param elementLanguage the current element language
*/
public void setParamElementlanguage(String elementLanguage) {
m_paramElementlanguage = elementLanguage;
}
/**
* Sets the "loaddefault" parameter to determine if the default editor should be loaded.<p>
*
* @param loadDefault the "loaddefault" parameter
*/
public void setParamLoaddefault(String loadDefault) {
m_paramLoadDefault = loadDefault;
}
/**
* Sets the modified parameter indicating if the resource has been saved.<p>
*
* @param modified the modified parameter indicating if the resource has been saved
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -