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

📄 cmswpmain.java

📁 内容管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			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.
	 * @throws CmsException
	 */

    public Integer getProjects(CmsObject cms, CmsXmlLanguageFile lang, Vector names, Vector values, Hashtable parameters) throws CmsException {
        if (m_ProjectNames == null || m_ProjectIds == null) {
            new Integer(0);
        }

        values.addAll(m_ProjectIds);
        names.addAll(m_ProjectNames);

        return new Integer(m_SelectedPrjIndex);
    }
    
    private void fetchProjects(CmsObject cms, CmsXmlTemplateFile xmlTemplateDocument) throws CmsException {
        // Get all project information
        CmsRequestContext reqCont = cms.getRequestContext();
        Vector allProjects = cms.getAllAccessibleProjects();
        int currentProjectId = reqCont.currentProject().getId();

        // Now loop through all projects and fill the result vectors
        int numProjects = allProjects.size();
        int currentProjectNum = 0;
        int currentLength = 0;
        
        int maxPrjNameLen = 0;
        m_ProjectIds = new Vector();
        m_ProjectNames = new Vector();
        
        for (int i = 0; i < numProjects; i++) {
            CmsProject loopProject = (CmsProject) allProjects.elementAt(i);
            String loopProjectName = loopProject.getName();
            String loopProjectId = loopProject.getId() + "";
            
            m_ProjectIds.addElement(loopProjectId);
            m_ProjectNames.addElement(loopProjectName);
            
            if (loopProject.getId() == currentProjectId) {
                // Fine. The project of this loop is the user's current project. Save it!
                currentProjectNum = i;
            }
            
            currentLength = loopProjectName.length();
            if (currentLength>maxPrjNameLen) {
                maxPrjNameLen = currentLength;
            }
        }
        
        m_SelectedPrjIndex = currentProjectNum;
        
        try {
            if (maxPrjNameLen <= 20) {
                xmlTemplateDocument.setData("PRJ_SELECT", xmlTemplateDocument.getProcessedDataValue("PRJ_SELECT_NORMAL", this));
            } else {
                xmlTemplateDocument.setData("PRJ_SELECT", xmlTemplateDocument.getProcessedDataValue("PRJ_SELECT_LARGE", this));
            }
        } catch (CmsException e) {
            // this exception is only caugth for backwards compatibility with older templates
            // missing the data blocks above.
        }
    }
    
    private int m_SelectedPrjIndex;
    private Vector m_ProjectIds;
    private Vector m_ProjectNames;

	/**
	 * 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.
	 * @throws 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.
	 * @throws 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -