Skip to content

Commit

Permalink
[FEATURE] Add BackendPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaseberle committed Nov 6, 2020
1 parent 2234756 commit 381bb74
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 35 deletions.
19 changes: 14 additions & 5 deletions Classes/Service/ConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Sci\SciApi\Constants;
use Sci\SciApi\Validator\ContentBlockValidator;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Yaml\Yaml;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
Expand Down Expand Up @@ -53,10 +54,10 @@ protected static function configurationUncached(): array
return $contentBlockConfiguration;
}

protected static function configurationForContentBlock(\Symfony\Component\Finder\SplFileInfo $splPath): array
protected static function configurationForContentBlock(SplFileInfo $splPath): array
{
// directory paths (full)
$realPath = $splPath->getRealPath() . DIRECTORY_SEPARATOR;
$realPath = $splPath->getPathname() . DIRECTORY_SEPARATOR;
$languageRealPath = $realPath . 'src' . DIRECTORY_SEPARATOR . 'Language' . DIRECTORY_SEPARATOR;

// directory paths (relative to publicPath())
Expand Down Expand Up @@ -87,7 +88,7 @@ protected static function configurationForContentBlock(\Symfony\Component\Finder
if (!is_readable($editorInterfaceYamlPath)) {
throw new \Exception($editorInterfaceYamlPath . ' not found');
}
$editorInterfaceYaml = Yaml::parseFile($editorInterfaceYamlPath);
$editorInterface = Yaml::parseFile($editorInterfaceYamlPath);

// .xlf
$editorInterfaceXlf = is_readable($languageRealPath . 'Default.xlf')
Expand Down Expand Up @@ -122,14 +123,22 @@ protected static function configurationForContentBlock(\Symfony\Component\Finder
);
}

// EditorPreview.html
$editorPreviewHtml = is_readable(
$realPath . 'src' . DIRECTORY_SEPARATOR . 'EditorPreview.html'
)
? $realPath . 'src' . DIRECTORY_SEPARATOR . 'EditorPreview.html'
: false;

$cbConfiguration = [
'path' => $realPath,
'path' => $path,
'icon' => $iconPath,
'iconProviderClass' => $iconProviderClass,
'CType' => $ctype,
'EditorPreview.html' => $editorPreviewHtml,
'EditorInterface.xlf' => $editorInterfaceXlf,
'Frontend.xlf' => $frontendXlf,
'yaml' => $editorInterfaceYaml,
'yaml' => $editorInterface,
];

// validate (throws on error)
Expand Down
60 changes: 30 additions & 30 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,15 @@
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][\Sci\SciApi\Constants::CACHE]['frontend'] =
\TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class;
}
})();



// ToDo: Remove this part
/***************
* PageTS
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:sci_api/Configuration/TsConfig/All.tsconfig">');


$contentBlocks = Sci\SciApi\Service\ConfigurationService::configuration();

$configuration = Sci\SciApi\Service\ConfigurationService::configuration();

foreach ($configuration as $contentBlock)
{
/***************
* Add content element PageTSConfig
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('
foreach ($contentBlocks as $contentBlock) {
/***************
* Add content element PageTSConfig
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'
mod.wizards.newContentElement.wizardItems.common {
elements {
' . $contentBlock['CType'] . ' {
Expand All @@ -46,16 +35,27 @@
}
show := addToList(' . $contentBlock['CType'] . ')
}
');
'
);

// Backend Preview PageTS
if ($contentBlock['EditorPreview.html']) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'
mod.web_layout.tt_content.preview.' . $contentBlock['CType'] . ' = ' . $contentBlock['EditorPreview.html']
);
}


/***************
* Register Icons
*/
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(
$contentBlock['CType'],
$contentBlock['iconProviderClass'],
['source' => $contentBlock['icon'] ]
);
}
/***************
* Register Icons
*/
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Imaging\IconRegistry::class
);
$iconRegistry->registerIcon(
$contentBlock['CType'],
$contentBlock['iconProviderClass'],
['source' => $contentBlock['icon']]
);
}
})();

0 comments on commit 381bb74

Please sign in to comment.