001    /**
002     * Copyright (c) 2000-2012 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                            pageContext.setAttribute("themeDisplay", themeDisplay);
038                            pageContext.setAttribute("company", themeDisplay.getCompany());
039                            pageContext.setAttribute("account", themeDisplay.getAccount());
040                            pageContext.setAttribute("user", themeDisplay.getUser());
041                            pageContext.setAttribute("realUser", themeDisplay.getRealUser());
042                            pageContext.setAttribute("contact", themeDisplay.getContact());
043    
044                            if (themeDisplay.getLayout() != null) {
045                                    pageContext.setAttribute("layout", themeDisplay.getLayout());
046                            }
047    
048                            if (themeDisplay.getLayouts() != null) {
049                                    pageContext.setAttribute("layouts", themeDisplay.getLayouts());
050                            }
051    
052                            pageContext.setAttribute("plid", new Long(themeDisplay.getPlid()));
053    
054                            if (themeDisplay.getLayoutTypePortlet() != null) {
055                                    pageContext.setAttribute(
056                                            "layoutTypePortlet", themeDisplay.getLayoutTypePortlet());
057                            }
058    
059                            pageContext.setAttribute(
060                                    "scopeGroupId", new Long(themeDisplay.getScopeGroupId()));
061                            pageContext.setAttribute(
062                                    "permissionChecker", themeDisplay.getPermissionChecker());
063                            pageContext.setAttribute("locale", themeDisplay.getLocale());
064                            pageContext.setAttribute("timeZone", themeDisplay.getTimeZone());
065                            pageContext.setAttribute("theme", themeDisplay.getTheme());
066                            pageContext.setAttribute(
067                                    "colorScheme", themeDisplay.getColorScheme());
068                            pageContext.setAttribute(
069                                    "portletDisplay", themeDisplay.getPortletDisplay());
070    
071                            // Deprecated
072    
073                            pageContext.setAttribute(
074                                    "portletGroupId", new Long(themeDisplay.getScopeGroupId()));
075                    }
076    
077                    return SKIP_BODY;
078            }
079    
080    }