Coder Social home page Coder Social logo

ichhabrecht / content_defender Goto Github PK

View Code? Open in Web Editor NEW
80.0 80.0 34.0 390 KB

Define allowed or denied content element types in your backend layouts

License: GNU General Public License v2.0

PHP 95.05% TypeScript 4.95%
backend content layout restriction typo3 typo3-cms typo3-extension

content_defender's People

Contributors

davidr93 avatar goldi42 avatar ichhabrecht avatar jdreesen avatar josefglatz avatar kevin-appelt avatar koehnlein avatar mbrodala avatar mkroener avatar mschwemer avatar revoltek-daniel avatar spoonerweb avatar svenjuergens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

content_defender's Issues

not providing a colPos results in configuration missmatch

It is possible to either define colPos = without a value, or to omit this value.
In the 2nd case, the extension might not work as expected.
Considering the following template:

 mod {
    web_layout {
        BackendLayouts {
            ContentWithCustomHeader {
                title = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:backendlayouts.contentWithCustomHeader
                config {
                    backend_layout {
                        colCount = 12
                        rowCount = 3
                        rows {
                            1 {
                                columns {
                                    1 {
                                        name = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:backendlayouts.columns.header.info
                                        colPos = 11
                                        colspan = 6
                                        allowed {
                                            CType = site_info
                                        }
                                    }
                                    2 {
                                        name = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:backendlayouts.columns.header.slider
                                        colspan = 6
                                    }
                                }
                            }
                            2 {
                                columns {
                                    1 {
                                        name = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:backendlayouts.columns.content
                                        colPos = 0
                                        colspan = 8
                                        disallowed {
                                            CType = site_info
                                        }
                                    }
                                    2 {
                                        name = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:backendlayouts.columns.navigation
                                        colspan = 4
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Will not work as expected for colPos = 0 as row 1 column 2 already is evaluated as 0 and re used.

I would recommend to either document that a colPos should always be defined, or add a isset($column['colPos']) && check to BackendLayoutConfiguration::getConfigurationByColPos().

I guess the issue only occurs if colPos=0 comes after an missing colPos.

maxitems together with EXT:container works different then expected

EXT:container supports content_defender to limit children to special content elements of a defined CType. That works like a charm. We also use the configuration maxitems like:

new \B13\Container\Tca\ContainerConfiguration(
        'container',
        'Header',
        'Description',
        [
            [
                [
                    'name' => 'children',
                    'colPos' => 111,
                    'allowed' => [
                        'CType' => 'containerchild'
                    ],
                    'maxitems' => 3
                ],
            ],
        ]
    )

This limits the children elements to 3 for the whole page and not for the container where the child is inserted so. I mean, you cannot add 3 children per container, but only 3 children overall for the complete page.
I'm not sure if this is related to EXT:content_defender or more to EXT:container, but the exception with 1494605357 is thrown in content_defender. I'm also not sure if you are willing to support maxitems for container.
Nevertheless I wanted to report this issue.

Version:

  • ichhabrecht/content-defender 3.2.2
  • b13/container 1.6.1
  • TYPO3 10.4.30

Don't show dropzones that aren't allowed for the content element you want to move (with drag and drop)

If I move a content element to a backend column, where it isn't allowed, I can drag it there and get an error message in the backend, that the content element couldn't be saved in this column. But after this move, the content element is shown in this not allowed column until you reload this page.

I think it would be better if you can't move it there in the first place. So the dropzones shouldn't be shown in that case.

Exception inside md5() call when there is no backend layout

We have content elements that use EXT:flux and EXT:fluidcontent. They are in the folder that does not have backend layout assigned. Now, when searching for content element by uid in the Backend and opening them in the List view, I see the exception:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: md5() expects parameter 1 to be string, null given | TypeError thrown in file /var/www/vhosts/xxx/typo3conf/ext/content_defender/Classes/BackendLayout/BackendLayoutConfiguration.php in line 61. Requested URL: https://xxx/typo3/index.php?route=%2Frecord%2Fedit&token=--AnonymizedToken--&edit%5Btt_content%5D%5B9338%5D=edit&returnUrl=%2Fcms%2Ftypo3%2Findex.php%3FM%3Dweb_list%26moduleToken%3D0912ea2b47ce5a3eb74993debaa31333c2d0ca74%26id%3D347

The problem is in EXT:content_defender/Classes/BackendLayout/BackendLayoutConfiguration.php:

    public function getConfigurationByColPos($colPos)
    {
        $configurationIdentifier = md5($this->backendLayout['config']);

Basically it uses non-existing backend layout config. There should be a check. I hotfixed it with

    public function getConfigurationByColPos($colPos)
    {
        $configurationIdentifier = md5((string)$this->backendLayout['config']);

and it works fine for me. I will make a PR but you may want to look for better solution :)

Show error message earlier, if maximum element number is reached in one column

I limit the number of content elements in one column, which technically works fine. Process is as follows:

  • Column is restricted to one element
  • One element already created
  • Editor clicks on "new content"
  • Editor selects new element type
  • Error message is shown, that maximum element number is reached.

Couldn't the error message be shown directly when the editor clicks on "new content"? In a flash message in the upper right corner for example? This would save a few extra clicks. Or maybe the "new content" button could be hidden directly or some kind of "deactivated" in that case?

(Tested it with TYPO3 8.7.6 and content_defender 2.2.3).

Compatible with TYPO3 9.3?

Currently this package cannot be installed with TYPO3 9.3. Does it need further tests or can the dependencies simply be updated?

Content Defender not working with DCE Extention

We use the DCE Extention with Content Defender. I add the dce elment to the backend allow Section.
As Example the Element Name is: dce_dceuid3
At the selection every think work as expected but if i want to save the Element i got the Error:
1: The record "" couldn't be saved due to disallowed value(s).
I debug the Ext and Found at this Line a problem.

I think the problem is that DCE Elements have a different TCA Strukrtur. Because every think at that expretion is null.

Default settings for backend layout columns

Not sure if this is the right place or if that should be a TYPO3 core feature.

We're using mutliple extensions providing content elements that should only be used in specific backend layouts.

I'd like to define a default setting for disallowed content elements that is applied to all backend layouts.

Current approach

The current approach would be defining a default value and copying that into the columns in PageTS via copy operator <.
The problem with that is that extensions defining own CEs can not exclude them from all other backend layouts they obviously don't know about.

MyDefaultColumn {
  disallowed {
    CType = some_ce
  }
}

mod {
  web_layout {
    BackendLayouts {
      my_backend_layout {
        config.backend_layout.rows.1 {
          columns {
            1 < MyDefaultColumn
            2 < MyDefaultColumn
          }
        }
      }
    }
  }
}

Suggested approach

Due to the limitations of PageTS in regards of using reference (=<) the suggested approach is supplying a default object for Ext:content_defender which is considered at runtime during evaluation of the settings. This effectively serves as default value for column settings which is extended by the regular settings on the backend layout.

Ext:content_defender

mod.web_layout.ContentDefender {
  Defaults {
    Column {
      disallowed {
        CType = 
      }
    }
  }
}

Ext:my_ext

// disallow my_ce for all backend layout columns
mod.web_layout.ContentDefender.Defaults.Column.disallowed.CType := addToList(my_ce)

mod {
  web_layout {
    BackendLayouts {
      my_backend_layout {
        config {
          backend_layout {
            rows {
              1 {
                columns {
                  1 {
                    disallowed {
                     // but allow it here
                     CType := addToList(my_ce)
                    }
                  }
                  2 {
                    // ...
                    // my_ce is disallowed here
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Maxitems and Translations

Testcase:
Set column maxitems = 1
Add 1 content element to default language -> works
Translate the content element into another language -> works not
Error: Maximum number of allowed content elements (1) reached

I think the problem is that translations are related to the default ce and therefore the item count increases with every translation.

Versions:
TYPO3 - 8.7.10
Content_Defender - 3.0.3

Adding allowed.CType breaks drag'n'drop in our backend (TYPO3 10.4.16)

We are working a lot with page types and backend layouts and allowing specific CTypes inside a backend layout area - basically what I assumed this extension could help us with.

Now adding a config like the one in the docs works and does not allow us to add other content elements. Unfortunately it also does not allow us to drag and drop content elements within that area anymore. I can still drag them to e.g. a gridelement which has no "allowed" config and back outside though. Otherwise the "orange/green" drag and drop area simply never appears.

I tried disallow instead and that actually works, so I do have a workaround - it's just not a pretty one as I have to list all content elements but the one allowed. Any idea what the problem could be?

MaxItems and Workspaces

Hi,

We are currently facing the same issue as #36 but in combination with the workspaces extension.
The content is not savable after editing due to the maxItems exception.

AFAIK is the fix from #41 not applicable to this specific combination.

Could you please have a quick look into this issue?

We are using the following specs:

  • TYPO3 v. 10.4.18
  • workspaces v. 10.4.18
  • content_defender v. 3.1.4

Filter colPos items by permissions

Currently when editing content elements the CType field is correctly filtered by permissions, only content element types allowed in the BE layout section are listed.

The same should be done for the colPos field however. ATM all available BE layout sections are listed here, even sections where the current content element type is not allowed.

When trying to change and save an error prevents moving the content element but for the UX it would be great if invalid options where not available in the first place.

Hook for add additional logic from other extensions

Content element is saved in wrong colPos

After i add a new content element and save the content element, it gets saved into the wrong colPos.

kapture 2018-10-29 at 16 42 08

Our backend layout config looks like this:

mod {
  web_layout {
    BackendLayouts {
      industry_standards_search {
        title = Industry Standards Search
        config {
          backend_layout {
            colCount = 1
            rowCount = 5
            rows {
              1 {
                columns {
                  1 {
                    name = Header
                    colPos = 1
                    allowed {
                      CType = mask_simple_header
                      list_type = industrystandards_header
                    }
                  }
                }
              }
              2 {
                columns {
                  1 {
                    name = Inhalt
                    rowspan = 3
                    colPos = 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

TYPO3 9.5.0
Content Defender 3.0.9

Space after coma in allowed CTypes

Are you sure it works when you put a space after the coma in allowed CTypes as mentioned in the documentation like this :

columns {
    1 {
        name = Column with header and textmedia elements
        colPos = 3
        colspan = 6
        allowed {
            CType = header, textmedia, div
        }
    }
}

By my side I am unable to drag and drop element in backend if I do so (it works only for the first element).

I had to write it like this :

columns {
    1 {
        name = Column with header and textmedia elements
        colPos = 3
        colspan = 6
        allowed {
            CType = header,textmedia,div
        }
    }
}

Hiding CType from showitem breaks editing and creating content

Hi there,

we want to hide the CType from editors by removing the field from the showitem and rely on default values. Notably, this way the CType is not send via the POST request of the form.

This leads to an exception thrown by DatabaseRecordTypeValue because the CType field is missing from the databaseRow at this point.

Looking into it, there are a couple of things that need to be adressed to fix this. So far, all in the DataHandler hooks.

1) This set of form data providers does not resolve the default values.

[
UserTsConfig::class,
PageTsConfig::class,
InitializeProcessedTca::class,
DatabaseRecordTypeValue::class,
TcaColumnsProcessCommon::class,
TcaColumnsProcessShowitem::class,
TcaColumnsRemoveUnused::class,
]

2) Adding DatabaseRowInitializeNew before DatabaseRecordTypeValue does not work since the form data compiler is called with the command edit. This also requires to pass the defaults from the DataHandler into isRecordAllowedByRestriction.

3) Additionally after that the original record/incomingFieldArray is used, which does not have the CType field set. This always allows the element regardless of any configuration.

protected function isAllowedValue(array $record, $field, array $values, $allowed = true)
{
return !isset($record[$field])
|| ($allowed && in_array($record[$field], $values))
|| (!$allowed && !in_array($record[$field], $values));
}

Kind regards,
Jona

EXT:container maxitems, same colPos + translation

Hi,
there is a bug for me with maxitems for containers created with b13/container.

I have multiple container elements on a single page, some of them use the same colPos for their children.
Even if the defined maxitems is not reached for the container element, you are not allowed to add more items or even create translations of theese child elements.

The issue seams to be the method fetchRecordsForColPos() in the ContentRepository.php. The result of the method fetchRecordsForColPos() is an array of uids with the same pid, colPos and language as my new record, so there will be UIDs in the result from other container elements with the same colPos, pid and language.

I have create a patch which also checks the field "tx_container_parent", so that we just get the child uids of the requested container element. With that patch, I have no issue translating container elements with maxitems anymore.

diff --git a/Classes/Repository/ContentRepository.php b/Classes/Repository/ContentRepository.php
index 81920c8..4f6536b 100644
--- a/Classes/Repository/ContentRepository.php
+++ b/Classes/Repository/ContentRepository.php
@@ -196,6 +196,10 @@ class ContentRepository
                 $queryBuilder->expr()->eq(
                     $languageField,
                     $queryBuilder->createNamedParameter($language[0], \PDO::PARAM_INT)
+                ),
+                $queryBuilder->expr()->eq(
+                    'tx_container_parent',
+                    $queryBuilder->createNamedParameter($record['tx_container_parent'], \PDO::PARAM_INT)
                 )
             )
             ->execute();

Inform the editor of an unintended list_type change

Following scenario in a real world project

  1. The TYPO3 instanced was initially developed and integrated in version 8.7 LTS.
  2. After the upgrade process to 9.5 LTS, ext:content_defender was integrated. One allowed list_type entry solr_pi_results was forgotten to set in the backend layout configuration. (I found that out today)
  3. A half year later an editor just edited the content element which exists already since before the upgrade process.
  4. The outcome is, that a) the list_type was changed (you get no message in the backend; you overlook it because it is displayed in a different tab) to another allowed list_type OR b) if you set TCEFORM.tt_content.list_type.disableNoMatchingValueElement = 1 then the content element get's updated to an empty list_type without informing the editor.

In both scenarios (maybe there are more) the frontend is broken and you can't revert it (even not with the history/rollback functionality).

Is there an approach how to intercept such scenarios? Or makes it sense to extend content_defender/core?

Didn't come up with a proper solution

Paste of CE with FAL references on wrong location leads to data doubling

System: TYPO3 10.4.10
contend_defender: 3.1.0
b13/bolt: 2.0.2
b13/container: 1.2.0

What I do: I copy a content element with FAL References from one page into another page into a position, where it doesn't belong, but not first position on page.

What happens:

  • The element does not appear on his new position (correct)
  • An error flash message pops up (correct, but I got 2 for one element, hard to read for an editor)
  • The original record gets all FAL references twice (Wrong)

Why does this happen (IMHO):

  • The insert of the new record is not stopped inside the DataHandler::processCmdmap_beforeStart it gets stopped inside the DataHandler::processDatamap_beforeStart so the copy of the references gets preprocessed but not postprocessed which leads to doubling the references on the source record.
  • The CmdmapDataHandlerHook doesn't support negative target ids (beside the DatamapDataHandlerHook does this) for inserting Data after a given record on target page. (Maybe this leads to #74 )
  • The newly introduced $backendLayoutConfiguration->getConfigurationByColPos gets the id of the source record and thinks it needs to handle this which leads to issues in b13/containers handling

What else may be wrong:

  • The BackendLayoutConfiguration::getConfigurationByColPos have a static cache on $columnConfiguration which holds configurations depending on $colPos but the result may also depend on $recordUid as this is a parameter for the hook manipulateConfiguration (Maybe the $recordId was meant as a hint/helper but b13/conteiner returns different results).

Content Column max doesn't work with copy - TYPO3 V9.5.11 and CD V3.0.11

If I restrict the max item count of a content column via the max attribut in my backend layout, every thing is fine as long as the client adds new content elements with the "new item" button. If the client try's to copy an allowed content element, the client is able to paste the element without any count restrictions. Debugging the extension code shows that in line 80 of CmdmapDataHandlerHook.php a backend layout for the pid of the element not of the page is loaded...assuming the variable $pageId definied in line 67, 70 and 74 should store the page id not the element pid. This results that the loaded config for the colPos in line 81 doesn't containing any item restriction for the column of the element.

I am using TYPO3 Version 9.5.11 and Content Defender 3.0.11.

Thanks for your help.

Cannot move records in "Languages" view with defLangBinding

When using the "Languages" view of the Page module with mod.web_layout.defLangBinding enabled, reordering content elements via drag and drop fails:

1: The record "<content title>" couldn't be saved due to disallowed value(s).

(Appears twice)

Evidently the following data is built in DragDrop.onDrop:

cmd[tt_content][254][move]: -10
data[tt_content][254][colPos]: false
data[tt_content][254][sys_language_uid]: NaN

(Here 10 is the UID of the content element after which the dragged element should be sorted)

It seems like these broken values are to be expected since they are the same on TYPO3v8 and on TYPO3v9. All DataHandler hooks will get a colPos of "false" (string) which makes all content elements invalid for any section, thus moving/reordering fails.

This works fine in the "Columns" view and with defLangBinding disabled however. In these cases the Page module has a quite different output which includes the necessary data-colpos and data-language-uid attributes.

So it might be necessary to take these values into account in the DataHandler hooks and always load the actual values from the dragged record instead.

(I cannot test with TYPO3v10 ATM since defLangBinding enabled makes all content elements disappear.)

Copy&Paste of container element with children

Our template has a number of container elements built with flux. The container elements are allowed inside the backend layout columns (e.g CType = xyz_sectioncontainer,xyz_teasercontainer) whereas basic elements like text, textpic, etc. are not allowed to be inserted directly into the content column. It works perfectly, except for the case when an editor tries to copy/paste a container to a new location. In this case only the container itself gets copied and for each of the children elements an error message "record couldn't be saved due to disallowed value(s)" appears.
image
An interesting observation - when the copied container is inserted before the original container, all works well; when after the original container the errors described above occur.
Thanks for looking into this and for your great work!

Not compatible with ext:workspaces

Given you have restricted a backend layout column to maxitems = 1, you won't be able to edit the containing CE record in a workspace.

It quits with:
image

The record "%s" couldn\'t be saved due to disallowed value(s).

The combination of restricted list_type and "normal" CType does not work as expected.

Allowed-Configuration
CType = div,list
list_type = news_pi1

At first time the normal-CE (div) is being created, the error does not show.
Since the second save the error appears.

TYPO3: 9.5.4
Content Defender: 3.0.9

colPos = 0 results in merged configuration

[TYPO3 9.5.17 | Content Defender 3.0.12]

What I did: Tried to create a "table" element in row 4 in BE.
What did I expect: Allowed to create a "table" element.
What happened: Only allowed to create a "teaser" or "list" element.
(only elements from row 1 column 2 are allowed)

In the following example, I configured columns for multiple rows.
Basically, it seems like configs getting merged.
I discovered that the issue only occurs if colPos = 0

Thanks in advance!


mod {
  web_layout {
    BackendLayouts {
      content {
        title = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:backend_layout.content
        config {
          backend_layout {
            colCount = 4
            rowCount = 4
            rows {

              1 {
                columns {

                  1 {
                    name = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf
                    colPos = 1
                    colspan = 2
                    allowed {
                      CType = html, div
                    }
                  }


                  2 {
                    name = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf
                    colPos = 0
                    colspan = 2
                    allowed {
                      CType = list, teaser
                    }
                  }
                }
              }

              2 {...}

              3 {...}

              4 {
                columns {

                  1 {
                    name = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf
                    colPos = 4
                    colspan = 4
                    allowed {
                      CType = text, table
                    }
                  }
                }

              }
            }
          }
        }
      }
    }
  }
}

TYPO3 cleanup:flexforms command fails with missing record

When executing the cleanup:flexforms TYPO3 command an error can occur in case a deleted tt_content row is processed:

typo3cms cleanup:flexforms

Updates all database records which have a FlexForm field and the XML data does not match the chosen datastructure.
==================================================================================================================

 ! [NOTE] Found 4 records with wrong FlexForms information.

Cleanup process starting now.
-----------------------------



  [ TYPO3\CMS\Core\Error\Exception ]
  Warning: array_merge(): Argument #1 is not an array in /.../typo3conf/ext/content_defender/Classes/Hooks/DatamapDataHandlerHook.php line 26


cleanup:flexforms [-p|--pid PID] [-d|--depth DEPTH] [--dry-run]

This happens because the CleanFlexFormsCommand also processes deleted rows which should be taken into account here.

TYPO3 v11 compatibility

  • An installation on TYPO3 v11.1 worked without problems.
  • The extension scanner in the TYPO3 backend does not show any messages.
  • The functionality is also given as far as I can tell - tested with b13/container and TYPO3 backend layouts

It would be wonderful if there was either a release or the dev-master (or something similar) was usable for now.

have a visual representation of maxitems

I think it would be nice to have a visualization next to a column that display the amount of content elements used in a column if one is using maxitems.
For example "1/5" if maxitems is 5 and there's currently 1 content element in the column.

Cannot save content elements with max items set to 1

Hallo,

there is a problem when I set the maxitems to 1 in the backend layout. Then the only content element for this colPos cannot be saved anymore and the following message is shown:

Sorry, you didn't have proper permissions to perform this change.

Maximum number of allowed content elements (1) reached. 1494605357

The problem only occurs if the maxitems is set to 1, when it is set to 2 I can add and save both content elements without any error.

If you need further information pls feel free to ask me πŸ˜€

Content Defender breaks for specific beLayout configuration

TYPO3 Version: 8.7 latest stable
EXT Version: 3.0.2

Steps to reproduce it

The following beLayout configuration makes EXT:content_defender working only partially

mod {
	web_layout {
		BackendLayouts {
			Default {
				title = LLL:EXT:theme/Resources/Private/Language/locallang_backendlayouts.xlf:default.title
				config {
					backend_layout {
						colCount = 12
						rowCount = 2
						rows {
							1 {
								columns {
									1 {
										name = LLL:EXT:theme/Resources/Private/Language/locallang_backendlayouts.xlf:col.sidebarDisabled
										colPos =
										colspan = 1
									}
									2 {
										name = LLL:EXT:theme/Resources/Private/Language/locallang_backendlayouts.xlf:col.mainBesideSidebar
										colPos = 5
										colspan = 11
										disallowed {
											CType = list, miniFactbox, miniYoutube, miniImage, themeproject_sidebarEvents, themeproject_whats_happening, fullwidthImage
										}
									}

								}
							}
							2 {
								columns {
									1 {
										name = LLL:EXT:theme/Resources/Private/Language/locallang_backendlayouts.xlf:col.main
										colPos = 0
										colspan = 12
										disallowed {
											CType = list, miniFactbox, miniYoutube, miniImage, themeproject_sidebarEvents, themeproject_whats_happening
										}
									}
								}
							}
						}
					}
				}
				icon = theme-belayout-sidebar-content
			}
		}
	}
}

Row 2 β†’ Column 1 (only one) β†’ colPos 0

... has no limitation.

Analysis of disallowed content

If content_defender is introduced at a later stage in a project, you will run into the situation where already used elements aren't allowed anymore, leading to #72

Feature Idea: Provide a BE Module / Info Page that provides a list of existing, but disallowed elements so they can be either allowed or migrated.

Limiting to single gridelement layout causes error

Hi

I found a bug using PHP 7.2, TYPO3 9.5.5, content_defender 3.0.10 and gridelements 9.1.1

When limiting a backend layout column to a single gridelement layout with

allowed {
  CType = gridelements_pi1
  tx_gridelements_backend_layout = IDENTIFIER
}

adding the gridelement causes an error.

TypeError
array_filter() expects parameter 1 to be array, null given

in PATH/typo3conf/ext/content_defender/Classes/Form/FormDataProvider/TcaCTypeItems.php line 50

Only the right gridelement layout is selctable, but when selecting it the Error ist thrown.

Without contentdefender this configuration works.

Thank you very much in advance.

Greetings Philipp

Add restriction for single list types

Currently you can just allow/disallow the "list" ctype as a whole. But if you want single plugins to be allowed, while the rest should be disallowed, this isn't possible right now.

This feature is currently missing from EXT:gridelements too. Here is a ticket about a possible integration with a colon syntax or something like "allowedListTypes".
https://forge.typo3.org/issues/77549

EXT:gridelements itself has a plugin from type "gridelements_pi1" with certain grid types (can be created and named individually). They can be restricted individually with "allowedGridTypes". Don't know how to deal with such cases, but it would be nice, to have some generic(?) way to handle those custom type restrictions.

The sorting of content is not working

As soon as i activate content_defender the rearranging/sorting of content elements/plugins with drag and drop isn't getting saved at all.

Experienced this behavior with content_defender 2.2.3 on TYPO3 7.6.21 and TYPO3 8.7.4

Cannot paste content elements with maxitems set to 1

Hello,

I'm using content_defender 3.1.3 with container 1.3.1 in TYPO3 10.4.19.
Gridelements, flux, fluid_pages, ... is not installed.

I have created a 2 col 50/50 container and a 4 col image|text|image|text container where only image CEs are allowed in image cols. While cut-paste an image CE from one col of 50/50 container into one of the image cols of my second container I get following error:

1: The command "paste" for record "" couldn't be executed due to reached maxitems configuration of 1.

Seems to be the same problem as #36 but instead of backend_layouts I'm using EXT:container.

Nice greetings

Stefan

Empty $result['databaseRow']['colPos'] array gets interpreted as 0

$colPos = (int)($result['databaseRow']['colPos'][0] ?? ($result['databaseRow']['colPos'] ?? 0));

This line causes issues with new IRRE inline elements that have for example a non existing colPos of 999.
If a inline child element is created, it will load all allowed CType values for colPos 0.

Before setting $colPos to 0, it should be checked if $result["processedTca"]["columns"]["colPos"]["config"]["default"] exists and if so,
$colPos should get the value.

A solution could look like this(this is probably doable with less code)

if (gettype($result['databaseRow']['colPos']) == 'array')
    $hasColPos = array_key_exists(0, $result['databaseRow']['colPos']);
else if (gettype($result['databaseRow']['colPos']) == 'int')
    $hasColPos = true;
else
    $hasColPos = false;

if (!$hasColPos) {
    $processedTcaTypeColPos = $result["processedTca"]["columns"]["colPos"]["config"]["default"] ?? false;
}

if (gettype($processedTcaTypeColPos) == 'string')
    $colPos = (int)$processedTcaTypeColPos;
else if (gettype($processedTcaTypeColPos) == 'integer')
    $colPos = $processedTcaTypeColPos;
else
    $colPos = (int)($result['databaseRow']['colPos'][0] ?? ($result['databaseRow']['colPos'] ?? 0));

Edit:
Steps to reproduce
This problem can be reproduced by creating an TCA inline element like this:

$GLOBALS['TCA']['tt_content']['columns']['text_tab_text_elements'] = [
    'config' => [
        'appearance' => [
            'collapseAll' => '1',
            'enabledControls' => [
                'dragdrop' => '1',
            ],
            'levelLinksPosition' => 'top',
            'showAllLocalizationLink' => '1',
            'showPossibleLocalizationRecords' => '1',
            'showSynchronizationLink' => '1',
            'useSortable' => '1',
        ],
        'foreign_sortby' => 'sorting',
        'foreign_table' => 'tt_content',
        'overrideChildTca' => [
            'columns' => [
                'colPos' => [
                    'config' => [
                        'default' => '999',
                    ],
                ],
                'CType' => [
                    'config' => [
                        'default' => 'text',
                    ],
                ],
            ],
        ],
        'type' => 'inline',
        'foreign_field' => 'text_tab_text_elements_parent',
    ],
    'exclude' => '1',
    'label' => 'LLL:EXT:sitepackage/Resources/Private/Language/Backend.xlf:text_tab_text_elements.label',
];

Then create a content element that is using this element.
After that try to add this content element to a page that has text elements disallowed on colPos 0.
Now creating child text elements inside the inline element is not working properly.

Typo3: ^10.4, ^11.5
Content Defender: ^3.2

Copy of records in columns with maxitems restrictions not possible

I have this backend layout:

mod {
    web_layout {
        BackendLayouts {
            contentPage {
                title = Defender test
                config {
                    backend_layout {
                        colCount = 1
                        rowCount = 3
                        rows {
                            1 {
                                columns {
                                    1 {
                                        name = Textmedia
                                        colPos = 1
                                        colspan = 1
                                        allowed.CType = textmedia
                                        maxitems = 1
                                    }
                                }
                            }
                            2 {
                                columns {
                                    1 {
                                        name = image
                                        colPos = 2
                                        colspan = 1
                                        allowed.CType = image
                                        maxitems = 1
                                    }
                                }
                            }
                            3 {
                                columns {
                                    1 {
                                        name = main
                                        colPos = 0
                                        colspan = 1
                                        allowed.CType = image,shortcut,textmedia,uploads
                                    }
                                }
                            }
                        }
                    }
                }
                icon = mimetypes-x-backend_layout
            }
        }
    }
}

When I try to copy an image element from main column to an empty image column, the element is not copied

Extensions stops page content from beeing reorderd in backend per drag & drop (Typo3 11.5.2)

Reordering page content is not working with ichhabrecht/content-defender:^3.2 and Typo3 ^11.5.0.

"Argument 2 passed to TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher::getPageIdByRecord() must be of the type int, array given, called in /var/www/html/public/typo3/sysext/backend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php on line 120"

PHP Warning: Undefined array key "colPos"

PHP Warning: Undefined array key "colPos" in /var/www/public/typo3conf/ext/content_defender/Classes/Hooks/DatamapDataHandlerHook.php line 51

This line
$colPos = (int)$incomingFieldArray['colPos'];

needs to be like this:

        $colPos = (int)(isset($incomingFieldArray['colPos']) ? $incomingFieldArray['colPos'] : 0);

Setup:
Typo3 v 11.5.4 in debug mode
php 8.0

Just try to create and save any content element.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.