Commit 724964f5 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Merge branch '401-planet-typo3' into 'develop'

Resolve "Planet TYPO3"

Closes #439 and #401

See merge request services/typo3.org/typo3.org!275
parents 502646cf a9645179
Pipeline #10251 failed with stages
in 10 minutes and 15 seconds
# You can copy this Dockerfile.example to Dockerfile to add configuration
# or packages or anything else to your dbimage
ARG BASE_IMAGE=drud/ddev-dbserver:v1.6.0-10.1
FROM $BASE_IMAGE
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y telnet netcat
RUN echo "Built from drud/ddev-dbserver:v1.6.0-10.1" >/var/tmp/built-from.txt
# You can copy this Dockerfile.example to Dockerfile to add configuration
# or packages or anything else to your webimage
ARG BASE_IMAGE=drud/ddev-webserver:v1.8.0
FROM $BASE_IMAGE
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y php-yaml
RUN npm install --global gulp-cli
RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime && dpkg-reconfigure --frontend noninteractive tzdata
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f76cc277ce921ce20c94d794aa9b5dc9", "content-hash": "e54fe9a4a45aa356217f37a616113654",
"packages": [ "packages": [
{ {
"name": "adoy/fastcgi-client", "name": "adoy/fastcgi-client",
...@@ -1957,6 +1957,10 @@ ...@@ -1957,6 +1957,10 @@
"logging", "logging",
"psr-3" "psr-3"
], ],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.2.0"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/Seldaek", "url": "https://github.com/Seldaek",
...@@ -3119,6 +3123,11 @@ ...@@ -3119,6 +3123,11 @@
], ],
"description": "Shariff implementation for TYPO3 CMS including the backend module, a viewhelper and a plugin.", "description": "Shariff implementation for TYPO3 CMS including the backend module, a viewhelper and a plugin.",
"homepage": "https://bitbucket.org/reelworx/rx_shariff", "homepage": "https://bitbucket.org/reelworx/rx_shariff",
"support": {
"docs": "https://docs.typo3.org/p/reelworx/rx-shariff/master/en-us/",
"issues": "https://bitbucket.org/reelworx/rx_shariff/issues",
"source": "https://bitbucket.org/reelworx/rx_shariff/src"
},
"time": "2020-12-10T09:37:43+00:00" "time": "2020-12-10T09:37:43+00:00"
}, },
{ {
...@@ -3259,6 +3268,10 @@ ...@@ -3259,6 +3268,10 @@
"logging", "logging",
"sentry" "sentry"
], ],
"support": {
"issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/2.5.1"
},
"funding": [ "funding": [
{ {
"url": "https://sentry.io/", "url": "https://sentry.io/",
...@@ -3335,7 +3348,7 @@ ...@@ -3335,7 +3348,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.spooner.io/spooner/deployer_information/", "url": "https://git.spooner.io/spooner/deployer_information/",
"reference": "b4d68d5f40cc914abe7aafe6eb46c47da40cc125" "reference": "b58feca58d103ff6358e44d83d592b11bc4e7813"
}, },
"require": { "require": {
"php": "^7.2", "php": "^7.2",
...@@ -3371,7 +3384,7 @@ ...@@ -3371,7 +3384,7 @@
"toolbar", "toolbar",
"typo3" "typo3"
], ],
"time": "2020-09-10T09:00:17+00:00" "time": "2020-09-10T09:11:16+00:00"
}, },
{ {
"name": "symfony/cache", "name": "symfony/cache",
...@@ -6245,7 +6258,7 @@ ...@@ -6245,7 +6258,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "extensions/t3o_donation", "url": "extensions/t3o_donation",
"reference": "247c988752ea693fd9dd427d69ed26cedb3ee59b" "reference": "93fd1e6b8c68704bd3dc8dc1011042be3dcaf0cd"
}, },
"replace": { "replace": {
"t3o_donation": "self.version", "t3o_donation": "self.version",
...@@ -6320,6 +6333,43 @@ ...@@ -6320,6 +6333,43 @@
}, },
"time": "2020-10-15T20:31:12+00:00" "time": "2020-10-15T20:31:12+00:00"
}, },
{
"name": "t3o/t3o_planet",
"version": "1.0.0",
"dist": {
"type": "path",
"url": "extensions/t3o_planet",
"reference": "dd99d60e0a2073f583f447881c5cf062634ed4d2"
},
"require": {
"typo3/cms-core": "^10.4"
},
"replace": {
"t3o_planet": "self.version",
"typo3-ter/t3o_planet": "self.version"
},
"type": "typo3-cms-extension",
"autoload": {
"psr-4": {
"T3o\\T3oPlanet\\": "Classes/"
}
},
"license": [
"GPL-3.0+"
],
"description": "Planet TYPO3 is the collection of news/articles/blog from the TYPO3 world.",
"keywords": [
"Planet TYPO3",
"TYPO3 CMS"
],
"support": {
"email": "maintenance@typo3.org",
"issues": "https://gitlab.typo3.org/t3o/typo3.org/issues"
},
"transport-options": {
"relative": true
}
},
{ {
"name": "t3o/t3olayout", "name": "t3o/t3olayout",
"version": "5.1.2", "version": "5.1.2",
...@@ -6384,7 +6434,7 @@ ...@@ -6384,7 +6434,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "extensions/t3org_layout", "url": "extensions/t3org_layout",
"reference": "0a3f5ad2e7c751eb9a4c6bbeaed83138a86b52a1" "reference": "6f3f0b323325bacb0bae7c524814e50212632317"
}, },
"replace": { "replace": {
"t3org_layout": "self.version" "t3org_layout": "self.version"
...@@ -8695,6 +8745,10 @@ ...@@ -8695,6 +8745,10 @@
"seo", "seo",
"yoast" "yoast"
], ],
"support": {
"issues": "https://github.com/Yoast/Yoast-SEO-for-TYPO3/issues",
"source": "https://github.com/Yoast/Yoast-SEO-for-TYPO3/tree/v7.0.7"
},
"time": "2020-12-10T07:02:50+00:00" "time": "2020-12-10T07:02:50+00:00"
} }
], ],
...@@ -8766,6 +8820,7 @@ ...@@ -8766,6 +8820,7 @@
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"t3o/t3o_planet": 20,
"t3o/t3org_layout": 20, "t3o/t3org_layout": 20,
"t3o/typo3_roadmap": 20 "t3o/typo3_roadmap": 20
}, },
......
<?php
namespace T3o\T3oPlanet\Backend\Preview;
/*
* This file is part of a TYPO3 extension.
*
* 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\Backend\View\BackendLayout\Grid\GridColumnItem;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
class PreviewRenderer implements \TYPO3\CMS\Backend\Preview\PreviewRendererInterface
{
public function renderPageModulePreviewContent(GridColumnItem $item): string
{
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setTemplatePathAndFilename('EXT:t3o_planet/Resources/Private/Backend/Planet.html');
$flexFormData = [];
if (!empty($row['pi_flexform'])) {
/** @var FlexFormService $flexFormService */
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
$flexFormData = $flexFormService->convertFlexFormContentToArray($row['pi_flexform']);
}
// assign all to view
$view->assignMultiple(
[
'data' => $row,
'flexformData' => $flexFormData,
]
);
return $view->render();
}
public function renderPageModulePreviewHeader(GridColumnItem $item): string
{
return '';
}
public function renderPageModulePreviewFooter(GridColumnItem $item): string
{
return '';
}
public function wrapPageModulePreview(string $previewHeader, string $previewContent, GridColumnItem $item): string
{
return $previewHeader . $previewContent;
}
}
<?php
namespace T3o\T3oPlanet\Controller;
/***
*
* This file is part of the "Planet TYPO3" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2019
*
***/
use T3o\T3oPlanet\Domain\Model\Article;
use T3o\T3oPlanet\Domain\Repository\ArticleRepository;
use T3o\T3oPlanet\Domain\Repository\TagRepository;
use T3o\T3oPlanet\Property\TypeConverter\UploadedFileReferenceConverter;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
use TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
use TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration;
class ArticleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
protected array $contentElementData;
protected ?ArticleRepository $articleRepository;
public function injectArticleRepository(ArticleRepository $articleRepository): void
{
$this->articleRepository = $articleRepository;
}
protected ?TagRepository $tagRepository;
public function injectTagRepository(TagRepository $tagRepository): void
{
$this->tagRepository = $tagRepository;
}
protected ?CategoryRepository $categoryRepository;
public function injectCategoryRepository(CategoryRepository $categoryRepository): void
{
$this->categoryRepository = $categoryRepository;
}
protected FrontendUserRepository $userRepository;
public function injectUserRepository(FrontendUserRepository $frontendUserRepository): void
{
$this->userRepository = $frontendUserRepository;
}
/**
* action initialize
*/
public function initializeAction()
{
parent::initializeAction();
$this->contentElementData = $this->configurationManager->getContentObject()->data;
}
/**
* action featuredList
*/
public function featuredListAction()
{
// Records per page
$limit = 4;
if ($this->settings['articlesPerPage']) {
$limit = (int)$this->settings['articlesPerPage'];
}
$t3planetArticles = $this->articleRepository->getFeaturedArticles($limit);
$this->view->assign('t3planetArticles', $t3planetArticles);
$this->view->assign('data', $this->contentElementData);
}
public function filterArticleAction()
{
$t3planetTags = $this->tagRepository->findAll();
$argument = $this->request->getArguments();
if ($argument['category']) {
$category = (int)$this->request->getArgument('category');
$t3planetArticles = $this->articleRepository->getAcceptedArticlesByCategoryId($category);
} else {
$t3planetArticles = $this->articleRepository->getAcceptedArticles();
}
$t3planetArticlesInfo = [];
if ($t3planetArticles) {
foreach ($t3planetArticles as $articleKey => $article) {
$t3planetArticlesInfo[$articleKey]['articleDate'] = $article->getArticleDate();
$t3planetArticlesInfo[$articleKey]['title'] = $article->getTitle();
$t3planetArticlesInfo[$articleKey]['teasertext'] = $article->getTeasertext();
$t3planetArticlesInfo[$articleKey]['link'] = $article->getLink();
$t3planetArticlesInfo[$articleKey]['name'] = $article->getName();
$t3planetArticlesInfo[$articleKey]['email'] = $article->getEmail();
$t3planetArticlesInfo[$articleKey]['feUserid'] = $article->getFeUserid();
$t3planetArticlesInfo[$articleKey]['image'] = $article->getImage();
$t3planetArticlesInfo[$articleKey]['tags'] = '';
$tags = $article->getTagId();
foreach ($tags as $tag) {
$t3planetArticlesInfo[$articleKey]['tags'] = 'tag-' . $tag->getUid();
}
}
}
$assignArray = [
't3planetArticles' => $t3planetArticlesInfo,
't3planetTags' => $t3planetTags,
'data' => $this->contentElementData,
];
$this->view->assignMultiple($assignArray);
}
/**
* action list
*/
public function articlesManagementAction()
{
$statusArr = [
Article::STATUS_PENDING => 'Pending',
Article::STATUS_ACCEPTED => 'Accepted',
Article::STATUS_REJECTED => 'Rejected',
];
$panelType = $this->settings['panelType'];
if ($panelType) {
$request = $this->request->getArguments();
if ($request['newT3planetArticles']['search'] != '') {
$t3planetArticles = $this->articleRepository->getArticlesBysearch($request['newT3planetArticles']['search']);
} else {
$t3planetArticles = $this->articleRepository->findAll();
}
} else {
$userID = $GLOBALS['TSFE']->fe_user->user['uid'];
$t3planetArticles = $this->articleRepository->getArticlesByUser($userID);
}
$assignArray = [
't3planetArticles' => $t3planetArticles,
'statusArr' => $statusArr,
'data' => $this->contentElementData,
];
$this->view->assignMultiple($assignArray);
}
/**
* action new
*/
public function newAction(int $backPid = 0)
{
$userId = $GLOBALS['TSFE']->fe_user->user['uid'];
$mainPlanetTypo3Category = $this->categoryRepository->findByUid((int)$this->settings['mainCategory']);
$t3planetCategories = $this->categoryRepository->findByParent($mainPlanetTypo3Category);
$t3planetTags = $this->tagRepository->findAll();
$assignArray = [
't3planetTags' => $t3planetTags,
't3planetCategories' => $t3planetCategories,
'backPID' => $backPid,
'user' => $userId,
'data' => $this->contentElementData,
];
$this->view->assignMultiple($assignArray);
}
/**
* Set TypeConverter option for image upload
*/
public function initializeCreateAction()
{
$this->setTypeConverterConfigurationForImageUpload('newT3planetArticles');
$getArguments = $this->request->getArguments();
if ($getArguments['newT3planetArticles']['image']['error'] > 0) {
unset($getArguments['newT3planetArticles']['image']);
}
if (isset($this->arguments['newT3planetArticles'])) {
$this->arguments['newT3planetArticles']
->getPropertyMappingConfiguration()
->forProperty('articleDate')
->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'd-m-Y');
}
$this->request->setArguments($getArguments);
}
/**
* action create
*
* @param \T3o\T3oPlanet\Domain\Model\Article $newT3planetArticles
*/
public function createAction(Article $newT3planetArticles)
{
$backPid = (int)GeneralUtility::_GP('backPID');
$user = $this->getCurrentUser();
$storagePid = $this->configurationManager->getContentObject()->data['pages'];
$date = \DateTime::createFromFormat('d-m-Y', date('d-m-Y'));
$newT3planetArticles->setArticleDate($date);
if ($user) {
$newT3planetArticles->setName($user->getName());
$newT3planetArticles->setEmail($user->getEmail());
$newT3planetArticles->setFeUserid($user->getUsername());
$newT3planetArticles->setPid($storagePid);
$this->articleRepository->add($newT3planetArticles);
} else {
$this->addFlashMessage('You need to login first!', 'No access!', FlashMessage::ERROR);
}
if ($backPid) {
$this->addFlashMessage('A new article inserted successfully!', 'Success!', FlashMessage::OK);
$uriBuilder = $this->uriBuilder;
$uri = $uriBuilder
->setTargetPageUid($backPid)
->build();
$this->redirectToUri($uri, 0, 301);
} else {
$this->redirect('articlesManagement');
}
}
public function getCurrentUser(): FrontendUser
{
if ($this->currentUser === null && $GLOBALS['TSFE']->fe_user->user['uid'] > 0) {
$this->currentUser = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
}
return $this->currentUser;
}
/**
* action edit
*
* @param \T3o\T3oPlanet\Domain\Model\Article $t3planetArticles
*/
public function editAction(Article $t3planetArticles)
{
$t3planetCategories = $this->categoryRepository->findAll();
$t3planetTags = $this->tagRepository->findAll();
$assignArray = [
't3planetTags' => $t3planetTags,
't3planetCategories' => $t3planetCategories,
't3planetArticles' => $t3planetArticles,
'data' => $this->contentElementData,
];
$this->view->assignMultiple($assignArray);
}
/**
* Set TypeConverter option for image upload
*/
public function initializeUpdateAction()
{
$this->setTypeConverterConfigurationForImageUpload('t3planetArticles');
}
/**
* action update
*
* @param \T3o\T3oPlanet\Domain\Model\Article $t3planetArticles
*/
public function updateAction(Article $t3planetArticles)
{
$this->addFlashMessage('The article updated successfully!', 'Success!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->articleRepository->update($t3planetArticles);
$this->redirect('list');
}
/**
* action updateStatus
*/
public function updateStatusAction()
{
$request = $this->request->getArguments();
if ($request['newT3planetArticles']) {
$articles = $this->articleRepository->findByUid($request['newT3planetArticles']['uid']);
$articles->setArticleStatus($request['newT3planetArticles']['articleStatus']);
$this->articleRepository->update($articles);
$this->addFlashMessage('The article updated successfully!', 'Success!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->redirect('articlesManagement');
}
}
/**
* action delete
*
* @param \T3o\T3oPlanet\Domain\Model\Article $t3planetArticles
*/
public function deleteAction(Article $t3planetArticles)
{
$this->articleRepository->remove($t3planetArticles);
$this->addFlashMessage('The article deleted successfully!', 'Success!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->redirect('list');
}
protected function setTypeConverterConfigurationForImageUpload(string $argumentName)
{
$uploadConfiguration = [
UploadedFileReferenceConverter::CONFIGURATION_ALLOWED_FILE_EXTENSIONS => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER => '1:/Planet/',
];