📄 cmsdialog.java
字号:
*
* @param segment the HTML segment (START / END)
* @param helpUrl the url for the online help to include on the page
* @param title the title for the page
* @return the start html of the page
*/
public String pageHtml(int segment, String helpUrl, String title) {
if (segment == HTML_START) {
String stylesheet = null;
if (isPopup() && !useNewStyle()) {
stylesheet = "popup.css";
}
StringBuffer result = new StringBuffer(pageHtmlStyle(segment, title, stylesheet));
if (getSettings().isViewExplorer()) {
result.append("<script type=\"text/javascript\" src=\"");
result.append(getSkinUri());
result.append("commons/explorer.js\"></script>\n");
}
result.append("<script type=\"text/javascript\">\n");
result.append(dialogScriptSubmit());
if (helpUrl != null) {
result.append("if (top.head && top.head.helpUrl) {\n");
result.append("\ttop.head.helpUrl=\"");
result.append(helpUrl + "\";\n");
result.append("}\n\n");
}
// the variable that may be set as path: if non-null this will be
// used as path for the online help window. This is needed because there are pages
// e.g. /administration/accounts/users/new that perform a jsp - forward while leaving the
// path param on the old page: no correct online help possible.
result.append("var onlineHelpUriCustom = ");
result.append(getOnlineHelpUriCustom());
result.append(";\n");
result.append("</script>\n");
return result.toString();
} else {
return super.pageHtml(segment, null);
}
}
/**
* Set the custom mapping for the online help. <p>
*
* This value will be set to a javascript variable called onlineHelpUriCustom.
* If it is set, the top.head javascript for the online help will use this value. <p>
*
* This method should be called from <code>{@link #initWorkplaceRequestValues(CmsWorkplaceSettings, HttpServletRequest)}</code>,
* <code>{@link CmsWorkplace#initWorkplaceMembers(CmsJspActionElement)}</code>
* or from the jsp if the dialog class is used for several actions.
* It should be used whenever the online help mapping does not work (due to jsp - forwards).<p>
*
* @param uri the left hand value in mapping.properties for the online help pages
*/
public void setOnlineHelpUriCustom(String uri) {
m_onlineHelpUriCustom = uri;
}
/**
* Sets the value of the action parameter.<p>
*
* @param value the value to set
*/
public void setParamAction(String value) {
m_paramAction = value;
}
/**
* Sets the value of the closelink parameter.<p>
*
* @param value the value to set
*/
public void setParamCloseLink(String value) {
// ensure decoded chars are re-encoded again properly
m_paramCloseLink = value;
}
/**
* Sets the value of the dialogtype parameter.<p>
*
* @param value the value to set
*/
public void setParamDialogtype(String value) {
m_paramDialogtype = value;
}
/**
* Sets the value of the frame name parameter.<p>
*
* @param value the value to set
*/
public void setParamFramename(String value) {
m_paramFrameName = value;
}
/**
* Sets the ispopup parameter.<p>
*
* @param value the ispopup parameter value
*/
public void setParamIsPopup(String value) {
m_paramIsPopup = value;
}
/**
* Sets the value of the message parameter.<p>
*
* @param value the value to set
*/
public void setParamMessage(String value) {
m_paramMessage = value;
}
/**
* Sets the value of the originalparams parameter.<p>
*
* @param paramOriginalParams the value of the originalparams parameter
*/
public void setParamOriginalParams(String paramOriginalParams) {
m_paramOriginalParams = paramOriginalParams;
}
/**
* Sets the value of the preactiondone parameter.<p>
*
* @param paramPreActionDone the value of the preactiondone parameter
*/
public void setParamPreActionDone(String paramPreActionDone) {
m_paramPreActionDone = paramPreActionDone;
}
/**
* Sets the value of the redirect flag parameter.<p>
*
* @param redirect the value of the redirect flag parameter
*/
public void setParamRedirect(String redirect) {
m_paramRedirect = redirect;
}
/**
* Sets the value of the file parameter.<p>
*
* @param value the value to set
*/
public void setParamResource(String value) {
m_paramResource = value;
}
/**
* Sets the value of the title parameter.<p>
*
* @param value the value to set
*/
public void setParamTitle(String value) {
m_paramTitle = value;
}
/**
* Appends a space char. between tag attribs.<p>
*
* @param attribute a tag attribute
* @return the tag attribute with a leading space char.
*/
protected String appendDelimiter(String attribute) {
if (CmsStringUtil.isNotEmpty(attribute)) {
if (!attribute.startsWith(" ")) {
// add a delimiter space between the beginning button HTML and the button tag attribs
return " " + attribute;
} else {
return attribute;
}
}
return "";
}
/**
* Returns ajax wait message.<p>
*
* @return html code
*/
protected String buildAjaxWaitMessage() {
StringBuffer html = new StringBuffer(512);
html.append("<table border='0' style='vertical-align:middle; height: 150px;'>\n");
html.append("<tr><td width='40' align='center' valign='middle'><img src='");
html.append(CmsWorkplace.getSkinUri());
html.append("commons/wait.gif' id='ajaxreport-img' width='32' height='32' alt=''></td>\n");
html.append("<td valign='middle'><span id='ajaxreport-txt' style='color: #000099; font-weight: bold;'>\n");
html.append(key(org.opencms.workplace.Messages.GUI_AJAX_REPORT_WAIT_0));
html.append("</span><br></td></tr></table>\n");
return html.toString();
}
/**
* Checks if the permissions of the current user on the resource to use in the dialog are sufficient.<p>
*
* Automatically generates a CmsMessageContainer object with an error message and stores it in the users session.<p>
*
* @param required the required permissions for the dialog
* @param neededForFolder if true, the permissions are required for the parent folder of the resource (e.g. for editors)
* @return true if the permissions are sufficient, otherwise false
*/
protected boolean checkResourcePermissions(CmsPermissionSet required, boolean neededForFolder) {
return checkResourcePermissions(required, neededForFolder, Messages.get().container(
Messages.GUI_ERR_RESOURCE_PERMISSIONS_2,
getParamResource(),
required.getPermissionString()));
}
/**
* Checks if the permissions of the current user on the resource to use in the dialog are sufficient.<p>
*
* Automatically generates a CmsMessageContainer object with an error message and stores it in the users session.<p>
*
* @param required the required permissions for the dialog
* @param neededForFolder if true, the permissions are required for the parent folder of the resource (e.g. for editors)
* @param errorMessage the message container that is stored in the session in case the permissions are not sufficient
* @return true if the permissions are sufficient, otherwise false
*/
protected boolean checkResourcePermissions(
CmsPermissionSet required,
boolean neededForFolder,
CmsMessageContainer errorMessage) {
boolean hasPermissions = false;
try {
CmsResource res;
if (neededForFolder) {
// check permissions for the folder the resource is in
res = getCms().readResource(CmsResource.getParentFolder(getParamResource()), CmsResourceFilter.ALL);
} else {
res = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);
}
hasPermissions = getCms().hasPermissions(res, required, false, CmsResourceFilter.ALL);
} catch (CmsException e) {
// should usually never happen
if (LOG.isInfoEnabled()) {
LOG.info(e);
}
}
if (!hasPermissions) {
// store the error message in the users session
getSettings().setErrorMessage(errorMessage);
}
return hasPermissions;
}
/**
* Returns the full path of the current workplace folder.<p>
*
* @return the full path of the current workplace folder
*/
protected String computeCurrentFolder() {
String currentFolder = getSettings().getExplorerResource();
if (currentFolder == null) {
// set current folder to root folder
try {
currentFolder = getCms().getSitePath(getCms().readFolder("/", CmsResourceFilter.IGNORE_EXPIRATION));
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e);
}
currentFolder = "/";
}
}
if (!currentFolder.endsWith("/")) {
// add folder separator to currentFolder
currentFolder += "/";
}
return currentFolder;
}
/**
* Renders the HTML for a single input button of a specified type.<p>
*
* @param result a string buffer where the rendered HTML gets appended to
* @param button a integer key to identify the button
* @param attribute an optional string with possible tag attributes, or null
*/
protected void dialogButtonsHtml(StringBuffer result, int button, String attribute) {
attribute = appendDelimiter(attribute);
switch (button) {
case BUTTON_OK:
result.append("<input name=\"ok\" value=\"");
result.append(key(Messages.GUI_DIALOG_BUTTON_OK_0) + "\"");
if (attribute.toLowerCase().indexOf("onclick") == -1) {
result.append(" type=\"submit\"");
} else {
result.append(" type=\"button\"");
}
result.append(" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
break;
case BUTTON_CANCEL:
result.append("<input name=\"cancel\" type=\"button\" value=\"");
result.append(key(Messages.GUI_DIALOG_BUTTON_CANCEL_0) + "\"");
if (attribute.toLowerCase().indexOf("onclick") == -1) {
result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\"");
}
result.append(" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
break;
case BUTTON_EDIT:
result.append("<input name=\"ok\" value=\"");
result.append(key(Messages.GUI_DIALOG_BUTTON_EDIT_0) + "\"");
if (attribute.toLowerCase().indexOf("onclick") == -1) {
result.append(" type=\"submit\"");
} else {
result.append(" type=\"button\"");
}
result.append(" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
break;
case BUTTON_DISCARD:
result.append("<input name=\"cancel\" type=\"button\" value=\"");
result.append(key(Messages.GUI_DIALOG_BUTTON_DISCARD_0) + "\"");
if (attribute.toLowerCase().indexOf("onclick") == -1) {
result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\"");
}
result.append(" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
break;
case BUTTON_CLOSE:
result.append("<input name=\"close\" type=\"button\" value=\"");
result.append(key(Messages.GUI_DIALOG_BUTTON_CLOSE_0) + "\"");
if (attribute.toLowerCase().indexOf("onclick") == -1) {
result.append(" onclick=\"submitAction('" + DIALOG_CANCEL + "', form);\"");
}
result.append(" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
break;
case BUTTON_ADVANCED:
result.append("<input name=\"advanced\" type=\"button\" value=\"");
result.append(key(Messages.GUI_DIALOG_BUTTON_ADVANCED_0) + "\"");
result.append(" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -