📄 cmschannelbackoffice.java
字号:
title=cd.getTitle();
owner=new Integer(cd.getOwner()).toString();
group=new Integer(cd.getGroupId()).toString();
accessFlags=cd.getAccessFlags();
}else if(cd==null){
//create a new ouputchannels content definition.
cd = new CmsChannelContent(cms);
idvalue=C_UNKNOWN_ID+"";
resid=C_UNKNOWN_ID+"";
}
//put parentId in session for user method
session.putValue("parentName",parentName);
session.putValue("id",resid+"");
//set data in CD when data is correct
if(error.equals("") && !action.equals("")){
cd.setChannelId(idvalue);
cd.setParentName(parentName);
cd.setChannelName(channelname);
cd.setTitle(title);
cd.setGroup(new Integer(group).intValue());
cd.setOwner(new Integer(owner).intValue());
cd.setAccessFlags(accessFlags);
}
//get values of the user for new entry
String defaultGroup=cms.getRequestContext().currentGroup().getName();
String defaultUser=cms.getRequestContext().currentUser().getName();
//get all groups
Vector cmsGroups=cms.getGroups();
// select box of group
String groupOptions="";
for (int i=0; i<cmsGroups.size(); i++) {
String groupName=((CmsGroup)cmsGroups.elementAt(i)).getName();
int groupId=((CmsGroup)cmsGroups.elementAt(i)).getId();
template.setData("name",groupName);
template.setData("value",(new Integer(groupId)).toString());
if (!group.equals("") && (cms.readGroup(Integer.parseInt(group)).getName()).equals(groupName)) {
template.setData("check","selected");
}else if(idvalue.equals(C_UNKNOWN_ID+"") && groupName.equals(defaultGroup)){
template.setData("check","selected");
}else{
template.setData("check","");
}
groupOptions=groupOptions+template.getProcessedDataValue("selectoption",this);
}
template.setData("groups",groupOptions);
// select box of owner
String userOptions="";
Vector cmsUsers=cms.getUsers();
for (int i=0;i<cmsUsers.size();i++) {
String userName=((CmsUser)cmsUsers.elementAt(i)).getName();
int userId=((CmsUser)cmsUsers.elementAt(i)).getId();
template.setData("name",userName);
template.setData("value",(new Integer(userId)).toString());
if (!owner.equals("") && (cms.readUser(Integer.parseInt(owner)).getName()).equals(userName)) {
template.setData("check","selected");
}else if(idvalue.equals(C_UNKNOWN_ID+"") && userName.equals(defaultUser)){
template.setData("check","selected");
}else{
template.setData("check","");
}
userOptions=userOptions+template.getProcessedDataValue("selectoption",this);
}
template.setData("users",userOptions);
// set the access flags
this.setAccessValue(template, cd.getAccessFlags());
//set data in template
template.setData("channelId", ""+cd.getChannelId());
template.setData("resourceid", ""+cd.getId());
template.setData("channelName", cd.getChannelName());
template.setData("title", Encoder.escape(cd.getTitle()));
template.setData("parentName", cd.getParentName());
template.setData("error", error);
//if the saveexit-button has been clicked.
if(action.equals("saveexit") && error.equals("")){
try{
//write/save
cd.write(cms);
//exit
clearSession(session);
templateSelector = "done";
return startProcessing(cms, template, "", parameters, templateSelector);
}catch (CmsException exc){
template.setData("channelId", idvalue);
template.setData("resourceid", ""+cd.getId());
template.setData("channelName", channelname);
template.setData("title", Encoder.escape(title));
template.setData("parentName", parentName);
error = lang.getLanguageValue(moduleName+".error.message3")+" "+exc.getShortException();
template.setData("error", error);
//log
exc.printStackTrace(System.err);
}catch (Exception e){
template.setData("channelId", idvalue);
template.setData("resourceid", ""+cd.getId());
template.setData("channelName", channelname);
template.setData("title", Encoder.escape(title));
template.setData("parentName", parentName);
error = lang.getLanguageValue(moduleName+".error.message3")+" "+e.getMessage();
template.setData("error", error);
//log
e.printStackTrace(System.err);
}
}
//if the "save"-button has been clicked.
if(action.equals("save") && error.equals("")){
try{
//write
cd.write(cms);
idvalue=cd.getChannelId();
template.setData("channelId", idvalue);
template.setData("resourceid", ""+cd.getId());
//indicator for saved new entrys - the new id
template.setData("newChannelId", idvalue);
}catch (CmsException exc){
template.setData("channelId", idvalue);
template.setData("resourceid", ""+cd.getId());
template.setData("channelName", channelname);
template.setData("title", Encoder.escape(title));
template.setData("parentName", parentName);
error = lang.getLanguageValue(moduleName+".error.message3")+" "+exc.getShortException();
template.setData("error", error);
//log
exc.printStackTrace(System.err);
}catch (Exception e){
e.printStackTrace(System.err);
template.setData("channelId", idvalue);
template.setData("resourceid", ""+cd.getId());
template.setData("channelName", channelname);
template.setData("title", Encoder.escape(title));
template.setData("parentName", parentName);
error = lang.getLanguageValue(moduleName+".error.message3")+" "+e.getMessage();
template.setData("error", error);
}
}
//finally start the processing
return startProcessing(cms, template, elementName, parameters, templateSelector);
}
/**
* get the accessFlags from the template
*/
private int getAccessValue(Hashtable parameters){
int accessFlag = 0;
for(int i=0; i<=8; i++){
String permissionsAtI=(String)parameters.get("permissions"+i);
if(permissionsAtI != null) {
if(permissionsAtI.equals("on")) {
accessFlag += new Integer(this.C_ACCESS_FLAGS[i]).intValue();
}
}
}
if(accessFlag == 0){
accessFlag = this.C_DEFAULT_PERMISSIONS;
}
return accessFlag;
}
/**
* Set the accessFlags in the template
*/
private void setAccessValue(CmsXmlWpTemplateFile template, int accessFlags){
// permissions check boxes
for(int i=0; i<=8; i++) {
int accessValueAtI = new Integer(this.C_ACCESS_FLAGS[i]).intValue();
if ((accessFlags & accessValueAtI) > 0) {
template.setData("permissions_check_"+i,"checked");
} else {
template.setData("permissions_check_"+i,"");
}
}
}
/**
* remove all session values used by outputchannel Backoffice
*/
private void clearSession(I_CmsSession session){
session.removeValue("parentName");
session.removeValue("id");
}
/**
*
*/
public boolean isExtendedList(){
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -