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

📄 cmschannelbackoffice.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            parentName=m_channel.getParentName();
            m_channelId=m_channel.getChannelId();
            m_folderId = m_channel.getId();
            channelname=m_channel.getChannelName();
            title=m_channel.getTitle();
            owner=m_channel.getOwner().toString();
            group=m_channel.getGroupId().toString();
            accessFlags=m_channel.getAccessFlags();
        }else if(m_channel==null){            
            //create a new ouputchannels content definition.
            m_channel = new CmsChannelContent(cms);
            m_channelId = CmsDbUtil.UNKNOWN_ID+"";
            m_folderId = CmsUUID.getNullUUID();
        }
        //put parentId in session for user method
        session.putValue("parentName",parentName);
        session.putValue("id",m_folderId.toString());
        //set data in CD when data is correct
        if(error.equals("") && !action.equals("")) {           
            m_channel.setChannelId(m_channelId);
            m_channel.setParentName(parentName);
            m_channel.setChannelName(channelname);
            m_channel.setTitle(title);
            m_channel.setGroup(new CmsUUID(group));
            m_channel.setOwner(new CmsUUID(owner));
            m_channel.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();
//            CmsUUID groupId=((CmsGroup)cmsGroups.elementAt(i)).getId();
//            template.setData("name",groupName);
//            template.setData("value",groupId.toString());
//            if (!group.equals("") && (cms.readGroup(new CmsUUID(group)).getName()).equals(groupName)) {
//                template.setData("check","selected");
//            }else if(m_channelId.equals(I_CmsConstants.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="";
        List cmsUsers=cms.getUsers();
        for (int i=0;i<cmsUsers.size();i++) {
            String userName=((CmsUser)cmsUsers.get(i)).getName();
            CmsUUID userId=((CmsUser)cmsUsers.get(i)).getId();
            template.setData("name",userName);
            template.setData("value",userId.toString());
            if (!owner.equals("") && (cms.readUser(new CmsUUID(owner)).getName()).equals(userName)) {
                template.setData("check","selected");
            }else if(m_channelId.equals(CmsDbUtil.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, m_channel.getAccessFlags());
        //set data in template
        template.setData("channelId", ""+m_channel.getChannelId());
        template.setData("resourceid", m_channel.getId().toString());
        template.setData("channelName", m_channel.getChannelName());
        template.setData("title", CmsEncoder.escape(m_channel.getTitle(),
            cms.getRequestContext().getEncoding()));
        template.setData("parentName", m_channel.getParentName());
        template.setData("error", error);

        //if the saveexit-button has been clicked.
        if(action.equals("saveexit") && error.equals("")){
            try{
                m_channel.setChannelId(channelId);
                //write/save
                m_channel.write(cms);
                //exit
                clearSession(session);
                templateSelector = "done";
                return startProcessing(cms, template, "", parameters, templateSelector);
            }catch (CmsException exc){
                template.setData("channelId", channelId);
                template.setData("resourceid", m_channel.getId().toString());
                template.setData("channelName", channelname);
                template.setData("title", CmsEncoder.escape(title,
                    cms.getRequestContext().getEncoding()));
                template.setData("parentName", parentName);
                error = lang.getLanguageValue(moduleName+".error.message3")+" "+exc.getMessage();
                template.setData("error", error);
                //log
                exc.printStackTrace(System.err);
            }catch (Exception e){
                template.setData("channelId", channelId);
                template.setData("resourceid", m_channel.getId().toString());
                template.setData("channelName", channelname);
                template.setData("title", CmsEncoder.escape(title,
                    cms.getRequestContext().getEncoding()));
                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{
                m_channel.setChannelId(channelId);                
                //write
                m_channel.write(cms);
                m_channelId=m_channel.getChannelId();
                template.setData("channelId", m_channelId);
                template.setData("resourceid", m_channel.getId().toString());
                //indicator for saved new entrys - the new id
                template.setData("newChannelId", m_channelId);
            }catch (CmsException exc){
                template.setData("channelId", channelId);
                template.setData("resourceid", m_channel.getId().toString());
                template.setData("channelName", channelname);
                template.setData("title", CmsEncoder.escape(title,
                    cms.getRequestContext().getEncoding()));
                template.setData("parentName", parentName);
                error = lang.getLanguageValue(moduleName+".error.message3")+" "+exc.getMessage();
                template.setData("error", error);
                //log
                exc.printStackTrace(System.err);
            }catch (Exception e){
                e.printStackTrace(System.err);
                template.setData("channelId",  channelId);
                template.setData("resourceid", m_channel.getId().toString());
                template.setData("channelName", channelname);
                template.setData("title", CmsEncoder.escape(title,
                    cms.getRequestContext().getEncoding()));
                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(C_ACCESS_FLAGS[i]).intValue();
                }
            }
        }
        if(accessFlag == 0){
            accessFlag = 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(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 + -