Skip to content

Commit

Permalink
fix: title of related record
Browse files Browse the repository at this point in the history
  • Loading branch information
jackd248 committed Nov 13, 2024
1 parent ad130ed commit b80d175
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Classes/Domain/Model/Dto/CommentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Xima\XimaTypo3ContentPlanner\Domain\Model\Status;
use Xima\XimaTypo3ContentPlanner\Utility\ContentUtility;
Expand All @@ -26,7 +27,8 @@ public static function create(array $row): static

public function getTitle(): string
{
return $this->getRelatedRecord() ? $this->getRelatedRecord()['title'] : '';
$titleField = $GLOBALS['TCA'][$this->data['foreign_table']]['ctrl']['label'];
return $this->getRelatedRecord() ? (array_key_exists($titleField, $this->getRelatedRecord()) ? $this->getRelatedRecord()[$titleField] : $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')) : $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title');
}

public function getRelatedRecord(): array|bool
Expand Down Expand Up @@ -73,4 +75,9 @@ public function getAuthorName(): ?string
{
return ContentUtility::getBackendUsernameById((int)$this->data['author']);
}

protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}
3 changes: 2 additions & 1 deletion Classes/Domain/Model/Dto/HistoryItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function getPid(): int

public function getTitle(): ?string
{
return array_key_exists('title', $this->getRelatedRecord()) ? $this->getRelatedRecord()['title'] : $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title');
$titleField = $GLOBALS['TCA'][$this->data['relatedRecordTablename']]['ctrl']['label'];
return array_key_exists($titleField, $this->getRelatedRecord()) ? $this->getRelatedRecord()[$titleField] : $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title');
}

public function getRelatedRecord(): array|bool
Expand Down

0 comments on commit b80d175

Please sign in to comment.