Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lps 75103 2 #54144

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -84,6 +84,7 @@
* @author Berentey Zsolt
* @author Jorge Ferrer
* @author Raymond Augé
* @author Neil Griffin
*/
public class LayoutTypePortletImpl
extends LayoutTypeImpl implements LayoutTypePortlet {
Expand All @@ -107,6 +108,13 @@ public void addModeConfigPortletId(String portletId) {
setModeConfig(StringUtil.add(getModeConfig(), portletId));
}

public void addModeCustomPortletId(String portletId, String portletMode) {
removeModesPortletId(portletId);
setModeCustom(
StringUtil.add(getModeCustom(portletMode), portletId), portletMode);
_addedCustomPortletMode = portletMode;
}

@Override
public void addModeEditDefaultsPortletId(String portletId) {
removeModesPortletId(portletId);
Expand Down Expand Up @@ -250,6 +258,10 @@ public List<Portlet> addStaticPortlets(
return list;
}

public String getAddedCustomPortletMode() {
return _addedCustomPortletMode;
}

@Override
public List<Portlet> getAllPortlets() {
List<Portlet> explicitlyAddedPortlets = getExplicitlyAddedPortlets();
Expand Down Expand Up @@ -403,6 +415,10 @@ public String getModeConfig() {
return getTypeSettingsProperty(LayoutTypePortletConstants.MODE_CONFIG);
}

public String getModeCustom(String portletMode) {
return getTypeSettingsProperty("mode-" + portletMode);
}

@Override
public String getModeEdit() {
return getTypeSettingsProperty(LayoutTypePortletConstants.MODE_EDIT);
Expand Down Expand Up @@ -525,6 +541,12 @@ public boolean hasModeConfigPortletId(String portletId) {
return StringUtil.contains(getModeConfig(), portletId);
}

public boolean hasModeCustomPortletId(
String portletId, String portletMode) {

return StringUtil.contains(getModeCustom(portletMode), portletId);
}

@Override
public boolean hasModeEditDefaultsPortletId(String portletId) {
return StringUtil.contains(getModeEditDefaults(), portletId);
Expand Down Expand Up @@ -1197,6 +1219,10 @@ public void setModeConfig(String modeConfig) {
LayoutTypePortletConstants.MODE_CONFIG, modeConfig);
}

public void setModeCustom(String modeCustom, String portletMode) {
setTypeSettingsProperty("mode-" + portletMode, modeCustom);
}

@Override
public void setModeEdit(String modeEdit) {
setTypeSettingsProperty(LayoutTypePortletConstants.MODE_EDIT, modeEdit);
Expand Down Expand Up @@ -2004,6 +2030,7 @@ private void _removeNestedColumns(

private static final Layout _nullLayout = new LayoutImpl();

private String _addedCustomPortletMode;
private boolean _customizedView;
private final Format _dateFormat =
FastDateFormatFactoryUtil.getSimpleDateFormat(
Expand Down
33 changes: 33 additions & 0 deletions portal-impl/src/com/liferay/portal/util/PortalImpl.java
Expand Up @@ -201,6 +201,7 @@
import com.liferay.portal.language.LanguageResources;
import com.liferay.portal.model.impl.CookieRemotePreference;
import com.liferay.portal.model.impl.LayoutTypeImpl;
import com.liferay.portal.model.impl.LayoutTypePortletImpl;
import com.liferay.portal.plugin.PluginPackageUtil;
import com.liferay.portal.security.jaas.JAASHelper;
import com.liferay.portal.security.lang.DoPrivilegedUtil;
Expand Down Expand Up @@ -312,6 +313,7 @@
* @author Hugo Huijser
* @author Juan Fernández
* @author Marco Leo
* @author Neil Griffin
*/
@DoPrivileged
public class PortalImpl implements Portal {
Expand Down Expand Up @@ -7171,6 +7173,20 @@ else if (portletMode.equals(PortletMode.VIEW) &&

updateLayout = true;
}
else if (layoutType instanceof LayoutTypePortletImpl) {
LayoutTypePortletImpl layoutTypePortletImpl =
(LayoutTypePortletImpl)layoutType;

if (_isCustomPortletMode(portletMode) &&
!layoutTypePortletImpl.hasModeCustomPortletId(
portletId, portletMode.toString())) {

layoutTypePortletImpl.addModeCustomPortletId(
portletId, portletMode.toString());

updateLayout = true;
}
}

if (updateLayout &&
PortletPermissionUtil.contains(
Expand Down Expand Up @@ -8689,6 +8705,23 @@ private Group _getSiteGroup(long groupId) {
return group;
}

private boolean _isCustomPortletMode(PortletMode portletMode) {
if (LiferayPortletMode.VIEW.equals(portletMode) ||
LiferayPortletMode.EDIT.equals(portletMode) ||
LiferayPortletMode.HELP.equals(portletMode) ||
LiferayPortletMode.ABOUT.equals(portletMode) ||
LiferayPortletMode.CONFIG.equals(portletMode) ||
LiferayPortletMode.EDIT_DEFAULTS.equals(portletMode) ||
LiferayPortletMode.EDIT_GUEST.equals(portletMode) ||
LiferayPortletMode.PREVIEW.equals(portletMode) ||
LiferayPortletMode.PRINT.equals(portletMode)) {

return false;
}

return true;
}

private boolean _isSameHostName(
String virtualHostName, String portalDomain) {

Expand Down
9 changes: 9 additions & 0 deletions portal-web/docroot/html/portal/render_portlet.jsp
Expand Up @@ -122,6 +122,15 @@ else if (modePreview) {
else if (modePrint) {
portletMode = LiferayPortletMode.PRINT;
}
else if (layoutTypePortlet instanceof LayoutTypePortletImpl) {
LayoutTypePortletImpl layoutTypePortletImpl = (LayoutTypePortletImpl)layoutTypePortlet;

String customPortletMode = layoutTypePortletImpl.getAddedCustomPortletMode();

if (customPortletMode != null) {
portletMode = new PortletMode(customPortletMode);
}
}

InvokerPortlet invokerPortlet = null;

Expand Down
2 changes: 1 addition & 1 deletion source-formatter.properties
Expand Up @@ -63,7 +63,7 @@
portal-impl/src/com/liferay/portal/fabric/netty/client/NettyFabricClientConfig.java@69,\
portal-impl/src/com/liferay/portal/spring/hibernate/PortalHibernateConfiguration.java@342,\
portal-impl/src/com/liferay/portal/tools/WebXML23Converter.java@82,\
portal-impl/src/com/liferay/portal/util/PortalImpl.java@556,\
portal-impl/src/com/liferay/portal/util/PortalImpl.java@558,\
portal-impl/src/com/liferay/portal/util/PropsValues.java,\
portal-impl/src/com/liferay/portal/util/WebKeys.java,\
portal-kernel/src/com/liferay/portal/kernel/model/ListTypeConstants.java@53,\
Expand Down