Commit 86cda5c0 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Merge branch '19-migrate-to-typo3-8' into 'master'

migrates extension to extbase, adds composer.json

See merge request !1
parents cc66238d d88a5c7c
<?php
/***************************************************************
* Copyright notice
*
* (c) 2016 Mathias Schreiber <mathias.schreiber@typo3.org>
* 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.
namespace T3o\Typo3Roadmap\Controller;
/**
* This file is part of the TYPO3 CMS project.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* 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.
*
* 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.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* The TYPO3 project - inspiring people to share!
*/
require_once(PATH_tslib . 'class.tslib_pibase.php');
use \TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use \T3o\Typo3Roadmap\Domain\Model\MajorVersion;
/**
* Plugin 'TYPO3 Roadmap' for the 'typo3_roadmap' extension.
*
* @author Mathias Schreiber <mathias.schreiber@typo3.org>
* @package TYPO3
* @subpackage tx_typo3roadmap
* Class \T3o\Typo3Roadmap\Controller\RoadmapController
* @author Sebastian Diez
*/
class tx_typo3roadmap_pi1 extends tslib_pibase
class RoadmapController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
public $prefixId = 'tx_typo3roadmap_pi1'; // Same as class name
public $scriptRelPath = 'pi1/class.tx_typo3roadmap_pi1.php'; // Path to this script relative to the extension dir.
public $extKey = 'typo3_roadmap'; // The extension key.
public $pi_checkCHash = true;
/**
* @var Tx_Fluid_View_StandaloneView
*/
protected $view;
/**
/*
* Color Codes for the charts
*
* @var array
*/
protected $colors = array(
'regular' => '#69A550',
'security' => '#FF8700',
'elts' => '#ffb767',
'sprint' => '#e6e6e6',
'stabilization' => '#983030'
);
/**
* @var t3lib_DB
*/
protected $db;
/**
* @var t3lib_PageRenderer
*/
protected $pageRenderer;
const COLOR_CODE_REGULAR = '#69A550';
const COLOR_CODE_SECURITY = '#FF8700';
const COLOR_CODE_ELTS = '#ffb767';
const COLOR_CODE_SPRINT = '#e6e6e6';
const COLOR_CODE_STABILIZATION = '#983030';
/**
* The main method of the Plugin.
* majorVersionRepository
*
* @param string $content The Plugin content
* @param array $conf The Plugin configuration
*
* @return string The content that is displayed on the website
* @var \T3o\Typo3Roadmap\Domain\Repository\MajorVersionRepository
* @inject
*/
public function main($content = '', array $conf)
{
$this->conf = $conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$this->initializeView();
$this->db = $GLOBALS['TYPO3_DB'];
$this->pageRenderer = $this->getFrontendController()->getPageRenderer();
$majorVersions = $this->getMajorVersions();
$phpVersions = $this->getAllAvailablePHPVersions();
$this->renderCharts($majorVersions);
$this->view->assign('majors', $majorVersions);
$this->view->assign('ceUid', $this->cObj->data['uid']);
$this->view->assign('phpVersions', $phpVersions);
$this->view->assign('majorVersions', $majorVersions);
$content .= $this->view->render();
return $content;
}
protected $majorVersionRepository = null;
/**
* Initialize the Fluid StandAlone View and set the template
*/
protected function initializeView()
{
$this->view = t3lib_div::makeInstance('Tx_Fluid_View_StandaloneView');
$this->view->setTemplatePathAndFilename(t3lib_extMgm::extPath($this->extKey) .
'/Resources/Private/Templates/Roadmap.html');
}
/**
* Fetches all major versions from the database
* majorVersionRepository
*
* @return array|NULL
* @var \T3o\Typo3Roadmap\Domain\Repository\PhpVersionRepository
* @inject
*/
protected function getMajorVersions()
{
$rows = $this->db->exec_SELECTgetRows(
'*',
'tx_typo3roadmap_majorversion',
'1 = 1 ' . $this->cObj->enableFields('tx_typo3roadmap_majorversion'),
'sorting'
);
foreach ($rows as $index => $singleRow) {
foreach ($singleRow as $fieldName => $fieldValue) {
if (t3lib_div::testInt($fieldValue)) {
$rows[$index][$fieldName] = (int)$fieldValue;
}
}
$rows[$index]['minorversions'] = $this->getMinorVersions($singleRow['uid']);
$rows[$index]['phpVersions'] = $this->getSupportedPHPVersions($singleRow['uid']);
}
return $rows;
}
protected $phpVersionRepository = null;
/**
* Fetches the minor versions of a given major version
* pageRenderer
*
* @param int $majorVersion The major version uid to fetch the minors for
*
* @return array|NULL
* @var \TYPO3\CMS\Core\Page\PageRenderer
* @inject
*/
protected function getMinorVersions($majorVersion)
{
$rows = $this->db->exec_SELECTgetRows(
'*',
'tx_typo3roadmap_minorversion',
'parent = ' . (int)$majorVersion . '' . $this->cObj->enableFields('tx_typo3roadmap_minorversion'),
'sorting'
);
return $rows;
}
protected $pageRenderer = null;
/**
* @param int $majorVersion
* action roadmap
*
* @return array
* @return void
*/
protected function getSupportedPHPVersions($majorVersion)
public function roadmapAction()
{
$rows = $this->db->exec_SELECTgetRows(
'uid, version',
'tx_typo3roadmap_majorversion_phpversions_mm
INNER JOIN tx_typo3roadmap_phpversion ON tx_typo3roadmap_phpversion.uid = tx_typo3roadmap_majorversion_phpversions_mm.uid_foreign',
'tx_typo3roadmap_majorversion_phpversions_mm.uid_local = ' . (int)$majorVersion .
$this->cObj->enableFields('tx_typo3roadmap_phpversion'),
'',
'',
'',
'uid'
);
return $rows;
}
/**
* @return array|NULL
*/
protected function getAllAvailablePHPVersions()
{
$rows = $this->db->exec_SELECTgetRows(
'uid, version',
'tx_typo3roadmap_phpversion',
'1 = 1 ' . $this->cObj->enableFields('tx_typo3roadmap_phpversion'),
'',
'version ASC',
'',
'uid'
);
if ($rows === null) {
return array();
}
return $rows;
$majorVersions = $this->majorVersionRepository->findAll()->toArray();
$this->view->assign('majorVersions', $majorVersions);
$phpVersions = $this->phpVersionRepository->findAll()->toArray();
$this->view->assign('phpVersions', $phpVersions);
$this->renderCharts($majorVersions);
}
/**
* Renders the LTS charts
*
* @param array $majorVersions
* @param MajorVersion[] $majorVersions
*/
protected function renderCharts(array $majorVersions)
protected function renderCharts($majorVersions)
{
$this->pageRenderer->addJsLibrary('amcharts', 'https://www.amcharts.com/lib/3/amcharts.js');
$this->pageRenderer->addJsLibrary('amcharts_serial', 'https://www.amcharts.com/lib/3/serial.js');
$this->pageRenderer->addJsLibrary('amcharts_gantt', 'https://www.amcharts.com/lib/3/gantt.js');
$this->pageRenderer->addJsLibrary('amcharts_lightheme', 'https://www.amcharts.com/lib/3/themes/light.js');
$this->pageRenderer->addJsLibrary('amcharts_export', 'https://www.amcharts.com/lib/3/plugins/export/export.js');
// $this->pageRenderer->addCssFile('https://www.amcharts.com/lib/3/plugins/export/export.css');
$this->pageRenderer->addCssFile('https://www.amcharts.com/lib/3/plugins/export/export.css');
// @TODO comment css
$data = $this->generateChartArray($majorVersions);
$this->view->assign('data', $data);
$chartJs = '
......@@ -295,46 +169,49 @@ class tx_typo3roadmap_pi1 extends tslib_pibase
* Creates the raw JSON data for the chart
* This is rather complex so take your time
*
* @param array $majorVersions
* @param MajorVersion[] $majorVersions
*
* @return array
*/
protected function generateChartArray(array $majorVersions)
protected function generateChartArray($majorVersions)
{
$data = array();
foreach ($majorVersions as $index => $majorVersion) {
$firstStart = (int)$majorVersion['developmentstart'];
$data[$index]['version'] = $majorVersion['title'];
foreach ($majorVersion['minorversions'] as $minorIndex => $minorVersion) {
$realDate = (int)$minorVersion['estimated'];
if ((int)$minorVersion['released'] >= (int)$minorVersion['estimated']) {
$realDate = (int)$minorVersion['released'];
$firstStart = (int)$majorVersion->getDevelopmentStart();
$data[$index]['version'] = $majorVersion->getTitle();
foreach ($majorVersion->getMinorVersions() as $minorIndex => $minorVersion) {
/* @var \T3o\Typo3Roadmap\Domain\Model\MinorVersion $minorVersion */
$realDate = (int)$minorVersion->getEstimated();
if ((int)$minorVersion->getReleased() >= (int)$minorVersion->getEstimated()) {
$realDate = (int)$minorVersion->getReleased();
}
// Check if we are in the first loop
if ($minorIndex === 0) {
$sprintStart = $firstStart = (int)$majorVersion['developmentstart'];
$sprintStart = $firstStart = (int)$majorVersion->getDevelopmentStart();
} else {
$sprintStart = $majorVersion['minorversions'][$minorIndex - 1]['estimated'];
if ((int)$majorVersion['minorversions'][$minorIndex - 1]['released'] >= (int)$majorVersion['minorversions'][$minorIndex - 1]['estimated']) {
$sprintStart = (int)$majorVersion['minorversions'][$minorIndex - 1]['released'];
/* @var \T3o\Typo3Roadmap\Domain\Model\MinorVersion $minorVersion */
$previousMinorVersion = $majorVersion->getMinorVersions()[$minorIndex - 1];
$sprintStart = $previousMinorVersion->getEstimated();
if ((int)$previousMinorVersion->getReleased() >= (int)$previousMinorVersion->getEstimated()) {
$sprintStart = (int)$previousMinorVersion->getReleased();
}
}
//Sprint Segment
$data[$index]['segments'][] = array(
'start' => $this->dateFromTimestamp($sprintStart),
'end' => $this->dateFromTimestamp($realDate - 1209600),
'color' => $this->colors['sprint'],
'task' => 'Sprint Phase ' . $minorVersion['version']
'end' => $this->dateFromTimestamp($realDate - 1209600),
'color' => self::COLOR_CODE_SPRINT,
'task' => 'Sprint Phase ' . $minorVersion->getVersion()
);
//Stabilization Segment
$data[$index]['segments'][] = array(
'start' => $this->dateFromTimestamp($realDate - 1209600),
'end' => $this->dateFromTimestamp($realDate),
'color' => $this->colors['stabilization'],
'task' => 'Stabilization Phase ' . $minorVersion['version']
'end' => $this->dateFromTimestamp($realDate),
'color' => self::COLOR_CODE_STABILIZATION,
'task' => 'Stabilization Phase ' . $minorVersion->getVersion()
);
// Set the last release date as start of maintenance
$firstStart = $realDate;
......@@ -345,37 +222,28 @@ class tx_typo3roadmap_pi1 extends tslib_pibase
// Regular Maintenance
$data[$index]['segments'][] = array(
'start' => $this->dateFromTimestamp($firstStart),
'end' => $this->dateFromTimestamp($majorVersion['regularsupport']),
'color' => $this->colors['regular'],
'task' => 'Regular Maintenance'
'end' => $this->dateFromTimestamp($majorVersion->getRegularSupport()),
'color' => self::COLOR_CODE_REGULAR,
'task' => 'Regular Maintenance'
);
// Security Maintenance
$data[$index]['segments'][] = array(
'start' => $this->dateFromTimestamp($majorVersion['regularsupport']),
'end' => $this->dateFromTimestamp($majorVersion['prioritysupport']),
'color' => $this->colors['security'],
'task' => 'Priority bugfixes'
'start' => $this->dateFromTimestamp($majorVersion->getRegularSupport()),
'end' => $this->dateFromTimestamp($majorVersion->getPrioritySupport()),
'color' => self::COLOR_CODE_SECURITY,
'task' => 'Priority bugfixes'
);
// ELTS Maintenance
if ($majorVersion['extendedsupport'] > 0) {
if ($majorVersion->getExtendedSupport() > 0) {
$data[$index]['segments'][] = array(
'start' => $this->dateFromTimestamp($majorVersion['prioritysupport']),
'end' => $this->dateFromTimestamp($majorVersion['extendedsupport']),
'color' => $this->colors['elts'],
'task' => 'Extended support (optional)'
'start' => $this->dateFromTimestamp($majorVersion->getPrioritySupport()),
'end' => $this->dateFromTimestamp($majorVersion->getExtendedSupport()),
'color' => self::COLOR_CODE_ELTS,
'task' => 'Extended support (optional)'
);
}
}
return $data;
}
/**
* @return tslib_fe
*/
protected function getFrontendController()
{
return $GLOBALS['TSFE'];
}
}
\ No newline at end of file
}
<?php
namespace T3o\Typo3Roadmap\Domain\Model;
/**
* 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 TYPO3\CMS\Extbase\Utility\DebuggerUtility;
/**
* Class \T3o\Typo3Roadmap\Domain\Model\MajorVersion
* @author Sebastian Diez
*/
class MajorVersion extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
*/
protected $title;
/**
* @var string
*/
protected $bodyText;
/**
* @var int
*/
protected $developmentStart;
/**
* @var int
*/
protected $regularSupport;
/**
* @var int
*/
protected $prioritySupport;
/**
* @var int
*/
protected $extendedSupport;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Typo3Roadmap\Domain\Model\PhpVersion>
*/
protected $phpVersions;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Typo3Roadmap\Domain\Model\MinorVersion>
*/
protected $minorVersions;
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @return string
*/
public function getBodyText()
{
return $this->bodyText;
}
/**
* @return int
*/
public function getDevelopmentStart()
{
return $this->developmentStart;
}
/**
* @return int
*/
public function getRegularSupport()
{
return $this->regularSupport;
}
/**
* @return int
*/
public function getPrioritySupport()
{
return $this->prioritySupport;
}
/**
* @return int
*/
public function getExtendedSupport()
{
return $this->extendedSupport;
}
/**
* @return \T3o\Typo3Roadmap\Domain\Model\PhpVersion[]
*/
public function getPhpVersions()
{
return $this->phpVersions->toArray();
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Typo3Roadmap\Domain\Model\PhpVersion> $phpVersions
*/
public function setPhpVersions($phpVersions)
{
return $this->phpVersions = $phpVersions;
}
/**
* @return \T3o\Typo3Roadmap\Domain\Model\MinorVersion[]
*/
public function getMinorVersions()
{
return $this->minorVersions->toArray();
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\Typo3Roadmap\Domain\Model\MinorVersion> $minorVersions
*/
public function setMinorVersions($minorVersions)
{
$this->minorVersions = $minorVersions;
}
}
<?php
namespace T3o\Typo3Roadmap\Domain\Model;
/**
* 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!
*/
/**
* Class \T3o\Typo3Roadmap\Domain\Model\MinorVersion
* @author Sebastian Diez
*/
class MinorVersion extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
*/
protected $version;
/**
* @var string
*/
protected $link;
/**
* @var string
*/
protected $focus;
/**
* @var int
*/
protected $estimated;
/**
* @var int
*/
protected $released;
/**
* @return string
*/
public function getVersion()
{
return $this->version;
}
/**
* @return string
*/
public function getLink()
{
return $this->link;
}
/**
* @return string
*/
public function getFocus()
{
return $this->focus;
}
/**
* @return int
*/
public function getEstimated()
{
return $this->estimated;
}