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

📄 cmspreferencespanels.java

📁 内容管理
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        // get all folders with language files
        Vector allLangFolders = cms.getSubFolders(I_CmsWpConstants.C_VFS_PATH_LOCALES);
        String langName = null;
        Hashtable startSettings = null;
        I_CmsSession session = cms.getRequestContext().getSession(true);
        startSettings = (Hashtable)session.getValue("STARTSETTINGS");

        if(startSettings != null) {
            langName = (String)startSettings.get(C_START_LANGUAGE);
        }
        if((langName == null) || ("".equals(langName))){
            langName = CmsXmlLanguageFile.getCurrentUserLanguage(cms);
        }
        
        int select = 0;

        // now go through all language files and add their name and reference to the
        // output vectors
        for(int i = 0;i < allLangFolders.size();i++) {
            CmsFolder folder = (CmsFolder)allLangFolders.elementAt(i);
            CmsXmlLanguageFile langFile = new CmsXmlLanguageFile(cms, folder.getName());
            names.addElement(langFile.getLanguageValue("name"));
            values.addElement(folder.getName());
            if(folder.getName().equals(langName)) {
                select = i;
            }
        }
        return new Integer(select);
    }

    /**
     * Gets all projects of the currently logged in user.
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     * <P>
     * Both <code>names</code> and <code>values</code> will contain
     * the project names after returning from this method.
     * <P>
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param lang reference to the currently valid language file
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the user's current project in the vectors.
     * @throws CmsException
     */
    public Integer getProjects(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {

        // Get all project information
        CmsRequestContext reqCont = cms.getRequestContext();
        I_CmsSession session = cms.getRequestContext().getSession(true);
        Integer currentProject = null;
        Vector allProjects = cms.getAllAccessibleProjects();
        Hashtable startSettings = null;
        startSettings = (Hashtable)session.getValue("STARTSETTINGS");

        // if this fails, get the settings from the user obeject
        if(startSettings == null) {
            startSettings = (Hashtable)reqCont.currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS);
        }
        if(startSettings != null) {
            currentProject = (Integer)startSettings.get(C_START_PROJECT);
        }

        // no project available in the user info, check out the current session
        if(currentProject == null) {
            currentProject = new Integer(reqCont.currentProject().getId());
        }

        // Now loop through all projects and fill the result vectors
        int numProjects = allProjects.size();
        int currentProjectNum = 0;
        for(int i = 0;i < numProjects;i++) {
            CmsProject loopProject = (CmsProject)allProjects.elementAt(i);
            String loopProjectName = loopProject.getName();
            String loopProjectNameId = loopProject.getId() + "";
            values.addElement(loopProjectNameId);
            names.addElement(loopProjectName);
            if(loopProjectNameId.equals(currentProject + "")) {

                // Fine. The project of this loop is the user's current project. Save it!
                currentProjectNum = i;
            }
        }
        return new Integer(currentProjectNum);
    }

    /**
     * Calculates the start settings from the data submitted in
     * the preference task panel.
     * @param parameters Hashtable containing all request parameters
     * @return Hashtable containing the start settings.
     */
    private Hashtable getStartSettings(CmsObject cms, Hashtable parameters) throws CmsException {
        Hashtable startSettings = new Hashtable();
        startSettings.put(C_START_LANGUAGE, (String)parameters.get("LANGUAGE"));
        startSettings.put(C_START_PROJECT, new Integer(Integer.parseInt((String)parameters.get("project"))));
        startSettings.put(C_START_VIEW, (String)parameters.get("view"));
        startSettings.put(C_START_DEFAULTGROUP, (String)parameters.get("dgroup"));
        String lockstuff = (String)parameters.get("lockdialog");
        if (lockstuff == null){
            lockstuff = "";
        }
        startSettings.put(C_START_LOCKDIALOG, lockstuff);
        cms.getRequestContext().setCurrentProject(Integer.parseInt((String)parameters.get("project")));

        // get all access flags from the request
        String gr = (String)parameters.get("gr");
        String gw = (String)parameters.get("gw");
        String gv = (String)parameters.get("gv");
        String pr = (String)parameters.get("pr");
        String pw = (String)parameters.get("pw");
        String pv = (String)parameters.get("pv");
        String ir = (String)parameters.get("ir");
        int flag = 0;

        // now check and set all flags
        flag += C_ACCESS_OWNER_READ;
        flag += C_ACCESS_OWNER_WRITE;
        flag += C_ACCESS_OWNER_VISIBLE;
        if(gr != null) {
            if(gr.equals("on")) {
                flag += C_ACCESS_GROUP_READ;
            }
        }
        if(gw != null) {
            if(gw.equals("on")) {
                flag += C_ACCESS_GROUP_WRITE;
            }
        }
        if(gv != null) {
            if(gv.equals("on")) {
                flag += C_ACCESS_GROUP_VISIBLE;
            }
        }
        if(pr != null) {
            if(pr.equals("on")) {
                flag += C_ACCESS_PUBLIC_READ;
            }
        }
        if(pw != null) {
            if(pw.equals("on")) {
                flag += C_ACCESS_PUBLIC_WRITE;
            }
        }
        if(pv != null) {
            if(pv.equals("on")) {
                flag += C_ACCESS_PUBLIC_VISIBLE;
            }
        }
        if(ir != null) {
            if(ir.equals("on")) {
                flag += C_ACCESS_INTERNAL_READ;
            }
        }
        startSettings.put(C_START_ACCESSFLAGS, new Integer(flag));
        return startSettings;
    }

    /**
     * Calculates the task settings from the data submitted in
     * the preference task panel.
     * @param parameters Hashtable containing all request parameters
     * @return Explorer filelist flags.
     */
    private Hashtable getTaskSettings(Hashtable parameters, I_CmsSession session) {
        Hashtable taskSettings = new Hashtable();
        if(parameters.get("CBALL") != null) {
            taskSettings.put(C_TASK_VIEW_ALL, new Boolean(true));
        }
        else {
            taskSettings.put(C_TASK_VIEW_ALL, new Boolean(false));
        }
        session.putValue(C_SESSION_TASK_ALLPROJECTS, taskSettings.get(C_TASK_VIEW_ALL));
        int taskMessages = 0;
        if(parameters.get("CBMSGACCEPTED") != null) {
            taskMessages += C_TASK_MESSAGES_ACCEPTED;
        }
        if(parameters.get("CBMSGFORWAREDED") != null) {
            taskMessages += C_TASK_MESSAGES_FORWARDED;
        }
        if(parameters.get("CBMSGCOMPLETED") != null) {
            taskMessages += C_TASK_MESSAGES_COMPLETED;
        }
        if(parameters.get("CBMSGMEMBERS") != null) {
            taskMessages += C_TASK_MESSAGES_MEMBERS;
        }
        taskSettings.put(C_TASK_MESSAGES, new Integer(taskMessages));
        String filter = (String)parameters.get("filter");
        if((filter != null) && (!filter.equals("-"))) {
            taskSettings.put(C_TASK_FILTER, parameters.get("filter"));
            session.putValue(C_SESSION_TASK_FILTER, parameters.get("filter"));
        }
        return taskSettings;
    }

    /**
     * Gets all views available in the workplace screen.
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     * <P>
     * <code>names</code> will contain language specific view descriptions
     * and <code>values</code> will contain the correspondig URL for each
     * of these views after returning from this method.
     * <P>
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param lang reference to the currently valid language file
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the user's current workplace view in the vectors.
     * @throws CmsException
     */
    public Integer getViews(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {

        // Let's see if we have a session
        CmsRequestContext reqCont = cms.getRequestContext();
        I_CmsSession session = cms.getRequestContext().getSession(true);
        Hashtable startSettings = null;
        String currentView = null;

        // try to get an existing value for the default value
        startSettings = (Hashtable)session.getValue("STARTSETTINGS");

        // if this fails, get the settings from the user obeject
        if(startSettings == null) {
            startSettings = (Hashtable)reqCont.currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS);
        }
        if(startSettings != null) {
            currentView = (String)startSettings.get(C_START_VIEW);
        }

        // If there ist a session, let's see if it has a view stored
        if(currentView == null) {
            if(session != null) {
                currentView = (String)session.getValue(C_PARA_VIEW);
            }
        }
        if(currentView == null) {
            currentView = "";
        }
        Vector viewNames = new Vector();
        Vector viewLinks = new Vector();

        // get the List of available views from the Registry
        int numViews = (cms.getRegistry()).getViews(viewNames, viewLinks);
        int currentViewIndex = 0;

        // Loop through the vectors and fill the resultvectors
        for(int i = 0;i < numViews;i++) {
            String loopName = (String)viewNames.elementAt(i);
            String loopLink = (String)viewLinks.elementAt(i);
            boolean visible = true;
            try {
                cms.readFileHeader(loopLink);
            }
            catch(CmsException e) {
                visible = false;
            }
            if(visible) {
                if(loopLink.equals(currentView)) {
                    currentViewIndex = values.size();
                }
                names.addElement(lang.getLanguageValue(loopName));
                values.addElement(loopLink);
            }
        }
        return new Integer(currentViewIndex);
    }

    /**
     * Indicates if the results of this class are cacheable.
     *
     * @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.
     * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
     */
    public boolean isCacheable(CmsObject cms, String templateFile, String elementName,
            Hashtable parameters, String templateSelector) {
        return false;
    }

    /**
     * Sets all data in the preference panel explorer 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 setExplorerSettings(I_CmsSession session, Hashtable parameters,
             CmsRequestContext reqCont, CmsXmlWpTemplateFile xmlTemplateDocument) {

        //get the actual user settings
        // first try to read them from the session
        String explorerSettings = null;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -