cmsadminmoduleadmin.java
来自「java 编写的程序」· Java 代码 · 共 404 行 · 第 1/2 页
JAVA
404 行
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/CmsAdminModuleAdmin.java,v $
* Date : $Date: 2001/07/31 15:50:17 $
* Version: $Revision: 1.13 $
*
* 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 com.opencms.file.*;
import com.opencms.core.*;
import com.opencms.util.*;
import com.opencms.template.*;
import java.text.*;
import java.util.*;
import javax.servlet.http.*;
/**
* Template class for displaying OpenCms workplace administration module administration.
*
* Creation date: (29.10.00 10:28:08)
* @author: Hanjo Riege
*/
public class CmsAdminModuleAdmin extends CmsWorkplaceDefault implements I_CmsConstants {
private final String C_FROM = "from";
private final String C_VERSION = "version";
private final String C_MODULENAME = "modulename";
private final String C_DESCRIPTION = "description";
private final String C_VIEW = "view";
private final String C_ADMINPOINT = "adminpoint";
private final String C_MAINTENANCE = "maintenance";
private final String C_AUTHOR = "author";
private final String C_EMAIL = "email";
private final String C_DATE = "date";
private final String C_DEPENDENCY = "dependencies";
private final String C_ALLDEPS = "alldeps";
private final String C_ONEDEP = "dependentry";
private final String C_OPTIONENTRY = "optionentry";
private final String C_NAME_PARAMETER = "module";
/**
* fills the data from the module in the hashtable.
* Creation date: (30.10.00 14:22:22)
* @return java.util.Hashtable
* @param param java.lang.String
*/
private void fillHashtable(CmsObject cms, I_CmsRegistry reg, Hashtable table, String module) {
table.put(C_MODULE_PACKETNAME, module);
table.put(C_VERSION, getStringValue("" + reg.getModuleVersion(module)));
table.put(C_MODULENAME, getStringValue(reg.getModuleNiceName(module)));
table.put(C_DESCRIPTION, getStringValue(reg.getModuleDescription(module)));
String check = getStringValue(reg.getModuleViewName(module));
if(!check.equals("")) {
check = "checked";
}
table.put(C_VIEW, check);
try {
cms.readFolder("/system/modules/" + module + "/administration/");
check = "checked";
}catch(Exception exc) {
check = "";
}
table.put(C_ADMINPOINT, check);
table.put(C_MAINTENANCE, getStringValue(reg.getModuleMaintenanceEventName(module)));
table.put(C_AUTHOR, getStringValue(reg.getModuleAuthor(module)));
table.put(C_EMAIL, getStringValue(reg.getModuleAuthorEmail(module)));
table.put(C_DATE, getStringValue(Utils.getNiceShortDate(reg.getModuleCreateDate(module))));
// get the dependencies
Vector depNames = new Vector();
Vector minVersion = new Vector();
Vector maxVersion = new Vector();
int deps = reg.getModuleDependencies(module, depNames, minVersion, maxVersion);
Vector stringDeps = new Vector();
for(int i = 0;i < deps;i++) {
String max = (String)maxVersion.elementAt(i);
if("-1".equals(max)) {
max = "*";
}
stringDeps.addElement((String)depNames.elementAt(i) + " Version:" + (String)minVersion.elementAt(i) + " - " + max);
}
table.put(C_DEPENDENCY, stringDeps);
// handle the properties
Vector paraNames = new Vector();
Vector paraDescr = new Vector();
Vector paraTyp = new Vector();
Vector paraVal = new Vector();
String[] allParas = reg.getModuleParameterNames(module);
for(int i = 0;i < allParas.length;i++) {
paraNames.addElement(allParas[i]);
paraDescr.addElement(getStringValue(reg.getModuleParameterDescription(module, allParas[i])));
paraVal.addElement(reg.getModuleParameterString(module, allParas[i]));
paraTyp.addElement(reg.getModuleParameterType(module, allParas[i]));
}
table.put(C_SESSION_MODULE_ADMIN_PROP_NAMES, paraNames);
table.put(C_SESSION_MODULE_ADMIN_PROP_DESCR, paraDescr);
table.put(C_SESSION_MODULE_ADMIN_PROP_TYP, paraTyp);
table.put(C_SESSION_MODULE_ADMIN_PROP_VAL, paraVal);
}
/**
* Gets the content of a defined section in a given template file and its subtemplates
* with the given parameters.
*
* @see getContent(CmsObject cms, String templateFile, String elementName, Hashtable parameters)
* @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(I_CmsLogChannels.C_PREPROCESSOR_IS_LOGGING && A_OpenCms.isLogging() && C_DEBUG ) {
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "getting content of element " + ((elementName == null) ? "<root>" : elementName));
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "template file is: " + templateFile);
A_OpenCms.log(C_OPENCMS_DEBUG, this.getClassName() + "selected template section is: " + ((templateSelector == null) ? "<default>" : templateSelector));
}
CmsXmlTemplateFile templateDocument = getOwnTemplateFile(cms, templateFile, elementName, parameters, templateSelector);
CmsRequestContext reqCont = cms.getRequestContext();
I_CmsRegistry reg = cms.getRegistry();
I_CmsSession session = cms.getRequestContext().getSession(true);
String stepTo = "";
String from = (String)parameters.get(C_FROM);
String packetName = (String)parameters.get(C_NAME_PARAMETER);
Hashtable sessionData = new Hashtable();
if((from == null) || "".equals(from)) {
// first call; clear session
session.removeValue(C_SESSION_MODULE_ADMIN_DATA);
fillHashtable(cms, reg, sessionData, packetName);
session.putValue(C_SESSION_MODULE_ADMIN_DATA, sessionData);
stepTo = "firstpage";
}else {
sessionData = (Hashtable)session.getValue(C_SESSION_MODULE_ADMIN_DATA);
if("first".equals(from)) {
// put the data in the session
sessionData.put(C_VERSION, getStringValue((String)parameters.get(C_VERSION)));
sessionData.put(C_MODULENAME, getStringValue((String)parameters.get(C_MODULENAME)));
sessionData.put(C_DESCRIPTION, getStringValue((String)parameters.get(C_DESCRIPTION)));
sessionData.put(C_VIEW, getStringValue((String)parameters.get(C_VIEW)));
sessionData.put(C_ADMINPOINT, getStringValue((String)parameters.get(C_ADMINPOINT)));
sessionData.put(C_MAINTENANCE, getStringValue((String)parameters.get(C_MAINTENANCE)));
sessionData.put(C_AUTHOR, getStringValue((String)parameters.get(C_AUTHOR)));
sessionData.put(C_EMAIL, getStringValue((String)parameters.get(C_EMAIL)));
sessionData.put(C_DATE, getStringValue((String)parameters.get(C_DATE)));
session.putValue(C_SESSION_MODULE_ADMIN_DATA, sessionData);
stepTo = "deps";
}
if("deps".equals(from)) {
// put the data in the session
String allData = (String)parameters.get(C_ALLDEPS);
Vector allDeps = new Vector();
allDeps = parseAllDeps(getStringValue(allData));
sessionData.put(C_DEPENDENCY, allDeps);
session.putValue(C_SESSION_MODULE_ADMIN_DATA, sessionData);
// decide if we are going back or forward => set stepTo
String back = (String)parameters.get("back");
if((back == null) || ("".equals(back))) {
stepTo = "props";
}
else {
stepTo = "firstpage";
}
}
if("props".equals(from)) {
stepTo = "deps";
}
if("edit".equals(from)) {
stepTo = "props";
}
if("propsready".equals(from)) {
// ready; save changes in registry
updateTheModule(cms, reg, sessionData, packetName);
session.removeValue(C_SESSION_MODULE_ADMIN_DATA);
templateSelector = "done";
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?