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

First bunch of getting t3o_planet running in v10

parent 6694880c
Pipeline #10023 failed with stages
in 1 minute and 52 seconds
......@@ -17,42 +17,37 @@ use T3o\T3oPlanet\Property\TypeConverter\UploadedFileReferenceConverter;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration;
/**
* T3planetArticlesController
*/
class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
class ArticleController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* t3planetArticlesRepository
*
* @var \T3o\T3oPlanet\Domain\Repository\T3planetArticlesRepository
* @inject
*/
protected $t3planetArticlesRepository = null;
protected array $contentElementData;
/**
* t3planetTagsRepository
*
* @var \T3o\T3oPlanet\Domain\Repository\T3planetTagsRepository
* @inject
*/
protected $t3planetTagsRepository = null;
protected ?\T3o\T3oPlanet\Domain\Repository\ArticleRepository $articleRepository;
/**
* t3planetCategoriesRepository
*
* @var \T3o\T3oPlanet\Domain\Repository\T3planetCategoriesRepository
* @inject
*/
protected $t3planetCategoriesRepository = null;
public function injectArticleRepository(\T3o\T3oPlanet\Domain\Repository\ArticleRepository $articleRepository): void
{
$this->articleRepository = $articleRepository;
}
/**
* User Repository
*
* @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
* @inject
*/
protected $userRepository;
protected ?\T3o\T3oPlanet\Domain\Repository\TagRepository $tagRepository;
public function injectTagRepository(\T3o\T3oPlanet\Domain\Repository\TagRepository $tagRepository): void
{
$this->tagRepository = $tagRepository;
}
protected ?\TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository $categoryRepository;
public function injectCategoryRepository(\TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository $categoryRepository): void
{
$this->categoryRepository = $categoryRepository;
}
protected \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $userRepository;
public function injectUserRepository(\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $frontendUserRepository): void
{
$this->userRepository = $frontendUserRepository;
}
/**
* action initialize
......@@ -60,8 +55,7 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
public function initializeAction()
{
parent::initializeAction();
$data = $this->configurationManager->getContentObject();
$this->contentElementData = $data->data;
$this->contentElementData = $this->configurationManager->getContentObject()->data;
}
/**
* action featuredList
......@@ -73,20 +67,20 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
if ($this->settings['articlesPerPage']) {
$limit = (int)$this->settings['articlesPerPage'];
}
$t3planetArticles = $this->t3planetArticlesRepository->getFeaturedArticles($limit);
$t3planetArticles = $this->articleRepository->getFeaturedArticles($limit);
$this->view->assign('t3planetArticles', $t3planetArticles);
$this->view->assign('data', $this->contentElementData);
}
public function filterArticleAction()
{
$t3planetTags = $this->t3planetTagsRepository->findAll();
$t3planetTags = $this->tagRepository->findAll();
$argument = $this->request->getArguments();
if ($argument['category']) {
$category = (int)$this->request->getArgument('category');
$t3planetArticles = $this->t3planetArticlesRepository->getAcceptedArticlesByCategoryId($category);
$t3planetArticles = $this->articleRepository->getAcceptedArticlesByCategoryId($category);
} else {
$t3planetArticles = $this->t3planetArticlesRepository->getAcceptedArticles();
$t3planetArticles = $this->articleRepository->getAcceptedArticles();
}
$t3planetArticlesInfo = [];
......@@ -123,21 +117,21 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
public function articlesManagementAction()
{
$statusArr = [
0 => 'Pending',
1 => 'Accepted',
2 => 'Rejected',
\T3o\T3oPlanet\Domain\Model\Article::STATUS_PENDING => 'Pending',
\T3o\T3oPlanet\Domain\Model\Article::STATUS_ACCEPTED => 'Accepted',
\T3o\T3oPlanet\Domain\Model\Article::STATUS_REJECTED => 'Rejected',
];
$panelType = $this->settings['panelType'];
if ($panelType) {
$request = $this->request->getArguments();
if ($request['newT3planetArticles']['search'] != '') {
$t3planetArticles = $this->t3planetArticlesRepository->getArticlesBysearch($request['newT3planetArticles']['search']);
$t3planetArticles = $this->articleRepository->getArticlesBysearch($request['newT3planetArticles']['search']);
} else {
$t3planetArticles = $this->t3planetArticlesRepository->findAll();
$t3planetArticles = $this->articleRepository->findAll();
}
} else {
$userID = $GLOBALS['TSFE']->fe_user->user['uid'];
$t3planetArticles = $this->t3planetArticlesRepository->getArticlesByUser($userID);
$t3planetArticles = $this->articleRepository->getArticlesByUser($userID);
}
$assignArray = [
......@@ -151,17 +145,17 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
/**
* action new
*/
public function newAction()
public function newAction(int $backPid = 0)
{
$backPID = GeneralUtility::_GP('backPID');
$userID = $GLOBALS['TSFE']->fe_user->user['uid'];
$t3planetCategories = $this->t3planetCategoriesRepository->findAll();
$t3planetTags = $this->t3planetTagsRepository->findAll();
$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,
'backPID' => $backPid,
'user' => $userId,
'data' => $this->contentElementData,
];
$this->view->assignMultiple($assignArray);
......@@ -189,18 +183,18 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
/**
* action create
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetArticles $newT3planetArticles
* @param \T3o\T3oPlanet\Domain\Model\Article $newT3planetArticles
*/
public function createAction(\T3o\T3oPlanet\Domain\Model\T3planetArticles $newT3planetArticles)
public function createAction(\T3o\T3oPlanet\Domain\Model\Article $newT3planetArticles)
{
$backPID = GeneralUtility::_GP('backPID');
$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 ($GLOBALS['TSFE']->fe_user->user['uid'] > 0) {
if ($user) {
$newT3planetArticles->setName($user->getUsername());
$newT3planetArticles->setEmail($user->getEmail());
$newT3planetArticles->setFeUserid($user->getUid());
......@@ -208,13 +202,13 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
$newT3planetArticles->setPid($storagePid);
$this->t3planetArticlesRepository->add($newT3planetArticles);
$this->articleRepository->add($newT3planetArticles);
if ($backPID) {
if ($backPid) {
$this->addFlashMessage('A new article inserted successfully!', 'Success!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$uriBuilder = $this->uriBuilder;
$uri = $uriBuilder
->setTargetPageUid($backPID)
->setTargetPageUid($backPid)
->build();
$this->redirectToUri($uri, 0, 301);
} else {
......@@ -222,29 +216,24 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
}
}
/**
* Den aktuell angemeldeten User auslesen
*
* @return \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
*/
public function getCurrentUser()
public function getCurrentUser(): \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
{
if ($this->currentUser == null && $GLOBALS['TSFE']->fe_user->user['uid'] > 0) {
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\T3planetArticles $t3planetArticles
* @ignorevalidation $t3planetArticles
* @param \T3o\T3oPlanet\Domain\Model\Article $t3planetArticles
*/
public function editAction(\T3o\T3oPlanet\Domain\Model\T3planetArticles $t3planetArticles)
public function editAction(\T3o\T3oPlanet\Domain\Model\Article $t3planetArticles)
{
$t3planetCategories = $this->t3planetCategoriesRepository->findAll();
$t3planetTags = $this->t3planetTagsRepository->findAll();
$t3planetCategories = $this->categoryRepository->findAll();
$t3planetTags = $this->tagRepository->findAll();
$assignArray = [
't3planetTags' => $t3planetTags,
't3planetCategories' => $t3planetCategories,
......@@ -265,12 +254,12 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
/**
* action update
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetArticles $t3planetArticles
* @param \T3o\T3oPlanet\Domain\Model\Article $t3planetArticles
*/
public function updateAction(\T3o\T3oPlanet\Domain\Model\T3planetArticles $t3planetArticles)
public function updateAction(\T3o\T3oPlanet\Domain\Model\Article $t3planetArticles)
{
$this->addFlashMessage('The article updated successfully!', 'Success!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->t3planetArticlesRepository->update($t3planetArticles);
$this->articleRepository->update($t3planetArticles);
$this->redirect('list');
}
......@@ -281,9 +270,9 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
{
$request = $this->request->getArguments();
if ($request['newT3planetArticles']) {
$articles = $this->t3planetArticlesRepository->findByUid($request['newT3planetArticles']['uid']);
$articles = $this->articleRepository->findByUid($request['newT3planetArticles']['uid']);
$articles->setArticleStatus($request['newT3planetArticles']['articleStatus']);
$this->t3planetArticlesRepository->update($articles);
$this->articleRepository->update($articles);
$this->addFlashMessage('The article updated successfully!', 'Success!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->redirect('articlesManagement');
}
......@@ -292,19 +281,16 @@ class T3planetArticlesController extends \TYPO3\CMS\Extbase\Mvc\Controller\Actio
/**
* action delete
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetArticles $t3planetArticles
* @param \T3o\T3oPlanet\Domain\Model\Article $t3planetArticles
*/
public function deleteAction(\T3o\T3oPlanet\Domain\Model\T3planetArticles $t3planetArticles)
public function deleteAction(\T3o\T3oPlanet\Domain\Model\Article $t3planetArticles)
{
$this->t3planetArticlesRepository->remove($t3planetArticles);
$this->articleRepository->remove($t3planetArticles);
$this->addFlashMessage('The article deleted successfully!', 'Success!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
$this->redirect('list');
}
/**
* @param $argumentName
*/
protected function setTypeConverterConfigurationForImageUpload($argumentName)
protected function setTypeConverterConfigurationForImageUpload(string $argumentName)
{
$uploadConfiguration = [
UploadedFileReferenceConverter::CONFIGURATION_ALLOWED_FILE_EXTENSIONS => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
......
<?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
*
***/
/**
* T3planetCategoriesController
*/
class T3planetCategoriesController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* t3planetCategoriesRepository
*
* @var \T3o\T3oPlanet\Domain\Repository\T3planetCategoriesRepository
* @inject
*/
protected $t3planetCategoriesRepository = null;
/**
* action initialize
*/
public function initializeAction()
{
parent::initializeAction();
$data = $this->configurationManager->getContentObject();
$this->contentElementData = $data->data;
}
/**
* action list
*/
public function listAction()
{
$t3planetCategories = $this->t3planetCategoriesRepository->findAll();
$this->view->assign('t3planetCategories', $t3planetCategories);
$this->view->assign('data', $this->contentElementData);
}
/**
* action show
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories
*/
public function showAction(\T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories)
{
$this->view->assign('t3planetCategories', $t3planetCategories);
}
/**
* action new
*/
public function newAction()
{
}
/**
* action create
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetCategories $newT3planetCategories
*/
public function createAction(\T3o\T3oPlanet\Domain\Model\T3planetCategories $newT3planetCategories)
{
$this->addFlashMessage('The object was created. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING);
$this->t3planetCategoriesRepository->add($newT3planetCategories);
$this->redirect('list');
}
/**
* action edit
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories
* @ignorevalidation $t3planetCategories
*/
public function editAction(\T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories)
{
$this->view->assign('t3planetCategories', $t3planetCategories);
}
/**
* action update
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories
*/
public function updateAction(\T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories)
{
$this->addFlashMessage('The object was updated. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING);
$this->t3planetCategoriesRepository->update($t3planetCategories);
$this->redirect('list');
}
/**
* action delete
*
* @param \T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories
*/
public function deleteAction(\T3o\T3oPlanet\Domain\Model\T3planetCategories $t3planetCategories)
{
$this->addFlashMessage('The object was deleted. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING);
$this->t3planetCategoriesRepository->remove($t3planetCategories);
$this->redirect('list');
}
}
......@@ -15,15 +15,14 @@ namespace T3o\T3oPlanet\Controller;
/**
* T3planetTagsController
*/
class T3planetTagsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
class TagController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* t3planetTagsRepository
*
* @var \T3o\T3oPlanet\Domain\Repository\T3planetTagsRepository
* @inject
*/
protected $t3planetTagsRepository = null;
protected ?\T3o\T3oPlanet\Domain\Repository\TagRepository $t3planetTagsRepository;
public function injectT3planetTagsRepository(\T3o\T3oPlanet\Domain\Repository\TagRepository $t3planetTagsRepository): void
{
$this->t3planetTagsRepository = $t3planetTagsRepository;
}
/**
* action list
......
......@@ -12,74 +12,76 @@ namespace T3o\T3oPlanet\Domain\Model;
*
***/
/**
* T3planetArticles
*/
class T3planetArticles extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
use TYPO3\CMS\Extbase\Annotation as Extbase;
class Article extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
const STATUS_PENDING = 0;
const STATUS_ACCEPTED = 1;
const STATUS_REJECTED = 2;
/**
* date
*
* @var \DateTime
*/
protected $articleDate = null;
protected ?\DateTime $articleDate;
/**
* articleStatus
*
* @var int
*/
protected $articleStatus = false;
protected bool $articleStatus = false;
/**
* title
*
* @var string
* @validate NotEmpty
* @Extbase\Validate("NotEmpty")
*/
protected $title = '';
protected string $title = '';
/**
* teasertext
*
* @var string
*/
protected $teasertext = '';
protected string $teasertext = '';
/**
* link
*
* @var string
*/
protected $link = '';
protected string $link = '';
/**
* isFeatured
*
* @var bool
*/
protected $isFeatured = false;
protected bool $isFeatured = false;
/**
* name
*
* @var string
*/
protected $name = '';
protected string $name = '';
/**
* email
*
* @var string
*/
protected $email = '';
protected string $email = '';
/**
* feUserid
*
* @var string
* @var int
*/
protected $feUserid = '';
protected int $feUserid = 0;
/**
* image
......@@ -87,23 +89,23 @@ class T3planetArticles extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
*/
protected $image = null;
protected ?\TYPO3\CMS\Extbase\Domain\Model\FileReference $image;
/**
* categoryId
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\T3oPlanet\Domain\Model\T3planetCategories>
* @cascade remove
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
* @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
*/
protected $categoryId = null;
protected ?\TYPO3\CMS\Extbase\Persistence\ObjectStorage $categoryId;
/**
* tagId
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\T3oPlanet\Domain\Model\T3planetTags>
* @cascade remove
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\T3oPlanet\Domain\Model\Tag>
* @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
*/
protected $tagId = null;
protected ?\TYPO3\CMS\Extbase\Persistence\ObjectStorage $tagId;
/**
* __construct
......@@ -131,7 +133,7 @@ class T3planetArticles extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string $title
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}
......@@ -141,7 +143,7 @@ class T3planetArticles extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @param string $title
*/
public function setTitle($title)
public function setTitle(string $title)
{
$this->title = $title;
}
......@@ -151,7 +153,7 @@ class T3planetArticles extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string $teasertext
*/
public function getTeasertext()
public function getTeasertext(): string
{
return $this->teasertext;
}
......@@ -161,7 +163,7 @@ class T3planetArticles extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @param string $teasertext
*/
public function setTeasertext($teasertext)
public function setTeasertext(string $teasertext)
{
$this->teasertext = $teasertext;
}
......@@ -171,7 +173,7 @@ class T3planetArticles extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*
* @return string $link
*/
public function getLink()
public function getLink():