1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.taglib.theme;
16  
17  import com.liferay.portal.kernel.util.WebKeys;
18  import com.liferay.portal.theme.ThemeDisplay;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.jsp.tagext.TagSupport;
22  
23  /**
24   * <a href="DefineObjectsTag.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class DefineObjectsTag extends TagSupport {
29  
30      public int doStartTag() {
31          HttpServletRequest request =
32              (HttpServletRequest)pageContext.getRequest();
33  
34          ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
35              WebKeys.THEME_DISPLAY);
36  
37          if (themeDisplay != null) {
38              pageContext.setAttribute("themeDisplay", themeDisplay);
39              pageContext.setAttribute("company", themeDisplay.getCompany());
40              pageContext.setAttribute("account", themeDisplay.getAccount());
41              pageContext.setAttribute("user", themeDisplay.getUser());
42              pageContext.setAttribute("realUser", themeDisplay.getRealUser());
43              pageContext.setAttribute("contact", themeDisplay.getContact());
44  
45              if (themeDisplay.getLayout() != null) {
46                  pageContext.setAttribute("layout", themeDisplay.getLayout());
47              }
48  
49              if (themeDisplay.getLayouts() != null) {
50                  pageContext.setAttribute("layouts", themeDisplay.getLayouts());
51              }
52  
53              pageContext.setAttribute("plid", new Long(themeDisplay.getPlid()));
54  
55              if (themeDisplay.getLayoutTypePortlet() != null) {
56                  pageContext.setAttribute(
57                      "layoutTypePortlet", themeDisplay.getLayoutTypePortlet());
58              }
59  
60              pageContext.setAttribute(
61                  "scopeGroupId", new Long(themeDisplay.getScopeGroupId()));
62              pageContext.setAttribute(
63                  "permissionChecker", themeDisplay.getPermissionChecker());
64              pageContext.setAttribute("locale", themeDisplay.getLocale());
65              pageContext.setAttribute("timeZone", themeDisplay.getTimeZone());
66              pageContext.setAttribute("theme", themeDisplay.getTheme());
67              pageContext.setAttribute(
68                  "colorScheme", themeDisplay.getColorScheme());
69              pageContext.setAttribute(
70                  "portletDisplay", themeDisplay.getPortletDisplay());
71  
72              // Deprecated
73  
74              pageContext.setAttribute(
75                  "portletGroupId", new Long(themeDisplay.getScopeGroupId()));
76          }
77  
78          return SKIP_BODY;
79      }
80  
81      public int doEndTag() {
82          return EVAL_PAGE;
83      }
84  
85  }