📄 cmsframeset.java
字号:
if (CmsStringUtil.isNotEmpty(htmlWidth)) {
StringBuffer buf = new StringBuffer(htmlAttributes.length() + htmlWidth.length() + 2);
buf.append(htmlAttributes);
buf.append(" ");
buf.append(htmlWidth);
htmlAttributes = buf.toString();
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Returns the html for the "publish project" button depending on the current users permissions and the default
* workplace settings.<p>
*
* @return the html for the "publish project" button
*/
public String getPublishButton() {
String publishButton = OpenCms.getWorkplaceManager().getDefaultUserSettings().getPublishButtonAppearance();
if (PUBLISHBUTTON_SHOW_NEVER.equals(publishButton)) {
return "";
}
int buttonStyle = getSettings().getUserSettings().getWorkplaceButtonStyle();
if (PUBLISHBUTTON_SHOW_AUTO.equals(publishButton)) {
if (getCms().isManagerOfProject()) {
return button("../commons/publishproject.jsp", "body", "publish.png", Messages.GUI_BUTTON_PUBLISH_0 , buttonStyle);
} else {
return "";
}
}
if (getCms().isManagerOfProject()) {
return (button("../commons/publishproject.jsp", "body", "publish.png", Messages.GUI_BUTTON_PUBLISH_0, buttonStyle));
} else {
return (button(null, null, "publish_in.png", Messages.GUI_BUTTON_PUBLISH_0, buttonStyle));
}
}
/**
* Returns a html select box filled with the current users accessible sites.<p>
*
* @param htmlAttributes attributes that will be inserted into the generated html
* @return a html select box filled with the current users accessible sites
*/
public String getSiteSelect(String htmlAttributes) {
List options = new ArrayList();
List values = new ArrayList();
int selectedIndex = 0;
List sites = CmsSiteManager.getAvailableSites(getCms(), true);
Iterator i = sites.iterator();
int pos = 0;
while (i.hasNext()) {
CmsSite site = (CmsSite)i.next();
values.add(site.getSiteRoot());
options.add(site.getTitle());
if (site.getSiteRoot().equals(getSettings().getSite())) {
// this is the user's current site
selectedIndex = pos;
}
pos++;
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Returns the startup URI for display in the main body frame, this can
* either be the user default view, or (if set) a sepcific startup resource.<p>
*
* @return the startup URI for display in the main body frame
*/
public String getStartupUri() {
String result = getSettings().getViewStartup();
if (result == null) {
// no specific startup URI is set, use view from user settings
result = getSettings().getViewUri();
} else {
// reset the startup URI, so that it is not displayed again on reload of the frameset
getSettings().setViewStartup(null);
}
return CmsRequestUtil.appendParameter(result, CmsFrameset.PARAM_WP_FRAME, FRAMES[2]);
}
/**
* Returns a html select box filled with the views accessible by the current user.<p>
*
* @param htmlAttributes attributes that will be inserted into the generated html
* @return a html select box filled with the views accessible by the current user
*/
public String getViewSelect(String htmlAttributes) {
List options = new ArrayList();
List values = new ArrayList();
int selectedIndex = 0;
// loop through the vectors and fill the result vectors
Iterator i = OpenCms.getWorkplaceManager().getViews().iterator();
int count = -1;
String currentView = getSettings().getViewUri();
if (CmsStringUtil.isNotEmpty(currentView)) {
// remove possible parameters from current view
int pos = currentView.indexOf('?');
if (pos >= 0) {
currentView = currentView.substring(0, pos);
}
}
while (i.hasNext()) {
CmsWorkplaceView view = (CmsWorkplaceView)i.next();
if (getCms().existsResource(view.getUri(), CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
count++;
// ensure the current user has +v+r permissions on the view
String loopLink = getJsp().link(view.getUri());
String localizedKey = resolveMacros(view.getKey());
options.add(localizedKey);
values.add(loopLink);
if (loopLink.equals(currentView)) {
selectedIndex = count;
}
}
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Returns the reload URI for the OpenCms workplace.<p>
*
* @return the reload URI for the OpenCms workplace
*/
public String getWorkplaceReloadUri() {
return getJsp().link(CmsFrameset.JSP_WORKPLACE_URI);
}
/**
* Returns <code>true</code> if a reload of the main body frame is required.<p>
*
* This value is modified with the select options (project, site or view) in the head frame of
* the Workplace. If a user changes one of these select values, the head frame is posted
* "against itself". The posted values will be processed by this class, causing
* the internal Workplace settings to change. After these settings have been changed,
* a reload of the main body frame is required in order to update it with the new values.
* A JavaScript in the Workplace head frame will be executed in this case.<p>
*
* @return <code>true</code> if a reload of the main body frame is required
*/
public boolean isReloadRequired() {
return m_reloadRequired;
}
/**
* Returns true if the user has enabled synchronization.<p>
*
* @return true if the user has enabled synchronization
*/
public boolean isSyncEnabled() {
CmsSynchronizeSettings syncSettings = getSettings().getUserSettings().getSynchronizeSettings();
return (syncSettings != null) && syncSettings.isSyncEnabled();
}
/**
* Indicates if the site selector should be shown in the top frame depending on the count of accessible sites.<p>
*
* @return true if site selector should be shown, otherwise false
*/
public boolean showSiteSelector() {
if (getSettings().getUserSettings().getRestrictExplorerView()) {
// restricted explorer view to site and folder, do not show site selector
return false;
}
// count available sites
int siteCount = CmsSiteManager.getAvailableSites(getCms(), true).size();
return (siteCount > 1);
}
/**
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
*/
protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
// check if a startup page has been set
String frame = CmsRequestUtil.getNotEmptyDecodedParameter(request, CmsFrameset.PARAM_WP_FRAME);
if ((frame == null) || (FRAMES_LIST.indexOf(frame) < 0)) {
// illegal or no frame selected, assume the "top" frame
frame = FRAMES[0];
}
if (FRAMES[0].equals(frame)) {
// top frame requested - execute special reload actions
topFrameReload(settings);
}
// check if a startup page has been set
String startup = CmsRequestUtil.getNotEmptyDecodedParameter(request, CmsFrameset.PARAM_WP_START);
if (startup != null) {
m_reloadRequired = true;
settings.setViewStartup(startup);
}
// check if the user requested a view change
String view = request.getParameter(CmsFrameset.PARAM_WP_VIEW);
if (view != null) {
m_reloadRequired = true;
settings.setViewUri(view);
// TODO: This is a workaround to make dialogs work in the legacy XMLTemplate views
settings.getFrameUris().put("body", view);
settings.getFrameUris().put("admin_content", "/system/workplace/action/administration_content_top.html");
}
m_reloadRequired = initSettings(settings, request) || m_reloadRequired;
}
/**
* Performs certain clear cache actions if the top frame is reloaded.<p>
*
* @param settings the current users workplace settings
*/
protected void topFrameReload(CmsWorkplaceSettings settings) {
// ensure to read the settings from the database
initUserSettings(getCms(), settings, true);
// reset the HTML list in order to force a full reload
settings.setListObject(null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -