001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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            public int doStartTag() {
029                    HttpServletRequest request =
030                            (HttpServletRequest)pageContext.getRequest();
031    
032                    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
033                            WebKeys.THEME_DISPLAY);
034    
035                    if (themeDisplay != null) {
036                            pageContext.setAttribute("themeDisplay", themeDisplay);
037                            pageContext.setAttribute("company", themeDisplay.getCompany());
038                            pageContext.setAttribute("account", themeDisplay.getAccount());
039                            pageContext.setAttribute("user", themeDisplay.getUser());
040                            pageContext.setAttribute("realUser", themeDisplay.getRealUser());
041                            pageContext.setAttribute("contact", themeDisplay.getContact());
042    
043                            if (themeDisplay.getLayout() != null) {
044                                    pageContext.setAttribute("layout", themeDisplay.getLayout());
045                            }
046    
047                            if (themeDisplay.getLayouts() != null) {
048                                    pageContext.setAttribute("layouts", themeDisplay.getLayouts());
049                            }
050    
051                            pageContext.setAttribute("plid", new Long(themeDisplay.getPlid()));
052    
053                            if (themeDisplay.getLayoutTypePortlet() != null) {
054                                    pageContext.setAttribute(
055                                            "layoutTypePortlet", themeDisplay.getLayoutTypePortlet());
056                            }
057    
058                            pageContext.setAttribute(
059                                    "scopeGroupId", new Long(themeDisplay.getScopeGroupId()));
060                            pageContext.setAttribute(
061                                    "permissionChecker", themeDisplay.getPermissionChecker());
062                            pageContext.setAttribute("locale", themeDisplay.getLocale());
063                            pageContext.setAttribute("timeZone", themeDisplay.getTimeZone());
064                            pageContext.setAttribute("theme", themeDisplay.getTheme());
065                            pageContext.setAttribute(
066                                    "colorScheme", themeDisplay.getColorScheme());
067                            pageContext.setAttribute(
068                                    "portletDisplay", themeDisplay.getPortletDisplay());
069    
070                            // Deprecated
071    
072                            pageContext.setAttribute(
073                                    "portletGroupId", new Long(themeDisplay.getScopeGroupId()));
074                    }
075    
076                    return SKIP_BODY;
077            }
078    
079    }