Skip to content

Commit

Permalink
[TASK] Drop icons for categories
Browse files Browse the repository at this point in the history
Fixes #3370
  • Loading branch information
oliverklee committed Oct 4, 2024
1 parent ffeda55 commit 739f36a
Show file tree
Hide file tree
Showing 21 changed files with 14 additions and 461 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Removed

- Drop icons for categories (#3777)
- Drop unused BE route configuration file (#3742)
- Remove the FE editor (#3685, #3686)
- Drop `RegistrationManager::existsSeminar()`/`::existsSeminarMessage()` (#3629)
Expand Down
14 changes: 0 additions & 14 deletions Classes/Configuration/ListViewConfigurationCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ protected function checkAllConfigurationValues(): void
$this->checkLimitListViewToCategories();
$this->checkLimitListViewToPlaces();
$this->checkLimitListViewToOrganizers();
$this->checkCategoryIconDisplay();
$this->checkSeminarImageSizesForListView();
$this->checkDisplaySearchFormFields();
$this->checkNumberOfYearsInDateFilter();
Expand Down Expand Up @@ -208,19 +207,6 @@ private function checkLimitListViewToOrganizers(): void
);
}

/**
* @deprecated will be removed in version 6.0.0 in #3370
*/
private function checkCategoryIconDisplay(): void
{
$this->checkIfSingleInSetNotEmpty(
'categoriesInListView',
'This setting determines whether the seminar category is shown, as icon and text,
as text only or as icon only. If this value is not set correctly, the category will only be shown as text.',
['both', 'text', 'icon']
);
}

/**
* Checks the settings for the image width and height in the list view.
*/
Expand Down
57 changes: 4 additions & 53 deletions Classes/FrontEnd/CategoryList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use OliverKlee\Seminars\BagBuilder\CategoryBagBuilder;
use OliverKlee\Seminars\BagBuilder\EventBagBuilder;
use OliverKlee\Seminars\OldModel\LegacyCategory;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -97,11 +96,7 @@ public function createLinkToListViewLimitedByCategory(int $categoryUid, string $
/**
* Creates the list of categories for the event list view.
*
* Depending on the configuration value, categoriesInListView returns
* either only the titles as comma-separated list, only the icons with the
* title as title attribute or both.
*
* @param array<int, array{title: string, icon: FileReference|null}> $categoriesToDisplay
* @param array<int, array{title: string}> $categoriesToDisplay
*
* @return string the HTML output, will be empty if $categoriesToDisplay is empty
*/
Expand All @@ -111,56 +106,12 @@ public function createCategoryList(array $categoriesToDisplay): string
return '';
}

$categoryUidsFromConfiguration = $this->getConfValueString('categoriesInListView', 's_listView');
$allCategoryLinks = [];
$categorySeparator = ($categoryUidsFromConfiguration !== 'icon') ? ', ' : ' ';

foreach ($categoriesToDisplay as $uid => $categoryData) {
$linkValue = '';
switch ($categoryUidsFromConfiguration) {
case 'both':
// @deprecated will be removed in version 6.0.0 in #3370
if ($categoryData['icon'] instanceof FileReference) {
$linkValue = $this->createCategoryIconImage($categoryData) . '&nbsp;';
}
$linkValue .= \htmlspecialchars($categoryData['title'], ENT_QUOTES | ENT_HTML5);
break;
case 'icon':
// @deprecated will be removed in version 6.0.0 in #3370
$linkValue = $this->createCategoryIconImage($categoryData);
if ($linkValue === '') {
$linkValue = \htmlspecialchars($categoryData['title'], ENT_QUOTES | ENT_HTML5);
$categorySeparator = ', ';
}
break;
default:
$linkValue = \htmlspecialchars($categoryData['title'], ENT_QUOTES | ENT_HTML5);
}
$allCategoryLinks[] = $this->createLinkToListViewLimitedByCategory($uid, $linkValue);
$linkText = \htmlspecialchars($categoryData['title'], ENT_QUOTES | ENT_HTML5);
$allCategoryLinks[] = $this->createLinkToListViewLimitedByCategory($uid, $linkText);
}

return implode($categorySeparator, $allCategoryLinks);
}

/**
* Creates the category icon with the icon title as alt text.
*
* @param array{title: string, icon: FileReference|null} $iconData
*
* @return string the icon tag with the given icon, will be empty if no icon was given
*
* @deprecated will be removed in version 6.0.0 in #3370
*/
private function createCategoryIconImage(array $iconData): string
{
$icon = $iconData['icon'];
if (!$icon instanceof FileReference) {
return '';
}

$imageConfiguration = ['file' => $icon->getPublicUrl(), 'titleText' => $iconData['title']];
$imageWithoutClass = $this->cObj->cObjGetSingle('IMAGE', $imageConfiguration);

return \str_replace('<img ', '<img class="category_image" ', $imageWithoutClass);
return \implode(', ', $allCategoryLinks);
}
}
24 changes: 1 addition & 23 deletions Classes/FrontEnd/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,9 @@ private function setCategoriesMarker(): void
}

$categoryMarker = '';
$this->setMarker('category_icon', '');
foreach ($this->seminar->getCategories() as $category) {
$this->setMarker('category_title', \htmlspecialchars($category['title'], ENT_QUOTES | ENT_HTML5));
// @deprecated will be removed in version 6.0.0 in #3370
$this->setMarker('category_icon', $this->createCategoryIconImage($category));
$categoryMarker .= $this->getSubpart('SINGLE_CATEGORY');
}
$this->setSubpart('SINGLE_CATEGORY', $categoryMarker);
Expand Down Expand Up @@ -2140,27 +2139,6 @@ private function hideColumnsForAllViewsFromTypoScriptSetup(): void
$this->hideColumns($columns);
}

/**
* Creates the category icon IMG tag with the icon title as title attribute.
*
* @param array{title: string, icon: FileReference|null} $iconData
*
* @return string the icon IMG tag with the given icon, will be empty if the category has no icon
*
* @deprecated will be removed in version 6.0.0 in #3370
*/
private function createCategoryIconImage(array $iconData): string
{
$icon = $iconData['icon'];
if (!$icon instanceof FileReference) {
return '';
}

$imageConfiguration = ['file' => $icon->getPublicUrl(), 'titleText' => $iconData['title']];

return $this->cObj->cObjGetSingle('IMAGE', $imageConfiguration);
}

/**
* Sets a heading for speakers, tutors, leaders or partners,
* depending on the speakers, tutors, leaders or partners belonging to the current seminar.
Expand Down
31 changes: 0 additions & 31 deletions Classes/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,6 @@ public function getTitle(): string
return $this->getAsString('title');
}

/**
* @return string the file name of the icon (relative to the extension
* upload path) of the category, will be empty if the
* category has no icon
*
* @deprecated will be removed in version 6.0.0 in #3370
*/
public function getIcon(): string
{
return $this->getAsString('icon');
}

/**
* @param string $icon the file name of the icon (relative to the extension upload path) of the category,
* may be empty
*
* @deprecated will be removed in version 6.0.0 in #3370
*/
public function setIcon(string $icon): void
{
$this->setAsString('icon', $icon);
}

/**
* @deprecated will be removed in version 6.0.0 in #3370
*/
public function hasIcon(): bool
{
return $this->hasString('icon');
}

/**
* @return int the single view page, will be 0 if none has been set
*/
Expand Down
24 changes: 0 additions & 24 deletions Classes/OldModel/LegacyCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace OliverKlee\Seminars\OldModel;

use TYPO3\CMS\Core\Resource\FileReference;

/**
* This class represents an event category.
*/
Expand All @@ -15,26 +13,4 @@ class LegacyCategory extends AbstractModel
* @var string the name of the SQL table this class corresponds to
*/
protected static string $tableName = 'tx_seminars_categories';

/**
* @deprecated will be removed in version 6.0.0 in #3370
*/
public function hasIcon(): bool
{
return $this->hasRecordPropertyInteger('icon');
}

/**
* @deprecated will be removed in version 6.0.0 in #3370
*/
public function getIcon(): ?FileReference
{
if (!$this->hasIcon()) {
return null;
}

$images = $this->getFileRepository()->findByRelation('tx_seminars_categories', 'icon', $this->getUid());

return \array_shift($images);
}
}
5 changes: 2 additions & 3 deletions Classes/OldModel/LegacyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3113,7 +3113,7 @@ public function getNumberOfCategories(): int
* Gets this event's category titles and icons as an associative
* array (which may be empty), using the category UIDs as keys.
*
* @return array<int, array{title: string, icon: FileReference|null}>
* @return array<int, array{title: string}>
*/
public function getCategories(): array
{
Expand All @@ -3127,8 +3127,7 @@ public function getCategories(): array

$result = [];
foreach ($builder->build() as $category) {
// @deprecated icons will be removed in version 6.0.0 in #3370
$result[$category->getUid()] = ['title' => $category->getTitle(), 'icon' => $category->getIcon()];
$result[$category->getUid()] = ['title' => $category->getTitle()];
}

return $result;
Expand Down
32 changes: 0 additions & 32 deletions Configuration/FlexForms/flexforms_pi1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -374,38 +374,6 @@
</config>
</TCEforms>
</showOnlyEventsWithVacancies>
<categoriesInListView>
<TCEforms>
<exclude>1</exclude>
<!-- @deprecated will be removed in version 6.0.0 in #3370 -->
<label>LLL:EXT:seminars/Resources/Private/Language/locallang.xlf:seminars.pi_flexform.categoriesInListView</label>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:seminars/Resources/Private/Language/locallang.xlf:seminars.pi_flexform.fromTsSetup</numIndex>
<numIndex index="1"></numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">LLL:EXT:seminars/Resources/Private/Language/locallang.xlf:seminars.pi_flexform.iconAndText</numIndex>
<numIndex index="1">both</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:seminars/Resources/Private/Language/locallang.xlf:seminars.pi_flexform.iconOnly</numIndex>
<numIndex index="1">icon</numIndex>
</numIndex>
<numIndex index="3" type="array">
<numIndex index="0">LLL:EXT:seminars/Resources/Private/Language/locallang.xlf:seminars.pi_flexform.textOnly</numIndex>
<numIndex index="1">text</numIndex>
</numIndex>
</items>
<size>1</size>
<minitems>0</minitems>
<maxitems>1</maxitems>
</config>
</TCEforms>
</categoriesInListView>
<linkToSingleView>
<TCEforms>
<exclude>1</exclude>
Expand Down
25 changes: 1 addition & 24 deletions Configuration/TCA/tx_seminars_categories.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

return [
Expand All @@ -25,27 +23,6 @@
'eval' => 'required,trim',
],
],
// @deprecated will be removed in version 6.0.0 in #3370
'icon' => [
'exclude' => 1,
'label' => 'LLL:EXT:seminars/Resources/Private/Language/locallang_db.xlf:tx_seminars_categories.icon',
'config' => ExtensionManagementUtility::getFileFieldTCAConfig(
'icon',
[
'maxitems' => 1,
'appearance' => [
'collapseAll' => true,
'expandSingle' => true,
'useSortable' => false,
'enabledControls' => [
'sort' => false,
'hide' => false,
],
'fileUploadAllowed' => true,
],
]
),
],
'single_view_page' => [
'exclude' => 1,
'label' => 'LLL:EXT:seminars/Resources/Private/Language/locallang_db.xlf:tx_seminars_categories.single_view_page',
Expand All @@ -60,6 +37,6 @@
],
],
'types' => [
'0' => ['showitem' => 'title, icon, single_view_page'],
'0' => ['showitem' => 'title, single_view_page'],
],
];
4 changes: 0 additions & 4 deletions Configuration/TypoScript/FrontEnd.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ plugin.tx_seminars_pi1 {
# the normal sorting)
sortListViewByCategory = 0

# how to display the categories in the event list view: icon, text, both
# @deprecated will be removed in version 6.0.0 in #3370
categoriesInListView = both

# whether to use the label "Price" as column header for the standard price (instead of "Standard price")
generalPriceInList = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,6 @@ override the corresponding value from TS Setup.**
0


.. container:: table-row

Property
categoriesInListView

Data type
string

Description
whether to show only the category title, only the category icon or
both. Allowed values are: icon, text, both

Default
both


.. container:: table-row

Property
Expand Down
16 changes: 0 additions & 16 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -675,22 +675,6 @@ This event now has been confirmed.</source>
<trans-unit id="seminars.pi_flexform.showRegistrationFieldsInRegistrationList" resname="seminars.pi_flexform.showRegistrationFieldsInRegistrationList">
<source>Which registration fields to show in the list of registrations for an event:</source>
</trans-unit>
<!-- @deprecated will be removed in version 6.0.0 in #3370 -->
<trans-unit id="seminars.pi_flexform.categoriesInListView" resname="seminars.pi_flexform.categoriesInListView">
<source>Display of the categories:</source>
</trans-unit>
<!-- @deprecated will be removed in version 6.0.0 in #3370 -->
<trans-unit id="seminars.pi_flexform.iconAndText" resname="seminars.pi_flexform.iconAndText">
<source>Icons and text</source>
</trans-unit>
<!-- @deprecated will be removed in version 6.0.0 in #3370 -->
<trans-unit id="seminars.pi_flexform.iconOnly" resname="seminars.pi_flexform.iconOnly">
<source>Icons only</source>
</trans-unit>
<!-- @deprecated will be removed in version 6.0.0 in #3370 -->
<trans-unit id="seminars.pi_flexform.textOnly" resname="seminars.pi_flexform.textOnly">
<source>Text only</source>
</trans-unit>
<trans-unit id="seminars.pi_flexform.linkToSingleView" resname="seminars.pi_flexform.linkToSingleView">
<source>Link the single view from the list view:</source>
</trans-unit>
Expand Down
Loading

0 comments on commit 739f36a

Please sign in to comment.