Commit b41ed06d authored by Benni Mack's avatar Benni Mack
Browse files

Merge branch 'T3DEMO-265' into 'main'

[TASK] Clean up backend preview warnings

See merge request !10
parents 04e18905 c20f1ba7
Pipeline #10117 passed with stages
in 6 minutes and 39 seconds
......@@ -56,12 +56,15 @@ class DrawItemDefault implements PageLayoutViewDrawItemHookInterface
// return all sys_file_reference rows
if ($row['assets']) {
$row['allAssets'] = \B13\SiteT3demo\Service\FilereferenceService::resolveFilereferences('assets', 'tt_content', $row['uid']);
$row['allAssets-numberOfVisibleItems'] = \B13\SiteT3demo\Service\FilereferenceService::countNumberOfVisibleFilereferences('assets', 'tt_content', $row['uid']);
}
if ($row['media']) {
$row['allMedia'] = \B13\SiteT3demo\Service\FilereferenceService::resolveFilereferences('media', 'tt_content', $row['uid']);
$row['allMedia-numberOfVisibleItems'] = \B13\SiteT3demo\Service\FilereferenceService::countNumberOfVisibleFilereferences('media', 'tt_content', $row['uid']);
}
if ($row['image']) {
$row['allImages'] = \B13\SiteT3demo\Service\FilereferenceService::resolveFilereferences('image', 'tt_content', $row['uid']);
$row['allImages-numberOfVisibleItems'] = \B13\SiteT3demo\Service\FilereferenceService::countNumberOfVisibleFilereferences('image', 'tt_content', $row['uid']);
}
}
......
......@@ -15,6 +15,7 @@ namespace B13\SiteT3demo\Service;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class FilereferenceService
......@@ -60,6 +61,25 @@ class FilereferenceService
return $references;
}
public static function countNumberOfVisibleFilereferences($field, $table, $uid)
{
$queryBuilder = self::getQueryBuilder('sys_file_reference');
$queryBuilder->getRestrictions()
->add(GeneralUtility::makeInstance(HiddenRestriction::class));
$references = $queryBuilder
->count('uid')
->from('sys_file_reference')
->orderBy('sorting_foreign')
->where(
$queryBuilder->expr()->eq('uid_foreign', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)),
$queryBuilder->expr()->eq('tablenames', $queryBuilder->createNamedParameter($table)),
$queryBuilder->expr()->eq('fieldname', $queryBuilder->createNamedParameter($field))
)
->execute()
->fetchColumn();
return $references;
}
protected static function getQueryBuilder(string $table): QueryBuilder
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
......
......@@ -5,32 +5,24 @@
<a href="{editLink.url -> f:format.raw()}" title="{editLink.title}">
<strong><f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:CType.contentstage.name" /></strong><br>
<f:if condition="{allImages}">
<f:variable name="numberOfMediaAssets" value="{allImages -> f:count()}" />
<f:variable name="numberOfVisibleImages" value="0" />
<f:for each="{allImages}" as="image">
<f:if condition="!{image.hidden}">
<f:variable name="imageIsVisible" value="true" />
<f:variable name="numberOfVisibleImages" value="{numberOfVisibleImages + 1}" />
</f:if>
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{numberOfMediaAssets} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
</f:if>
<f:for each="{allImages}" as="image">
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{allImages-numberOfVisibleItems} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
<f:if condition="{link}">
<br>
<strong>CTA: </strong>{linklabel} (Link to {f:uri.typolink(parameter: link, absolute: true)})
</f:if>
<f:if condition="!{imageIsVisible} && !{hidden}">
<f:if condition="!{allImages-numberOfVisibleItems} && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.noImageVisible" /></strong></p>
</f:if>
<f:if condition="{numberOfVisibleImages} > 1 && !{hidden}">
<f:if condition="{allImages-numberOfVisibleItems} > 1 && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.onlyFirstImageInUse" /></strong></p>
</f:if>
......
......@@ -5,20 +5,12 @@
<a href="{editLink.url -> f:format.raw()}" title="{editLink.title}">
<strong><f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:CType.keyvisual.name" /></strong><br>
<f:if condition="{allImages}">
<f:variable name="numberOfMediaAssets" value="{allImages -> f:count()}" />
<f:variable name="numberOfVisibleImages" value="0" />
<f:for each="{allImages}" as="image">
<f:if condition="!{image.hidden}">
<f:variable name="imageIsVisible" value="true" />
<f:variable name="numberOfVisibleImages" value="{numberOfVisibleImages + 1}" />
</f:if>
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{numberOfMediaAssets} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
</f:if>
<f:for each="{allImages}" as="image">
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{allImages-numberOfVisibleItems} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
<br>
{bodytext_processed -> f:format.raw()}
......@@ -28,12 +20,12 @@
<strong>CTA: </strong>{linklabel} (Link to {f:uri.typolink(parameter: link, absolute: true)})
</f:if>
<f:if condition="!{imageIsVisible} && !{hidden}">
<f:if condition="!{allImages-numberOfVisibleItems} && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.noImageVisible" /></strong></p>
</f:if>
<f:if condition="{numberOfVisibleImages} > 1 && !{hidden}">
<f:if condition="{allImages-numberOfVisibleItems} > 1 && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.onlyFirstImageInUse" /></strong></p>
</f:if>
......
......@@ -4,32 +4,25 @@
>
<a href="{editLink.url -> f:format.raw()}" title="{editLink.title}">
<strong><f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:CType.mainteaser.name" /></strong><br>
<f:if condition="{allImages}">
<f:variable name="numberOfMediaAssets" value="{allImages -> f:count()}" />
<f:variable name="numberOfVisibleImages" value="0" />
<f:for each="{allImages}" as="image">
<f:if condition="!{image.hidden}">
<f:variable name="imageIsVisible" value="true" />
<f:variable name="numberOfVisibleImages" value="{numberOfVisibleImages + 1}" />
<f:for each="{allImages}" as="image">
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{allImages-numberOfVisibleItems} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" />
<f:image src="{image.uid}" height="64" treatIdAsReference="1" cropVariant="desktop"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" />
<f:image src="{image.uid}" height="64" treatIdAsReference="1" cropVariant="desktop-xl"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
<f:if condition="{image.description}">
<f:then>
{image.description}
</f:then>
<f:else if="{image.originalFileMetaData.description}">
{image.originalFileMetaData.description}
</f:else>
</f:if>
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{numberOfMediaAssets} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" />
<f:image src="{image.uid}" height="64" treatIdAsReference="1" cropVariant="desktop"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" />
<f:image src="{image.uid}" height="64" treatIdAsReference="1" cropVariant="desktop-xl"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
<f:if condition="{image.description}">
<f:then>
{image.description}
</f:then>
<f:else if="{image.originalFileMetaData.description}">
{image.originalFileMetaData.description}
</f:else>
</f:if>
</span>
</f:for>
</f:if>
</span>
</f:for>
<br>
{bodytext -> f:format.raw()}
......@@ -39,11 +32,11 @@
<strong>Link to {f:uri.typolink(parameter: link, absolute: true)}</strong>
</f:if>
<f:if condition="!{imageIsVisible} && !{hidden}">
<f:if condition="!{allImages-numberOfVisibleItems} && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.noImageVisible" /></strong></p>
</f:if>
<f:if condition="{numberOfVisibleImages} > 1 && !{hidden}">
<f:if condition="{allImages-numberOfVisibleItems} > 1 && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.onlyFirstImageInUse" /></strong></p>
</f:if>
......
......@@ -5,32 +5,19 @@
<a href="{editLink.url -> f:format.raw()}" title="{editLink.title}">
<strong><f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:CType.textpic.name" /></strong><br>
<f:if condition="{allImages}">
<f:variable name="numberOfMediaAssets" value="{allImages -> f:count()}" />
<f:variable name="numberOfVisibleImages" value="0" />
<f:for each="{allImages}" as="image">
<f:if condition="!{image.hidden}">
<f:variable name="imageIsVisible" value="true" />
<f:variable name="numberOfVisibleImages" value="{numberOfVisibleImages + 1}" />
</f:if>
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{numberOfMediaAssets} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
</f:if>
<f:for each="{allImages}" as="image">
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{allImages-numberOfVisibleItems} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{image.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
<f:if condition="{bodytext}">
<br>
{bodytext -> f:format.raw()}
</f:if>
<f:if condition="!{imageIsVisible} && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.noImageVisible" /></strong></p>
</f:if>
<f:if condition="{numberOfVisibleImages} > 1 && !{hidden}">
<f:if condition="{allImages-numberOfVisibleItems} > 1 && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.onlyFirstImageInUse" /></strong></p>
</f:if>
......
......@@ -5,37 +5,22 @@
<a href="{editLink.url -> f:format.raw()}" title="{editLink.title}">
<strong><f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:CType.textmedia.name" /></strong><br>
<f:if condition="{allAssets}">
<f:variable name="numberOfMediaAssets" value="{allAssets -> f:count()}" />
<f:variable name="numberOfVisibleAssets" value="0" />
<f:for each="{allAssets}" as="media">
<f:if condition="!{media.hidden}">
<f:variable name="mediaIsVisible" value="true" />
<f:variable name="numberOfVisibleAssets" value="{numberOfVisibleAssets + 1}" />
</f:if>
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{numberOfMediaAssets} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{media.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
</f:if>
<f:for each="{allAssets}" as="media">
<span class="b_ce__thumbnail-wrapper {f:if(condition: '{allAssets-numberOfVisibleItems} > 1', else: 'b_ce__thumbnail-wrapper--single')}">
<f:image src="{media.uid}" height="64" treatIdAsReference="1"
class="b_ce__thumbnail {f:if(condition:image.hidden, then: 'b_ce__thumbnail--hidden')}" /><br>
</span>
</f:for>
<f:if condition="{bodytext}">
<br>
{bodytext -> f:format.raw()}
</f:if>
<f:if condition="!{mediaIsVisible} && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.noAssetVisible" /></strong></p>
</f:if>
<f:if condition="{numberOfVisibleAssets} > 1 && !{hidden}">
<f:if condition="{allAssets-numberOfVisibleItems} > 1 && !{hidden}">
<p><strong class="b_ce__warning"><core:icon identifier="exclamation-circle" size="small" />
<f:translate key="LLL:EXT:site_t3demo/Resources/Private/Language/locallang_db.xlf:pageLayoutView.onlyFirstAssetInUse" /></strong></p>
</f:if>
</a>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment