001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.jsp.userdata;
029
030import org.opencms.configuration.CmsParameterConfiguration;
031import org.opencms.file.CmsObject;
032import org.opencms.file.CmsUser;
033
034import java.util.List;
035
036import org.jsoup.nodes.Element;
037
038/**
039 * Shows email address / user name as a header.
040 */
041public class CmsUserDataHeader implements I_CmsUserDataDomain {
042
043    /** The configuration (not needed). */
044    private CmsParameterConfiguration m_config = new CmsParameterConfiguration();
045
046    /**
047     * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#addConfigurationParameter(java.lang.String, java.lang.String)
048     */
049    public void addConfigurationParameter(String paramName, String paramValue) {
050
051        m_config.add(paramName, paramValue);
052    }
053
054    /**
055     * @see org.opencms.jsp.userdata.I_CmsUserDataDomain#appendInfoHtml(org.opencms.file.CmsObject, org.opencms.jsp.userdata.CmsUserDataRequestType, java.util.List, org.jsoup.nodes.Element)
056     */
057    public void appendInfoHtml(CmsObject cms, CmsUserDataRequestType reqType, List<CmsUser> user, Element element) {
058
059        String username;
060        if (user.size() == 0) {
061            return;
062        }
063        switch (reqType) {
064            case email:
065                username = user.get(0).getEmail();
066                break;
067            case singleUser:
068            default:
069                username = user.get(0).getName();
070                break;
071        }
072        element.appendElement("h1").attr("class", "udr-header").text(
073            Messages.get().getBundle(cms.getRequestContext().getLocale()).key(
074                Messages.GUI_USER_INFORMATION_FOR_1,
075                username));
076    }
077
078    /**
079     * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#getConfiguration()
080     */
081    public CmsParameterConfiguration getConfiguration() {
082
083        return m_config;
084    }
085
086    /**
087     * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#initConfiguration()
088     */
089    public void initConfiguration() {
090
091        // do nothing
092    }
093
094    /**
095     * @see org.opencms.jsp.userdata.I_CmsUserDataDomain#initialize(org.opencms.file.CmsObject)
096     */
097    public void initialize(CmsObject cms) {
098
099        // do nothing
100    }
101
102    /**
103     * @see org.opencms.jsp.userdata.I_CmsUserDataDomain#isAvailableForMode(org.opencms.jsp.userdata.I_CmsUserDataDomain.Mode)
104     */
105    public boolean isAvailableForMode(Mode mode) {
106
107        return Mode.frontend == mode;
108    }
109
110    /**
111     * @see org.opencms.jsp.userdata.I_CmsUserDataDomain#matchesUser(org.opencms.file.CmsObject, org.opencms.jsp.userdata.CmsUserDataRequestType, org.opencms.file.CmsUser)
112     */
113    public boolean matchesUser(CmsObject cms, CmsUserDataRequestType reqType, CmsUser user) {
114
115        return true;
116    }
117
118}