📄 cmsadminmoduleadmin.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/workplace/CmsAdminModuleAdmin.java,v $
* Date : $Date: 2003/03/07 11:17:22 $
* Version: $Revision: 1.25 $
*
* 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.boot.I_CmsLogChannels;
import com.opencms.core.A_OpenCms;
import com.opencms.core.CmsException;
import com.opencms.core.I_CmsConstants;
import com.opencms.core.I_CmsSession;
import com.opencms.file.CmsObject;
import com.opencms.file.CmsRegistry;
import com.opencms.file.I_CmsRegistry;
import com.opencms.template.CmsXmlTemplateFile;
import com.opencms.util.Utils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Vector;
/**
* Template class for displaying OpenCms workplace administration module administration.
*
* Creation date: (29.10.00 10:28:08)
* @author Hanjo Riege
* @author Thomas Weckert
*/
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_PUBLISHCLASS = "publishclass";
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";
private final String C_MODULE_TYPE = "moduletype";
/**
* 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(C_VFS_PATH_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_PUBLISHCLASS, getStringValue(reg.getModulePublishClass(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(max.startsWith("-")) {
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);
String moduleType = reg.getModuleType(module);
if (moduleType!=null && moduleType.equals(CmsRegistry.C_MODULE_TYPE_SIMPLE)) {
table.put( C_MODULE_TYPE, "checked" );
}
else {
table.put( C_MODULE_TYPE, "" );
}
}
/**
* 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(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);
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_PUBLISHCLASS, getStringValue((String)parameters.get(C_PUBLISHCLASS)));
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)));
sessionData.put(C_MODULE_TYPE, getStringValue((String)parameters.get(C_MODULE_TYPE)));
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)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -