1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* BreadcrumbService |
5
|
|
|
*/ |
6
|
|
|
declare(strict_types=1); |
7
|
|
|
|
8
|
|
|
namespace HDNET\Calendarize\Service; |
9
|
|
|
|
10
|
|
|
use GeorgRinger\News\Hooks\BackendUtility; |
11
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
12
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
13
|
|
|
use TYPO3\CMS\Extbase\Utility\DebuggerUtility; |
14
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
15
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* BreadcrumbService |
19
|
|
|
*/ |
20
|
|
|
class BreadcrumbService extends AbstractService |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param string $content |
25
|
|
|
* @param array $configuration |
26
|
|
|
*/ |
27
|
|
|
public function generate(string $content, array $configuration) |
28
|
|
|
{ |
29
|
|
|
$arguments = GeneralUtility::_GET('tx_calendarize_calendar'); |
30
|
|
|
$indexUid = isset($arguments['index']) ? (int) $arguments['index'] : 0; |
31
|
|
|
if ($indexUid === 0) { |
32
|
|
|
return $content; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$index = $this->getIndex($indexUid); |
36
|
|
|
if ($index === null) { |
37
|
|
|
return $content; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$event = $this->getEventByIndex($index); |
41
|
|
|
$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class); |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
if(isset($configuration['doNotLinkIt']) && (bool)$configuration['doNotLinkIt']) { |
45
|
|
|
$content = $event['title']; |
46
|
|
|
} else { |
47
|
|
|
$linkConfiguration = [ |
48
|
|
|
'parameter' => $GLOBALS['TSFE']->id, |
49
|
|
|
'additionalParams' => '&tx_calendarize_calendar[index]=' . $indexUid, |
50
|
|
|
]; |
51
|
|
|
$content = $contentObjectRenderer->typoLink($event['title'], $linkConfiguration); |
52
|
|
|
} |
53
|
|
|
return $contentObjectRenderer->stdWrap($content, $configuration); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param $row |
58
|
|
|
* @return mixed|null |
59
|
|
|
*/ |
60
|
|
|
protected function getEventByIndex($row) |
61
|
|
|
{ |
62
|
|
|
return $this->fetchRecordByUid($row['foreign_table'], (int) $row['foreign_uid']); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $uid |
67
|
|
|
* @return mixed|null |
68
|
|
|
*/ |
69
|
|
|
protected function getIndex($uid) |
70
|
|
|
{ |
71
|
|
|
return $this->fetchRecordByUid('tx_calendarize_domain_model_index', $uid); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param $uid |
76
|
|
|
* @return mixed|null |
77
|
|
|
*/ |
78
|
|
|
protected function fetchRecordByUid($table, $uid) |
79
|
|
|
{ |
80
|
|
|
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); |
81
|
|
|
$where = [ |
82
|
|
|
$queryBuilder->expr()->eq('uid', (int) $uid) |
83
|
|
|
]; |
84
|
|
|
$rows = $queryBuilder->select('*') |
85
|
|
|
->from($table) |
86
|
|
|
->where(...$where) |
87
|
|
|
->execute() |
88
|
|
|
->fetchAll(); |
89
|
|
|
|
90
|
|
|
return isset($rows[0]) ? $rows[0] : null; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
} |
94
|
|
|
|