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

Commit

Permalink
[TASK] formhandler Typo3 11
Browse files Browse the repository at this point in the history
- Apply rector
- Update language files
- Add minor changes not applied by rector
  • Loading branch information
amphx committed Nov 16, 2021
1 parent 8571c16 commit db35289
Show file tree
Hide file tree
Showing 35 changed files with 1,832 additions and 562 deletions.
23 changes: 19 additions & 4 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace Typoheads\Formhandler\Controller;

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter;
use Typoheads\Formhandler\Component\Manager;
use Typoheads\Formhandler\Domain\Model\Demand;
use Typoheads\Formhandler\Domain\Model\LogData;
use Typoheads\Formhandler\Generator\BackendCsv;
use Typoheads\Formhandler\Domain\Repository\LogDataRepository;

/*
* This file is part of the TYPO3 CMS project.
Expand Down Expand Up @@ -47,11 +49,20 @@ class ModuleController extends ActionController
protected $utilityFuncs;

/**
* @var \Typoheads\Formhandler\Domain\Repository\LogDataRepository
* @var LogDataRepository
* @TYPO3\CMS\Extbase\Annotation\Inject
*/
protected $logDataRepository;

/**
* @param LogDataRepository $logDataRepository
*/
public function injectLogDataRepository(LogDataRepository $logDataRepository)
{
$this->logDataRepository = $logDataRepository;
}


/**
* @var \TYPO3\CMS\Core\Page\PageRenderer
*/
Expand Down Expand Up @@ -93,7 +104,7 @@ public function initializeAction()
/**
* Displays log data
*/
public function indexAction(Demand $demand = null)
public function indexAction(Demand $demand = null): ResponseInterface
{
if ($demand === null) {
$demand = $this->objectManager->get('Typoheads\Formhandler\Domain\Model\Demand');
Expand All @@ -102,6 +113,7 @@ public function indexAction(Demand $demand = null)
}
}

//@TODO findDemanded funktioniert nicht, da die Datepicker zunächst gefixt werden müssen
$logDataRows = $this->logDataRepository->findDemanded($demand);
$this->view->assign('demand', $demand);
$this->view->assign('logDataRows', $logDataRows);
Expand All @@ -112,15 +124,17 @@ public function indexAction(Demand $demand = null)
$this->view->assign('showItems', $this->gp['show']);
$permissions = [];
$this->view->assign('permissions', $permissions);
return $this->htmlResponse();
}

public function viewAction(LogData $logDataRow = null)
public function viewAction(LogData $logDataRow = null): ResponseInterface
{
if ($logDataRow !== null) {
$logDataRow->setParams(unserialize($logDataRow->getParams()));
$this->view->assign('data', $logDataRow);
$this->view->assign('settings', $this->settings);
}
return $this->htmlResponse();
}

/**
Expand Down Expand Up @@ -192,7 +206,7 @@ public function selectFieldsAction($logDataUids = null, $filetype = '')
* @param array fields to export
* @param string export file type (PDF || CSV)
*/
public function exportAction($logDataUids = null, array $fields, $filetype = '')
public function exportAction($logDataUids = null, array $fields, $filetype = ''): ResponseInterface
{
if ($logDataUids !== null && !empty($fields)) {
$logDataRows = $this->logDataRepository->findByUids($logDataUids);
Expand Down Expand Up @@ -229,5 +243,6 @@ public function exportAction($logDataUids = null, array $fields, $filetype = '')
$generator->process();
}
}
return $this->htmlResponse();
}
}
9 changes: 3 additions & 6 deletions Classes/Domain/Repository/LogDataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ public function findByUids($uids)
$uidConstraints[] = $query->equals('uid', $value);
}
return $query->matching(
$query->logicalAnd(
$query->equals('deleted', 0),
$query->logicalOr(
$uidConstraints
)
)
$query->logicalAnd([$query->equals('deleted', 0), $query->logicalOr(
$uidConstraints
)])
)->execute();
}

Expand Down
3 changes: 2 additions & 1 deletion Classes/Generator/WebkitPdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Typoheads\Formhandler\Generator;

use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -62,7 +63,7 @@ public function process()
*/
protected function readWebkitPdfConf()
{
$sysPageObj = GeneralUtility::makeInstance('\TYPO3\CMS\Frontend\Page\PageRepository');
$sysPageObj = GeneralUtility::makeInstance(PageRepository::class);

if (!$GLOBALS['TSFE']->sys_page) {
$GLOBALS['TSFE']->sys_page = $sysPageObj;
Expand Down
4 changes: 2 additions & 2 deletions Classes/Mailer/TYPO3Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function addHeader($value)
*/
public function addAttachment($value)
{
$this->emailObj->attach(\Swift_Attachment::fromPath($value));
$this->emailObj->attachFromPath($value);
}

/* (non-PHPdoc)
Expand Down Expand Up @@ -274,6 +274,6 @@ public function getReturnPath()

public function embed($image)
{
return $this->emailObj->embed(\Swift_Image::fromPath($image));
return $this->emailObj->embedFromPath($image);
}
}
9 changes: 3 additions & 6 deletions Classes/Utility/GeneralUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public static function getFilledLangMarkers(&$template, $langFiles)
* Method to log a debug message.
* The message will be handled by one or more configured "Debuggers".
*
* @param string $key The message or key in language file (locallang_debug.xml)
* @param string $key The message or key in language file (locallang_debug.xlf)
* @param array $printfArgs If the messsage contains placeholders for usage with printf, pass the replacement values in this array.
* @param int $severity The severity of the message. Valid values are 1,2 and 3 (1= info, 2 = warning, 3 = error)
* @param array $data Additional debug data (e.g. the array of GET/POST values)
Expand Down Expand Up @@ -834,9 +834,6 @@ public static function initializeTSFE($pid)
$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $pid, 0, true);
$GLOBALS['TSFE']->tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\TypoScript\TemplateService');
$GLOBALS['TSFE']->tmpl->init();

// then initialize fe user
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->fe_user->fetchGroupData();

// Get the page
Expand All @@ -857,7 +854,7 @@ public static function initializeTSFE($pid)
*/
public static function getDebugMessage($key)
{
return trim($GLOBALS['TSFE']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_debug.xml:' . $key));
return trim($GLOBALS['TSFE']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_debug.xlf:' . $key));
}

/**
Expand All @@ -868,7 +865,7 @@ public static function getDebugMessage($key)
*/
public static function getExceptionMessage($key)
{
return trim($GLOBALS['TSFE']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_exceptions.xml:' . $key));
return trim($GLOBALS['TSFE']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_exceptions.xlf:' . $key));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Classes/Utility/TcaUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function addFields_predefined($config)
// no config available
if (!is_array($ts['plugin.']['Tx_Formhandler.']['settings.']['predef.']) || count($ts['plugin.']['Tx_Formhandler.']['settings.']['predef.']) === 0) {
$optionList[] = [
0 => $GLOBALS['LANG']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_db.xml:be_missing_config'),
0 => $GLOBALS['LANG']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_db.xlf:be_missing_config'),
1 => ''
];
return $config['items'] = array_merge($config['items'], $optionList);
Expand All @@ -164,7 +164,7 @@ public function addFields_predefined($config)

$optionList = [
[
0 => $GLOBALS['LANG']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_db.xml:be_please_select'),
0 => $GLOBALS['LANG']->sL('LLL:EXT:formhandler/Resources/Private/Language/locallang_db.xlf:be_please_select'),
1 => ''
]
];
Expand Down
7 changes: 4 additions & 3 deletions Classes/Utility/TemplateTCPDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Typoheads\Formhandler\Utility;

use TYPO3\CMS\Core\Http\ApplicationType;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand Down Expand Up @@ -44,7 +45,7 @@ class TemplateTCPDF extends \TCPDF
public function __construct()
{
parent::__construct();
$this->sysLangFile = 'EXT:formhandler/Resources/Private/Language/locallang.xml';
$this->sysLangFile = 'EXT:formhandler/Resources/Private/Language/locallang.xlf';
}

/**
Expand Down Expand Up @@ -105,15 +106,15 @@ public function Footer()
}

/**
* Get a translation for given key from "EXT:formhandler/Resources/Private/Language/locallang.xml"
* Get a translation for given key from "EXT:formhandler/Resources/Private/Language/locallang.xlf"
*
* @param string $key The key
* @return string The translation
*/
private function getLL($key)
{
global $LANG;
if (TYPO3_MODE == 'BE') {
if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) {
$LANG->includeLLFile($this->sysLangFile);
$text = trim($LANG->getLL($key));
} else {
Expand Down
4 changes: 2 additions & 2 deletions Classes/Validator/ErrorCheck/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Typoheads\Formhandler\Validator\ErrorCheck;

use ThinkopenAt\Captcha\Utility;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand All @@ -14,7 +15,6 @@
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
* Public License for more details. *
* */

/**
* Validates that a specified field's value matches the generated word of the extension "captcha"
*/
Expand All @@ -27,7 +27,7 @@ public function check()
// get captcha string
session_start();

$captchaSolved = \ThinkopenAt\Captcha\Utility::checkCaptcha($this->gp[$this->formFieldName]);
$captchaSolved = Utility::checkCaptcha($this->gp[$this->formFieldName]);
if (!$captchaSolved) {
$checkFailed = $this->getCheckFailed();
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/View/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Typoheads\Formhandler\View;

use ThinkopenAt\Captcha\Utility;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -623,7 +624,7 @@ protected function fillDefaultMarkers()
protected function fillCaptchaMarkers(&$markers)
{
if (stristr($this->template, '###CAPTCHA###') && ExtensionManagementUtility::isLoaded('captcha')) {
$markers['###CAPTCHA###'] = \ThinkopenAt\Captcha\Utility::makeCaptcha();
$markers['###CAPTCHA###'] = Utility::makeCaptcha();
$markers['###captcha###'] = $markers['###CAPTCHA###'];
}
if (stristr($this->template, '###SR_FREECAP_IMAGE###') && ExtensionManagementUtility::isLoaded('sr_freecap')) {
Expand Down
Loading

0 comments on commit db35289

Please sign in to comment.