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.ui;
16  
17  import com.liferay.portal.kernel.util.GetterUtil;
18  import com.liferay.portal.kernel.util.PropsKeys;
19  import com.liferay.portal.kernel.util.PropsUtil;
20  import com.liferay.portal.model.Layout;
21  import com.liferay.taglib.util.IncludeTag;
22  
23  import javax.portlet.PortletURL;
24  
25  import javax.servlet.http.HttpServletRequest;
26  
27  /**
28   * <a href="BreadcrumbTag.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class BreadcrumbTag extends IncludeTag {
33  
34      public void setDisplayStyle(int displayStyle) {
35          _displayStyle = displayStyle;
36      }
37  
38      public void setPortletURL(PortletURL portletURL) {
39          _portletURL = portletURL;
40      }
41  
42      public void setSelLayout(Layout selLayout) {
43          _selLayout = selLayout;
44      }
45  
46      public void setSelLayoutParam(String selLayoutParam) {
47          _selLayoutParam = selLayoutParam;
48      }
49  
50      public void setShowGuestGroup(boolean showGuestGroup) {
51          _showGuestGroup = showGuestGroup;
52      }
53  
54      public void setShowLayout(boolean showLayout) {
55          _showLayout = showLayout;
56      }
57  
58      public void setShowParentGroups(boolean showParentGroups) {
59          _showParentGroups = showParentGroups;
60      }
61  
62      public void setShowPortletBreadcrumb(boolean showPortletBreadcrumb) {
63          _showPortletBreadcrumb = showPortletBreadcrumb;
64      }
65  
66      protected void cleanUp() {
67          _displayStyle = _DISPLAY_STYLE;
68          _portletURL = null;
69          _selLayout = null;
70          _selLayoutParam = null;
71          _showGuestGroup = _SHOW_GUEST_GROUP;
72          _showLayout = true;
73          _showParentGroups = _SHOW_PARENT_GROUPS;
74          _showPortletBreadcrumb = true;
75      }
76  
77      protected String getPage() {
78          return _PAGE;
79      }
80  
81      protected void setAttributes(HttpServletRequest request) {
82          request.setAttribute(
83              "liferay-ui:breadcrumb:displayStyle",
84              String.valueOf(_displayStyle));
85          request.setAttribute("liferay-ui:breadcrumb:portletURL", _portletURL);
86          request.setAttribute("liferay-ui:breadcrumb:selLayout", _selLayout);
87          request.setAttribute(
88              "liferay-ui:breadcrumb:selLayoutParam", _selLayoutParam);
89          request.setAttribute(
90              "liferay-ui:breadcrumb:showGuestGroup",
91              String.valueOf(_showGuestGroup));
92          request.setAttribute(
93              "liferay-ui:breadcrumb:showLayout", String.valueOf(_showLayout));
94          request.setAttribute(
95              "liferay-ui:breadcrumb:showParentGroups",
96              String.valueOf(_showParentGroups));
97          request.setAttribute(
98              "liferay-ui:breadcrumb:showPortletBreadcrumb",
99              String.valueOf(_showPortletBreadcrumb));
100     }
101 
102     private static final int _DISPLAY_STYLE = 0;
103 
104     private static final String _PAGE = "/html/taglib/ui/breadcrumb/page.jsp";
105 
106     private static final boolean _SHOW_GUEST_GROUP = GetterUtil.getBoolean(
107         PropsUtil.get(PropsKeys.BREADCRUMB_SHOW_GUEST_GROUP));
108 
109     private static final boolean _SHOW_PARENT_GROUPS = GetterUtil.getBoolean(
110         PropsUtil.get(PropsKeys.BREADCRUMB_SHOW_PARENT_GROUPS));
111 
112     private int _displayStyle = _DISPLAY_STYLE;
113     private PortletURL _portletURL;
114     private Layout _selLayout;
115     private String _selLayoutParam;
116     private boolean _showGuestGroup = _SHOW_GUEST_GROUP;
117     private boolean _showLayout = true;
118     private boolean _showParentGroups = _SHOW_PARENT_GROUPS;
119     private boolean _showPortletBreadcrumb = true;
120 
121 }