1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Event (Default) for the calendarize function. |
5
|
|
|
*/ |
6
|
|
|
declare(strict_types=1); |
7
|
|
|
|
8
|
|
|
namespace HDNET\Calendarize\Domain\Model; |
9
|
|
|
|
10
|
|
|
use HDNET\Autoloader\Annotation\DatabaseField; |
11
|
|
|
use HDNET\Autoloader\Annotation\DatabaseTable; |
12
|
|
|
use HDNET\Autoloader\Annotation\EnableRichText; |
13
|
|
|
use HDNET\Autoloader\Annotation\SmartExclude; |
14
|
|
|
use HDNET\Calendarize\Features\FeedInterface; |
15
|
|
|
use HDNET\Calendarize\Features\KeSearchIndexInterface; |
16
|
|
|
use HDNET\Calendarize\Features\SpeakingUrlInterface; |
17
|
|
|
use TYPO3\CMS\Extbase\Domain\Model\Category; |
18
|
|
|
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Event (Default) for the calendarize function. |
22
|
|
|
* |
23
|
|
|
* @DatabaseTable |
24
|
|
|
* @SmartExclude(excludes={"Workspaces"}) |
25
|
|
|
*/ |
26
|
|
|
class Event extends AbstractModel implements FeedInterface, SpeakingUrlInterface, KeSearchIndexInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Title. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
* @DatabaseField("string") |
33
|
|
|
*/ |
34
|
|
|
protected $title; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Abstract / Teaser. |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
* @DatabaseField("string") |
41
|
|
|
*/ |
42
|
|
|
protected $abstract; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Description. |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
* @DatabaseField("string") |
49
|
|
|
* @EnableRichText |
50
|
|
|
*/ |
51
|
|
|
protected $description; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Location. |
55
|
|
|
* |
56
|
|
|
* @var string |
57
|
|
|
* @DatabaseField("string") |
58
|
|
|
*/ |
59
|
|
|
protected $location; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Location link. |
63
|
|
|
* |
64
|
|
|
* @var string |
65
|
|
|
* @DatabaseField("string") |
66
|
|
|
*/ |
67
|
|
|
protected $locationLink; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Organizer. |
71
|
|
|
* |
72
|
|
|
* @var string |
73
|
|
|
* @DatabaseField("string") |
74
|
|
|
*/ |
75
|
|
|
protected $organizer; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Organizer link. |
79
|
|
|
* |
80
|
|
|
* @var string |
81
|
|
|
* @DatabaseField("string") |
82
|
|
|
*/ |
83
|
|
|
protected $organizerLink; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Import ID if the item is based on an ICS structure. |
87
|
|
|
* |
88
|
|
|
* @var string |
89
|
|
|
* @DatabaseField("string") |
90
|
|
|
*/ |
91
|
|
|
protected $importId; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Images. |
95
|
|
|
* |
96
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
97
|
|
|
* @DatabaseField("\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>") |
98
|
|
|
* @TYPO3\CMS\Extbase\Annotation\ORM\Lazy |
99
|
|
|
*/ |
100
|
|
|
protected $images; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Downloads. |
104
|
|
|
* |
105
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
106
|
|
|
* @DatabaseField("\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>") |
107
|
|
|
* @TYPO3\CMS\Extbase\Annotation\ORM\Lazy |
108
|
|
|
*/ |
109
|
|
|
protected $downloads; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Relation field. It is just used by the importer of the default events. |
113
|
|
|
* You do not need this field, if you don't use the default Event. |
114
|
|
|
* |
115
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\HDNET\Calendarize\Domain\Model\Configuration> |
116
|
|
|
* @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove") |
117
|
|
|
*/ |
118
|
|
|
protected $calendarize; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Categories. |
122
|
|
|
* |
123
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> |
124
|
|
|
*/ |
125
|
|
|
protected $categories; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Hidden. |
129
|
|
|
* |
130
|
|
|
* @var bool |
131
|
|
|
*/ |
132
|
|
|
protected $hidden = false; |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Slug. |
136
|
|
|
* |
137
|
|
|
* @var string |
138
|
|
|
* @DatabaseField("string") |
139
|
|
|
*/ |
140
|
|
|
protected $slug = ''; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Build up the object. |
144
|
|
|
*/ |
145
|
|
|
public function __construct() |
146
|
|
|
{ |
147
|
|
|
$this->calendarize = new ObjectStorage(); |
148
|
|
|
$this->images = new ObjectStorage(); |
149
|
|
|
$this->downloads = new ObjectStorage(); |
150
|
|
|
$this->categories = new ObjectStorage(); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Get title. |
155
|
|
|
* |
156
|
|
|
* @return string |
157
|
|
|
*/ |
158
|
|
|
public function getTitle() |
159
|
|
|
{ |
160
|
|
|
return $this->title; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Set title. |
165
|
|
|
* |
166
|
|
|
* @param string $title |
167
|
|
|
*/ |
168
|
|
|
public function setTitle($title) |
169
|
|
|
{ |
170
|
|
|
$this->title = $title; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Get abstract. |
175
|
|
|
* |
176
|
|
|
* @return string |
177
|
|
|
*/ |
178
|
|
|
public function getAbstract() |
179
|
|
|
{ |
180
|
|
|
return $this->abstract; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Set abstract. |
185
|
|
|
* |
186
|
|
|
* @param string $abstract |
187
|
|
|
*/ |
188
|
|
|
public function setAbstract($abstract) |
189
|
|
|
{ |
190
|
|
|
$this->abstract = $abstract; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Get description. |
195
|
|
|
* |
196
|
|
|
* @return string |
197
|
|
|
*/ |
198
|
|
|
public function getDescription() |
199
|
|
|
{ |
200
|
|
|
return $this->description; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Set description. |
205
|
|
|
* |
206
|
|
|
* @param string $description |
207
|
|
|
*/ |
208
|
|
|
public function setDescription($description) |
209
|
|
|
{ |
210
|
|
|
$this->description = $description; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get downloads. |
215
|
|
|
* |
216
|
|
|
* @return ObjectStorage |
217
|
|
|
*/ |
218
|
|
|
public function getDownloads() |
219
|
|
|
{ |
220
|
|
|
return $this->downloads; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Set downloads. |
225
|
|
|
* |
226
|
|
|
* @param ObjectStorage $downloads |
227
|
|
|
*/ |
228
|
|
|
public function setDownloads($downloads) |
229
|
|
|
{ |
230
|
|
|
$this->downloads = $downloads; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Get images. |
235
|
|
|
* |
236
|
|
|
* @return ObjectStorage |
237
|
|
|
*/ |
238
|
|
|
public function getImages() |
239
|
|
|
{ |
240
|
|
|
return $this->images; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Set images. |
245
|
|
|
* |
246
|
|
|
* @param ObjectStorage $images |
247
|
|
|
*/ |
248
|
|
|
public function setImages($images) |
249
|
|
|
{ |
250
|
|
|
$this->images = $images; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Get Import ID. |
255
|
|
|
* |
256
|
|
|
* @return string |
257
|
|
|
*/ |
258
|
|
|
public function getImportId() |
259
|
|
|
{ |
260
|
|
|
return $this->importId; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Set import ID. |
265
|
|
|
* |
266
|
|
|
* @param string $importId |
267
|
|
|
*/ |
268
|
|
|
public function setImportId($importId) |
269
|
|
|
{ |
270
|
|
|
$this->importId = $importId; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* Get calendarize. |
275
|
|
|
* |
276
|
|
|
* @return ObjectStorage |
277
|
|
|
*/ |
278
|
|
|
public function getCalendarize() |
279
|
|
|
{ |
280
|
|
|
return $this->calendarize; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Set calendarize. |
285
|
|
|
* |
286
|
|
|
* @param ObjectStorage $calendarize |
287
|
|
|
*/ |
288
|
|
|
public function setCalendarize($calendarize) |
289
|
|
|
{ |
290
|
|
|
$this->calendarize = $calendarize; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* Add one calendarize configuration. |
295
|
|
|
* |
296
|
|
|
* @param Configuration $calendarize |
297
|
|
|
*/ |
298
|
|
|
public function addCalendarize($calendarize) |
299
|
|
|
{ |
300
|
|
|
$this->calendarize->attach($calendarize); |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Get the feed title. |
305
|
|
|
* |
306
|
|
|
* @return string |
307
|
|
|
*/ |
308
|
|
|
public function getFeedTitle(): string |
309
|
|
|
{ |
310
|
|
|
return (string)$this->getTitle(); |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* Get the feed abstract. |
315
|
|
|
* |
316
|
|
|
* @return string |
317
|
|
|
*/ |
318
|
|
|
public function getFeedAbstract(): string |
319
|
|
|
{ |
320
|
|
|
return (string)$this->getFeedContent(); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* Get the feed content. |
325
|
|
|
* |
326
|
|
|
* @return string |
327
|
|
|
*/ |
328
|
|
|
public function getFeedContent(): string |
329
|
|
|
{ |
330
|
|
|
return (string)$this->getDescription(); |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Get the feed location. |
335
|
|
|
* |
336
|
|
|
* @return string |
337
|
|
|
*/ |
338
|
|
|
public function getFeedLocation(): string |
339
|
|
|
{ |
340
|
|
|
if ($this->getLocationLink()) { |
341
|
|
|
return "{$this->getLocation()} ({$this->getLocationLink()})"; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
return (string)$this->getLocation(); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* Get the base for the realurl alias. |
349
|
|
|
* |
350
|
|
|
* @return string |
351
|
|
|
*/ |
352
|
|
|
public function getRealUrlAliasBase(): string |
353
|
|
|
{ |
354
|
|
|
return $this->getSlug() ?: $this->getTitle(); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* Adds a Category. |
359
|
|
|
* |
360
|
|
|
* @param Category $category |
361
|
|
|
*/ |
362
|
|
|
public function addCategory(Category $category) |
363
|
|
|
{ |
364
|
|
|
$this->categories->attach($category); |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* Removes a Category. |
369
|
|
|
* |
370
|
|
|
* @param Category $categoryToRemove The Category to be removed |
371
|
|
|
*/ |
372
|
|
|
public function removeCategory(Category $categoryToRemove) |
373
|
|
|
{ |
374
|
|
|
$this->categories->detach($categoryToRemove); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* Returns the categories. |
379
|
|
|
* |
380
|
|
|
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories |
381
|
|
|
*/ |
382
|
|
|
public function getCategories() |
383
|
|
|
{ |
384
|
|
|
return $this->categories; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Sets the categories. |
389
|
|
|
* |
390
|
|
|
* @param ObjectStorage $categories |
391
|
|
|
*/ |
392
|
|
|
public function setCategories(ObjectStorage $categories) |
393
|
|
|
{ |
394
|
|
|
$this->categories = $categories; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* Get the title. |
399
|
|
|
* |
400
|
|
|
* @param Index $index |
401
|
|
|
* |
402
|
|
|
* @return string |
403
|
|
|
*/ |
404
|
|
|
public function getKeSearchTitle(Index $index): string |
405
|
|
|
{ |
406
|
|
|
return (string)$this->getTitle() . ' - ' . $index->getStartDate() |
407
|
|
|
->format('d.m.Y'); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* Get the abstract. |
412
|
|
|
* |
413
|
|
|
* @param Index $index |
414
|
|
|
* |
415
|
|
|
* @return string |
416
|
|
|
*/ |
417
|
|
|
public function getKeSearchAbstract(Index $index): string |
418
|
|
|
{ |
419
|
|
|
return (string)$this->getDescription(); |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Get the content. |
424
|
|
|
* |
425
|
|
|
* @param Index $index |
426
|
|
|
* |
427
|
|
|
* @return string |
428
|
|
|
*/ |
429
|
|
|
public function getKeSearchContent(Index $index): string |
430
|
|
|
{ |
431
|
|
|
return (string)$this->getDescription(); |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
/** |
435
|
|
|
* Get the tags. |
436
|
|
|
* |
437
|
|
|
* @param Index $index |
438
|
|
|
* |
439
|
|
|
* @return string Comma separated list of tags, e.g. '#syscat1#,#syscat2#' |
440
|
|
|
*/ |
441
|
|
|
public function getKeSearchTags(Index $index): string |
442
|
|
|
{ |
443
|
|
|
$keSearchTags = []; |
444
|
|
|
if (empty($keSearchTags)) { |
445
|
|
|
foreach ($this->getCategories() as $category) { |
446
|
|
|
$keSearchTags[] = "#syscat{$category->getUid()}#"; |
447
|
|
|
} |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
return implode(',', $keSearchTags); |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Get location. |
455
|
|
|
* |
456
|
|
|
* @return string |
457
|
|
|
*/ |
458
|
|
|
public function getLocation() |
459
|
|
|
{ |
460
|
|
|
return $this->location; |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
/** |
464
|
|
|
* Set location. |
465
|
|
|
* |
466
|
|
|
* @param string $location |
467
|
|
|
*/ |
468
|
|
|
public function setLocation($location) |
469
|
|
|
{ |
470
|
|
|
$this->location = $location; |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* Get orginzer. |
475
|
|
|
* |
476
|
|
|
* @return string |
477
|
|
|
*/ |
478
|
|
|
public function getOrganizer() |
479
|
|
|
{ |
480
|
|
|
return $this->organizer; |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
/** |
484
|
|
|
* Set organizer. |
485
|
|
|
* |
486
|
|
|
* @param string $organizer |
487
|
|
|
*/ |
488
|
|
|
public function setOrganizer($organizer) |
489
|
|
|
{ |
490
|
|
|
$this->organizer = $organizer; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Is hidden. |
495
|
|
|
* |
496
|
|
|
* @return bool |
497
|
|
|
*/ |
498
|
|
|
public function isHidden() |
499
|
|
|
{ |
500
|
|
|
return $this->hidden; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* Set hidden. |
505
|
|
|
* |
506
|
|
|
* @param bool $hidden |
507
|
|
|
*/ |
508
|
|
|
public function setHidden($hidden) |
509
|
|
|
{ |
510
|
|
|
$this->hidden = $hidden; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
/** |
514
|
|
|
* Get location link. |
515
|
|
|
* |
516
|
|
|
* @return string |
517
|
|
|
*/ |
518
|
|
|
public function getLocationLink() |
519
|
|
|
{ |
520
|
|
|
return $this->locationLink; |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
/** |
524
|
|
|
* Set location link. |
525
|
|
|
* |
526
|
|
|
* @param string $locationLink |
527
|
|
|
*/ |
528
|
|
|
public function setLocationLink($locationLink) |
529
|
|
|
{ |
530
|
|
|
$this->locationLink = $locationLink; |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* Get organizer link. |
535
|
|
|
* |
536
|
|
|
* @return string |
537
|
|
|
*/ |
538
|
|
|
public function getOrganizerLink() |
539
|
|
|
{ |
540
|
|
|
return $this->organizerLink; |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
/** |
544
|
|
|
* Set organizer link. |
545
|
|
|
* |
546
|
|
|
* @param string $organizerLink |
547
|
|
|
*/ |
548
|
|
|
public function setOrganizerLink($organizerLink) |
549
|
|
|
{ |
550
|
|
|
$this->organizerLink = $organizerLink; |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* @return string |
555
|
|
|
*/ |
556
|
|
|
public function getSlug(): string |
557
|
|
|
{ |
558
|
|
|
return $this->slug; |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
/** |
562
|
|
|
* @param string $slug |
563
|
|
|
*/ |
564
|
|
|
public function setSlug(string $slug): void |
565
|
|
|
{ |
566
|
|
|
$this->slug = $slug; |
567
|
|
|
} |
568
|
|
|
} |
569
|
|
|
|