001
014
015 package com.liferay.taglib.util;
016
017 import com.liferay.portal.kernel.servlet.taglib.BaseBodyTagSupport;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.kernel.util.Validator;
020 import com.liferay.portal.kernel.util.WebKeys;
021 import com.liferay.portal.theme.ThemeDisplay;
022
023 import javax.servlet.http.HttpServletRequest;
024 import javax.servlet.jsp.tagext.BodyTag;
025
026
029 public class PositionTagSupport extends BaseBodyTagSupport implements BodyTag {
030
031 public String getPosition() {
032 return getPositionValue();
033 }
034
035 public boolean isPositionAuto() {
036 String position = getPosition();
037
038 if (position.equals(_POSITION_AUTO)) {
039 return true;
040 }
041 else {
042 return false;
043 }
044 }
045
046 public boolean isPositionInLine() {
047 String position = getPosition();
048
049 if (position.equals(_POSITION_INLINE)) {
050 return true;
051 }
052 else {
053 return false;
054 }
055 }
056
057 public void setPosition(String position) {
058 _position = position;
059 }
060
061 protected void cleanUp() {
062 _position = null;
063 }
064
065 protected String getPositionValue() {
066 HttpServletRequest request =
067 (HttpServletRequest)pageContext.getRequest();
068
069 String position = _position;
070
071 String fragmentId = ParamUtil.getString(request, "p_f_id");
072
073 if (Validator.isNotNull(fragmentId)) {
074 position = _POSITION_INLINE;
075 }
076
077 if (Validator.isNull(position)) {
078 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
079 WebKeys.THEME_DISPLAY);
080
081 if (themeDisplay.isStateExclusive() || themeDisplay.isIsolated()) {
082 position = _POSITION_INLINE;
083 }
084 else {
085 position = _POSITION_AUTO;
086 }
087 }
088
089 return position;
090 }
091
092 private static final String _POSITION_AUTO = "auto";
093
094 private static final String _POSITION_INLINE = "inline";
095
096 private String _position;
097
098 }