Skip to content

Commit

Permalink
Merge pull request #28 from xima-media/v11
Browse files Browse the repository at this point in the history
TYPO3 v11 support
  • Loading branch information
maikschneider authored Jun 28, 2024
2 parents 57d5909 + 77bdd7a commit 12910b4
Show file tree
Hide file tree
Showing 16 changed files with 366 additions and 119 deletions.
22 changes: 21 additions & 1 deletion .ddev/commands/web/init-typo3
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readonly dbName="db"
readonly dbCredentials="-h${dbHost} -u${dbUser} -p${dbPassword}"
readonly fixturePath="/var/www/html/Tests/Acceptance/Fixtures"
readonly typo3Binary="/var/www/html/vendor/bin/typo3"
readonly typo3cmsBinary="/var/www/html/vendor/bin/typo3cms"

function _progress() {
printf "%s... " "$1"
Expand Down Expand Up @@ -42,9 +43,28 @@ export TYPO3_SETUP_ADMIN_PASSWORD=Passw0rd!
export TYPO3_SERVER_TYPE=other
export TYPO3_PROJECT_NAME="EXT:xm_formcycle"

export TYPO3_INSTALL_DB_DRIVER=mysqli
export TYPO3_INSTALL_DB_USER="$dbUser"
export TYPO3_INSTALL_DB_PASSWORD="$dbPassword"
export TYPO3_INSTALL_DB_PORT=3306
export TYPO3_INSTALL_DB_HOST="$dbHost"
export TYPO3_INSTALL_DB_DBNAME="$dbName"
export TYPO3_INSTALL_ADMIN_USER=admin
export TYPO3_INSTALL_ADMIN_PASSWORD=Passw0rd!
export TYPO3_INSTALL_SITE_SETUP_TYPE="no"
export TYPO3_INSTALL_WEB_SERVER_CONFIG="apache"
export TYPO3_INSTALL_SITE_NAME="EXT:xm_formcycle"
export TYPO3_INSTALL_DB_UNIX_SOCKET=""

# Set up environment
_progress "Setting up TYPO3 installation"
"$typo3Binary" setup --no-interaction --force --quiet
# TYPO3 v11
if [ -f "$typo3cmsBinary" ]; then
"$typo3cmsBinary" install:setup --force --use-existing-database
"$typo3cmsBinary" configuration:set SYS/trustedHostsPattern ".*"
else
"$typo3Binary" setup --no-interaction --force --quiet
fi
_done

# Import DB fixtures
Expand Down
2 changes: 1 addition & 1 deletion .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ nodejs_version: "20"
disable_settings_management: true
web_environment:
- TESTING_DOMAIN=$DDEV_HOSTNAME
- XDEBUG_MODE=coverage
- XDEBUG_MODE=debug,coverage
- TYPO3_CONTEXT=Development/DDEV
- typo3DatabaseHost=db
- typo3DatabaseUsername=root
Expand Down
14 changes: 8 additions & 6 deletions Classes/DataProcessing/AbstractProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Xima\XmFormcycle\DataProcessing;

use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
use Xima\XmFormcycle\Dto\ElementSettings;
Expand All @@ -13,23 +14,24 @@ abstract class AbstractProcessor implements DataProcessorInterface
{
protected ElementSettings $settings;

public function __construct(
protected readonly FormcycleService $formcycleService,
private readonly FlexFormService $flexFormService
) {
}
protected FormcycleService $formcycleService;

public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
// construct element settings
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
$this->settings = ElementSettings::createFromContentElement(
$this->flexFormService,
$flexFormService,
$cObj,
);

$this->formcycleService = GeneralUtility::makeInstance(FormcycleService::class);

// check if concrete processor should be used
$currentIntegrationMode = $this->settings->integrationMode ?? $this->formcycleService->getDefaultIntegrationMode();
if ($currentIntegrationMode->forDataProcessing() !== $this->getIntegrationMode()) {
return $processedData;
Expand Down
12 changes: 10 additions & 2 deletions Classes/Form/Element/FormcycleSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Xima\XmFormcycle\Form\Element;

use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand Down Expand Up @@ -57,8 +58,15 @@ public function render()
$resultArray['html'] = '<div class="formengine-field-item t3js-formengine-field-item">' . $hiddenInput . '</div><div id="xm-formcycle-forms" class="open">' . $view->render() . '</div>';
$resultArray['stylesheetFiles'][] = 'EXT:xm_formcycle/Resources/Public/Css/Backend/FormcycleSelection.css';

$resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@xima/xm-formcycle/FormcycleSelectionElement.js')
->instance($this->data['parameterArray']['itemFormElID']);
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
if ($versionInformation->getMajorVersion() < 12) {
$resultArray['requireJsModules'][] = JavaScriptModuleInstruction::forRequireJS(
'TYPO3/CMS/XmFormcycle/Backend/FormcycleSelectionElementV11'
)->instance($this->data['parameterArray']['itemFormElID']);
} else {
$resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@xima/xm-formcycle/FormcycleSelectionElement.js')
->instance($this->data['parameterArray']['itemFormElID']);
}

return $resultArray;
}
Expand Down
51 changes: 0 additions & 51 deletions Classes/Upgrades/ElementUpgradeWizard.php

This file was deleted.

92 changes: 63 additions & 29 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
@@ -1,61 +1,95 @@
temp.formcycle =< lib.contentElement
temp.formcycle {
templateRootPaths.1 = EXT:xm_formcycle/Resources/Private/Templates/
templateRootPaths.2 = {$plugin.tx_xmformcycle.view.templateRootPath}
partialRootPaths.1 = EXT:xm_formcycle/Resources/Private/Partials/
partialRootPaths.2 = {$plugin.tx_xmformcycle.view.partialRootPath}
layoutRootPaths.1 = EXT:xm_formcycle/Resources/Private/Layouts/
layoutRootPaths.2 = {$plugin.tx_xmformcycle.view.layoutRootPath}

templateName = Formcycle
}

tt_content.formcycle = COA
tt_content.formcycle {

10 = COA_INT
10.stdWrap.if.equals = default
10.stdWrap.if.value.data = flexform : pi_flexform:settings.xf.integrationMode
10.1 =< temp.formcycle
10.1.dataProcessing {
1709129505 = formcycle-ajax
1709129509 = formcycle-iframe
1709129512 = formcycle-integrated
10.1 =< lib.contentElement
10.1 {
templateRootPaths.1 = EXT:xm_formcycle/Resources/Private/Templates/
templateRootPaths.2 = {$plugin.tx_xmformcycle.view.templateRootPath}
partialRootPaths.1 = EXT:xm_formcycle/Resources/Private/Partials/
partialRootPaths.2 = {$plugin.tx_xmformcycle.view.partialRootPath}
layoutRootPaths.1 = EXT:xm_formcycle/Resources/Private/Layouts/
layoutRootPaths.2 = {$plugin.tx_xmformcycle.view.layoutRootPath}
templateName = Formcycle
dataProcessing {
1709129505 = Xima\XmFormcycle\DataProcessing\AjaxProcessor
1709129509 = Xima\XmFormcycle\DataProcessing\iFrameProcessor
1709129512 = Xima\XmFormcycle\DataProcessing\IntegratedProcessor
}
}

20 = COA_INT
20.stdWrap.if.equals = integrated
20.stdWrap.if.value.data = flexform : pi_flexform:settings.xf.integrationMode
20.1 =< temp.formcycle
20.1.dataProcessing {
1709129512 = formcycle-integrated
20.1 =< lib.contentElement
20.1 {
templateRootPaths.1 = EXT:xm_formcycle/Resources/Private/Templates/
templateRootPaths.2 = {$plugin.tx_xmformcycle.view.templateRootPath}
partialRootPaths.1 = EXT:xm_formcycle/Resources/Private/Partials/
partialRootPaths.2 = {$plugin.tx_xmformcycle.view.partialRootPath}
layoutRootPaths.1 = EXT:xm_formcycle/Resources/Private/Layouts/
layoutRootPaths.2 = {$plugin.tx_xmformcycle.view.layoutRootPath}
templateName = Formcycle
dataProcessing {
1709129512 = Xima\XmFormcycle\DataProcessing\IntegratedProcessor
}
}

30 = COA
30.stdWrap.if.equals = AJAX (TYPO3)
30.stdWrap.if.value.data = flexform : pi_flexform:settings.xf.integrationMode
30.1 =< temp.formcycle
30.1.dataProcessing {
1709129505 = formcycle-ajax
30.1 =< lib.contentElement
30.1 {
templateRootPaths.1 = EXT:xm_formcycle/Resources/Private/Templates/
templateRootPaths.2 = {$plugin.tx_xmformcycle.view.templateRootPath}
partialRootPaths.1 = EXT:xm_formcycle/Resources/Private/Partials/
partialRootPaths.2 = {$plugin.tx_xmformcycle.view.partialRootPath}
layoutRootPaths.1 = EXT:xm_formcycle/Resources/Private/Layouts/
layoutRootPaths.2 = {$plugin.tx_xmformcycle.view.layoutRootPath}
templateName = Formcycle
dataProcessing {
1709129505 = Xima\XmFormcycle\DataProcessing\AjaxProcessor
}
}

40 = COA
40.stdWrap.if.equals = AJAX (FORMCYCLE)
40.stdWrap.if.value.data = flexform : pi_flexform:settings.xf.integrationMode
40.1 =< temp.formcycle
40.1.dataProcessing {
1709129505 = formcycle-ajax
40.1 =< lib.contentElement
40.1 {
templateRootPaths.1 = EXT:xm_formcycle/Resources/Private/Templates/
templateRootPaths.2 = {$plugin.tx_xmformcycle.view.templateRootPath}
partialRootPaths.1 = EXT:xm_formcycle/Resources/Private/Partials/
partialRootPaths.2 = {$plugin.tx_xmformcycle.view.partialRootPath}
layoutRootPaths.1 = EXT:xm_formcycle/Resources/Private/Layouts/
layoutRootPaths.2 = {$plugin.tx_xmformcycle.view.layoutRootPath}
templateName = Formcycle
dataProcessing {
1709129505 = Xima\XmFormcycle\DataProcessing\AjaxProcessor
}
}

50 = COA
50.stdWrap.if.equals = iFrame
50.stdWrap.if.value.data = flexform : pi_flexform:settings.xf.integrationMode
50.1 =< temp.formcycle
50.1.dataProcessing {
1709129509 = formcycle-iframe
50.1 =< lib.contentElement
50.1 {
templateRootPaths.1 = EXT:xm_formcycle/Resources/Private/Templates/
templateRootPaths.2 = {$plugin.tx_xmformcycle.view.templateRootPath}
partialRootPaths.1 = EXT:xm_formcycle/Resources/Private/Partials/
partialRootPaths.2 = {$plugin.tx_xmformcycle.view.partialRootPath}
layoutRootPaths.1 = EXT:xm_formcycle/Resources/Private/Layouts/
layoutRootPaths.2 = {$plugin.tx_xmformcycle.view.layoutRootPath}
templateName = Formcycle
dataProcessing {
1709129509 = Xima\XmFormcycle\DataProcessing\iFrameProcessor
}
}

}


formcycle_ajax = PAGE
formcycle_ajax.typeNum = 1464705954
10 changes: 5 additions & 5 deletions Resources/Private/Templates/Backend/FormcycleSelection.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
<f:if condition="!{loading} && !{errorCode}">
<div class="mb-4 btn-group">
<button id="xm-reload-available-forms" class="btn btn-default">
<core:icon title="Refresh forms" identifier="actions-refresh" />
<core:icon identifier="actions-cog" />
{f:translate(key: 'button.reload', extensionName:'XmFormcycle')}
</button>
<button class="btn btn-default" id="xm-settings">
<core:icon title="Opens settings" identifier="actions-cog" />
<core:icon identifier="actions-cog" />
{f:translate(key: 'button.settings', extensionName:'XmFormcycle')}
</button>
<a href="{adminUrl}" class="btn btn-default" target="_blank">
<core:icon title="Open Formcycle admin in new window" identifier="actions-window-open" />
<core:icon identifier="actions-window-open" />
{f:translate(key: 'button.admin', extensionName:'XmFormcycle')}
</a>
</div>
</f:if>

<div class="py-3 text-center {f:if(condition: loading, else: 'hidden')}" id="xm-loading-spinner">
<core:icon identifier="spinner-circle" size="medium" />
<core:icon identifier="spinner-circle" size="small" />
</div>

<f:if condition="{forms} && !{errorCode}">
Expand All @@ -36,7 +36,7 @@ <h4>
<hr />
<div class="d-flex flex-wrap gap-3">
<f:for each="{group}" as="form">
<a href="#" class="card btn btn-primary {f:if(condition: '{itemFormElValue}=={form.id}', then: 'active')}" style="width: 14rem;" data-form-id="{form.id}">
<a href="#" class="card btn btn-primary {f:if(condition: '{itemFormElValue}=={form.id}', then: 'active')}" style="width: 14rem; --bs-btn-color:inherit;" data-form-id="{form.id}">
<div style="background: #ededed">
<img src="{form.thumbnail}" class="card-img-top" alt="Preview {form.title}">
</div>
Expand Down
Loading

0 comments on commit 12910b4

Please sign in to comment.