|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Integration service |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace HDNET\Tagger\Service; |
|
8
|
|
|
|
|
9
|
|
|
use TYPO3\CMS\Core\Database\DatabaseConnection; |
|
10
|
|
|
use TYPO3\CMS\Core\DataHandling\DataHandler; |
|
11
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class IntegrationService |
|
15
|
|
|
*/ |
|
16
|
|
|
class IntegrationService |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Get the field configuration for a Tag field |
|
21
|
|
|
* |
|
22
|
|
|
* @param string $tableName |
|
23
|
|
|
* @return array |
|
24
|
|
|
*/ |
|
25
|
|
|
public static function getTagFieldConfiguration($tableName) |
|
26
|
|
|
{ |
|
27
|
|
|
$config = [ |
|
28
|
|
|
'type' => 'select', |
|
29
|
|
|
'foreign_table' => 'tx_tagger_domain_model_tag', |
|
30
|
|
|
'foreign_table_where' => 'ORDER BY tx_tagger_domain_model_tag.title', |
|
31
|
|
|
'MM' => 'tx_tagger_tag_mm', |
|
32
|
|
|
'MM_hasUidField' => true, |
|
33
|
|
|
'multiple' => false, |
|
34
|
|
|
'MM_opposite_field' => 'content', |
|
35
|
|
|
'MM_match_fields' => [ |
|
36
|
|
|
'tablenames' => $tableName |
|
37
|
|
|
], |
|
38
|
|
|
'size' => 5, |
|
39
|
|
|
'autoSizeMax' => 20, |
|
40
|
|
|
'minitems' => 0, |
|
41
|
|
|
'maxitems' => 30, |
|
42
|
|
|
'wizards' => [ |
|
43
|
|
|
'_PADDING' => 2, |
|
44
|
|
|
'_VERTICAL' => 1, |
|
45
|
|
|
'suggest' => [ |
|
46
|
|
|
'type' => 'suggest', |
|
47
|
|
|
'default' => [ |
|
48
|
|
|
'receiverClass' => \HDNET\Tagger\Hooks\SuggestReceiver::class |
|
49
|
|
|
], |
|
50
|
|
|
], |
|
51
|
|
|
], |
|
52
|
|
|
]; |
|
53
|
|
|
|
|
54
|
|
|
return $config; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Create a new Tag Record |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $title |
|
61
|
|
|
* @return integer The ID of the New Tag |
|
62
|
|
|
*/ |
|
63
|
|
|
public static function createTagRecord($title) |
|
64
|
|
|
{ |
|
65
|
|
|
$tcemainData = [ |
|
66
|
|
|
'tx_tagger_domain_model_tag' => [ |
|
67
|
|
|
'NEW' => [ |
|
68
|
|
|
'pid' => 0, |
|
69
|
|
|
'title' => $title |
|
70
|
|
|
] |
|
71
|
|
|
] |
|
72
|
|
|
]; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var DataHandler |
|
76
|
|
|
*/ |
|
77
|
|
|
$tce = GeneralUtility::makeInstance(DataHandler::class); |
|
78
|
|
|
$tce->start($tcemainData, []); |
|
79
|
|
|
$tce->process_datamap(); |
|
80
|
|
|
|
|
81
|
|
|
return $tce->substNEWwithIDs['NEW']; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Get related contents |
|
86
|
|
|
* |
|
87
|
|
|
* @param string $table |
|
88
|
|
|
* @param integer $uid |
|
89
|
|
|
* @return array |
|
90
|
|
|
* @TODO: implement |
|
91
|
|
|
*/ |
|
92
|
|
|
public static function gerRelatedContent($table, $uid) |
|
|
|
|
|
|
93
|
|
|
{ |
|
94
|
|
|
$records = []; |
|
95
|
|
|
/* |
|
96
|
|
|
$GLOBALS['TSFE']->exec_SELECTgetRows('uid_foreign as uid, tablenames', 'tx_tagger_tag_mm', |
|
97
|
|
|
, |
|
98
|
|
|
$ groupBy = '', |
|
99
|
|
|
$ orderBy = '', |
|
100
|
|
|
$ limit = '', |
|
101
|
|
|
$ uidIndexField = '' |
|
102
|
|
|
) |
|
103
|
|
|
* Ü */ |
|
104
|
|
|
|
|
105
|
|
|
return $records; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Get related by same tag |
|
110
|
|
|
* |
|
111
|
|
|
* @param integer $uid |
|
112
|
|
|
* @return array |
|
113
|
|
|
*/ |
|
114
|
|
|
public static function gerRelatedByTag($uid) |
|
115
|
|
|
{ |
|
116
|
|
|
/** @var DatabaseConnection $databaseConnection */ |
|
117
|
|
|
$databaseConnection = $GLOBALS['TYPO3_DB']; |
|
118
|
|
|
return $databaseConnection->exec_SELECTgetRows( |
|
119
|
|
|
'uid_foreign as uid, tablenames', |
|
120
|
|
|
'tx_tagger_tag_mm', |
|
121
|
|
|
'uid_local=' . $uid |
|
122
|
|
|
); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.