📄 cmsworkplace.java
字号:
/**
* Returns the uri (including context path) to the explorer file list.<p>
*
* @return the uri (including context path) to the explorer file list
*/
public String getExplorerFileListFullUri() {
if (m_file_explorer_filelist != null) {
return m_file_explorer_filelist;
}
synchronized (this) {
m_file_explorer_filelist = OpenCms.getLinkManager().substituteLink(getCms(), FILE_EXPLORER_FILELIST);
}
return m_file_explorer_filelist;
}
/**
* Returns the html for the frame name and source and stores this information in the workplace settings.<p>
*
* @param frameName the name of the frame
* @param uri the absolute path of the frame
* @return the html for the frame name and source
*/
public String getFrameSource(String frameName, String uri) {
String frameString = "name=\"" + frameName + "\" src=\"" + uri + "\"";
int paramIndex = uri.indexOf("?");
if (paramIndex != -1) {
// remove request parameters from URI before putting it to Map
uri = uri.substring(0, uri.indexOf("?"));
}
getSettings().getFrameUris().put(frameName, uri);
return frameString;
}
/**
* Returns the JSP action element.<p>
*
* @return the JSP action element
*/
public CmsJspActionElement getJsp() {
return m_jsp;
}
/**
* Returns the current users workplace locale settings.<p>
*
* @return the current users workplace locale setting
*/
public Locale getLocale() {
return m_settings.getUserSettings().getLocale();
}
/**
* Returns the current used macro resolver instance.<p>
*
* @return the macro resolver
*/
public CmsMacroResolver getMacroResolver() {
if (m_macroResolver == null) {
// create a new macro resolver "with everything we got"
m_macroResolver = CmsMacroResolver.newInstance()
// initialize resolver with the objects available
.setCmsObject(m_cms).setMessages(getMessages()).setJspPageContext(
(m_jsp == null) ? null : m_jsp.getJspContext());
}
return m_macroResolver;
}
/**
* Returns the current used message object.<p>
*
* @return the current used message object
*/
public CmsMessages getMessages() {
return m_messages;
}
/**
* Returns a list of FileItem instances parsed from the request, in the order that they were transmitted.<p>
*
* This list is automatically initialized from the createParameterMapFromMultiPart(HttpServletRequest) method.<p>
*
* @return list of FileItem instances parsed from the request, in the order that they were transmitted
*/
public List getMultiPartFileItems() {
return m_multiPartFileItems;
}
/**
* Returns the path to the workplace static resources.<p>
*
* Workplaces static resources are images, css files etc.
* These are exported during the installation of OpenCms,
* and are usually only read from this exported location to
* avoid the overhaead of accessing the database later.<p>
*
* @return the path to the workplace static resources
*/
public String getResourceUri() {
if (m_resourceUri == null) {
m_resourceUri = OpenCms.getSystemInfo().getContextPath() + CmsWorkplace.RFS_PATH_RESOURCES;
}
return m_resourceUri;
}
/**
* Returns the current user http session.<p>
*
* @return the current user http session
*/
public HttpSession getSession() {
return m_session;
}
/**
* Returns the current users workplace settings.<p>
*
* @return the current users workplace settings
*/
public CmsWorkplaceSettings getSettings() {
return m_settings;
}
/**
* Returns the path to the cascading stylesheets.<p>
*
* @param filename the name of the stylesheet
* @return the path to the cascading stylesheets
*/
public String getStyleUri(String filename) {
return getStyleUri(getJsp(), filename);
}
/**
* Builds the end html of the page.<p>
*
* @return the end html of the page
*/
public String htmlEnd() {
return pageHtml(HTML_END, null);
}
/**
* Builds the start html of the page, including setting of DOCTYPE and
* inserting a header with the content-type.<p>
*
* @param title the content for the title tag
* @return the start html of the page
*/
public String htmlStart(String title) {
return pageHtml(HTML_START, title);
}
/**
* Sets site and project in the workplace settings with the request values of parameters
* <code>{@link CmsWorkplace#PARAM_WP_SITE}</code> and <code>{@link CmsWorkplace#PARAM_WP_PROJECT}</code>.<p>
*
* @param settings the workplace settings
* @param request the current request
*
* @return true, if a reload of the main body frame is required
*/
public boolean initSettings(CmsWorkplaceSettings settings, HttpServletRequest request) {
// check if the user requested a project change
String project = request.getParameter(PARAM_WP_PROJECT);
boolean reloadRequired = false;
if (project != null) {
reloadRequired = true;
try {
getCms().readProject(Integer.parseInt(project));
} catch (Exception e) {
// project not found, set online project
project = String.valueOf(CmsProject.ONLINE_PROJECT_ID);
}
try {
m_cms.getRequestContext().setCurrentProject(getCms().readProject(Integer.parseInt(project)));
} catch (Exception e) {
if (LOG.isInfoEnabled()) {
LOG.info(e);
}
}
settings.setProject(Integer.parseInt(project));
}
// check if the user requested a site change
String site = request.getParameter(PARAM_WP_SITE);
if (site != null) {
reloadRequired = true;
m_cms.getRequestContext().setSiteRoot(site);
settings.setSite(site);
}
// check which resource was requested
String explorerResource = request.getParameter(PARAM_WP_EXPLORER_RESOURCE);
if (explorerResource != null) {
reloadRequired = true;
settings.setExplorerResource(explorerResource);
}
return reloadRequired;
}
/**
* Returns the forwarded flag.<p>
*
* @return the forwarded flag
*/
public boolean isForwarded() {
return m_forwarded;
}
/**
* Returns true if the online help for the users current workplace language is installed.<p>
*
* @return true if the online help for the users current workplace language is installed
*/
public boolean isHelpEnabled() {
return getCms().existsResource(
resolveMacros(CmsHelpTemplateBean.PATH_HELP),
CmsResourceFilter.IGNORE_EXPIRATION);
}
/**
* Returns true if the currently processed element is an included sub element.<p>
*
* @return true if the currently processed element is an included sub element
*/
public boolean isSubElement() {
return !getJsp().getRequestContext().getUri().equals(getJsp().info("opencms.request.element.uri"));
}
/**
* Returns the localized resource string for a given message key,
* checking the workplace default resources and all module bundles.<p>
*
* If the key was not found, the return value is
* <code>"??? " + keyName + " ???"</code>.<p>
*
* If the key starts with <code>"help."</code> and is not found,
* the value <code>"index.html"</code> is returned.<p>
*
* @param keyName the key for the desired string
* @return the resource string for the given key
*
* @see CmsMessages#key(String)
*/
public String key(String keyName) {
return getMessages().key(keyName);
}
/**
* Returns the localized resource string for a given message key,
* with the provided replacement parameters.<p>
*
* If the key was found in the bundle, it will be formatted using
* a <code>{@link java.text.MessageFormat}</code> using the provided parameters.<p>
*
* If the key was not found in the bundle, the return value is
* <code>"??? " + keyName + " ???"</code>. This will also be returned
* if the bundle was not properly initialized first.
*
* @param keyName the key for the desired string
* @param params the parameters to use for formatting
* @return the resource string for the given key
*
* @see CmsMessages#key(String)
*/
public String key(String keyName, Object[] params) {
return getMessages().key(keyName, params);
}
/**
* Returns the localized resource string for the given message key,
* checking the workplace default resources and all module bundles.<p>
*
* If the key was not found, the provided default value
* is returned.<p>
*
* @param keyName the key for the desired string
* @param defaultValue the default value in case the key does not exist in the bundle
* @return the resource string for the given key it it exists, or the given default if not
*
* @see CmsMessages#keyDefault(String, String)
*/
public String keyDefault(String keyName, String defaultValue) {
return getMessages().keyDefault(keyName, defaultValue);
}
/**
* Returns the empty String "" if the provided value is null, otherwise just returns
* the provided value.<p>
*
* Use this method in forms if a getParamXXX method is used, but a String (not null)
* is required.
*
* @param value the String to check
* @return the empty String "" if the provided value is null, otherwise just returns
* the provided value
*/
public String nullToEmpty(String value) {
if (value != null) {
return value;
}
return "";
}
/**
* Builds the html of the body.<p>
*
* @param segment the HTML segment (START / END)
* @param className optional class attribute to add to the body tag
* @param parameters optional parameters to add to the body tag
* @return the html of the body
*/
public String pageBody(int segment, String className, String parameters) {
if (segment == HTML_START) {
StringBuffer result = new StringBuffer(128);
result.append
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -