Skip to content

Commit

Permalink
Added sitemap config option for hiding dynamic functions which don't fit
Browse files Browse the repository at this point in the history
in any container.
  • Loading branch information
gWestenberger committed Mar 24, 2023
1 parent 12b37f6 commit 4b30c4e
Show file tree
Hide file tree
Showing 19 changed files with 464 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ label.SitemapConfiguration.UseFormatterKeys.help=Speichert die Zuordnung von For
label.SitemapConfiguration.DisabledTypesMode='Inhalte hinzufügen' Menü
label.SitemapConfiguration.DisabledTypesMode.help=Legt fest wie Elemente im "Inhalte hinzufügen" Menü des Seiteneditors angezeigt wirden, für den Fall dass sich kein passender Container für ein Element auf der Seite befindet.
label.SitemapConfiguration.DisabledFunctionsMode='Inhalte hinzufügen' Menü
label.SitemapConfiguration.DisabledFunctionsMode.help=Legt fest wie dynamische Funktionen im "Inhalte hinzufügen" Menü des Seiteneditors angezeigt wirden, für den Fall dass sich kein passender Container auf der Seite befindet.
label.SitePlugin.NiceName=Name
label.SitePlugin.Description=Beschreibung
Expand Down Expand Up @@ -602,6 +605,8 @@ discardprops.true=Ja
discardprops.top=Ja, und schiebe Eigenschaften aus dieser Sitemapkonfiguration nach oben
disabledtypesmode.mark=Elemente deaktiviert anzeigen wenn kein passender Container auf der Seite
disabledtypesmode.hide=Elemente ausblenden wenn kein passender Container auf der Seite
disabledfunctionsmode.mark=Funktionen deaktiviert anzeigen wenn kein passender Container auf der Seite
disabledfunctionsmode.hide=Funktionen ausblenden wenn kein passender Container auf der Seite
formatterkey.validation=Formatterschlüssel darf nur die Zeichen A-Z, a-z, 0-9, /, #, Minus (-) und Punkt (.) enthalten.
LOG_CONTAINER_PAGE_LOCALE_NOT_FOUND_2=Locale "{1}" in der Containerpage "{0}" nicht vorhanden.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.opencms.gwt.client.util.I_CmsSimpleCallback;
import org.opencms.gwt.shared.CmsContextMenuEntryBean;
import org.opencms.gwt.shared.CmsCoreData.AdeContext;
import org.opencms.gwt.shared.CmsGalleryContainerInfo;
import org.opencms.gwt.shared.CmsGwtConstants;
import org.opencms.gwt.shared.CmsListInfoBean;
import org.opencms.gwt.shared.CmsTemplateContextInfo;
Expand Down Expand Up @@ -1336,6 +1337,23 @@ public void handleElement(CmsContainerPageElementPanel current) {
}
}

/**
* Gets the container info to send to the gallery service.
*
* @return the container info to send to the gallery service
*/
public CmsGalleryContainerInfo getContainerInfoForGalleries() {

if (m_targetContainers != null) {
HashSet<CmsGalleryContainerInfo.Item> items = new HashSet<>();
for (CmsContainerPageContainer cont : m_targetContainers.values()) {
items.add(new CmsGalleryContainerInfo.Item(cont.getContainerType(), cont.getConfiguredWidth()));
}
return new CmsGalleryContainerInfo(items);
}
return null;
}

/**
* Returns the container-page RPC service.<p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ public void onToolbarActivate() {
}
final Predicate<CmsResultItemBean> finalDndFilter = resultDndFilter;
CmsGalleryDialog galleryDialog = new CmsGalleryDialog(new GalleryHandler(finalDndFilter));
new CmsGalleryController(new CmsGalleryControllerHandler(galleryDialog), m_galleryData, m_search);
CmsGalleryController galleryController = new CmsGalleryController(
new CmsGalleryControllerHandler(galleryDialog),
m_galleryData,
m_search);
galleryController.setContainerInfoProvider(
() -> CmsContainerpageController.get().getContainerInfoForGalleries());
m_dialog = galleryDialog;
m_dialog.setDialogSize(dialogWidth, dialogHeight);
getPopup().setWidth(dialogWidth);
Expand Down
23 changes: 19 additions & 4 deletions src-gwt/org/opencms/ade/galleries/client/CmsGalleryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.opencms.gwt.client.util.I_CmsSimpleCallback;
import org.opencms.gwt.shared.CmsCategoryBean;
import org.opencms.gwt.shared.CmsCategoryTreeEntry;
import org.opencms.gwt.shared.CmsGalleryContainerInfo;
import org.opencms.gwt.shared.rpc.I_CmsVfsServiceAsync;
import org.opencms.gwt.shared.sort.CmsComparatorPath;
import org.opencms.gwt.shared.sort.CmsComparatorTitle;
Expand All @@ -74,6 +75,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

import com.google.common.collect.Lists;
import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -128,6 +130,9 @@ public class CmsGalleryController implements HasValueChangeHandlers<CmsGallerySe
/** The gallery configuration. */
private I_CmsGalleryConfiguration m_configuration;

/** Provides container information for the gallery dialog. */
private Supplier<CmsGalleryContainerInfo> m_containerInfoProvider = () -> null;

/** The current resource preview. */
private I_CmsResourcePreview<?> m_currentPreview;

Expand Down Expand Up @@ -304,10 +309,6 @@ public static void registerPreviewFactory(String previewProviderName, I_CmsPrevi
m_previewFactoryRegistration.put(previewProviderName, factory);
}

private static native void debugger() /*-{
debugger;
}-*/;

/**
* Add category to search object.<p>
*
Expand Down Expand Up @@ -1292,6 +1293,19 @@ public void selectResultTab() {
m_handler.selectResultTab();
}

/**
* Sets the function that provides the container information.
*
* @param containerInfoProvider the container info provider
*/
public void setContainerInfoProvider(Supplier<CmsGalleryContainerInfo> containerInfoProvider) {

if (containerInfoProvider == null) {
containerInfoProvider = () -> null;
}
m_containerInfoProvider = containerInfoProvider;
}

/**
* Sets the controller handler for gallery dialog.<p>
*
Expand Down Expand Up @@ -1811,6 +1825,7 @@ CmsGallerySearchBean prepareSearchObject() {
preparedSearchObj.setGalleriesChanged(true);
m_galleriesChanged = false;
}
preparedSearchObj.setContainerInfo(m_containerInfoProvider.get());
return preparedSearchObj;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public CmsResultListItem(
} else {
setName(resultItem.getClientId());
}
initMoveHandle(dndHandler);
if (!resultItem.isDeactivated()) {
initMoveHandle(dndHandler);
}
}
if (resultItemWidget.hasTileView()) {
addStyleName(I_CmsLayoutBundle.INSTANCE.galleryResultItemCss().tilingItem());
Expand All @@ -114,7 +116,7 @@ public CmsResultListItem(
m_selectButton.setVisible(false);
resultItemWidget.addButton(m_selectButton);

if (!resultItem.isReleasedAndNotExpired()) {
if (!resultItem.isReleasedAndNotExpired() || resultItem.isDeactivated()) {
addStyleName(I_CmsLayoutBundle.INSTANCE.galleryResultItemCss().expired());
}
}
Expand Down
24 changes: 23 additions & 1 deletion src/org/opencms/ade/configuration/CmsADEConfigData.java
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,24 @@ public SitemapDirectEditPermissions getDirectEditPermissions(String type) {
return SitemapDirectEditPermissions.all;
}

/**
* Gets the display mode for deactivated functions in the gallery dialog.
*
* @param defaultValue the default value to return if it's not set
* @return the display mode for deactivated types
*/
public CmsGalleryDisabledTypesMode getDisabledFunctionsMode(CmsGalleryDisabledTypesMode defaultValue) {

CmsADEConfigData parentData = parent();
if (m_data.getGalleryDisabledFunctionsMode() != null) {
return m_data.getGalleryDisabledFunctionsMode();
} else if (parentData != null) {
return parentData.getDisabledFunctionsMode(defaultValue);
} else {
return defaultValue;
}
}

/**
* Gets the display mode for deactivated types in the gallery dialog.
*
Expand All @@ -925,7 +943,6 @@ public CmsGalleryDisabledTypesMode getDisabledTypeMode(CmsGalleryDisabledTypesMo
} else {
return defaultValue;
}

}

/**
Expand Down Expand Up @@ -1561,6 +1578,11 @@ public boolean isExcludeExternalDetailContents() {
return m_data.isExcludeExternalDetailContents();
}

public boolean isHideNonMatchingFunctions() {

return getDisabledFunctionsMode(CmsGalleryDisabledTypesMode.hide) == CmsGalleryDisabledTypesMode.hide;
}

/**
* Returns true if the subsite should be included in the site selector.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public String toString() {
/** The display mode for deactivated types in the gallery dialog. */
private CmsGalleryDisabledTypesMode m_galleryDisabledTypesMode;

private CmsGalleryDisabledTypesMode m_galleryDisabledFunctionsMode;

/** Model page data with no resources. */
private List<CmsModelPageConfigWithoutResource> m_ownModelPageConfigRaw = new ArrayList<>();

Expand Down Expand Up @@ -259,6 +261,7 @@ public CmsADEConfigDataInternal(
List<CmsUUID> masterConfigs,
List<CmsResourceTypeConfig> resourceTypeConfig,
CmsGalleryDisabledTypesMode galleryDisabledTypesMode,
CmsGalleryDisabledTypesMode galleryDisabledFunctionsMode,
boolean discardInheritedTypes,
List<CmsPropertyConfig> propertyConfig,
DiscardPropertiesMode discardPropertiesMode,
Expand Down Expand Up @@ -290,6 +293,7 @@ public CmsADEConfigDataInternal(
m_basePath = basePath;
m_ownResourceTypes = resourceTypeConfig;
m_galleryDisabledTypesMode = galleryDisabledTypesMode;
m_galleryDisabledFunctionsMode = galleryDisabledFunctionsMode;
m_ownPropertyConfigurations = propertyConfig;
m_ownModelPageConfigRaw = modelPages;
m_ownDetailPages = detailPageInfos;
Expand Down Expand Up @@ -537,6 +541,11 @@ public Collection<CmsUUID> getFunctionsToRemove() {
return m_functionsToRemove;
}

public CmsGalleryDisabledTypesMode getGalleryDisabledFunctionsMode() {

return m_galleryDisabledFunctionsMode;
}

/**
* Gets the structure ids of the master configuration files.
*
Expand Down
3 changes: 2 additions & 1 deletion src/org/opencms/ade/configuration/CmsADEManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.CmsUser;
import org.opencms.file.types.CmsResourceTypeFunctionConfig;
import org.opencms.file.types.CmsResourceTypeXmlContainerPage;
import org.opencms.file.types.CmsResourceTypeXmlContent;
import org.opencms.file.types.I_CmsResourceType;
Expand Down Expand Up @@ -880,7 +881,7 @@ public CmsPermissionInfo getPermissionInfo(CmsObject cms, CmsResource resource,
true);

boolean isFunction = false;
for (String type : new String[] {"function", "function_config"}) {
for (String type : new String[] {"function", CmsResourceTypeFunctionConfig.TYPE_NAME}) {
if (OpenCms.getResourceManager().matchResourceType(type, resource.getTypeId())) {
isFunction = true;
break;
Expand Down
10 changes: 10 additions & 0 deletions src/org/opencms/ade/configuration/CmsConfigurationReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public String getStringValue() {
/** The DisabledTypesMode node name. */
public static final String N_DISABLED_TYPES_MODE = "DisabledTypesMode";

/** The DisabledFunctionsMode node name. */
public static final String N_DISABLED_FUNCTIONS_MODE = "DisabledFunctionsMode";

/** The discard model pages node name. */
public static final String N_DISCARD_MODEL_PAGES = "DiscardModelPages";

Expand Down Expand Up @@ -619,6 +622,12 @@ public CmsADEConfigDataInternal parseConfiguration(String basePath, CmsXmlConten
galleryDisabledTypesMode = CmsGalleryDisabledTypesMode.valueOf(galleryDisabledTypesStr);
}

String galleryDisabledFunctionsStr = getString(root.getSubValue(N_DISABLED_FUNCTIONS_MODE));
CmsGalleryDisabledTypesMode galleryDisabledFunctionsMode = null;
if (galleryDisabledFunctionsStr != null) {
galleryDisabledFunctionsMode = CmsGalleryDisabledTypesMode.valueOf(galleryDisabledFunctionsStr);
}

I_CmsXmlContentValueLocation typeOrderingLoc = root.getSubValue(N_TYPE_ORDERING_MODE);
CmsTypeOrderingMode typeOrderingMode = null;
if (typeOrderingLoc != null) {
Expand Down Expand Up @@ -669,6 +678,7 @@ public CmsADEConfigDataInternal parseConfiguration(String basePath, CmsXmlConten
masterConfigIds,
m_resourceTypeConfigs,
galleryDisabledTypesMode,
galleryDisabledFunctionsMode,
discardInheritedTypes,
m_propertyConfigs,
discardPropertiesMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.CmsUser;
import org.opencms.file.CmsVfsResourceNotFoundException;
import org.opencms.file.types.CmsResourceTypeFunctionConfig;
import org.opencms.file.types.CmsResourceTypeXmlContainerPage;
import org.opencms.file.types.CmsResourceTypeXmlContent;
import org.opencms.file.types.I_CmsResourceType;
Expand Down Expand Up @@ -1143,7 +1144,6 @@ public CmsContainerPageGalleryData getGalleryDataForPage(

CmsGalleryDataBean data = null;
try {

CmsObject cms = getCmsObject();

CmsAddDialogTypeHelper typeHelper = new CmsAddDialogTypeHelper(CmsResourceTypeConfig.AddMenuType.ade);
Expand Down Expand Up @@ -1175,7 +1175,7 @@ public boolean checkEnabled(
String subsite = OpenCms.getADEManager().getSubSiteRoot(cms, cms.addSiteRoot(uri));
String searchStoreKey = elementView + "|" + subsite + "|" + locale;
data.getContextParameters().put("searchStoreKey", searchStoreKey);
if (search != null) {
if ((search != null) && !search.getServerSearchTypes().contains(CmsResourceTypeFunctionConfig.TYPE_NAME)) {
if (searchStoreKey.equals(
search.getOriginalGalleryData().getContextParameters().get("searchStoreKey"))) {
if (hasCompatibleSearchData(search.getOriginalGalleryData(), data, search)) {
Expand Down
Loading

0 comments on commit 4b30c4e

Please sign in to comment.