001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.LocaleUtil;
020 import com.liferay.portal.kernel.util.UnicodeProperties;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.model.ColorScheme;
023 import com.liferay.portal.model.LayoutBranch;
024 import com.liferay.portal.model.LayoutRevision;
025 import com.liferay.portal.model.LayoutSet;
026 import com.liferay.portal.model.Theme;
027 import com.liferay.portal.service.LayoutBranchLocalServiceUtil;
028 import com.liferay.portal.service.LayoutRevisionLocalServiceUtil;
029 import com.liferay.portal.service.LayoutSetLocalServiceUtil;
030 import com.liferay.portal.service.ThemeLocalServiceUtil;
031
032 import java.util.List;
033 import java.util.Locale;
034
035
038 public class LayoutRevisionImpl extends LayoutRevisionBaseImpl {
039
040 public LayoutRevisionImpl() {
041 }
042
043 public List<LayoutRevision> getChildren() throws SystemException {
044 return LayoutRevisionLocalServiceUtil.getChildLayoutRevisions(
045 getLayoutSetBranchId(), getLayoutRevisionId(), getPlid());
046 }
047
048 public ColorScheme getColorScheme()
049 throws PortalException, SystemException {
050
051 if (isInheritLookAndFeel()) {
052 return getLayoutSet().getColorScheme();
053 }
054 else {
055 return ThemeLocalServiceUtil.getColorScheme(
056 getCompanyId(), getTheme().getThemeId(), getColorSchemeId(),
057 false);
058 }
059 }
060
061 public String getCssText() throws PortalException, SystemException {
062 if (isInheritLookAndFeel()) {
063 return getLayoutSet().getCss();
064 }
065 else {
066 return getCss();
067 }
068 }
069
070 public String getHTMLTitle(Locale locale) {
071 String localeLanguageId = LocaleUtil.toLanguageId(locale);
072
073 return getHTMLTitle(localeLanguageId);
074 }
075
076 public String getHTMLTitle(String localeLanguageId) {
077 String htmlTitle = getTitle(localeLanguageId);
078
079 if (Validator.isNull(htmlTitle)) {
080 htmlTitle = getName(localeLanguageId);
081 }
082
083 return htmlTitle;
084 }
085
086 public LayoutBranch getLayoutBranch()
087 throws PortalException, SystemException {
088
089 return LayoutBranchLocalServiceUtil.getLayoutBranch(
090 getLayoutBranchId());
091 }
092
093 public LayoutSet getLayoutSet() throws PortalException, SystemException {
094 return LayoutSetLocalServiceUtil.getLayoutSet(
095 getGroupId(), isPrivateLayout());
096 }
097
098 public Theme getTheme() throws PortalException, SystemException {
099 if (isInheritLookAndFeel()) {
100 return getLayoutSet().getTheme();
101 }
102 else {
103 return ThemeLocalServiceUtil.getTheme(
104 getCompanyId(), getThemeId(), false);
105 }
106 }
107
108 @Override
109 public String getTypeSettings() {
110 if (_typeSettingsProperties == null) {
111 return super.getTypeSettings();
112 }
113 else {
114 return _typeSettingsProperties.toString();
115 }
116 }
117
118 public UnicodeProperties getTypeSettingsProperties() {
119 if (_typeSettingsProperties == null) {
120 _typeSettingsProperties = new UnicodeProperties(true);
121
122 _typeSettingsProperties.fastLoad(super.getTypeSettings());
123 }
124
125 return _typeSettingsProperties;
126 }
127
128 public ColorScheme getWapColorScheme()
129 throws PortalException, SystemException {
130
131 if (isInheritLookAndFeel()) {
132 return getLayoutSet().getWapColorScheme();
133 }
134 else {
135 return ThemeLocalServiceUtil.getColorScheme(
136 getCompanyId(), getWapTheme().getThemeId(),
137 getWapColorSchemeId(), true);
138 }
139 }
140
141 public Theme getWapTheme() throws PortalException, SystemException {
142 if (isInheritWapLookAndFeel()) {
143 return getLayoutSet().getWapTheme();
144 }
145 else {
146 return ThemeLocalServiceUtil.getTheme(
147 getCompanyId(), getWapThemeId(), true);
148 }
149 }
150
151 public boolean hasChildren() throws SystemException {
152 if (!getChildren().isEmpty()) {
153 return true;
154 }
155
156 return false;
157 }
158
159 public boolean isInheritLookAndFeel() {
160 if (Validator.isNull(getThemeId()) ||
161 Validator.isNull(getColorSchemeId())) {
162
163 return true;
164 }
165 else {
166 return false;
167 }
168 }
169
170 public boolean isInheritWapLookAndFeel() {
171 if (Validator.isNull(getWapThemeId()) ||
172 Validator.isNull(getWapColorSchemeId())) {
173
174 return true;
175 }
176 else {
177 return false;
178 }
179 }
180
181 @Override
182 public void setTypeSettings(String typeSettings) {
183 _typeSettingsProperties = null;
184
185 super.setTypeSettings(typeSettings);
186 }
187
188 public void setTypeSettingsProperties(
189 UnicodeProperties typeSettingsProperties) {
190
191 _typeSettingsProperties = typeSettingsProperties;
192
193 super.setTypeSettings(_typeSettingsProperties.toString());
194 }
195
196 private UnicodeProperties _typeSettingsProperties;
197
198 }