📄 cmspreferencespanels.java
字号:
int explorerSettingsValue = 0;
explorerSettings = (String)session.getValue(C_PARA_EXPLORERSETTINGS);
// if this fails, get the settings from the user obeject
if(explorerSettings == null) {
explorerSettings = (String)reqCont.currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_EXPLORERSETTINGS);
}
//check if the default button was selected.
// if so, delete all user settings so that they are set to the defaults later.
if(parameters.get(C_PARA_DEFAULT) != null) {
explorerSettings = null;
}
// if the settings are still empty, set them to default
if(explorerSettings != null) {
explorerSettingsValue = new Integer(explorerSettings).intValue();
}
else {
explorerSettingsValue = C_FILELIST_TITLE + C_FILELIST_TYPE + C_FILELIST_CHANGED;
}
// now update the datablocks in the template
if((explorerSettingsValue & C_FILELIST_TITLE) > 0) {
xmlTemplateDocument.setData(C_CHECKTITLE, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKTITLE, " ");
}
if((explorerSettingsValue & C_FILELIST_TYPE) > 0) {
xmlTemplateDocument.setData(C_CHECKTYPE, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKTYPE, " ");
}
if((explorerSettingsValue & C_FILELIST_CHANGED) > 0) {
xmlTemplateDocument.setData(C_CHECKCHANGED, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKCHANGED, " ");
}
if((explorerSettingsValue & C_FILELIST_SIZE) > 0) {
xmlTemplateDocument.setData(C_CHECKSIZE, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKSIZE, " ");
}
if((explorerSettingsValue & C_FILELIST_STATE) > 0) {
xmlTemplateDocument.setData(C_CHECKSTATE, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKSTATE, " ");
}
if((explorerSettingsValue & C_FILELIST_OWNER) > 0) {
xmlTemplateDocument.setData(C_CHECKOWNER, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKOWNER, " ");
}
if((explorerSettingsValue & C_FILELIST_GROUP) > 0) {
xmlTemplateDocument.setData(C_CHECKGROUP, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKGROUP, " ");
}
if((explorerSettingsValue & C_FILELIST_ACCESS) > 0) {
xmlTemplateDocument.setData(C_CHECKACCESS, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKACCESS, " ");
}
if((explorerSettingsValue & C_FILELIST_LOCKED) > 0) {
xmlTemplateDocument.setData(C_CHECKLOCKEDBY, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKLOCKEDBY, " ");
}
}
/**
* User method to get the actual panel of the PReferences dialog.
* <P>
* @param cms CmsObject Object for accessing system resources.
* @param tagcontent Unused in this special case of a user method. Can be ignored.
* @param doc Reference to the A_CmsXmlContent object of the initiating XLM document <em>(not used here)</em>.
* @param userObj Hashtable with parameters <em>(not used here)</em>.
* @return String with the pics URL.
* @throws CmsException
*/
public Object setPanel(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObj) throws CmsException {
I_CmsSession session = cms.getRequestContext().getSession(true);
String panel = (String)session.getValue(C_PARA_OLDPANEL);
return panel;
}
/**
* Sets all data in the preference panel start settings.
* Data is either taken form the default values, the current user or the current session.
* @param cms The current CmsObject.
* @param session The current session.
* @param parameters Hashtable containing all request parameters.
* @param reqCont The request context.
* @param xmlTemplateDocument The template in which all data is added.
*/
private void setStartSettings(CmsObject cms, I_CmsSession session, Hashtable parameters,
CmsRequestContext reqCont, CmsXmlWpTemplateFile xmlTemplateDocument) {
// get the actual user settings
// first try to read them from the session
Hashtable startSettings = null;
startSettings = (Hashtable)session.getValue(C_PARA_STARTSETTINGS);
// if this fails, get the settings from the user object
if(startSettings == null) {
startSettings = (Hashtable)reqCont.currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS);
if(startSettings != null) {
startSettings.put(C_START_DEFAULTGROUP, reqCont.currentUser().getDefaultGroup().getName());
}
}
// if the settings are still empty, set them to default
if(startSettings == null) {
startSettings = new Hashtable();
startSettings.put(C_START_LANGUAGE, C_DEFAULT_LANGUAGE);
startSettings.put(C_START_PROJECT, new Integer(reqCont.currentProject().getId()));
String currentView = (String)session.getValue(C_PARA_VIEW);
if(currentView == null) {
currentView = "/system/workplace/action/explorer.html";
}
startSettings.put(C_START_VIEW, currentView);
startSettings.put(C_START_DEFAULTGROUP, reqCont.currentUser().getDefaultGroup().getName());
startSettings.put(C_START_LOCKDIALOG, "");
startSettings.put(C_START_ACCESSFLAGS, new Integer(C_ACCESS_DEFAULT_FLAGS));
}
// check for languages and diasable if only one locale is found
Vector langValues = new Vector();
try {
getLanguageFiles(cms, null, new Vector(), langValues, parameters);
if (langValues.size() == 1) {
// only one locale installed - deactivate the language selection
xmlTemplateDocument.setData("LANG_SELECT", "<input type=\"hidden\" name=\"LANGUAGE\" value=\"" + langValues.elementAt(0) + "\">");
}
// no else is required as the default behaviour is preset in the template
} catch (Exception e) {
// no exception handling is required as the default behaviour is preset in the template
}
// now update the data in the template
int flags = ((Integer)startSettings.get(C_START_ACCESSFLAGS)).intValue();
if((flags & C_ACCESS_OWNER_READ) > 0) {
xmlTemplateDocument.setData(C_CHECKUR, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKUR, " ");
}
String lockD = (String)startSettings.get(C_START_LOCKDIALOG);
if (lockD!=null && "on".equals(lockD)){
xmlTemplateDocument.setData(C_LOCKDIALOG, C_CHECKED);
}else{
xmlTemplateDocument.setData(C_LOCKDIALOG, " ");
}
if((flags & C_ACCESS_OWNER_WRITE) > 0) {
xmlTemplateDocument.setData(C_CHECKUW, C_CHECKED);
}else {
xmlTemplateDocument.setData(C_CHECKUW, " ");
}
if((flags & C_ACCESS_OWNER_VISIBLE) > 0) {
xmlTemplateDocument.setData(C_CHECKUV, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKUV, " ");
}
if((flags & C_ACCESS_GROUP_READ) > 0) {
xmlTemplateDocument.setData(C_CHECKGR, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKGR, " ");
}
if((flags & C_ACCESS_GROUP_WRITE) > 0) {
xmlTemplateDocument.setData(C_CHECKGW, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKGW, " ");
}
if((flags & C_ACCESS_GROUP_VISIBLE) > 0) {
xmlTemplateDocument.setData(C_CHECKGV, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKGV, " ");
}
if((flags & C_ACCESS_PUBLIC_READ) > 0) {
xmlTemplateDocument.setData(C_CHECKPR, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKPR, " ");
}
if((flags & C_ACCESS_PUBLIC_WRITE) > 0) {
xmlTemplateDocument.setData(C_CHECKPW, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKPW, " ");
}
if((flags & C_ACCESS_PUBLIC_VISIBLE) > 0) {
xmlTemplateDocument.setData(C_CHECKPV, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKPV, " ");
}
if((flags & C_ACCESS_INTERNAL_READ) > 0) {
xmlTemplateDocument.setData(C_CHECKIF, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHECKIF, " ");
}
}
/**
* Sets all data in the preference panel task settings.
* Data is either taken form the default values, the current user or the current session.
* @param session The current session.
* @param parameters Hashtable containing all request parameters.
* @param reqCont The request context.
* @param xmlTemplateDocument The template in which all data is added.
*/
private void setTaskSettings(I_CmsSession session, Hashtable parameters,
CmsRequestContext reqCont, CmsXmlWpTemplateFile xmlTemplateDocument) {
// get the actual user settings
// first try to read them from the session
Hashtable taskSettings = null;
taskSettings = (Hashtable)session.getValue(C_PARA_TASKSETTINGS);
// if this fails, get the settings from the user obeject
if(taskSettings == null) {
taskSettings = (Hashtable)reqCont.currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_TASKSETTINGS);
}
// if the settings are still empty, set them to default
if(taskSettings == null) {
taskSettings = new Hashtable();
taskSettings.put(C_TASK_VIEW_ALL, new Boolean(false));
taskSettings.put(C_TASK_MESSAGES, new Integer(C_TASK_MESSAGES_ACCEPTED +
C_TASK_MESSAGES_FORWARDED + C_TASK_MESSAGES_COMPLETED + C_TASK_MESSAGES_MEMBERS));
taskSettings.put(C_TASK_FILTER, new String("a1"));
}
//now update the data in the template
if(((Boolean)taskSettings.get(C_TASK_VIEW_ALL)).booleanValue()) {
xmlTemplateDocument.setData(C_CHVIEWALL, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHVIEWALL, " ");
}
int taskMessages = ((Integer)taskSettings.get(C_TASK_MESSAGES)).intValue();
if((taskMessages & C_TASK_MESSAGES_ACCEPTED) > 0) {
xmlTemplateDocument.setData(C_CHMESSAGEACCEPTED, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHMESSAGEACCEPTED, " ");
}
if((taskMessages & C_TASK_MESSAGES_FORWARDED) > 0) {
xmlTemplateDocument.setData(C_CHMESSAGEFORWARDED, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHMESSAGEFORWARDED, " ");
}
if((taskMessages & C_TASK_MESSAGES_COMPLETED) > 0) {
xmlTemplateDocument.setData(C_CHMESSAGECOMPLETED, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHMESSAGECOMPLETED, " ");
}
if((taskMessages & C_TASK_MESSAGES_MEMBERS) > 0) {
xmlTemplateDocument.setData(C_CHMESSAGEMEMEBERS, C_CHECKED);
}
else {
xmlTemplateDocument.setData(C_CHMESSAGEMEMEBERS, " ");
}
}
/**
* Sets all data in the preference panel user settings.
* Data is either taken form the default values, the current user or the current session.
* @param session The current session.
* @param parameters Hashtable containing all request parameters.
* @param reqCont The request context.
* @param xmlTemplateDocument The template in which all data is added.
*/
private void setUserSettings(I_CmsSession session, Hashtable parameters,
CmsRequestContext reqCont, CmsXmlWpTemplateFile xmlTemplateDocument) {
// get the current user
CmsUser user = reqCont.currentUser();
//set the required datablocks
xmlTemplateDocument.setData("USER", user.getName());
xmlTemplateDocument.setData("FIRSTNAME", user.getFirstname());
xmlTemplateDocument.setData("LASTNAME", user.getLastname());
xmlTemplateDocument.setData("DESCRIPTION", user.getDescription());
xmlTemplateDocument.setData("EMAIL", user.getEmail());
xmlTemplateDocument.setData("ADRESS", user.getAddress());
xmlTemplateDocument.setData("CURRENTGROUP", reqCont.currentGroup().getName());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -