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.LayoutTypePortletConstants;
027 import com.liferay.portal.model.Theme;
028 import com.liferay.portal.service.LayoutBranchLocalServiceUtil;
029 import com.liferay.portal.service.LayoutRevisionLocalServiceUtil;
030 import com.liferay.portal.service.LayoutSetLocalServiceUtil;
031 import com.liferay.portal.service.ThemeLocalServiceUtil;
032
033 import java.util.List;
034 import java.util.Locale;
035
036
039 public class LayoutRevisionImpl extends LayoutRevisionBaseImpl {
040
041 public LayoutRevisionImpl() {
042 }
043
044 @Override
045 public List<LayoutRevision> getChildren() throws SystemException {
046 return LayoutRevisionLocalServiceUtil.getChildLayoutRevisions(
047 getLayoutSetBranchId(), getLayoutRevisionId(), getPlid());
048 }
049
050 @Override
051 public ColorScheme getColorScheme()
052 throws PortalException, SystemException {
053
054 if (isInheritLookAndFeel()) {
055 return getLayoutSet().getColorScheme();
056 }
057 else {
058 return ThemeLocalServiceUtil.getColorScheme(
059 getCompanyId(), getTheme().getThemeId(), getColorSchemeId(),
060 false);
061 }
062 }
063
064 @Override
065 public String getCssText() throws PortalException, SystemException {
066 if (isInheritLookAndFeel()) {
067 return getLayoutSet().getCss();
068 }
069 else {
070 return getCss();
071 }
072 }
073
074 @Override
075 public String getHTMLTitle(Locale locale) {
076 String localeLanguageId = LocaleUtil.toLanguageId(locale);
077
078 return getHTMLTitle(localeLanguageId);
079 }
080
081 @Override
082 public String getHTMLTitle(String localeLanguageId) {
083 String htmlTitle = getTitle(localeLanguageId);
084
085 if (Validator.isNull(htmlTitle)) {
086 htmlTitle = getName(localeLanguageId);
087 }
088
089 return htmlTitle;
090 }
091
092 @Override
093 public LayoutBranch getLayoutBranch()
094 throws PortalException, SystemException {
095
096 return LayoutBranchLocalServiceUtil.getLayoutBranch(
097 getLayoutBranchId());
098 }
099
100 @Override
101 public LayoutSet getLayoutSet() throws PortalException, SystemException {
102 return LayoutSetLocalServiceUtil.getLayoutSet(
103 getGroupId(), isPrivateLayout());
104 }
105
106 @Override
107 public Theme getTheme() throws PortalException, SystemException {
108 if (isInheritLookAndFeel()) {
109 return getLayoutSet().getTheme();
110 }
111 else {
112 return ThemeLocalServiceUtil.getTheme(
113 getCompanyId(), getThemeId(), false);
114 }
115 }
116
117 @Override
118 public String getThemeSetting(String key, String device) {
119 UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
120
121 String value = typeSettingsProperties.getProperty(
122 ThemeSettingImpl.namespaceProperty(device, key));
123
124 if (value != null) {
125 return value;
126 }
127
128 if (!isInheritLookAndFeel()) {
129 try {
130 Theme theme = getTheme(device);
131
132 return theme.getSetting(key);
133 }
134 catch (Exception e) {
135 }
136 }
137
138 try {
139 LayoutSet layoutSet = getLayoutSet();
140
141 value = layoutSet.getThemeSetting(key, device);
142 }
143 catch (Exception e) {
144 }
145
146 return value;
147 }
148
149 @Override
150 public String getTypeSettings() {
151 if (_typeSettingsProperties == null) {
152 return super.getTypeSettings();
153 }
154 else {
155 return _typeSettingsProperties.toString();
156 }
157 }
158
159 @Override
160 public UnicodeProperties getTypeSettingsProperties() {
161 if (_typeSettingsProperties == null) {
162 _typeSettingsProperties = new UnicodeProperties(true);
163
164 _typeSettingsProperties.fastLoad(super.getTypeSettings());
165 }
166
167 return _typeSettingsProperties;
168 }
169
170 @Override
171 public ColorScheme getWapColorScheme()
172 throws PortalException, SystemException {
173
174 if (isInheritLookAndFeel()) {
175 return getLayoutSet().getWapColorScheme();
176 }
177 else {
178 return ThemeLocalServiceUtil.getColorScheme(
179 getCompanyId(), getWapTheme().getThemeId(),
180 getWapColorSchemeId(), true);
181 }
182 }
183
184 @Override
185 public Theme getWapTheme() throws PortalException, SystemException {
186 if (isInheritWapLookAndFeel()) {
187 return getLayoutSet().getWapTheme();
188 }
189 else {
190 return ThemeLocalServiceUtil.getTheme(
191 getCompanyId(), getWapThemeId(), true);
192 }
193 }
194
195 @Override
196 public boolean hasChildren() throws SystemException {
197 if (!getChildren().isEmpty()) {
198 return true;
199 }
200
201 return false;
202 }
203
204 @Override
205 public boolean isContentDisplayPage() {
206 UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
207
208 String defaultAssetPublisherPortletId =
209 typeSettingsProperties.getProperty(
210 LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);
211
212 if (Validator.isNotNull(defaultAssetPublisherPortletId)) {
213 return true;
214 }
215 else {
216 return false;
217 }
218 }
219
220 @Override
221 public boolean isInheritLookAndFeel() {
222 if (Validator.isNull(getThemeId()) ||
223 Validator.isNull(getColorSchemeId())) {
224
225 return true;
226 }
227 else {
228 return false;
229 }
230 }
231
232 @Override
233 public boolean isInheritWapLookAndFeel() {
234 if (Validator.isNull(getWapThemeId()) ||
235 Validator.isNull(getWapColorSchemeId())) {
236
237 return true;
238 }
239 else {
240 return false;
241 }
242 }
243
244 @Override
245 public void setTypeSettings(String typeSettings) {
246 _typeSettingsProperties = null;
247
248 super.setTypeSettings(typeSettings);
249 }
250
251 @Override
252 public void setTypeSettingsProperties(
253 UnicodeProperties typeSettingsProperties) {
254
255 _typeSettingsProperties = typeSettingsProperties;
256
257 super.setTypeSettings(_typeSettingsProperties.toString());
258 }
259
260 protected Theme getTheme(String device)
261 throws PortalException, SystemException {
262
263 if (device.equals("regular")) {
264 return getTheme();
265 }
266 else {
267 return getWapTheme();
268 }
269 }
270
271 private UnicodeProperties _typeSettingsProperties;
272
273 }