Passed
Push — master ( b6d8fc...c76be6 )
by Julius
23:41 queued 14s
created
lib/public/RichObjectStrings/Definitions.php 1 patch
Indentation   +627 added lines, -627 removed lines patch added patch discarded remove patch
@@ -34,633 +34,633 @@
 block discarded – undo
34 34
  * @since 11.0.0
35 35
  */
36 36
 class Definitions {
37
-	/**
38
-	 * @var array
39
-	 * @since 11.0.0
40
-	 */
41
-	public $definitions = [
42
-		'addressbook' => [
43
-			'author' => 'Nextcloud',
44
-			'app' => 'dav',
45
-			'since' => '11.0.0',
46
-			'parameters' => [
47
-				'id' => [
48
-					'since' => '11.0.0',
49
-					'required' => true,
50
-					'description' => 'The id used to identify the addressbook on the instance',
51
-					'example' => '42',
52
-				],
53
-				'name' => [
54
-					'since' => '11.0.0',
55
-					'required' => true,
56
-					'description' => 'The display name of the addressbook which should be used in the visual representation',
57
-					'example' => 'Contacts',
58
-				],
59
-			],
60
-		],
61
-		'addressbook-contact' => [
62
-			'author' => 'Nextcloud',
63
-			'app' => 'dav',
64
-			'since' => '11.0.0',
65
-			'parameters' => [
66
-				'id' => [
67
-					'since' => '11.0.0',
68
-					'required' => true,
69
-					'description' => 'The id used to identify the contact on the instance',
70
-					'example' => '42',
71
-				],
72
-				'name' => [
73
-					'since' => '11.0.0',
74
-					'required' => true,
75
-					'description' => 'The display name of the contact which should be used in the visual representation',
76
-					'example' => 'John Doe',
77
-				],
78
-			],
79
-		],
80
-		'announcement' => [
81
-			'author' => 'Joas Schilling',
82
-			'app' => 'announcementcenter',
83
-			'since' => '11.0.0',
84
-			'parameters' => [
85
-				'id' => [
86
-					'since' => '11.0.0',
87
-					'required' => true, 'description' => 'The id used to identify the announcement on the instance',
88
-					'example' => '42',
89
-				],
90
-				'name' => [
91
-					'since' => '11.0.0',
92
-					'required' => true,
93
-					'description' => 'The announcement subject which should be used in the visual representation',
94
-					'example' => 'file.txt',
95
-				],
96
-				'link' => [
97
-					'since' => '11.0.0',
98
-					'required' => false,
99
-					'description' => 'The full URL to the file',
100
-					'example' => 'http://localhost/index.php/apps/announcements/#23',
101
-				],
102
-			],
103
-		],
104
-		'app' => [
105
-			'author' => 'Nextcloud',
106
-			'app' => 'updatenotification',
107
-			'since' => '11.0.0',
108
-			'parameters' => [
109
-				'id' => [
110
-					'since' => '11.0.0',
111
-					'required' => true, 'description' => 'The app id',
112
-					'example' => 'updatenotification',
113
-				],
114
-				'name' => [
115
-					'since' => '11.0.0',
116
-					'required' => true,
117
-					'description' => 'The name of the app which should be used in the visual representation',
118
-					'example' => 'Update notification',
119
-				],
120
-			],
121
-		],
122
-		'calendar' => [
123
-			'author' => 'Nextcloud',
124
-			'app' => 'dav',
125
-			'since' => '11.0.0',
126
-			'parameters' => [
127
-				'id' => [
128
-					'since' => '11.0.0',
129
-					'required' => true,
130
-					'description' => 'The id used to identify the calendar on the instance',
131
-					'example' => '42',
132
-				],
133
-				'name' => [
134
-					'since' => '11.0.0',
135
-					'required' => true,
136
-					'description' => 'The display name of the calendar which should be used in the visual representation',
137
-					'example' => 'Personal',
138
-				],
139
-			],
140
-		],
141
-		'calendar-event' => [
142
-			'author' => 'Nextcloud',
143
-			'app' => 'dav',
144
-			'since' => '11.0.0',
145
-			'parameters' => [
146
-				'id' => [
147
-					'since' => '11.0.0',
148
-					'required' => true,
149
-					'description' => 'The id used to identify the event on the instance',
150
-					'example' => '42',
151
-				],
152
-				'name' => [
153
-					'since' => '11.0.0',
154
-					'required' => true,
155
-					'description' => 'The display name of the event which should be used in the visual representation',
156
-					'example' => 'Workout',
157
-				],
158
-				'link' => [
159
-					'since' => '19.0.0',
160
-					'required' => false,
161
-					'description' => 'A link to the page displaying the calendar',
162
-					'example' => 'http://localhost/index.php/apps/calendar/dayGridMonth/2020-01-20/edit/sidebar/base64string/1579046400'
163
-				]
164
-			],
165
-		],
166
-		'call' => [
167
-			'author' => 'Nextcloud',
168
-			'app' => 'spreed',
169
-			'since' => '11.0.2',
170
-			'parameters' => [
171
-				'id' => [
172
-					'since' => '11.0.2',
173
-					'required' => true,
174
-					'description' => 'The id used to identify the call on the instance',
175
-					'example' => '42',
176
-				],
177
-				'name' => [
178
-					'since' => '11.0.2',
179
-					'required' => true,
180
-					'description' => 'The display name of the call which should be used in the visual representation',
181
-					'example' => 'Company call',
182
-				],
183
-				'call-type' => [
184
-					'since' => '11.0.2',
185
-					'required' => true,
186
-					'description' => 'The type of the call: one2one, group or public',
187
-					'example' => 'one2one',
188
-				],
189
-				'link' => [
190
-					'since' => '19.0.0',
191
-					'required' => false,
192
-					'description' => 'The link to the conversation',
193
-					'example' => 'https://localhost/index.php/call/R4nd0mToken',
194
-				],
195
-			],
196
-		],
197
-		'circle' => [
198
-			'author' => 'Maxence Lange',
199
-			'app' => 'circles',
200
-			'since' => '12.0.0',
201
-			'parameters' => [
202
-				'id' => [
203
-					'since' => '12.0.0',
204
-					'required' => true,
205
-					'description' => 'The id used to identify the circle on the instance',
206
-					'example' => '42',
207
-				],
208
-				'name' => [
209
-					'since' => '12.0.0',
210
-					'required' => true,
211
-					'description' => 'The display name of the circle which should be used in the visual representation',
212
-					'example' => 'My friends',
213
-				],
214
-				'link' => [
215
-					'since' => '12.0.0',
216
-					'required' => true,
217
-					'description' => 'The full URL to the circle',
218
-					'example' => 'http://localhost/index.php/apps/circles/#42',
219
-				],
220
-			],
221
-		],
222
-		'deck-board' => [
223
-			'author' => 'Nextcloud',
224
-			'app' => 'deck',
225
-			'since' => '21.0.0',
226
-			'parameters' => [
227
-				'id' => [
228
-					'since' => '21.0.0',
229
-					'required' => true,
230
-					'description' => 'The id used to identify the board on the instance',
231
-					'example' => '1',
232
-				],
233
-				'name' => [
234
-					'since' => '21.0.0',
235
-					'required' => true,
236
-					'description' => 'The display name of the deck board',
237
-					'example' => 'Personal',
238
-				],
239
-				'link' => [
240
-					'since' => '21.0.0',
241
-					'required' => true,
242
-					'description' => 'The full URL to the board',
243
-					'example' => 'http://localhost/index.php/apps/deck/#/board/1',
244
-				],
245
-			],
246
-		],
247
-		'deck-card' => [
248
-			'author' => 'Nextcloud',
249
-			'app' => 'deck',
250
-			'since' => '21.0.0',
251
-			'parameters' => [
252
-				'id' => [
253
-					'since' => '21.0.0',
254
-					'required' => true,
255
-					'description' => 'The id used to identify the card on the instance',
256
-					'example' => '1',
257
-				],
258
-				'name' => [
259
-					'since' => '21.0.0',
260
-					'required' => true,
261
-					'description' => 'The title of the deck card',
262
-					'example' => 'Foo Bar',
263
-				],
264
-				'boardname' => [
265
-					'since' => '21.0.0',
266
-					'required' => true,
267
-					'description' => 'The display name of board which contains the card',
268
-					'example' => 'Personal',
269
-				],
270
-				'stackname' => [
271
-					'since' => '21.0.0',
272
-					'required' => true,
273
-					'description' => 'The display name of the stack which contains the card in the board',
274
-					'example' => 'To do',
275
-				],
276
-				'link' => [
277
-					'since' => '21.0.0',
278
-					'required' => true,
279
-					'description' => 'The full URL to the card directly',
280
-					'example' => 'https://nextcloud21.local/index.php/apps/deck/#/board/1/card/1',
281
-				],
282
-			],
283
-		],
284
-		'email' => [
285
-			'author' => 'Nextcloud',
286
-			'app' => 'sharebymail',
287
-			'since' => '11.0.0',
288
-			'parameters' => [
289
-				'id' => [
290
-					'since' => '11.0.0',
291
-					'required' => true,
292
-					'description' => 'The mail-address used to identify the event on the instance',
293
-					'example' => 'test@localhost',
294
-				],
295
-				'name' => [
296
-					'since' => '11.0.0',
297
-					'required' => true,
298
-					'description' => 'The display name of a matching contact or the email (fallback) which should be used in the visual representation',
299
-					'example' => 'Foo Bar',
300
-				],
301
-			],
302
-		],
303
-		'file' => [
304
-			'author' => 'Nextcloud',
305
-			'app' => 'dav',
306
-			'since' => '11.0.0',
307
-			'parameters' => [
308
-				'id' => [
309
-					'since' => '11.0.0',
310
-					'required' => true,
311
-					'description' => 'The id used to identify the file on the instance',
312
-					'example' => '42',
313
-				],
314
-				'name' => [
315
-					'since' => '11.0.0',
316
-					'required' => true,
317
-					'description' => 'The file name which should be used in the visual representation',
318
-					'example' => 'file.txt',
319
-				],
320
-				'size' => [
321
-					'since' => '21.0.0',
322
-					'required' => false,
323
-					'description' => 'The file size in bytes',
324
-					'example' => '3145728',
325
-				],
326
-				'path' => [
327
-					'since' => '11.0.0',
328
-					'required' => true,
329
-					'description' => 'The full path of the file for the user, should not start with a slash',
330
-					'example' => 'path/to/file.txt',
331
-				],
332
-				'link' => [
333
-					'since' => '11.0.0',
334
-					'required' => false,
335
-					'description' => 'The full URL to the file',
336
-					'example' => 'http://localhost/index.php/f/42',
337
-				],
338
-				'mimetype' => [
339
-					'since' => '16.0.0',
340
-					'required' => false,
341
-					'description' => 'The mimetype of the file/folder to allow clients to show a placeholder',
342
-					'example' => 'text/plain',
343
-				],
344
-				'preview-available' => [
345
-					'since' => '16.0.0',
346
-					'required' => false,
347
-					'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used',
348
-					'example' => 'yes',
349
-				],
350
-				'mtime' => [
351
-					'since' => '25.0.0',
352
-					'required' => false,
353
-					'description' => 'The mtime of the file/folder as unix timestamp',
354
-					'example' => '1661854213',
355
-				],
356
-			],
357
-		],
358
-		'forms-form' => [
359
-			'author' => 'Nextcloud',
360
-			'app' => 'forms',
361
-			'since' => '21.0.1',
362
-			'parameters' => [
363
-				'id' => [
364
-					'since' => '21.0.1',
365
-					'required' => true,
366
-					'description' => 'The form-hash of the form',
367
-					'example' => 'q72GGqbfbLBC6xNB',
368
-				],
369
-				'name' => [
370
-					'since' => '21.0.1',
371
-					'required' => true,
372
-					'description' => 'The title of the form',
373
-					'example' => 'Nice Form',
374
-				],
375
-				'link' => [
376
-					'since' => '21.0.1',
377
-					'required' => true,
378
-					'description' => 'The full URL to the board',
379
-					'example' => 'http://localhost/index.php/apps/forms/q72GGqbfbLBC6xNB',
380
-				],
381
-			],
382
-		],
383
-		'guest' => [
384
-			'author' => 'Nextcloud',
385
-			'app' => 'spreed',
386
-			'since' => '17.0.0',
387
-			'parameters' => [
388
-				'id' => [
389
-					'since' => '17.0.0',
390
-					'required' => true,
391
-					'description' => 'The id used to identify the guest user',
392
-					'example' => '42',
393
-				],
394
-				'name' => [
395
-					'since' => '17.0.0',
396
-					'required' => true,
397
-					'description' => 'Potential displayname of the guest user',
398
-					'example' => 'Foobar Cats',
399
-				],
400
-			],
401
-		],
402
-		'highlight' => [
403
-			'author' => 'Nextcloud',
404
-			'app' => 'core',
405
-			'since' => '13.0.0',
406
-			'parameters' => [
407
-				'id' => [
408
-					'since' => '13.0.0',
409
-					'required' => true,
410
-					'description' => 'The id used to identify the highlighted object on the instance',
411
-					'example' => '42',
412
-				],
413
-				'name' => [
414
-					'since' => '13.0.0',
415
-					'required' => true,
416
-					'description' => 'The string that should be highlighted.',
417
-					'example' => 'Hello World',
418
-				],
419
-				'link' => [
420
-					'since' => '13.0.0',
421
-					'required' => false,
422
-					'description' => 'The full URL that should be opened when clicking the highlighted text.',
423
-					'example' => 'http://localhost/index.php/f/42',
424
-				],
425
-			],
426
-		],
427
-		'geo-location' => [
428
-			'author' => 'Nextcloud',
429
-			'app' => 'core',
430
-			'since' => '22.0.0',
431
-			'parameters' => [
432
-				'id' => [
433
-					'since' => '22.0.0',
434
-					'required' => true,
435
-					'description' => 'The geo URI (https://en.wikipedia.org/wiki/Geo_URI_scheme) to identify the location',
436
-					'example' => 'geo:52.5450511,13.3741463',
437
-				],
438
-				'name' => [
439
-					'since' => '22.0.0',
440
-					'required' => true,
441
-					'description' => 'A description of the location',
442
-					'example' => 'Nextcloud Berlin Office',
443
-				],
444
-				'latitude' => [
445
-					'since' => '22.0.0',
446
-					'required' => true,
447
-					'description' => 'The latitude of the location MUST be the same as in the id',
448
-					'example' => '52.5450511',
449
-				],
450
-				'longitude' => [
451
-					'since' => '22.0.0',
452
-					'required' => true,
453
-					'description' => 'The longitude of the location MUST be the same as in the id',
454
-					'example' => '13.3741463',
455
-				],
456
-			],
457
-		],
458
-		'open-graph' => [
459
-			'author' => 'Maxence Lange',
460
-			'app' => 'mood',
461
-			'since' => '12.0.0',
462
-			'parameters' => [
463
-				'id' => [
464
-					'since' => '12.0.0',
465
-					'required' => true,
466
-					'description' => 'The id used to identify the open graph data on the instance',
467
-					'example' => '42',
468
-				],
469
-				'name' => [
470
-					'since' => '12.0.0',
471
-					'required' => true,
472
-					'description' => 'The open graph title of the website',
473
-					'example' => 'This is a website',
474
-				],
475
-				'description' => [
476
-					'since' => '12.0.0',
477
-					'required' => false,
478
-					'description' => 'The open graph description from the website',
479
-					'example' => 'This is the description of the website',
480
-				],
481
-				'thumb' => [
482
-					'since' => '12.0.0',
483
-					'required' => false,
484
-					'description' => 'The full URL of the open graph thumbnail',
485
-					'example' => 'http://localhost/index.php/apps/mood/data/image?url=https%3A%2F%2Fthumb.example.com%2Fimage.png',
486
-				],
487
-				'website' => [
488
-					'since' => '12.0.0',
489
-					'required' => false,
490
-					'description' => 'The name of the described website',
491
-					'example' => 'Nextcloud - App Store',
492
-				],
493
-				'link' => [
494
-					'since' => '12.0.0',
495
-					'required' => false,
496
-					'description' => 'The full link to the website',
497
-					'example' => 'https://apps.nextcloud.com/apps/mood',
498
-				],
499
-			],
500
-		],
501
-		'pending-federated-share' => [
502
-			'author' => 'Nextcloud',
503
-			'app' => 'dav',
504
-			'since' => '11.0.0',
505
-			'parameters' => [
506
-				'id' => [
507
-					'since' => '11.0.0',
508
-					'required' => true,
509
-					'description' => 'The id used to identify the federated share on the instance',
510
-					'example' => '42',
511
-				],
512
-				'name' => [
513
-					'since' => '11.0.0',
514
-					'required' => true,
515
-					'description' => 'The name of the shared item which should be used in the visual representation',
516
-					'example' => 'file.txt',
517
-				],
518
-			],
519
-		],
520
-		'systemtag' => [
521
-			'author' => 'Nextcloud',
522
-			'app' => 'core',
523
-			'since' => '11.0.0',
524
-			'parameters' => [
525
-				'id' => [
526
-					'since' => '11.0.0',
527
-					'required' => true,
528
-					'description' => 'The id used to identify the systemtag on the instance',
529
-					'example' => '23',
530
-				],
531
-				'name' => [
532
-					'since' => '11.0.0',
533
-					'required' => true,
534
-					'description' => 'The display name of the systemtag which should be used in the visual representation',
535
-					'example' => 'Project 1',
536
-				],
537
-				'visibility' => [
538
-					'since' => '11.0.0',
539
-					'required' => true,
540
-					'description' => 'If the user can see the systemtag',
541
-					'example' => '1',
542
-				],
543
-				'assignable' => [
544
-					'since' => '11.0.0',
545
-					'required' => true,
546
-					'description' => 'If the user can assign the systemtag',
547
-					'example' => '0',
548
-				],
549
-			],
550
-		],
551
-		'talk-attachment' => [
552
-			'author' => 'Nextcloud',
553
-			'app' => 'talk',
554
-			'since' => '18.0.0',
555
-			'parameters' => [
556
-				'id' => [
557
-					'since' => '18.0.0',
558
-					'required' => true,
559
-					'description' => 'The id used to identify the attachment on the instance',
560
-					'example' => '12345',
561
-				],
562
-				'name' => [
563
-					'since' => '18.0.0',
564
-					'required' => true,
565
-					'description' => 'The name of the attachment',
566
-					'example' => 'John Doe',
567
-				],
568
-				'conversation' => [
569
-					'since' => '18.0.0',
570
-					'required' => true,
571
-					'description' => 'The token of the conversation',
572
-					'example' => 'a1b2c3d4',
573
-				],
574
-				'mimetype' => [
575
-					'since' => '18.0.0',
576
-					'required' => false,
577
-					'description' => 'The mimetype of the file/folder to allow clients to show a placeholder',
578
-					'example' => 'text/plain',
579
-				],
580
-				'preview-available' => [
581
-					'since' => '18.0.0',
582
-					'required' => false,
583
-					'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used',
584
-					'example' => 'yes',
585
-				],
586
-			],
587
-		],
588
-		'talk-poll' => [
589
-			'author' => 'Nextcloud',
590
-			'app' => 'talk',
591
-			'since' => '25.0.0',
592
-			'parameters' => [
593
-				'id' => [
594
-					'since' => '25.0.0',
595
-					'required' => true,
596
-					'description' => 'The id used to identify the poll on the instance',
597
-					'example' => '12345',
598
-				],
599
-				'name' => [
600
-					'since' => '25.0.0',
601
-					'required' => true,
602
-					'description' => 'The poll question',
603
-					'example' => 'What is the question?',
604
-				],
605
-			],
606
-		],
607
-		'user' => [
608
-			'author' => 'Nextcloud',
609
-			'app' => 'core',
610
-			'since' => '11.0.0',
611
-			'parameters' => [
612
-				'id' => [
613
-					'since' => '11.0.0',
614
-					'required' => true,
615
-					'description' => 'The id used to identify the user on the instance',
616
-					'example' => 'johndoe',
617
-				],
618
-				'name' => [
619
-					'since' => '11.0.0',
620
-					'required' => true,
621
-					'description' => 'The display name of the user which should be used in the visual representation',
622
-					'example' => 'John Doe',
623
-				],
624
-				'server' => [
625
-					'since' => '11.0.0',
626
-					'required' => false,
627
-					'description' => 'The URL of the instance the user lives on',
628
-					'example' => 'localhost',
629
-				],
630
-			],
631
-		],
632
-		'user-group' => [
633
-			'author' => 'Nextcloud',
634
-			'app' => 'core',
635
-			'since' => '11.0.0',
636
-			'parameters' => [
637
-				'id' => [
638
-					'since' => '11.0.0',
639
-					'required' => true,
640
-					'description' => 'The id used to identify the group on the instance',
641
-					'example' => 'supportteam',
642
-				],
643
-				'name' => [
644
-					'since' => '11.0.0',
645
-					'required' => true,
646
-					'description' => 'The display name of the group which should be used in the visual representation',
647
-					'example' => 'Support Team',
648
-				],
649
-			],
650
-		],
651
-	];
37
+    /**
38
+     * @var array
39
+     * @since 11.0.0
40
+     */
41
+    public $definitions = [
42
+        'addressbook' => [
43
+            'author' => 'Nextcloud',
44
+            'app' => 'dav',
45
+            'since' => '11.0.0',
46
+            'parameters' => [
47
+                'id' => [
48
+                    'since' => '11.0.0',
49
+                    'required' => true,
50
+                    'description' => 'The id used to identify the addressbook on the instance',
51
+                    'example' => '42',
52
+                ],
53
+                'name' => [
54
+                    'since' => '11.0.0',
55
+                    'required' => true,
56
+                    'description' => 'The display name of the addressbook which should be used in the visual representation',
57
+                    'example' => 'Contacts',
58
+                ],
59
+            ],
60
+        ],
61
+        'addressbook-contact' => [
62
+            'author' => 'Nextcloud',
63
+            'app' => 'dav',
64
+            'since' => '11.0.0',
65
+            'parameters' => [
66
+                'id' => [
67
+                    'since' => '11.0.0',
68
+                    'required' => true,
69
+                    'description' => 'The id used to identify the contact on the instance',
70
+                    'example' => '42',
71
+                ],
72
+                'name' => [
73
+                    'since' => '11.0.0',
74
+                    'required' => true,
75
+                    'description' => 'The display name of the contact which should be used in the visual representation',
76
+                    'example' => 'John Doe',
77
+                ],
78
+            ],
79
+        ],
80
+        'announcement' => [
81
+            'author' => 'Joas Schilling',
82
+            'app' => 'announcementcenter',
83
+            'since' => '11.0.0',
84
+            'parameters' => [
85
+                'id' => [
86
+                    'since' => '11.0.0',
87
+                    'required' => true, 'description' => 'The id used to identify the announcement on the instance',
88
+                    'example' => '42',
89
+                ],
90
+                'name' => [
91
+                    'since' => '11.0.0',
92
+                    'required' => true,
93
+                    'description' => 'The announcement subject which should be used in the visual representation',
94
+                    'example' => 'file.txt',
95
+                ],
96
+                'link' => [
97
+                    'since' => '11.0.0',
98
+                    'required' => false,
99
+                    'description' => 'The full URL to the file',
100
+                    'example' => 'http://localhost/index.php/apps/announcements/#23',
101
+                ],
102
+            ],
103
+        ],
104
+        'app' => [
105
+            'author' => 'Nextcloud',
106
+            'app' => 'updatenotification',
107
+            'since' => '11.0.0',
108
+            'parameters' => [
109
+                'id' => [
110
+                    'since' => '11.0.0',
111
+                    'required' => true, 'description' => 'The app id',
112
+                    'example' => 'updatenotification',
113
+                ],
114
+                'name' => [
115
+                    'since' => '11.0.0',
116
+                    'required' => true,
117
+                    'description' => 'The name of the app which should be used in the visual representation',
118
+                    'example' => 'Update notification',
119
+                ],
120
+            ],
121
+        ],
122
+        'calendar' => [
123
+            'author' => 'Nextcloud',
124
+            'app' => 'dav',
125
+            'since' => '11.0.0',
126
+            'parameters' => [
127
+                'id' => [
128
+                    'since' => '11.0.0',
129
+                    'required' => true,
130
+                    'description' => 'The id used to identify the calendar on the instance',
131
+                    'example' => '42',
132
+                ],
133
+                'name' => [
134
+                    'since' => '11.0.0',
135
+                    'required' => true,
136
+                    'description' => 'The display name of the calendar which should be used in the visual representation',
137
+                    'example' => 'Personal',
138
+                ],
139
+            ],
140
+        ],
141
+        'calendar-event' => [
142
+            'author' => 'Nextcloud',
143
+            'app' => 'dav',
144
+            'since' => '11.0.0',
145
+            'parameters' => [
146
+                'id' => [
147
+                    'since' => '11.0.0',
148
+                    'required' => true,
149
+                    'description' => 'The id used to identify the event on the instance',
150
+                    'example' => '42',
151
+                ],
152
+                'name' => [
153
+                    'since' => '11.0.0',
154
+                    'required' => true,
155
+                    'description' => 'The display name of the event which should be used in the visual representation',
156
+                    'example' => 'Workout',
157
+                ],
158
+                'link' => [
159
+                    'since' => '19.0.0',
160
+                    'required' => false,
161
+                    'description' => 'A link to the page displaying the calendar',
162
+                    'example' => 'http://localhost/index.php/apps/calendar/dayGridMonth/2020-01-20/edit/sidebar/base64string/1579046400'
163
+                ]
164
+            ],
165
+        ],
166
+        'call' => [
167
+            'author' => 'Nextcloud',
168
+            'app' => 'spreed',
169
+            'since' => '11.0.2',
170
+            'parameters' => [
171
+                'id' => [
172
+                    'since' => '11.0.2',
173
+                    'required' => true,
174
+                    'description' => 'The id used to identify the call on the instance',
175
+                    'example' => '42',
176
+                ],
177
+                'name' => [
178
+                    'since' => '11.0.2',
179
+                    'required' => true,
180
+                    'description' => 'The display name of the call which should be used in the visual representation',
181
+                    'example' => 'Company call',
182
+                ],
183
+                'call-type' => [
184
+                    'since' => '11.0.2',
185
+                    'required' => true,
186
+                    'description' => 'The type of the call: one2one, group or public',
187
+                    'example' => 'one2one',
188
+                ],
189
+                'link' => [
190
+                    'since' => '19.0.0',
191
+                    'required' => false,
192
+                    'description' => 'The link to the conversation',
193
+                    'example' => 'https://localhost/index.php/call/R4nd0mToken',
194
+                ],
195
+            ],
196
+        ],
197
+        'circle' => [
198
+            'author' => 'Maxence Lange',
199
+            'app' => 'circles',
200
+            'since' => '12.0.0',
201
+            'parameters' => [
202
+                'id' => [
203
+                    'since' => '12.0.0',
204
+                    'required' => true,
205
+                    'description' => 'The id used to identify the circle on the instance',
206
+                    'example' => '42',
207
+                ],
208
+                'name' => [
209
+                    'since' => '12.0.0',
210
+                    'required' => true,
211
+                    'description' => 'The display name of the circle which should be used in the visual representation',
212
+                    'example' => 'My friends',
213
+                ],
214
+                'link' => [
215
+                    'since' => '12.0.0',
216
+                    'required' => true,
217
+                    'description' => 'The full URL to the circle',
218
+                    'example' => 'http://localhost/index.php/apps/circles/#42',
219
+                ],
220
+            ],
221
+        ],
222
+        'deck-board' => [
223
+            'author' => 'Nextcloud',
224
+            'app' => 'deck',
225
+            'since' => '21.0.0',
226
+            'parameters' => [
227
+                'id' => [
228
+                    'since' => '21.0.0',
229
+                    'required' => true,
230
+                    'description' => 'The id used to identify the board on the instance',
231
+                    'example' => '1',
232
+                ],
233
+                'name' => [
234
+                    'since' => '21.0.0',
235
+                    'required' => true,
236
+                    'description' => 'The display name of the deck board',
237
+                    'example' => 'Personal',
238
+                ],
239
+                'link' => [
240
+                    'since' => '21.0.0',
241
+                    'required' => true,
242
+                    'description' => 'The full URL to the board',
243
+                    'example' => 'http://localhost/index.php/apps/deck/#/board/1',
244
+                ],
245
+            ],
246
+        ],
247
+        'deck-card' => [
248
+            'author' => 'Nextcloud',
249
+            'app' => 'deck',
250
+            'since' => '21.0.0',
251
+            'parameters' => [
252
+                'id' => [
253
+                    'since' => '21.0.0',
254
+                    'required' => true,
255
+                    'description' => 'The id used to identify the card on the instance',
256
+                    'example' => '1',
257
+                ],
258
+                'name' => [
259
+                    'since' => '21.0.0',
260
+                    'required' => true,
261
+                    'description' => 'The title of the deck card',
262
+                    'example' => 'Foo Bar',
263
+                ],
264
+                'boardname' => [
265
+                    'since' => '21.0.0',
266
+                    'required' => true,
267
+                    'description' => 'The display name of board which contains the card',
268
+                    'example' => 'Personal',
269
+                ],
270
+                'stackname' => [
271
+                    'since' => '21.0.0',
272
+                    'required' => true,
273
+                    'description' => 'The display name of the stack which contains the card in the board',
274
+                    'example' => 'To do',
275
+                ],
276
+                'link' => [
277
+                    'since' => '21.0.0',
278
+                    'required' => true,
279
+                    'description' => 'The full URL to the card directly',
280
+                    'example' => 'https://nextcloud21.local/index.php/apps/deck/#/board/1/card/1',
281
+                ],
282
+            ],
283
+        ],
284
+        'email' => [
285
+            'author' => 'Nextcloud',
286
+            'app' => 'sharebymail',
287
+            'since' => '11.0.0',
288
+            'parameters' => [
289
+                'id' => [
290
+                    'since' => '11.0.0',
291
+                    'required' => true,
292
+                    'description' => 'The mail-address used to identify the event on the instance',
293
+                    'example' => 'test@localhost',
294
+                ],
295
+                'name' => [
296
+                    'since' => '11.0.0',
297
+                    'required' => true,
298
+                    'description' => 'The display name of a matching contact or the email (fallback) which should be used in the visual representation',
299
+                    'example' => 'Foo Bar',
300
+                ],
301
+            ],
302
+        ],
303
+        'file' => [
304
+            'author' => 'Nextcloud',
305
+            'app' => 'dav',
306
+            'since' => '11.0.0',
307
+            'parameters' => [
308
+                'id' => [
309
+                    'since' => '11.0.0',
310
+                    'required' => true,
311
+                    'description' => 'The id used to identify the file on the instance',
312
+                    'example' => '42',
313
+                ],
314
+                'name' => [
315
+                    'since' => '11.0.0',
316
+                    'required' => true,
317
+                    'description' => 'The file name which should be used in the visual representation',
318
+                    'example' => 'file.txt',
319
+                ],
320
+                'size' => [
321
+                    'since' => '21.0.0',
322
+                    'required' => false,
323
+                    'description' => 'The file size in bytes',
324
+                    'example' => '3145728',
325
+                ],
326
+                'path' => [
327
+                    'since' => '11.0.0',
328
+                    'required' => true,
329
+                    'description' => 'The full path of the file for the user, should not start with a slash',
330
+                    'example' => 'path/to/file.txt',
331
+                ],
332
+                'link' => [
333
+                    'since' => '11.0.0',
334
+                    'required' => false,
335
+                    'description' => 'The full URL to the file',
336
+                    'example' => 'http://localhost/index.php/f/42',
337
+                ],
338
+                'mimetype' => [
339
+                    'since' => '16.0.0',
340
+                    'required' => false,
341
+                    'description' => 'The mimetype of the file/folder to allow clients to show a placeholder',
342
+                    'example' => 'text/plain',
343
+                ],
344
+                'preview-available' => [
345
+                    'since' => '16.0.0',
346
+                    'required' => false,
347
+                    'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used',
348
+                    'example' => 'yes',
349
+                ],
350
+                'mtime' => [
351
+                    'since' => '25.0.0',
352
+                    'required' => false,
353
+                    'description' => 'The mtime of the file/folder as unix timestamp',
354
+                    'example' => '1661854213',
355
+                ],
356
+            ],
357
+        ],
358
+        'forms-form' => [
359
+            'author' => 'Nextcloud',
360
+            'app' => 'forms',
361
+            'since' => '21.0.1',
362
+            'parameters' => [
363
+                'id' => [
364
+                    'since' => '21.0.1',
365
+                    'required' => true,
366
+                    'description' => 'The form-hash of the form',
367
+                    'example' => 'q72GGqbfbLBC6xNB',
368
+                ],
369
+                'name' => [
370
+                    'since' => '21.0.1',
371
+                    'required' => true,
372
+                    'description' => 'The title of the form',
373
+                    'example' => 'Nice Form',
374
+                ],
375
+                'link' => [
376
+                    'since' => '21.0.1',
377
+                    'required' => true,
378
+                    'description' => 'The full URL to the board',
379
+                    'example' => 'http://localhost/index.php/apps/forms/q72GGqbfbLBC6xNB',
380
+                ],
381
+            ],
382
+        ],
383
+        'guest' => [
384
+            'author' => 'Nextcloud',
385
+            'app' => 'spreed',
386
+            'since' => '17.0.0',
387
+            'parameters' => [
388
+                'id' => [
389
+                    'since' => '17.0.0',
390
+                    'required' => true,
391
+                    'description' => 'The id used to identify the guest user',
392
+                    'example' => '42',
393
+                ],
394
+                'name' => [
395
+                    'since' => '17.0.0',
396
+                    'required' => true,
397
+                    'description' => 'Potential displayname of the guest user',
398
+                    'example' => 'Foobar Cats',
399
+                ],
400
+            ],
401
+        ],
402
+        'highlight' => [
403
+            'author' => 'Nextcloud',
404
+            'app' => 'core',
405
+            'since' => '13.0.0',
406
+            'parameters' => [
407
+                'id' => [
408
+                    'since' => '13.0.0',
409
+                    'required' => true,
410
+                    'description' => 'The id used to identify the highlighted object on the instance',
411
+                    'example' => '42',
412
+                ],
413
+                'name' => [
414
+                    'since' => '13.0.0',
415
+                    'required' => true,
416
+                    'description' => 'The string that should be highlighted.',
417
+                    'example' => 'Hello World',
418
+                ],
419
+                'link' => [
420
+                    'since' => '13.0.0',
421
+                    'required' => false,
422
+                    'description' => 'The full URL that should be opened when clicking the highlighted text.',
423
+                    'example' => 'http://localhost/index.php/f/42',
424
+                ],
425
+            ],
426
+        ],
427
+        'geo-location' => [
428
+            'author' => 'Nextcloud',
429
+            'app' => 'core',
430
+            'since' => '22.0.0',
431
+            'parameters' => [
432
+                'id' => [
433
+                    'since' => '22.0.0',
434
+                    'required' => true,
435
+                    'description' => 'The geo URI (https://en.wikipedia.org/wiki/Geo_URI_scheme) to identify the location',
436
+                    'example' => 'geo:52.5450511,13.3741463',
437
+                ],
438
+                'name' => [
439
+                    'since' => '22.0.0',
440
+                    'required' => true,
441
+                    'description' => 'A description of the location',
442
+                    'example' => 'Nextcloud Berlin Office',
443
+                ],
444
+                'latitude' => [
445
+                    'since' => '22.0.0',
446
+                    'required' => true,
447
+                    'description' => 'The latitude of the location MUST be the same as in the id',
448
+                    'example' => '52.5450511',
449
+                ],
450
+                'longitude' => [
451
+                    'since' => '22.0.0',
452
+                    'required' => true,
453
+                    'description' => 'The longitude of the location MUST be the same as in the id',
454
+                    'example' => '13.3741463',
455
+                ],
456
+            ],
457
+        ],
458
+        'open-graph' => [
459
+            'author' => 'Maxence Lange',
460
+            'app' => 'mood',
461
+            'since' => '12.0.0',
462
+            'parameters' => [
463
+                'id' => [
464
+                    'since' => '12.0.0',
465
+                    'required' => true,
466
+                    'description' => 'The id used to identify the open graph data on the instance',
467
+                    'example' => '42',
468
+                ],
469
+                'name' => [
470
+                    'since' => '12.0.0',
471
+                    'required' => true,
472
+                    'description' => 'The open graph title of the website',
473
+                    'example' => 'This is a website',
474
+                ],
475
+                'description' => [
476
+                    'since' => '12.0.0',
477
+                    'required' => false,
478
+                    'description' => 'The open graph description from the website',
479
+                    'example' => 'This is the description of the website',
480
+                ],
481
+                'thumb' => [
482
+                    'since' => '12.0.0',
483
+                    'required' => false,
484
+                    'description' => 'The full URL of the open graph thumbnail',
485
+                    'example' => 'http://localhost/index.php/apps/mood/data/image?url=https%3A%2F%2Fthumb.example.com%2Fimage.png',
486
+                ],
487
+                'website' => [
488
+                    'since' => '12.0.0',
489
+                    'required' => false,
490
+                    'description' => 'The name of the described website',
491
+                    'example' => 'Nextcloud - App Store',
492
+                ],
493
+                'link' => [
494
+                    'since' => '12.0.0',
495
+                    'required' => false,
496
+                    'description' => 'The full link to the website',
497
+                    'example' => 'https://apps.nextcloud.com/apps/mood',
498
+                ],
499
+            ],
500
+        ],
501
+        'pending-federated-share' => [
502
+            'author' => 'Nextcloud',
503
+            'app' => 'dav',
504
+            'since' => '11.0.0',
505
+            'parameters' => [
506
+                'id' => [
507
+                    'since' => '11.0.0',
508
+                    'required' => true,
509
+                    'description' => 'The id used to identify the federated share on the instance',
510
+                    'example' => '42',
511
+                ],
512
+                'name' => [
513
+                    'since' => '11.0.0',
514
+                    'required' => true,
515
+                    'description' => 'The name of the shared item which should be used in the visual representation',
516
+                    'example' => 'file.txt',
517
+                ],
518
+            ],
519
+        ],
520
+        'systemtag' => [
521
+            'author' => 'Nextcloud',
522
+            'app' => 'core',
523
+            'since' => '11.0.0',
524
+            'parameters' => [
525
+                'id' => [
526
+                    'since' => '11.0.0',
527
+                    'required' => true,
528
+                    'description' => 'The id used to identify the systemtag on the instance',
529
+                    'example' => '23',
530
+                ],
531
+                'name' => [
532
+                    'since' => '11.0.0',
533
+                    'required' => true,
534
+                    'description' => 'The display name of the systemtag which should be used in the visual representation',
535
+                    'example' => 'Project 1',
536
+                ],
537
+                'visibility' => [
538
+                    'since' => '11.0.0',
539
+                    'required' => true,
540
+                    'description' => 'If the user can see the systemtag',
541
+                    'example' => '1',
542
+                ],
543
+                'assignable' => [
544
+                    'since' => '11.0.0',
545
+                    'required' => true,
546
+                    'description' => 'If the user can assign the systemtag',
547
+                    'example' => '0',
548
+                ],
549
+            ],
550
+        ],
551
+        'talk-attachment' => [
552
+            'author' => 'Nextcloud',
553
+            'app' => 'talk',
554
+            'since' => '18.0.0',
555
+            'parameters' => [
556
+                'id' => [
557
+                    'since' => '18.0.0',
558
+                    'required' => true,
559
+                    'description' => 'The id used to identify the attachment on the instance',
560
+                    'example' => '12345',
561
+                ],
562
+                'name' => [
563
+                    'since' => '18.0.0',
564
+                    'required' => true,
565
+                    'description' => 'The name of the attachment',
566
+                    'example' => 'John Doe',
567
+                ],
568
+                'conversation' => [
569
+                    'since' => '18.0.0',
570
+                    'required' => true,
571
+                    'description' => 'The token of the conversation',
572
+                    'example' => 'a1b2c3d4',
573
+                ],
574
+                'mimetype' => [
575
+                    'since' => '18.0.0',
576
+                    'required' => false,
577
+                    'description' => 'The mimetype of the file/folder to allow clients to show a placeholder',
578
+                    'example' => 'text/plain',
579
+                ],
580
+                'preview-available' => [
581
+                    'since' => '18.0.0',
582
+                    'required' => false,
583
+                    'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used',
584
+                    'example' => 'yes',
585
+                ],
586
+            ],
587
+        ],
588
+        'talk-poll' => [
589
+            'author' => 'Nextcloud',
590
+            'app' => 'talk',
591
+            'since' => '25.0.0',
592
+            'parameters' => [
593
+                'id' => [
594
+                    'since' => '25.0.0',
595
+                    'required' => true,
596
+                    'description' => 'The id used to identify the poll on the instance',
597
+                    'example' => '12345',
598
+                ],
599
+                'name' => [
600
+                    'since' => '25.0.0',
601
+                    'required' => true,
602
+                    'description' => 'The poll question',
603
+                    'example' => 'What is the question?',
604
+                ],
605
+            ],
606
+        ],
607
+        'user' => [
608
+            'author' => 'Nextcloud',
609
+            'app' => 'core',
610
+            'since' => '11.0.0',
611
+            'parameters' => [
612
+                'id' => [
613
+                    'since' => '11.0.0',
614
+                    'required' => true,
615
+                    'description' => 'The id used to identify the user on the instance',
616
+                    'example' => 'johndoe',
617
+                ],
618
+                'name' => [
619
+                    'since' => '11.0.0',
620
+                    'required' => true,
621
+                    'description' => 'The display name of the user which should be used in the visual representation',
622
+                    'example' => 'John Doe',
623
+                ],
624
+                'server' => [
625
+                    'since' => '11.0.0',
626
+                    'required' => false,
627
+                    'description' => 'The URL of the instance the user lives on',
628
+                    'example' => 'localhost',
629
+                ],
630
+            ],
631
+        ],
632
+        'user-group' => [
633
+            'author' => 'Nextcloud',
634
+            'app' => 'core',
635
+            'since' => '11.0.0',
636
+            'parameters' => [
637
+                'id' => [
638
+                    'since' => '11.0.0',
639
+                    'required' => true,
640
+                    'description' => 'The id used to identify the group on the instance',
641
+                    'example' => 'supportteam',
642
+                ],
643
+                'name' => [
644
+                    'since' => '11.0.0',
645
+                    'required' => true,
646
+                    'description' => 'The display name of the group which should be used in the visual representation',
647
+                    'example' => 'Support Team',
648
+                ],
649
+            ],
650
+        ],
651
+    ];
652 652
 
653
-	/**
654
-	 * @param string $type
655
-	 * @return array
656
-	 * @throws InvalidObjectExeption
657
-	 * @since 11.0.0
658
-	 */
659
-	public function getDefinition($type) {
660
-		if (isset($this->definitions[$type])) {
661
-			return $this->definitions[$type];
662
-		}
653
+    /**
654
+     * @param string $type
655
+     * @return array
656
+     * @throws InvalidObjectExeption
657
+     * @since 11.0.0
658
+     */
659
+    public function getDefinition($type) {
660
+        if (isset($this->definitions[$type])) {
661
+            return $this->definitions[$type];
662
+        }
663 663
 
664
-		throw new InvalidObjectExeption('Object type is undefined');
665
-	}
664
+        throw new InvalidObjectExeption('Object type is undefined');
665
+    }
666 666
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Reference/File/FileReferenceProvider.php 1 patch
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -41,149 +41,149 @@
 block discarded – undo
41 41
 use OCP\L10N\IFactory;
42 42
 
43 43
 class FileReferenceProvider extends ADiscoverableReferenceProvider {
44
-	private IURLGenerator $urlGenerator;
45
-	private IRootFolder $rootFolder;
46
-	private ?string $userId;
47
-	private IPreview $previewManager;
48
-	private IMimeTypeDetector $mimeTypeDetector;
49
-	private IL10N $l10n;
50
-
51
-	public function __construct(
52
-		IURLGenerator $urlGenerator,
53
-		IRootFolder $rootFolder,
54
-		IUserSession $userSession,
55
-		IMimeTypeDetector $mimeTypeDetector,
56
-		IPreview $previewManager,
57
-		IFactory $l10n
58
-	) {
59
-		$this->urlGenerator = $urlGenerator;
60
-		$this->rootFolder = $rootFolder;
61
-		$this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
62
-		$this->previewManager = $previewManager;
63
-		$this->mimeTypeDetector = $mimeTypeDetector;
64
-		$this->l10n = $l10n->get('files');
65
-	}
66
-
67
-	public function matchReference(string $referenceText): bool {
68
-		return $this->getFilesAppLinkId($referenceText) !== null;
69
-	}
70
-
71
-	private function getFilesAppLinkId(string $referenceText): ?int {
72
-		$start = $this->urlGenerator->getAbsoluteURL('/apps/files/');
73
-		$startIndex = $this->urlGenerator->getAbsoluteURL('/index.php/apps/files/');
74
-
75
-		$fileId = null;
76
-
77
-		if (mb_strpos($referenceText, $start) === 0) {
78
-			$parts = parse_url($referenceText);
79
-			parse_str($parts['query'] ?? '', $query);
80
-			$fileId = isset($query['fileid']) ? (int)$query['fileid'] : $fileId;
81
-			$fileId = isset($query['openfile']) ? (int)$query['openfile'] : $fileId;
82
-		}
83
-
84
-		if (mb_strpos($referenceText, $startIndex) === 0) {
85
-			$parts = parse_url($referenceText);
86
-			parse_str($parts['query'] ?? '', $query);
87
-			$fileId = isset($query['fileid']) ? (int)$query['fileid'] : $fileId;
88
-			$fileId = isset($query['openfile']) ? (int)$query['openfile'] : $fileId;
89
-		}
90
-
91
-		if (mb_strpos($referenceText, $this->urlGenerator->getAbsoluteURL('/index.php/f/')) === 0) {
92
-			$fileId = str_replace($this->urlGenerator->getAbsoluteURL('/index.php/f/'), '', $referenceText);
93
-		}
94
-
95
-		if (mb_strpos($referenceText, $this->urlGenerator->getAbsoluteURL('/f/')) === 0) {
96
-			$fileId = str_replace($this->urlGenerator->getAbsoluteURL('/f/'), '', $referenceText);
97
-		}
98
-
99
-		return $fileId !== null ? (int)$fileId : null;
100
-	}
101
-
102
-	public function resolveReference(string $referenceText): ?IReference {
103
-		if ($this->matchReference($referenceText)) {
104
-			$reference = new Reference($referenceText);
105
-			try {
106
-				$this->fetchReference($reference);
107
-			} catch (NotFoundException $e) {
108
-				$reference->setRichObject('file', null);
109
-				$reference->setAccessible(false);
110
-			}
111
-			return $reference;
112
-		}
113
-
114
-		return null;
115
-	}
116
-
117
-	/**
118
-	 * @throws NotFoundException
119
-	 */
120
-	private function fetchReference(Reference $reference): void {
121
-		if ($this->userId === null) {
122
-			throw new NotFoundException();
123
-		}
124
-
125
-		$fileId = $this->getFilesAppLinkId($reference->getId());
126
-		if ($fileId === null) {
127
-			throw new NotFoundException();
128
-		}
129
-
130
-		try {
131
-			$userFolder = $this->rootFolder->getUserFolder($this->userId);
132
-			$files = $userFolder->getById($fileId);
133
-
134
-			if (empty($files)) {
135
-				throw new NotFoundException();
136
-			}
137
-
138
-			/** @var Node $file */
139
-			$file = array_shift($files);
140
-
141
-			$reference->setTitle($file->getName());
142
-			$reference->setDescription($file->getMimetype());
143
-			$reference->setUrl($this->urlGenerator->getAbsoluteURL('/index.php/f/' . $fileId));
144
-			if ($this->previewManager->isMimeSupported($file->getMimeType())) {
145
-				$reference->setImageUrl($this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', ['x' => 1600, 'y' => 630, 'fileId' => $fileId]));
146
-			} else {
147
-				$fileTypeIconUrl = $this->mimeTypeDetector->mimeTypeIcon($file->getMimeType());
148
-				$reference->setImageUrl($fileTypeIconUrl);
149
-			}
150
-
151
-			$reference->setRichObject('file', [
152
-				'id' => $file->getId(),
153
-				'name' => $file->getName(),
154
-				'size' => $file->getSize(),
155
-				'path' => $userFolder->getRelativePath($file->getPath()),
156
-				'link' => $reference->getUrl(),
157
-				'mimetype' => $file->getMimetype(),
158
-				'mtime' => $file->getMTime(),
159
-				'preview-available' => $this->previewManager->isAvailable($file)
160
-			]);
161
-		} catch (InvalidPathException|NotFoundException|NotPermittedException|NoUserException $e) {
162
-			throw new NotFoundException();
163
-		}
164
-	}
165
-
166
-	public function getCachePrefix(string $referenceId): string {
167
-		return (string)$this->getFilesAppLinkId($referenceId);
168
-	}
169
-
170
-	public function getCacheKey(string $referenceId): ?string {
171
-		return $this->userId ?? '';
172
-	}
173
-
174
-	public function getId(): string {
175
-		return 'files';
176
-	}
177
-
178
-	public function getTitle(): string {
179
-		return $this->l10n->t('Files');
180
-	}
181
-
182
-	public function getOrder(): int {
183
-		return 0;
184
-	}
185
-
186
-	public function getIconUrl(): string {
187
-		return $this->urlGenerator->imagePath('files', 'folder.svg');
188
-	}
44
+    private IURLGenerator $urlGenerator;
45
+    private IRootFolder $rootFolder;
46
+    private ?string $userId;
47
+    private IPreview $previewManager;
48
+    private IMimeTypeDetector $mimeTypeDetector;
49
+    private IL10N $l10n;
50
+
51
+    public function __construct(
52
+        IURLGenerator $urlGenerator,
53
+        IRootFolder $rootFolder,
54
+        IUserSession $userSession,
55
+        IMimeTypeDetector $mimeTypeDetector,
56
+        IPreview $previewManager,
57
+        IFactory $l10n
58
+    ) {
59
+        $this->urlGenerator = $urlGenerator;
60
+        $this->rootFolder = $rootFolder;
61
+        $this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
62
+        $this->previewManager = $previewManager;
63
+        $this->mimeTypeDetector = $mimeTypeDetector;
64
+        $this->l10n = $l10n->get('files');
65
+    }
66
+
67
+    public function matchReference(string $referenceText): bool {
68
+        return $this->getFilesAppLinkId($referenceText) !== null;
69
+    }
70
+
71
+    private function getFilesAppLinkId(string $referenceText): ?int {
72
+        $start = $this->urlGenerator->getAbsoluteURL('/apps/files/');
73
+        $startIndex = $this->urlGenerator->getAbsoluteURL('/index.php/apps/files/');
74
+
75
+        $fileId = null;
76
+
77
+        if (mb_strpos($referenceText, $start) === 0) {
78
+            $parts = parse_url($referenceText);
79
+            parse_str($parts['query'] ?? '', $query);
80
+            $fileId = isset($query['fileid']) ? (int)$query['fileid'] : $fileId;
81
+            $fileId = isset($query['openfile']) ? (int)$query['openfile'] : $fileId;
82
+        }
83
+
84
+        if (mb_strpos($referenceText, $startIndex) === 0) {
85
+            $parts = parse_url($referenceText);
86
+            parse_str($parts['query'] ?? '', $query);
87
+            $fileId = isset($query['fileid']) ? (int)$query['fileid'] : $fileId;
88
+            $fileId = isset($query['openfile']) ? (int)$query['openfile'] : $fileId;
89
+        }
90
+
91
+        if (mb_strpos($referenceText, $this->urlGenerator->getAbsoluteURL('/index.php/f/')) === 0) {
92
+            $fileId = str_replace($this->urlGenerator->getAbsoluteURL('/index.php/f/'), '', $referenceText);
93
+        }
94
+
95
+        if (mb_strpos($referenceText, $this->urlGenerator->getAbsoluteURL('/f/')) === 0) {
96
+            $fileId = str_replace($this->urlGenerator->getAbsoluteURL('/f/'), '', $referenceText);
97
+        }
98
+
99
+        return $fileId !== null ? (int)$fileId : null;
100
+    }
101
+
102
+    public function resolveReference(string $referenceText): ?IReference {
103
+        if ($this->matchReference($referenceText)) {
104
+            $reference = new Reference($referenceText);
105
+            try {
106
+                $this->fetchReference($reference);
107
+            } catch (NotFoundException $e) {
108
+                $reference->setRichObject('file', null);
109
+                $reference->setAccessible(false);
110
+            }
111
+            return $reference;
112
+        }
113
+
114
+        return null;
115
+    }
116
+
117
+    /**
118
+     * @throws NotFoundException
119
+     */
120
+    private function fetchReference(Reference $reference): void {
121
+        if ($this->userId === null) {
122
+            throw new NotFoundException();
123
+        }
124
+
125
+        $fileId = $this->getFilesAppLinkId($reference->getId());
126
+        if ($fileId === null) {
127
+            throw new NotFoundException();
128
+        }
129
+
130
+        try {
131
+            $userFolder = $this->rootFolder->getUserFolder($this->userId);
132
+            $files = $userFolder->getById($fileId);
133
+
134
+            if (empty($files)) {
135
+                throw new NotFoundException();
136
+            }
137
+
138
+            /** @var Node $file */
139
+            $file = array_shift($files);
140
+
141
+            $reference->setTitle($file->getName());
142
+            $reference->setDescription($file->getMimetype());
143
+            $reference->setUrl($this->urlGenerator->getAbsoluteURL('/index.php/f/' . $fileId));
144
+            if ($this->previewManager->isMimeSupported($file->getMimeType())) {
145
+                $reference->setImageUrl($this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', ['x' => 1600, 'y' => 630, 'fileId' => $fileId]));
146
+            } else {
147
+                $fileTypeIconUrl = $this->mimeTypeDetector->mimeTypeIcon($file->getMimeType());
148
+                $reference->setImageUrl($fileTypeIconUrl);
149
+            }
150
+
151
+            $reference->setRichObject('file', [
152
+                'id' => $file->getId(),
153
+                'name' => $file->getName(),
154
+                'size' => $file->getSize(),
155
+                'path' => $userFolder->getRelativePath($file->getPath()),
156
+                'link' => $reference->getUrl(),
157
+                'mimetype' => $file->getMimetype(),
158
+                'mtime' => $file->getMTime(),
159
+                'preview-available' => $this->previewManager->isAvailable($file)
160
+            ]);
161
+        } catch (InvalidPathException|NotFoundException|NotPermittedException|NoUserException $e) {
162
+            throw new NotFoundException();
163
+        }
164
+    }
165
+
166
+    public function getCachePrefix(string $referenceId): string {
167
+        return (string)$this->getFilesAppLinkId($referenceId);
168
+    }
169
+
170
+    public function getCacheKey(string $referenceId): ?string {
171
+        return $this->userId ?? '';
172
+    }
173
+
174
+    public function getId(): string {
175
+        return 'files';
176
+    }
177
+
178
+    public function getTitle(): string {
179
+        return $this->l10n->t('Files');
180
+    }
181
+
182
+    public function getOrder(): int {
183
+        return 0;
184
+    }
185
+
186
+    public function getIconUrl(): string {
187
+        return $this->urlGenerator->imagePath('files', 'folder.svg');
188
+    }
189 189
 }
Please login to merge, or discard this patch.
apps/files/lib/Listener/RenderReferenceEventListener.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@
 block discarded – undo
29 29
 use OCP\EventDispatcher\IEventListener;
30 30
 
31 31
 class RenderReferenceEventListener implements IEventListener {
32
-	public function handle(Event $event): void {
33
-		if (!$event instanceof RenderReferenceEvent) {
34
-			return;
35
-		}
32
+    public function handle(Event $event): void {
33
+        if (!$event instanceof RenderReferenceEvent) {
34
+            return;
35
+        }
36 36
 
37
-		\OCP\Util::addScript('files', 'reference-files');
38
-	}
37
+        \OCP\Util::addScript('files', 'reference-files');
38
+    }
39 39
 }
Please login to merge, or discard this patch.
apps/files/lib/AppInfo/Application.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -69,119 +69,119 @@
 block discarded – undo
69 69
 use Psr\Container\ContainerInterface;
70 70
 
71 71
 class Application extends App implements IBootstrap {
72
-	public const APP_ID = 'files';
73
-
74
-	public function __construct(array $urlParams = []) {
75
-		parent::__construct(self::APP_ID, $urlParams);
76
-	}
77
-
78
-	public function register(IRegistrationContext $context): void {
79
-		/**
80
-		 * Controllers
81
-		 */
82
-		$context->registerService('APIController', function (ContainerInterface $c) {
83
-			/** @var IServerContainer $server */
84
-			$server = $c->get(IServerContainer::class);
85
-
86
-			return new ApiController(
87
-				$c->get('AppName'),
88
-				$c->get(IRequest::class),
89
-				$c->get(IUserSession::class),
90
-				$c->get(TagService::class),
91
-				$c->get(IPreview::class),
92
-				$c->get(IShareManager::class),
93
-				$c->get(IConfig::class),
94
-				$server->getUserFolder(),
95
-				$c->get(UserConfig::class),
96
-			);
97
-		});
98
-
99
-		/**
100
-		 * Services
101
-		 */
102
-		$context->registerService(TagService::class, function (ContainerInterface $c) {
103
-			/** @var IServerContainer $server */
104
-			$server = $c->get(IServerContainer::class);
105
-
106
-			return new TagService(
107
-				$c->get(IUserSession::class),
108
-				$c->get(IActivityManager::class),
109
-				$c->get(ITagManager::class)->load(self::APP_ID),
110
-				$server->getUserFolder(),
111
-				$server->getEventDispatcher()
112
-			);
113
-		});
114
-
115
-		/*
72
+    public const APP_ID = 'files';
73
+
74
+    public function __construct(array $urlParams = []) {
75
+        parent::__construct(self::APP_ID, $urlParams);
76
+    }
77
+
78
+    public function register(IRegistrationContext $context): void {
79
+        /**
80
+         * Controllers
81
+         */
82
+        $context->registerService('APIController', function (ContainerInterface $c) {
83
+            /** @var IServerContainer $server */
84
+            $server = $c->get(IServerContainer::class);
85
+
86
+            return new ApiController(
87
+                $c->get('AppName'),
88
+                $c->get(IRequest::class),
89
+                $c->get(IUserSession::class),
90
+                $c->get(TagService::class),
91
+                $c->get(IPreview::class),
92
+                $c->get(IShareManager::class),
93
+                $c->get(IConfig::class),
94
+                $server->getUserFolder(),
95
+                $c->get(UserConfig::class),
96
+            );
97
+        });
98
+
99
+        /**
100
+         * Services
101
+         */
102
+        $context->registerService(TagService::class, function (ContainerInterface $c) {
103
+            /** @var IServerContainer $server */
104
+            $server = $c->get(IServerContainer::class);
105
+
106
+            return new TagService(
107
+                $c->get(IUserSession::class),
108
+                $c->get(IActivityManager::class),
109
+                $c->get(ITagManager::class)->load(self::APP_ID),
110
+                $server->getUserFolder(),
111
+                $server->getEventDispatcher()
112
+            );
113
+        });
114
+
115
+        /*
116 116
 		 * Register capabilities
117 117
 		 */
118
-		$context->registerCapability(Capabilities::class);
119
-		$context->registerCapability(DirectEditingCapabilities::class);
120
-
121
-		$context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
122
-		$context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class);
123
-		$context->registerEventListener(RenderReferenceEvent::class, RenderReferenceEventListener::class);
124
-
125
-		$context->registerSearchProvider(FilesSearchProvider::class);
126
-
127
-		$context->registerNotifierService(Notifier::class);
128
-	}
129
-
130
-	public function boot(IBootContext $context): void {
131
-		$context->injectFn(Closure::fromCallable([$this, 'registerCollaboration']));
132
-		$context->injectFn([Listener::class, 'register']);
133
-		$context->injectFn(Closure::fromCallable([$this, 'registerSearchProvider']));
134
-		$this->registerTemplates();
135
-		$context->injectFn(Closure::fromCallable([$this, 'registerNavigation']));
136
-		$this->registerHooks();
137
-	}
138
-
139
-	private function registerCollaboration(IProviderManager $providerManager): void {
140
-		$providerManager->registerResourceProvider(ResourceProvider::class);
141
-	}
142
-
143
-	private function registerSearchProvider(ISearch $search): void {
144
-		$search->registerProvider(File::class, ['apps' => ['files']]);
145
-	}
146
-
147
-	private function registerTemplates(): void {
148
-		$templateManager = \OC_Helper::getFileTemplateManager();
149
-		$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');
150
-		$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
151
-		$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
152
-	}
153
-
154
-	private function registerNavigation(IL10N $l10n): void {
155
-		\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
156
-			return [
157
-				'id' => 'files',
158
-				'appname' => 'files',
159
-				'script' => 'list.php',
160
-				'order' => 0,
161
-				'name' => $l10n->t('All files')
162
-			];
163
-		});
164
-		\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
165
-			return [
166
-				'id' => 'recent',
167
-				'appname' => 'files',
168
-				'script' => 'recentlist.php',
169
-				'order' => 2,
170
-				'name' => $l10n->t('Recent')
171
-			];
172
-		});
173
-		\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
174
-			return [
175
-				'id' => 'favorites',
176
-				'appname' => 'files',
177
-				'script' => 'simplelist.php',
178
-				'order' => 5,
179
-				'name' => $l10n->t('Favorites'),
180
-			];
181
-		});
182
-	}
183
-
184
-	private function registerHooks(): void {
185
-		Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig');
186
-	}
118
+        $context->registerCapability(Capabilities::class);
119
+        $context->registerCapability(DirectEditingCapabilities::class);
120
+
121
+        $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
122
+        $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class);
123
+        $context->registerEventListener(RenderReferenceEvent::class, RenderReferenceEventListener::class);
124
+
125
+        $context->registerSearchProvider(FilesSearchProvider::class);
126
+
127
+        $context->registerNotifierService(Notifier::class);
128
+    }
129
+
130
+    public function boot(IBootContext $context): void {
131
+        $context->injectFn(Closure::fromCallable([$this, 'registerCollaboration']));
132
+        $context->injectFn([Listener::class, 'register']);
133
+        $context->injectFn(Closure::fromCallable([$this, 'registerSearchProvider']));
134
+        $this->registerTemplates();
135
+        $context->injectFn(Closure::fromCallable([$this, 'registerNavigation']));
136
+        $this->registerHooks();
137
+    }
138
+
139
+    private function registerCollaboration(IProviderManager $providerManager): void {
140
+        $providerManager->registerResourceProvider(ResourceProvider::class);
141
+    }
142
+
143
+    private function registerSearchProvider(ISearch $search): void {
144
+        $search->registerProvider(File::class, ['apps' => ['files']]);
145
+    }
146
+
147
+    private function registerTemplates(): void {
148
+        $templateManager = \OC_Helper::getFileTemplateManager();
149
+        $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');
150
+        $templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
151
+        $templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
152
+    }
153
+
154
+    private function registerNavigation(IL10N $l10n): void {
155
+        \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
156
+            return [
157
+                'id' => 'files',
158
+                'appname' => 'files',
159
+                'script' => 'list.php',
160
+                'order' => 0,
161
+                'name' => $l10n->t('All files')
162
+            ];
163
+        });
164
+        \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
165
+            return [
166
+                'id' => 'recent',
167
+                'appname' => 'files',
168
+                'script' => 'recentlist.php',
169
+                'order' => 2,
170
+                'name' => $l10n->t('Recent')
171
+            ];
172
+        });
173
+        \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
174
+            return [
175
+                'id' => 'favorites',
176
+                'appname' => 'files',
177
+                'script' => 'simplelist.php',
178
+                'order' => 5,
179
+                'name' => $l10n->t('Favorites'),
180
+            ];
181
+        });
182
+    }
183
+
184
+    private function registerHooks(): void {
185
+        Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig');
186
+    }
187 187
 }
Please login to merge, or discard this patch.