001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.theme;
016    
017    import com.liferay.portal.kernel.util.WebKeys;
018    import com.liferay.portal.theme.ThemeDisplay;
019    
020    import javax.servlet.http.HttpServletRequest;
021    import javax.servlet.jsp.tagext.TagSupport;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class DefineObjectsTag extends TagSupport {
027    
028            @Override
029            public int doStartTag() {
030                    HttpServletRequest request =
031                            (HttpServletRequest)pageContext.getRequest();
032    
033                    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
034                            WebKeys.THEME_DISPLAY);
035    
036                    if (themeDisplay == null) {
037                            return SKIP_BODY;
038                    }
039    
040                    pageContext.setAttribute("account", themeDisplay.getAccount());
041                    pageContext.setAttribute("colorScheme", themeDisplay.getColorScheme());
042                    pageContext.setAttribute("company", themeDisplay.getCompany());
043                    pageContext.setAttribute("contact", themeDisplay.getContact());
044    
045                    if (themeDisplay.getLayout() != null) {
046                            pageContext.setAttribute("layout", themeDisplay.getLayout());
047                    }
048    
049                    if (themeDisplay.getLayouts() != null) {
050                            pageContext.setAttribute("layouts", themeDisplay.getLayouts());
051                    }
052    
053                    if (themeDisplay.getLayoutTypePortlet() != null) {
054                            pageContext.setAttribute(
055                                    "layoutTypePortlet", themeDisplay.getLayoutTypePortlet());
056                    }
057    
058                    pageContext.setAttribute("locale", themeDisplay.getLocale());
059                    pageContext.setAttribute(
060                            "permissionChecker", themeDisplay.getPermissionChecker());
061                    pageContext.setAttribute("plid", Long.valueOf(themeDisplay.getPlid()));
062                    pageContext.setAttribute(
063                            "portletDisplay", themeDisplay.getPortletDisplay());
064                    pageContext.setAttribute("realUser", themeDisplay.getRealUser());
065                    pageContext.setAttribute(
066                            "scopeGroupId", Long.valueOf(themeDisplay.getScopeGroupId()));
067                    pageContext.setAttribute("theme", themeDisplay.getTheme());
068                    pageContext.setAttribute("themeDisplay", themeDisplay);
069                    pageContext.setAttribute("timeZone", themeDisplay.getTimeZone());
070                    pageContext.setAttribute("user", themeDisplay.getUser());
071    
072                    // Deprecated
073    
074                    pageContext.setAttribute(
075                            "portletGroupId", themeDisplay.getScopeGroupId());
076    
077                    return SKIP_BODY;
078            }
079    
080    }