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

Commit

Permalink
[TASK] Rectify formhandler for v10 comaptibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon authored and 7elix committed Apr 2, 2021
1 parent 72a1102 commit 85a02f4
Show file tree
Hide file tree
Showing 82 changed files with 914 additions and 787 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
*.ipr
*.iws
/.php_cs.cache
composer.lock
vendor
public
8 changes: 5 additions & 3 deletions Classes/Ajax/RemoveFile.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Typoheads\Formhandler\Ajax;

use Typoheads\Formhandler\Component\Manager;
use Typoheads\Formhandler\Utility\Globals;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand Down Expand Up @@ -96,12 +98,12 @@ protected function init()
$this->id = intval($_GET['id']);
}

$this->componentManager = GeneralUtility::makeInstance(\Typoheads\Formhandler\Component\Manager::class);
$this->globals = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\Globals::class);
$this->componentManager = GeneralUtility::makeInstance(Manager::class);
$this->globals = GeneralUtility::makeInstance(Globals::class);
$this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
$this->utilityFuncs->initializeTSFE($this->id);
$this->globals->setCObj($GLOBALS['TSFE']->cObj);
$randomID = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('randomID'));
$randomID = htmlspecialchars(GeneralUtility::_GP('randomID'));
$this->globals->setRandomID($randomID);

if (!$this->globals->getSession()) {
Expand Down
5 changes: 3 additions & 2 deletions Classes/Ajax/Submit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Typoheads\Formhandler\Ajax;

use Typoheads\Formhandler\Component\Manager;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand Down Expand Up @@ -59,7 +60,7 @@ protected function init()
{
$id = (int)($_GET['pid'] ?? $_GET['id'] ?? 0);

$this->componentManager = GeneralUtility::makeInstance(\Typoheads\Formhandler\Component\Manager::class);
$this->componentManager = GeneralUtility::makeInstance(Manager::class);
\Typoheads\Formhandler\Utility\GeneralUtility::initializeTSFE($id);

$elementUID = (int)$_GET['uid'];
Expand All @@ -79,7 +80,7 @@ protected function init()
}

Globals::setCObj($GLOBALS['TSFE']->cObj);
$randomID = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('randomID'));
$randomID = htmlspecialchars(GeneralUtility::_GP('randomID'));
Globals::setRandomID($randomID);
Globals::setAjaxMode(true);
if (!Globals::getSession()) {
Expand Down
22 changes: 12 additions & 10 deletions Classes/Ajax/Validate.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Typoheads\Formhandler\Ajax;

use Typoheads\Formhandler\Utility\Globals;
use Typoheads\Formhandler\Component\Manager;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand Down Expand Up @@ -39,18 +41,18 @@ class Validate
public function main()
{
$this->init();
$field = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('field'));
$field = htmlspecialchars(GeneralUtility::_GP('field'));
if ($field) {
$randomID = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('randomID'));
\Typoheads\Formhandler\Utility\Globals::setCObj($GLOBALS['TSFE']->cObj);
\Typoheads\Formhandler\Utility\Globals::setRandomID($randomID);
if (!\Typoheads\Formhandler\Utility\Globals::getSession()) {
$randomID = htmlspecialchars(GeneralUtility::_GP('randomID'));
Globals::setCObj($GLOBALS['TSFE']->cObj);
Globals::setRandomID($randomID);
if (!Globals::getSession()) {
$ts = $GLOBALS['TSFE']->tmpl->setup['plugin.']['Tx_Formhandler.']['settings.'];
$sessionClass = \Typoheads\Formhandler\Utility\GeneralUtility::getPreparedClassName($ts['session.'], 'Session\PHP');
\Typoheads\Formhandler\Utility\Globals::setSession($this->componentManager->getComponent($sessionClass));
Globals::setSession($this->componentManager->getComponent($sessionClass));
}
$this->settings = \Typoheads\Formhandler\Utility\Globals::getSession()->get('settings');
\Typoheads\Formhandler\Utility\Globals::setFormValuesPrefix(\Typoheads\Formhandler\Utility\GeneralUtility::getSingle($this->settings, 'formValuesPrefix'));
$this->settings = Globals::getSession()->get('settings');
Globals::setFormValuesPrefix(\Typoheads\Formhandler\Utility\GeneralUtility::getSingle($this->settings, 'formValuesPrefix'));
$gp = \Typoheads\Formhandler\Utility\GeneralUtility::getMergedGP();
$validator = $this->componentManager->getComponent('\Typoheads\Formhandler\Validator\Ajax');
$errors = [];
Expand Down Expand Up @@ -95,8 +97,8 @@ protected function init()
} else {
$this->id = intval($_GET['id']);
}
$this->componentManager = GeneralUtility::makeInstance(\Typoheads\Formhandler\Component\Manager::class);
\Typoheads\Formhandler\Utility\Globals::setAjaxMode(true);
$this->componentManager = GeneralUtility::makeInstance(Manager::class);
Globals::setAjaxMode(true);
\Typoheads\Formhandler\Utility\GeneralUtility::initializeTSFE($this->id);
}

Expand Down
26 changes: 13 additions & 13 deletions Classes/AjaxHandler/AbstractAjaxHandler.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?php
namespace Typoheads\Formhandler\AjaxHandler;

use Typoheads\Formhandler\Component\AbstractClass;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
* TYPO3 is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License version 2 as published by *
* the Free Software Foundation. *
* *
* This script is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
* Public License for more details. *
* */

* This script is part of the TYPO3 project - inspiring people to share! *
* *
* TYPO3 is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License version 2 as published by *
* the Free Software Foundation. *
* *
* This script is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
* Public License for more details. *
* */
/**
* Abstract class for an AjaxHandler.
* The AjaxHandler takes care of adding AJAX related markers and JS used for validation and file removal.
* @abstract
*/
abstract class AbstractAjaxHandler extends \Typoheads\Formhandler\Component\AbstractClass
abstract class AbstractAjaxHandler extends AbstractClass
{

/**
Expand Down
6 changes: 4 additions & 2 deletions Classes/AjaxHandler/JQuery.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Typoheads\Formhandler\AjaxHandler;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Context\Context;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand All @@ -22,7 +24,7 @@
* The AjaxHandler takes care of adding AJAX related markers and JS used for validation and file removal.
* @abstract
*/
class JQuery extends \Typoheads\Formhandler\AjaxHandler\AbstractAjaxHandler
class JQuery extends AbstractAjaxHandler
{
/**
* @var array
Expand Down Expand Up @@ -208,7 +210,7 @@ protected function getJavascriptFormInit($formSelector, $submitButtonSelector, $
contentID: "' . $this->cObj->data['uid'] . '",
randomID: "' . $this->globals->getRandomID() . '",
formValuesPrefix: "' . $this->globals->getFormValuesPrefix() . '",
lang: "' . $GLOBALS['TSFE']->sys_language_uid . '",
lang: "' . GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id') . '",
submitButtonSelector: "' . $submitButtonSelector . '",
ajaxSubmit: ' . ($isAjaxSubmit ? 'true' : 'false') . ',
autoDisableSubmitButton: ' . ($autoDisableSubmitButton ? 'true' : 'false') . ',
Expand Down
34 changes: 18 additions & 16 deletions Classes/Component/AbstractClass.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?php
namespace Typoheads\Formhandler\Component;

use Typoheads\Formhandler\Controller\Configuration;
use Typoheads\Formhandler\Utility\Globals;
use Typoheads\Formhandler\Utility\GeneralUtility;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
* TYPO3 is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License version 2 as published by *
* the Free Software Foundation. *
* *
* This script is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
* Public License for more details. *
* */

* This script is part of the TYPO3 project - inspiring people to share! *
* *
* TYPO3 is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License version 2 as published by *
* the Free Software Foundation. *
* *
* This script is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
* Public License for more details. *
* */
/**
* Abstract class for any usable Formhandler component.
* This class defines some useful variables and a default constructor for all Formhandler components.
Expand Down Expand Up @@ -64,10 +66,10 @@ abstract class AbstractClass
* @param \Typoheads\Formhandler\Controller\Configuration $configuration
*/
public function __construct(
\Typoheads\Formhandler\Component\Manager $componentManager,
\Typoheads\Formhandler\Controller\Configuration $configuration,
\Typoheads\Formhandler\Utility\Globals $globals,
\Typoheads\Formhandler\Utility\GeneralUtility $utilityFuncs
Manager $componentManager,
Configuration $configuration,
Globals $globals,
GeneralUtility $utilityFuncs
) {
$this->componentManager = $componentManager;
$this->configuration = $configuration;
Expand Down
6 changes: 4 additions & 2 deletions Classes/Component/Manager.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Typoheads\Formhandler\Component;

use Typoheads\Formhandler\Utility\Globals;
use TYPO3\CMS\Extbase\Object\ObjectManager;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand Down Expand Up @@ -42,7 +44,7 @@ class Manager implements SingletonInterface

public function __construct()
{
$this->globals = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\Globals::class);
$this->globals = GeneralUtility::makeInstance(Globals::class);
$this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
}

Expand All @@ -64,7 +66,7 @@ public function getComponent($componentName)
$arguments = array_slice(func_get_args(), 1, null, true);

/** @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */
$objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$componentObject = $objectManager->get($componentName, $arguments);

return $componentObject;
Expand Down
3 changes: 2 additions & 1 deletion Classes/Controller/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Typoheads\Formhandler\Controller;

use Typoheads\Formhandler\Utility\Globals;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand Down Expand Up @@ -41,7 +42,7 @@ class Configuration implements \ArrayAccess
public function __construct()
{
if (TYPO3_MODE === 'FE') {
$this->globals = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\Globals::class);
$this->globals = GeneralUtility::makeInstance(Globals::class);
$this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
$this->setup = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->getPrefixedPackageKey() . '.'];
if (!is_array($this->setup)) {
Expand Down
13 changes: 8 additions & 5 deletions Classes/Controller/Dispatcher.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
namespace Typoheads\Formhandler\Controller;

use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
use Typoheads\Formhandler\Component\Manager;
use Typoheads\Formhandler\Utility\Globals;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
Expand All @@ -18,7 +21,7 @@
/**
* The Dispatcher instantiates the Component Manager and delegates the process to the given controller.
*/
class Dispatcher extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
class Dispatcher extends AbstractPlugin
{

/**
Expand Down Expand Up @@ -52,8 +55,8 @@ class Dispatcher extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
public function main($content, $setup)
{
$this->pi_USER_INT_obj = 1;
$this->componentManager = GeneralUtility::makeInstance(\Typoheads\Formhandler\Component\Manager::class);
$this->globals = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\Globals::class);
$this->componentManager = GeneralUtility::makeInstance(Manager::class);
$this->globals = GeneralUtility::makeInstance(Globals::class);
$this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
try {

Expand Down Expand Up @@ -110,10 +113,10 @@ public function main($content, $setup)

$result = $controller->process();
} catch (\Exception $e) {
\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog(
GeneralUtility::sysLog(
$e->getFile() . '(' . $e->getLine() . ')' . ' ' . $e->getMessage(),
'formhandler',
\TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR
GeneralUtility::SYSLOG_SEVERITY_ERROR
);
$result = $this->utilityFuncs->getTranslatedMessage($this->globals->getLangFiles(), 'fe-exception');
if (!$result) {
Expand Down
Loading

0 comments on commit 85a02f4

Please sign in to comment.