⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmswpmain.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* File   : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsWpMain.java,v $
* Date   : $Date: 2005/06/27 23:22:07 $
* Version: $Revision: 1.4 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001  The OpenCms Group
*
* 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 OpenCms, please see the
* OpenCms 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 com.opencms.workplace;

import org.opencms.db.CmsUserSettings;
import org.opencms.file.CmsGroup;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsRequestContext;
import org.opencms.file.CmsUser;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;

import com.opencms.core.I_CmsSession;
import com.opencms.legacy.CmsXmlTemplateLoader;
import com.opencms.template.A_CmsXmlContent;
import com.opencms.template.CmsXmlTemplateFile;

import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

/**
 * Template class for displaying OpenCms workplace main screen.
 * <P>
 * Reads template files of the content type <code>CmsXmlWpTemplateFile</code>.
 *
 * @author Alexander Lucas
 * @author Michael Emmerich
 * @version $Revision: 1.4 $ $Date: 2005/06/27 23:22:07 $
 * @see com.opencms.workplace.CmsXmlWpTemplateFile
 * 
 * @deprecated Will not be supported past the OpenCms 6 release.
 */

public class CmsWpMain extends CmsWorkplaceDefault {
        
    /**
     * The name of the tag for sync button.
     */
    static final String C_SYNC_BUTTON = "SYNC";

    /**
     * The name of the tag for disabled sync button.
     */
    static final String C_SYNC_BUTTON_DISABLED = "SYNC_DISABLED";

    
    public CmsWpMain() {
        super();
        
        m_SelectedPrjIndex = 0;
        m_ProjectIds = null;
        m_ProjectNames = null;
    }
        
	/**
	 * Gets the content of a defined section in a given template file and its subtemplates
	 * with the given parameters.
	 *
	 * @see #getContent(CmsObject, String, String, Hashtable, String)
	 * @param cms CmsObject Object for accessing system resources.
	 * @param templateFile Filename of the template file.
	 * @param elementName Element name of this template in our parent template.
	 * @param parameters Hashtable with all template class parameters.
	 * @param templateSelector template section that should be processed.
	 */

	public byte[] getContent(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) throws CmsException {
		if (CmsLog.getLog(this).isDebugEnabled() && C_DEBUG) {
			CmsLog.getLog(this).debug("[CmsXmlTemplate] getting content of element " + ((elementName == null) ? "<root>" : elementName));
			CmsLog.getLog(this).debug("[CmsXmlTemplate] template file is: " + templateFile);
			CmsLog.getLog(this).debug("[CmsXmlTemplate] selected template section is: " + ((templateSelector == null) ? "<default>" : templateSelector));
		}

		I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
		CmsRequestContext reqCont = cms.getRequestContext();
//		String newGroup = (String) parameters.get("group");
		String newProject = (String) parameters.get("project");
		String newView = (String) parameters.get(CmsWorkplaceDefault.C_PARA_VIEW);
		CmsXmlTemplateFile xmlTemplateDocument = getOwnTemplateFile(cms, templateFile, elementName, parameters, templateSelector);

		// Check if the user requested a group change
//		if (newGroup != null && !("".equals(newGroup))) {
//			if (!(newGroup.equals(reqCont.currentGroup().getName()))) {
//				reqCont.setCurrentGroup(newGroup);
//			}
//		}

		// Check if the user requested a project change
		if (newProject != null && !("".equals(newProject))) {
			if (!(Integer.parseInt(newProject) == reqCont.currentProject().getId())) {
				reqCont.setCurrentProject(cms.readProject(Integer.parseInt(newProject)));
			}
		}

		// Check if the user requested a new view
		if (newView != null && !("".equals(newView))) {
			session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
			session.putValue(CmsWorkplaceDefault.C_PARA_VIEW, newView);
		}

		// set the publishProject Button to enable if user has the right to publish the project
		if (templateFile.equalsIgnoreCase(CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + "head")) {
			if ((cms.isAdmin() || cms.isManagerOfProject()) && (!reqCont.currentProject().isOnlineProject())) {
				xmlTemplateDocument.setData("publish", xmlTemplateDocument.getProcessedDataValue("PUBLISH_ENABLED", this));
			}
			else {
				xmlTemplateDocument.setData("publish", xmlTemplateDocument.getProcessedDataValue("PUBLISH_DISABLED", this));
			}
		}

		// set the sync button to enabled if no entries for synchronisation in registry
//		if (templateFile.equalsIgnoreCase(C_VFS_PATH_DEFAULT_INTERNAL + "head")) {
//			String syncpath = null;
//			syncpath = cms.getRegistry().getSystemValue(I_CmsConstants.C_SYNCHRONISATION_PROJECT);
//			if (syncpath == null) {
				xmlTemplateDocument.setData(C_SYNC_BUTTON, xmlTemplateDocument.getProcessedDataValue(C_SYNC_BUTTON_DISABLED, this));
//			}
//			else {
//				xmlTemplateDocument.setData(CmsSyncFolder.C_SYNC_BUTTON, xmlTemplateDocument.getProcessedDataValue(CmsSyncFolder.C_SYNC_BUTTON_ENABLED, this));
//			}
//		}

//		// send message, if this is the foot
//		if (templateFile.equalsIgnoreCase(C_VFS_PATH_DEFAULT_INTERNAL + "foot")) {
//			String message = (String) CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true).getValue(I_CmsConstants.C_SESSION_BROADCASTMESSAGE);
//			if (message != null) {
//				CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true).removeValue(I_CmsConstants.C_SESSION_BROADCASTMESSAGE);
//				xmlTemplateDocument.setData("message", "alert(unescape('BROADCASTMESSAGE: " + CmsEncoder.escape(message, cms.getRequestContext().getEncoding()) + "'));");
//			}
//		}

		// test if the "help"- button has to be displayed for the user's 
		// current language in case we process the head template
		if (templateFile.equalsIgnoreCase(CmsWorkplaceDefault.C_VFS_PATH_DEFAULT_INTERNAL + "head")) {
			String userLanguage = CmsXmlLanguageFile.getCurrentUserLanguage(cms);
			xmlTemplateDocument.setData("LOCALE", "" + userLanguage);

			try {
				cms.readFolder(CmsWorkplaceDefault.C_VFS_PATH_HELP + userLanguage);
				// the localized help- folder exists
				xmlTemplateDocument.setData("HELP", xmlTemplateDocument.getProcessedDataValue("HELP_ENABLED", this));
			}
			catch (CmsException e) {
				// the localized help- folder does not exist
                try {
				    xmlTemplateDocument.setData("HELP", xmlTemplateDocument.getProcessedDataValue("HELP_DISABLED", this));
                } catch (Exception ex) {
                    // probably the "head" template is old, ignore this error so the workplace can still be used
                } 
			}
		}
        
        this.fetchProjects(cms, xmlTemplateDocument);

		// Now load the template file and start the processing
		return startProcessing(cms, xmlTemplateDocument, elementName, parameters, templateSelector);
	}

	/**
	 * Gets all groups of the currently logged in user.
	 * <P>
	 * The given vectors <code>names</code> and <code>values</code> will
	 * be filled with the appropriate information to be used for building
	 * a select box.
	 * <P>
	 * Both <code>names</code> and <code>values</code> will contain
	 * the group names after returning from this method.
	 * <P>
	 *
	 * @param cms CmsObject Object for accessing system resources.
	 * @param lang reference to the currently valid language file
	 * @param names Vector to be filled with the appropriate values in this method.
	 * @param values Vector to be filled with the appropriate values in this method.
	 * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
	 * @return Index representing the user's current group in the vectors.
	 * @throws CmsException
	 */

	public Integer getGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector names, Vector values, Hashtable parameters) throws CmsException {

		// Get a vector of all of the user's groups by asking the request context
		CmsRequestContext reqCont = cms.getRequestContext();
//		CmsGroup currentGroup = reqCont.currentGroup();
		List allGroups = cms.getGroupsOfUser(reqCont.currentUser().getName());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -