Commit d7f3b1d6 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen
Browse files

Merge branch 'namespaces-task-for-ter' into 'develop'

Namespaces task for ter

See merge request !107
parents d79d8298 261218e5
Pipeline #1554 passed with stages
in 4 minutes
......@@ -52,6 +52,7 @@
},
"autoload": {
"psr-4": {
"T3o\\Ter\\": "html/typo3conf/ext/ter/Classes",
"T3o\\TerFe2\\": "html/typo3conf/ext/ter_fe2/Classes"
},
"classmap": [
......
<?php
namespace T3o\Ter\Task;
/**
* This file is part of the TYPO3 CMS project.
*
......@@ -16,12 +18,8 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Update json file with information of core versions
*
* @author Jigal van Hemert <jigal.van.hemert@typo3.org>
* @package TYPO3
* @subpackage tx_ter
*/
class tx_ter_updateCurrentVersionListTask extends tx_scheduler_Task
class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task
{
/**
......
......@@ -5,15 +5,8 @@ if (!defined('TYPO3_MODE')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'pi1/class.tx_ter_pi1.php', '_pi1', 'list_type', 0);
// Register extension list update task
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_ter_updateExtensionIndexTask'] = [
'extension' => $_EXTKEY,
'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:tx_ter_updateExtensionIndexTask.name',
'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:tx_ter_updateExtensionIndexTask.description',
'additionalFields' => 'tx_ter_updateExtensionIndexTask_additionalFieldProvider',
];
// Register core version update task
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_ter_updateCurrentVersionListTask'] = [
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\T3o\Ter\Task\UpdateCurrentVersionListTask::class] = [
'extension' => $_EXTKEY,
'title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:tx_ter_updateCurrentVersionListTask.name',
'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:tx_ter_updateCurrentVersionListTask.description',
......
<?php
/**
* 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\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
require_once ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.php';
/**
* Create xml file to force update of ter_fe tables
*
* @author Kai Vogel <kai.vogel@speedprogs.de>
* @package TYPO3
* @subpackage tx_ter
*/
class tx_ter_updateExtensionIndexTask extends TYPO3\CMS\Scheduler\Task\AbstractTask
{
/**
* @var string
*/
public $clearCachePages;
/**
* Public method, usually called by scheduler
*
* @return boolean TRUE on success
*/
public function execute()
{
// Check extension configuration
if (empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ter'])) {
throw new Exception('No extension configuration found in $TYPO3_CONF_VARS', 1303220916);
return false;
}
// Check extension repository path
$extensionConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ter']);
if (empty($extensionConfig['repositoryDir'])) {
throw new Exception('No repository path found in extension configuration', 1303220917);
return false;
}
// Write new extensions xml file
$repositoryDir = rtrim($extensionConfig['repositoryDir'], '/') . '/';
$dummyObject = new stdClass();
$dummyObject->repositoryDir = $repositoryDir;
$terHelper = GeneralUtility::makeInstance('tx_ter_helper', $dummyObject);
$terHelper->writeExtensionIndexFile();
// Clear page cache to force reload of the extension list
$pageIds = GeneralUtility::intExplode(',', $this->clearCachePages, true);
if (!empty($pageIds)) {
$terHelper->loadBackendUser(1, '_ter_', true);
$terHelper->loadLang();
$tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
$tce->admin = 1;
$tce->start([], []);
foreach ($pageIds as $pageId) {
$tce->clear_cacheCmd($pageId);
}
}
return true;
}
}
\ No newline at end of file
<?php
/**
* 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!
*/
/**
* Additional BE fields for ter extension publish task
*
* Creates an input field to define UIDs of pages to clear their
* cache after successfully running the scheduler task
*
* @author Kai Vogel <kai.vogel@speedprogs.de>
* @package TYPO3
* @subpackage tx_ter
*/
class tx_ter_updateExtensionIndexTask_additionalFieldProvider implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
{
/**
* @var string
*/
protected $fieldName = 'scheduler_updateExtensionIndexTask_clearCachePages';
/**
* @var string
*/
protected $fieldId = 'task_updateExtensionIndexTask_clearCachePages';
/**
* Add an input field to define UIDs of pages to clear their
* cache after successfully running the scheduler task
*
* @param array Reference to the array containing the info used in the add/edit form
* @param object When editing, reference to the current task object. Null when adding.
* @param tx_scheduler_Module Reference to the calling object (Scheduler's BE module)
* @return array Array containg all the information pertaining to the additional fields
*/
public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
{
// Initialize selected fields
if (empty($taskInfo[$this->fieldName])) {
$taskInfo[$this->fieldName] = '';
if ($parentObject->CMD === 'edit') {
$taskInfo[$this->fieldName] = $task->clearCachePages;
}
}
$fieldName = 'tx_scheduler[' . $this->fieldName . ']';
$fieldValue = htmlspecialchars($taskInfo[$this->fieldName]);
$fieldHtml = '<input type="text" name="' . $fieldName . '" id="' . $this->fieldId . '" value="' . $fieldValue . '" size="30" />';
$additionalFields[$fieldId] = [
'code' => $fieldHtml,
'label' => 'LLL:EXT:ter/locallang.xml:tx_ter_updateExtensionIndexTask.clearCachePages',
'cshKey' => '_MOD_tools_txschedulerM1',
'cshLabel' => $fieldId,
];
return $additionalFields;
}
/**
* Checks if the given value is valid
*
* @param array Reference to the array containing the data submitted by the user
* @param tx_scheduler_Module Reference to the calling object (Scheduler's BE module)
* @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
*/
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
{
$value = str_replace([',', ' '], '', $submittedData[$this->fieldName]);
return (empty($value) || ctype_digit($value));
}
/**
* Saves given integer value in task object
*
* @param array Contains data submitted by the user
* @param tx_scheduler_Task Reference to the current task object
* @return void
*/
public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
{
$task->clearCachePages = $submittedData[$this->fieldName];
}
}
if (defined(
'TYPO3_MODE'
) && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/tasks/class.tx_scheduler_recyclergarbagecollection_additionalfieldprovider.php'])
) {
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/tasks/class.tx_scheduler_recyclergarbagecollection_additionalfieldprovider.php']);
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment