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