cmswpmain.java

来自「java 编写的程序」· Java 代码 · 共 342 行 · 第 1/2 页

JAVA
342
字号
            values.addElement(loopGroupName);
            names.addElement(loopGroupName);
            if(loopGroup.equals(currentGroup)) {

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

    /**
     * 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.
     * @exception CmsException
     */

    public Integer getProjects(CmsObject cms, CmsXmlLanguageFile lang, Vector names, Vector values,
            Hashtable parameters) throws CmsException {

        // Get all project information
        CmsRequestContext reqCont = cms.getRequestContext();
        String currentProject = null;
        Vector allProjects = cms.getAllAccessibleProjects();
        currentProject = reqCont.currentProject().getName();
        int currentProjectId = 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 loopProjectId = loopProject.getId() + "";
            values.addElement(loopProjectId);
            names.addElement(loopProjectName);
            if(loopProject.getId() == currentProjectId ) {

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

    /**
     * Gets all views available for this user in the workplace screen from the Registry.
     * <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.
     * @exception CmsException
     */

    public Integer getRegViews(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);

        // try to get an existing view
        String currentView = null;
        Hashtable startSettings = null;

        // check out the user infor1ation if a default view is stored there.
        startSettings = (Hashtable)reqCont.currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS);
        if(startSettings != null) {
            currentView = (String)startSettings.get(C_START_VIEW);
        }

        // If there is a session, let's see if it has a view stored
        if(session != null) {
            if(session.getValue(C_PARA_VIEW) != 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);
    }

    /**
     * Gets the currently logged in user.
     * <P>
     * Used for displaying information in the 'foot' frame of the workplace.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param tagcontent Additional parameter passed to the method <em>(not used here)</em>.
     * @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 containing the current user.
     * @exception CmsException
     */

    public Object getUser(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObj) throws CmsException {
        CmsRequestContext reqContext = cms.getRequestContext();
        CmsUser currentUser = reqContext.currentUser();
        return currentUser.getName();
    }

    /**
     * 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;
    }
}

⌨️ 快捷键说明

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