-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add scheduler tasks * Support for TYPO3 9 together with typo3db_legacy
- Loading branch information
Showing
14 changed files
with
668 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
(add new changes on top of this file) | ||
2019-11-28 Franz Holzinger <[email protected]> | ||
|
||
* Add example slots | ||
* Add scheduler tasks | ||
* Support for TYPO3 9 together with typo3db_legacy | ||
|
||
2019-01-18 Franz Holzinger <[email protected]> | ||
|
||
* Make usage of the scheduler | ||
|
||
2019-01-18 Franz Holzinger <[email protected]> | ||
|
||
* rename Classes/Slots/ExampleSlots.php -> Classes/Slots/ExampleFunctionSlots.php | ||
|
||
2017-06-06 Franz Holzinger <[email protected]> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
namespace JambageCom\Import\Api; | ||
|
||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2019 Franz Holzinger ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
/** | ||
* Import Api | ||
* | ||
* @author Franz Holzinger <[email protected]> | ||
* @maintainer Franz Holzinger <[email protected]> | ||
* @package TYPO3 | ||
* @subpackage import | ||
*/ | ||
|
||
|
||
|
||
class ImportApi { | ||
|
||
static public function getTableArray () { | ||
$result = array(); | ||
|
||
if ( | ||
isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]) && | ||
is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]) && | ||
isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']) | ||
) { | ||
$systemTableArray = array(); | ||
$extensionTableArray = array(); | ||
|
||
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']['systemtables'] != '') { | ||
$systemTableArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']['systemtables']); | ||
} | ||
|
||
if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']['extensiontables'] != '') { | ||
$extensionTableArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']['extensiontables']); | ||
} | ||
|
||
$tableArray = array_merge($systemTableArray, $extensionTableArray); | ||
foreach ($tableArray as $table) { | ||
$result[] = array( | ||
'table' => $table, | ||
'title' => $table // TODO: title of the table | ||
); | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
static public function getLocalDefinitionArray () { | ||
$tableArray = self::getTableArray(); | ||
|
||
$result = array( | ||
array( | ||
'ext' => IMPORT_EXT, | ||
'tables' => $tableArray | ||
) | ||
); | ||
return $result; | ||
} | ||
|
||
static public function getPathname () { | ||
$result = false; | ||
|
||
if ( | ||
isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]) && | ||
is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]) && | ||
isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']) && | ||
isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']['path']) | ||
) { | ||
$result = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][IMPORT_EXT]['import.']['path']; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
|
||
static public function execute (...$params) { | ||
$result = false; | ||
|
||
if ( | ||
isset($params) && | ||
is_array($params) && | ||
!empty($params) | ||
) { | ||
$result = true; | ||
$tableArray = $params['0']; | ||
foreach ($tableArray as $table) { | ||
if ( | ||
isset($GLOBALS['TCA'][$table]) && | ||
isset($GLOBALS['TCA'][$table]['columns']) | ||
) { | ||
$select_fields = '*'; | ||
$where_clause = | ||
$table . '.deleted=0'; | ||
// $result = \JambageCom\Move\Api\MoveItemsApi::execute( | ||
// $configurationFile, | ||
// $table, | ||
// $select_fields, | ||
// $where_clause | ||
// ); | ||
} | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
} |
Empty file modified
0
Classes/Controller/ImportTablesWizardModuleFunctionController.php
100644 → 100755
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
namespace JambageCom\Import\Slots; | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
use JambageCom\Import\Api\Api; | ||
|
||
/** | ||
* Class for example slots to import files into TYPO3 tables based on the Scheduler Module | ||
*/ | ||
class ExampleSchedulerSlots implements \TYPO3\CMS\Core\SingletonInterface | ||
{ | ||
protected $tables = array('pages', 'tt_content'); | ||
|
||
public function addDefinitionArray( | ||
$pObj, | ||
array $definitionArray | ||
) | ||
{ | ||
$newDefinitionArray = | ||
array( | ||
'ext' => IMPORT_EXT, | ||
'class' => null, | ||
'tables' => array( | ||
array( | ||
'table' => 'pages', | ||
'title' => 'Pages' | ||
), | ||
array( | ||
'table' => 'fe_users', | ||
'title' => 'Front End Users' | ||
), | ||
) | ||
); | ||
|
||
$definitionArray[] = $newDefinitionArray; | ||
$result = array($pObj, $definitionArray); | ||
return $result; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
|
||
namespace JambageCom\Import\Task; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2019 Franz Holzinger ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
/** | ||
* Import Task | ||
* | ||
* @author Franz Holzinger <[email protected]> | ||
* @maintainer Franz Holzinger <[email protected]> | ||
* @package TYPO3 | ||
* @subpackage import | ||
*/ | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class ImportTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask { | ||
|
||
/** | ||
* Array of tables to import | ||
* | ||
* @var array $tableArray | ||
*/ | ||
public $tableArray; | ||
|
||
/** | ||
* @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher | ||
*/ | ||
protected $signalSlotDispatcher; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); | ||
} | ||
|
||
public function execute () | ||
{ | ||
$result = false; | ||
$slotDefinitionArray = array(); | ||
$slotResult = | ||
$this->signalSlotDispatcher->dispatch( | ||
__CLASS__, | ||
'definition', | ||
array( | ||
$this, | ||
$slotDefinitionArray | ||
) | ||
); | ||
$slotDefinitionArray = $slotResult['1']; | ||
|
||
if ( | ||
isset($this->tableArray) && | ||
is_array($this->tableArray) && | ||
!empty($this->tableArray) | ||
) { | ||
$result = true; | ||
$localDefinitionArray = \JambageCom\Import\Api\ImportApi::getLocalDefinitionArray(); | ||
$definitionArray = array_merge($localDefinitionArray, $slotDefinitionArray); | ||
// | ||
foreach ($definitionArray as $definition) { | ||
if ( | ||
!isset($definition['tables']) || | ||
!is_array($definition['tables']) | ||
) { | ||
continue; | ||
} | ||
|
||
if (isset($definition['ext'])) { | ||
|
||
$foreignExtension = $definition['ext']; | ||
if ( | ||
$foreignExtension != IMPORT_EXT && | ||
!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($foreignExtension) | ||
) { | ||
return false; | ||
} | ||
} | ||
|
||
$extensionTables = array(); | ||
foreach ($definition['tables'] as $tableDefinition) { | ||
$extensionTables[] = $tableDefinition['table']; | ||
} | ||
$theTableArray = array(); | ||
|
||
foreach ($this->tableArray as $table) { | ||
if (in_array($table, $extensionTables)) { | ||
$theTableArray[] = $table; | ||
} | ||
} | ||
|
||
if (!empty($theTableArray)) { | ||
if (isset($definition['class'])) { | ||
|
||
$foreignClass = $definition['class']; | ||
if ( | ||
class_exists($foreignClass) && | ||
method_exists($foreignClass, 'execute') | ||
) { | ||
$foreignObject = GeneralUtility::makeInstance($foreignClass); | ||
$result = $foreignObject->execute($theTableArray); | ||
} else { | ||
$result = false; | ||
break; | ||
} | ||
} else { | ||
\JambageCom\Import\Api\ImportApi::execute($theTableArray); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
|
||
public function getAdditionalInformation () | ||
{ | ||
} | ||
} |
Oops, something went wrong.