📄 cmsframeset.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsFrameset.java,v $
* Date : $Date: 2006/07/21 12:01:54 $
* Version: $Revision: 1.87 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.workplace;
import org.opencms.file.CmsGroup;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsResourceFilter;
import org.opencms.i18n.CmsEncoder;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.main.OpenCms;
import org.opencms.site.CmsSite;
import org.opencms.site.CmsSiteManager;
import org.opencms.synchronize.CmsSynchronizeSettings;
import org.opencms.util.CmsRequestUtil;
import org.opencms.util.CmsStringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
/**
* Provides methods for building the main framesets of the OpenCms Workplace.<p>
*
* The following files use this class:
* <ul>
* <li>/views/top.html
* <li>/views/top_foot.html
* <li>/views/top_head.html
* </ul>
* <p>
*
* @author Alexander Kandzior
*
* @version $Revision: 1.87 $
*
* @since 6.0.0
*/
public class CmsFrameset extends CmsWorkplace {
/** The names of the supported frames. */
public static final String[] FRAMES = {"top", "head", "body", "foot"};
/** The names of the supported frames in a list. */
public static final List FRAMES_LIST = Arrays.asList(FRAMES);
/** Path to the JSP workplace frame loader file. */
public static final String JSP_WORKPLACE_URI = CmsWorkplace.VFS_PATH_WORKPLACE + "views/workplace.jsp";
/** The request parameter for the workplace start selection. */
public static final String PARAM_WP_START = "wpStart";
/** The request parameter for the workplace view selection. */
public static final String PARAM_WP_VIEW = "wpView";
/** Publish button appearance: show always. */
public static final String PUBLISHBUTTON_SHOW_ALWAYS = "always";
/** Publish button appearance: show auto (only if user has publish permissions). */
public static final String PUBLISHBUTTON_SHOW_AUTO = "auto";
/** Publish button appearance: show never. */
public static final String PUBLISHBUTTON_SHOW_NEVER = "never";
/** The log object for this class. */
private static final Log LOG = CmsLog.getLog(CmsFrameset.class);
/** Indicates if a reload of the main body frame is required. */
private boolean m_reloadRequired;
/** The request parameter for the selection of the frame. */
public static final String PARAM_WP_FRAME = "wpFrame";
/**
* Public constructor.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsFrameset(CmsJspActionElement jsp) {
super(jsp);
}
/**
* Returns the javascript code for the broadcast message alert in the foot of the workplace.<p>
*
* @return javascript code showing an alert box when the foot load
*/
public String getBroadcastMessage() {
StringBuffer result = new StringBuffer(512);
String message = getBroadcastMessageString();
if (CmsStringUtil.isNotEmpty(message)) {
// create a javascript alert for the message
result.append("\n<script type=\"text/javascript\">\n<!--\n");
// the timeout gives the frameset enough time to load before the alert is shown
result.append("function showMessage() {\n");
result.append("\talert(decodeURIComponent(\"");
// the user has pending messages, display them all
result.append(CmsEncoder.escapeWBlanks(message, CmsEncoder.ENCODING_UTF_8));
result.append("\"));\n}\n");
result.append("setTimeout('showMessage();', 2000);");
result.append("\n//-->\n</script>");
}
return result.toString();
}
/**
* Returns a html select box filled with groups of the current user.<p>
*
* @param htmlAttributes attributes that will be inserted into the generated html
* @return a html select box filled with groups of the current user
*/
public String getGroupSelect(String htmlAttributes) {
// get the users groups from the request context
List allGroups = new Vector();
try {
allGroups = getCms().getGroupsOfUser(getSettings().getUser().getName());
} catch (CmsException e) {
// should usually never happen
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
List options = new ArrayList();
List values = new ArrayList();
// loop through all groups and build the result vectors
int numGroups = allGroups.size();
for (int i = 0; i < numGroups; i++) {
CmsGroup loopGroup = (CmsGroup)allGroups.get(i);
String loopGroupName = loopGroup.getName();
values.add(loopGroupName);
options.add(loopGroupName);
}
return buildSelect(htmlAttributes, options, values, 0);
}
/**
* Returns the remote ip address of the current user.<p>
*
* @return the remote ip address of the current user
*/
public String getLoginAddress() {
return getCms().getRequestContext().getRemoteAddress();
}
/**
* Returns the last login time of the current user in localized format.<p>
*
* @return the last login time of the current user in localized format
*/
public String getLoginTime() {
return getMessages().getDateTime(getSettings().getUser().getLastlogin());
}
/**
* Returns a html select box filled with the current users accessible projects.<p>
*
* @param htmlAttributes attributes that will be inserted into the generated html
* @param htmlWidth additional style attributes containing width information
* @return a html select box filled with the current users accessible projects
*/
public String getProjectSelect(String htmlAttributes, String htmlWidth) {
// get all project information
List allProjects;
try {
allProjects = getCms().getAllAccessibleProjects();
} catch (CmsException e) {
// should usually never happen
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
allProjects = Collections.EMPTY_LIST;
}
List options = new ArrayList();
List values = new ArrayList();
int selectedIndex = 0;
// now loop through all projects and fill the result vectors
for (int i = 0, n = allProjects.size(); i < n; i++) {
CmsProject loopProject = (CmsProject)allProjects.get(i);
String loopProjectName = loopProject.getName();
String loopProjectId = Integer.toString(loopProject.getId());
values.add(loopProjectId);
options.add(loopProjectName);
if (loopProject.getId() == getSettings().getProject()) {
// this is the user's current project
selectedIndex = i;
}
// check the length of the project name, to optionallly adjust the size of the selector
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -