Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Apr 26, 2017
2 parents c508466 + 9251e04 commit c4162cc
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 52 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ php:
matrix:
include:
- php: "7.0"
env: COVERAGE="YES" TYPO3_VERSION="8.5.*"
env: COVERAGE="YES" TYPO3_VERSION="8.7.*"
- php: "7.1"
env: COVERAGE="NO" TYPO3_VERSION="8.5.*"
env: COVERAGE="NO" TYPO3_VERSION="8.7.*"
- php: "7.0"
env: COVERAGE="NO" TYPO3_VERSION="dev-master"
env: COVERAGE="NO" TYPO3_VERSION="dev-master as 8.x-dev"
- php: "7.1"
env: COVERAGE="NO" TYPO3_VERSION="dev-master"
env: COVERAGE="NO" TYPO3_VERSION="dev-master as 8.x-dev"

cache:
directories:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Latest release: 5.1.0 (2017/03/04)
Latest release: 5.2.0 (2017/04/26)

All previous release change logs:

* [5.2.0 (2017/04/26)](Documentation/Changelog/5.2.0.md) [Full list of changes](https://github.com/FluidTYPO3/fluidcontent/compare/5.1.0...5.2.0)
* [5.1.0 (2017/03/04)](Documentation/Changelog/5.1.0.md) [Full list of changes](https://github.com/FluidTYPO3/fluidcontent/compare/5.0.0...5.1.0)
* [5.0.0 (2017/01/28)](Documentation/Changelog/5.0.0.md) [Full list of changes](https://github.com/FluidTYPO3/fluidcontent/compare/4.4.1...5.0.0)
* [4.4.1 (2016/03/02)](Documentation/Changelog/4.4.1.md) [Full list of changes](https://github.com/FluidTYPO3/fluidcontent/compare/4.4.0...4.4.1)
Expand Down
163 changes: 163 additions & 0 deletions Classes/Hooks/ContentIconUserFunction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?php
namespace FluidTYPO3\Fluidcontent\Hooks;

/*
* This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Utility\MiscellaneousUtility;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

/**
* Renders content type icons.
*/
class ContentIconUserFunction
{

/**
* @param array $parameters
* @return string
*/
public function getIcon(array $parameters)
{
$record = $parameters['row'];
if (empty($record)) {
// fast skip; this can happen for custom template-as-CType registrations. Icon delivered later in runtime.
return;
}

if ($record['CType'] !== 'fluidcontent_content') {
return $GLOBALS['TCA']['tt_content']['typeicon_classes'][$record['CType']];
}

$cacheId = 'content_icon_' . $record['CType'] . '_' . $record['uid'];

$iconIdentifierFromCache = $this->getIconFromCache($cacheId);
if ($iconIdentifierFromCache) {
return $iconIdentifierFromCache;
}

$field = $this->detectFirstFlexTypeFieldInTableFromPossibilities('tt_content', array_keys($record));
$provider = $this->getProviderResolver()->resolvePrimaryConfigurationProvider('tt_content', $field, $record);
if (!$provider) {
return '';
}

$form = $provider->getForm($parameters['row']);
if (!$form) {
return '';
}

$icon = MiscellaneousUtility::getIconForTemplate($form);
if (0 === strpos($icon, 'EXT:')) {
$icon = GeneralUtility::getFileAbsFileName($icon);
} elseif ('/' === $icon[0]) {
$icon = rtrim(PATH_site, '/') . $icon;
}
$iconIdentifier = null;
if (!file_exists($icon)) {
return 'apps-pagetree-root';
}
$extension = pathinfo($icon, PATHINFO_EXTENSION);
switch (strtolower($extension)) {
case 'svg':
case 'svgz':
$iconProvider = SvgIconProvider::class;
break;
default:
$iconProvider = BitmapIconProvider::class;
}
$iconIdentifier = 'icon-flux-' . $form->getId();
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
$iconRegistry->registerIcon($iconIdentifier, $iconProvider, ['source' => $icon]);
$this->storeIconMetadataInCache(
$cacheId,
[
'identifier' => $iconIdentifier,
'provider' => $iconProvider,
'configuration' => [
'source' => $icon
]
]
);
return $iconIdentifier;
}

/**
* @param string $identifier
* @return string
*/
protected function getIconFromCache($identifier)
{
$entry = $this->getCache()->get($identifier);
if (!$entry) {
return '';
}
$iconIdentifier = $entry['identifier'];
if (!empty($entry['provider'])) {
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
$iconRegistry->registerIcon($iconIdentifier, $entry['provider'], $entry['configuration']);
}
return $iconIdentifier;
}

/**
* @param string $table
* @param array $fields
* @return string
*/
protected function detectFirstFlexTypeFieldInTableFromPossibilities($table, $fields)
{
foreach ($fields as $fieldName) {
if ('flex' === $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['type']) {
return $fieldName;
}
}
return null;
}

/**
* @param string $identifier
* @param array $iconMetadata
*/
protected function storeIconMetadataInCache($identifier, array $iconMetadata)
{
$this->getCache()->set($identifier, $iconMetadata);
}

/**
* @return VariableFrontend
*/
protected function getCache()
{
$objectManager = $this->getObjectManager();
return $objectManager->get(CacheManager::class, $objectManager)->getCache('flux');
}

/**
* @return ProviderResolver
*/
protected function getProviderResolver()
{
return $this->getObjectManager()->get(ProviderResolver::class);
}

/**
* @return ObjectManager
*/
protected function getObjectManager()
{
return GeneralUtility::makeInstance(ObjectManager::class);
}

}
34 changes: 14 additions & 20 deletions Classes/Service/ConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ class ConfigurationService extends FluxService implements SingletonInterface
*/
protected $manager;

/**
* @var PageRepository
*/
protected $pageRepository;

/**
* @var WorkspacesAwareRecordService
*/
Expand Down Expand Up @@ -89,15 +84,6 @@ public function injectRecordService(WorkspacesAwareRecordService $recordService)
$this->recordService = $recordService;
}

/**
* @param PageRepository $pageRepository
* @return void
*/
public function injectPageRepository(PageRepository $pageRepository)
{
$this->pageRepository = $pageRepository;
}

/**
* Constructor
*/
Expand Down Expand Up @@ -268,7 +254,7 @@ protected function getAllRootTypoScriptTemplates()
*/
protected function getTypoScriptTemplatesInRootline()
{
$rootline = $this->pageRepository->getRootLine($this->configurationManager->getCurrentPageId());
$rootline = $this->getPageRepository()->getRootLine($this->configurationManager->getCurrentPageId());
$pageUids = [];
foreach ($rootline as $page) {
$pageUids[] = $page['uid'];
Expand Down Expand Up @@ -307,12 +293,12 @@ protected function buildAllWizardTabGroups()
continue;
}
$sanitizedGroup = $this->sanitizeString($group);
$tabId = $group === $sanitizedGroup ? $group : 'group_' . $sanitizedGroup;
$tabId = $group === $sanitizedGroup ? $group : 'group' . $sanitizedGroup;
if (!isset($wizardTabs[$tabId]['title'])) {
$wizardTabs[$tabId]['title'] = $this->translateLabel(
'fluidcontent.newContentWizard.group.' . $group,
ExtensionNamingUtility::getExtensionKey($extensionKey)
) ?? $tabId;
) ?? $group;
}
$contentElementId = $form->getOption('contentElementId');
$elementTsConfig = $this->buildWizardTabItem($tabId, $id, $form, $contentElementId);
Expand Down Expand Up @@ -432,7 +418,7 @@ protected function buildAllWizardTabsPageTsConfig($wizardTabs)
mod.wizards.newContentElement.wizardItems.%s.position = 0
',
$tabId,
!empty($existingItems[$tabId]['header']) ? $existingItems[$tabId]['header'] : $tabId,
!empty($existingItems[$tabId]['header']) ? $existingItems[$tabId]['header'] : $tab['title'],
$tabId,
implode(',', array_keys($tab['elements'])),
$tabId
Expand Down Expand Up @@ -541,8 +527,8 @@ protected function buildWizardTabItem($tabId, $id, $form, $templateFileIdentity)
protected function sanitizeString($string)
{
$pattern = '/([^a-z0-9\-]){1,}/i';
$replaced = preg_replace($pattern, '_', $string);
$replaced = trim($replaced, '_');
$replaced = preg_replace($pattern, '', $string);
$replaced = trim($replaced);
return empty($replaced) ? md5($string) : $replaced;
}

Expand Down Expand Up @@ -600,4 +586,12 @@ protected function getTypoScriptParser()
{
return new TypoScriptParser();
}

/**
* @return PageRepository
*/
protected function getPageRepository()
{
return $this->objectManager->get(PageRepository::class);
}
}
18 changes: 18 additions & 0 deletions Documentation/Changelog/5.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Release: 5.2.0 (2017/04/26)

* 2017-04-25 [FEATURE] Support TYPO3 8.7 LTS (#404) (Commit 4f14596 by Cedric Ziel)
* 2017-04-07 [BUGFIX] Support spaces in group name (#403) (Commit 7050c13 by DA COSTA Filipe)
* 2017-04-03 [BUGFIX] Avoid injecting non-singleton class (Commit 56a5b29 by Claus Due)

Generated by:

```
git log --since="2017/03/04" --until="2017/04/26" --abbrev-commit --pretty='%ad %s (Commit %h by %an)' \
--date=short | egrep '(\[FEATURE|BUGFIX|REMOVAL\])+'`
```

Full list of changes: https://github.com/FluidTYPO3/fluidcontent/compare/5.1.0...5.2.0

*Please note: the change list above does not contain any TASK commits since they are considered
infrastructure-only and not relevant to end users. The full list includes these!*

4 changes: 2 additions & 2 deletions Tests/Unit/Backend/TableConfigurationPostProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

use FluidTYPO3\Fluidcontent\Backend\TableConfigurationPostProcessor;
use FluidTYPO3\Fluidcontent\Service\ConfigurationService;
use TYPO3\CMS\Core\Tests\UnitTestCase;
use FluidTYPO3\Development\AbstractTestCase;

/**
* Class TableConfigurationPostProcessorTest
*/
class TableConfigurationPostProcessorTest extends UnitTestCase
class TableConfigurationPostProcessorTest extends AbstractTestCase
{

/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Controller/ContentControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
*/

use FluidTYPO3\Fluidcontent\Controller\ContentController;
use FluidTYPO3\Development\AbstractTestCase;
use FluidTYPO3\Flux\Configuration\ConfigurationManager;
use FluidTYPO3\Flux\View\ExposedTemplateView;
use TYPO3\CMS\Core\Tests\UnitTestCase;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Reflection\PropertyReflection;

/**
* Class ContentControllerTest
*/
class ContentControllerTest extends UnitTestCase
class ContentControllerTest extends AbstractTestCase
{

public function testInitializeView()
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Hooks/WizardItemsHookSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use FluidTYPO3\Fluidcontent\Hooks\WizardItemsHookSubscriber;
use FluidTYPO3\Fluidcontent\Service\ConfigurationService;
use FluidTYPO3\Development\AbstractTestCase;
use FluidTYPO3\Flux\Form\Container\Column;
use FluidTYPO3\Flux\Form\Container\Grid;
use FluidTYPO3\Flux\Form\Container\Row;
Expand All @@ -19,14 +20,13 @@
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\PreparedStatement;
use TYPO3\CMS\Core\Tests\UnitTestCase;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

/**
* Class WizardItemsHookSubscriberTest
*/
class WizardItemsHookSubscriberTest extends UnitTestCase
class WizardItemsHookSubscriberTest extends AbstractTestCase
{

public function testCreatesInstance()
Expand Down
7 changes: 2 additions & 5 deletions Tests/Unit/Provider/ContentProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

use FluidTYPO3\Fluidcontent\Provider\ContentProvider;
use FluidTYPO3\Fluidcontent\Service\ConfigurationService;
use FluidTYPO3\Flux\Configuration\BackendConfigurationManager;
use FluidTYPO3\Flux\Configuration\ConfigurationManager;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Development\AbstractTestCase;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\PreparedStatement;
use TYPO3\CMS\Core\Tests\UnitTestCase;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand All @@ -25,7 +22,7 @@
/**
* Class ContentProviderTest
*/
class ContentProviderTest extends UnitTestCase
class ContentProviderTest extends AbstractTestCase
{

/**
Expand Down
Loading

0 comments on commit c4162cc

Please sign in to comment.