Commit 9837df1a authored by Stefan Busemann's avatar Stefan Busemann

Merge branch '499-add-multiple-contributors-and-their-role-to-news-articles' into 'develop'

Resolve "Add multiple contributors and their role to news articles"

Closes #499

See merge request !372
parents 2fde6b87 c1ac1c71
Pipeline #9585 passed with stages
in 6 minutes and 48 seconds
This diff is collapsed.
<?php
namespace T3o\T3orgLayout\Domain\Model;
/*
* This file is part of the TYPO3 project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License, either version 3
* of the License, or (at your option) any later version.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class News
*/
class Contributors extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
*/
protected $role;
/**
* @var int
*/
protected $parent;
/**
* @var string
*/
protected $authorFeUser;
/**
* @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser|null
*/
public function getAuthorFeUser()
{
if (!$this->authorFeUser) {
return null;
}
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$querySettings = $objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$userRepository = $objectManager->get(\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository::class);
$userRepository->setDefaultQuerySettings($querySettings);
return $userRepository->findOneByUsername($this->authorFeUser);
}
/**
* @param string $authorFeUser
*/
public function setAuthorFeUser(string $authorFeUser)
{
$this->authorFeUser = $authorFeUser;
}
public function getRole(): string
{
return $this->role;
}
public function setRole(string $role)
{
$this->role = $role;
}
public function getParent(): int
{
return $this->parent;
}
public function setParent(int $parent)
{
$this->parent = $parent;
}
}
......@@ -25,6 +25,11 @@ class News extends \GeorgRinger\News\Domain\Model\News
*/
protected $authorFeUser;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\T3orgLayout\Domain\Model\Contributors>
*/
protected $contributors;
/**
* @var string
*/
......@@ -64,4 +69,19 @@ class News extends \GeorgRinger\News\Domain\Model\News
return $userRepository->findOneByUsername($this->authorFeUser);
}
/**
* Sets the contributors
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\T3orgLayout\Domain\Model\Contributors> $contributors
*/
public function setContributors($contributors): void
{
$this->contributors = $contributors;
}
public function getContributors(): \TYPO3\CMS\Extbase\Persistence\ObjectStorage
{
return $this->contributors;
}
}
<?php
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['author_fe_user'] = [
'exclude' => '0',
'exclude' => 0,
'label' => 'Select fe user',
'config' => [
'type' => 'select',
......@@ -13,6 +13,29 @@ $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['author_fe_user'] = [
]
];
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['contributors'] = [
'exclude' => 0,
'label' => 'Select contributors for this article',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_t3orglayout_domain_model_contributors',
'foreign_field' => 'parent',
'foreign_sortby' => 'sorting',
'size' => 5,
'minitems' => 0,
'maxitems' => 10,
'appearance' => [
'collapseAll' => true,
'expandSingle' => true,
'levelLinksPosition' => 'bottom',
'useSortable' => true,
'enabledControls' => [
'info' => false,
]
],
]
];
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['default_image'] = [
'exclude' => 0,
'label' => 'Default Image',
......@@ -93,3 +116,10 @@ $GLOBALS['TCA']['tx_news_domain_model_news']['types']['0']['columnsOverrides'] =
'',
'before:author'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tx_news_domain_model_news',
'contributors',
'',
'before:author'
);
<?php
use T3o\T3orgLayout\TCA\TcaProcFunc;
defined('TYPO3_MODE') or die();
return [
'ctrl' => [
'title' => 'tx_news_domain_model_contributors',
'label' => 'author_fe_user',
'label_alt' => 'role',
'label_alt_force' => true,
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'default_sortby' => 'ORDER BY sorting',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
],
'hideTable' => true,
],
'interface' => [
'showRecordFieldList' => 'hidden,role,author_fe_user'
],
'columns' => [
'pid' => [
'label' => 'pid',
'config' => [
'type' => 'passthrough'
]
],
'crdate' => [
'label' => 'crdate',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
]
],
'tstamp' => [
'label' => 'tstamp',
'config' => [
'type' => 'input',
'renderType' => 'inputDateTime',
'eval' => 'datetime',
]
],
'hidden' => [
'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
'config' => [
'type' => 'check',
'default' => 0
]
],
'role' => [
'exclude' => false,
'label' => 'Role',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['Please select a role', 0],
['Reviewer', 1],
['Copy Editor', 2],
['Proofreader', 3],
['Translator', 4],
]
],
],
'author_fe_user' => [
'exclude' => '0',
'label' => 'Select fe user',
'config' => [
'type' => 'select',
'minitems' => 0,
'maxitems' => 1,
'renderType' => 'selectMultipleSideBySide',
'enableMultiSelectFilterTextfield' => true,
'itemsProcFunc' => TcaProcFunc::class . '->feUserItems',
]
],
],
'types' => [
0 => [
'showitem' => 'role,author_fe_user, --palette--;;paletteCore'
]
],
'palettes' => [
'paletteCore' => [
'showitem' => 'hidden,sys_language_uid,l10n_parent, l10n_diffsource,',
]
]
];
......@@ -11,6 +11,21 @@
<trans-unit id="tx_t3org_layout.events.importdate">
<source>Import event dates</source>
</trans-unit>
<trans-unit id="tx_t3org_layout.news.contributors.roles.0">
<source>Contributor</source>
</trans-unit>
<trans-unit id="tx_t3org_layout.news.contributors.roles.1">
<source>Reviewer</source>
</trans-unit>
<trans-unit id="tx_t3org_layout.news.contributors.roles.2">
<source>Copy Editor</source>
</trans-unit>
<trans-unit id="tx_t3org_layout.news.contributors.roles.3">
<source>Proofreader</source>
</trans-unit>
<trans-unit id="tx_t3org_layout.news.contributors.roles.4">
<source>Translator</source>
</trans-unit>
</body>
</file>
</xliff>
......@@ -10,5 +10,15 @@ CREATE TABLE tx_sfeventmgt_domain_model_event (
#
CREATE TABLE tx_news_domain_model_news (
author_fe_user varchar(30) DEFAULT '' NOT NULL,
default_image varchar(30) DEFAULT '' NOT NULL
default_image varchar(30) DEFAULT '' NOT NULL,
contributors int DEFAULT 0
);
#
# Table structure for table 'tx_t3orglayout_domain_model_contributors'
#
CREATE TABLE tx_t3orglayout_domain_model_contributors (
author_fe_user varchar(30) DEFAULT '' NOT NULL,
role varchar(100) DEFAULT '' NOT NULL,
parent int(11) DEFAULT '0' NOT NULL
);
Markdown is supported
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