|
2 | 2 |
|
3 | 3 | namespace mauricerenck\Komments; |
4 | 4 |
|
5 | | -use mauricerenck\Komments\KommentBaseUtils; |
6 | 5 | use mauricerenck\Komments\KommentModeration; |
7 | 6 | use mauricerenck\Komments\KommentReceiver; |
8 | | -use mauricerenck\Komments\MastodonSender; |
9 | | -use mauricerenck\Komments\WebmentionSender; |
10 | 7 | use Kirby; |
11 | 8 | use Kirby\Toolkit\V; |
12 | 9 | use Kirby\Toolkit\F; |
|
15 | 12 | use Kirby\Data\Data; |
16 | 13 | use Kirby\Data\yaml; |
17 | 14 | use Kirby\Cms\Structure; |
| 15 | +use Kirby\Http\Response; |
18 | 16 | use StdClass; |
19 | 17 | use is_null; |
20 | 18 | use json_encode; |
21 | | -use \Response; |
22 | 19 | use \Throwable; |
23 | 20 |
|
24 | 21 | @include_once __DIR__ . '/vendor/autoload.php'; |
25 | 22 |
|
26 | 23 | Kirby::plugin('mauricerenck/komments', [ |
27 | 24 | 'areas' => require_once(__DIR__ . '/components/areas.php'), |
28 | 25 | 'options' => require_once(__DIR__ . '/config/options.php'), |
29 | | - 'snippets' => require_once(__DIR__ . '/config/snippets.php'), |
| 26 | + 'snippets' => require_once(__DIR__ . '/components/snippets.php'), |
30 | 27 | 'templates' => [ |
31 | 28 | 'emails/newcomments' => __DIR__ . '/templates/emails/newComments.php' |
32 | 29 | ], |
33 | 30 | 'blueprints' => [ |
34 | 31 | 'sections/komments' => __DIR__ . '/blueprints/sections/komments.yml' |
35 | 32 | ], |
36 | | - 'pageMethods' => [ |
37 | | - 'kommentCount' => function () { |
38 | | - $count = 0; |
39 | | - foreach ($this->kommentsInbox()->yaml() as $komment) { |
40 | | - if ($komment['status'] !== 'false' && $komment['status'] !== false) { |
41 | | - $count++; |
42 | | - } |
43 | | - } |
44 | | - return $count; |
45 | | - }, |
46 | | - 'hasQueuedKomments' => function ($kommentId, $kommenStatus) { |
47 | | - $kommentModeration = new KommentModeration(); |
48 | | - return $kommentModeration->pageHasQueuedKomments($kommentId, $kommenStatus); |
49 | | - }, |
50 | | - 'kommentsAreEnabled' => function () { |
51 | | - $kommentBaseUtils = new KommentBaseUtils(); |
52 | | - |
53 | | - if ($kommentBaseUtils->kommentsAreExpired($this)) { |
54 | | - return false; |
55 | | - } |
56 | | - |
57 | | - return $this->kommentsEnabledOnpage()->isEmpty() || $this->kommentsEnabledOnpage()->isTrue(); |
58 | | - }, |
59 | | - ], |
60 | | - 'siteMethods' => [ |
61 | | - 'numberOfPendingComments' => function () { |
62 | | - $kommentBaseUtils = new KommentBaseUtils(); |
63 | | - return $kommentBaseUtils->getPendingCommentCount(); |
64 | | - }, |
65 | | - 'numberOfSpamComments' => function () { |
66 | | - $kommentBaseUtils = new KommentBaseUtils(); |
67 | | - return $kommentBaseUtils->getSpamCommentCount(); |
68 | | - } |
69 | | - ], |
| 33 | + 'pageMethods' => require_once(__DIR__ . '/components/page-methods.php'), |
| 34 | + 'siteMethods' => require_once(__DIR__ . '/components/site-methods.php'), |
70 | 35 | 'fields' => require_once(__DIR__ . '/components/fields.php'), |
71 | 36 | 'translations' => require_once(__DIR__ . '/config/translations.php'), |
72 | | - 'api' => require_once(__DIR__ . '/config/api.php'), |
73 | | - 'hooks' => require_once(__DIR__ . '/config/hooks.php'), |
| 37 | + 'api' => require_once(__DIR__ . '/components/api.php'), |
| 38 | + 'hooks' => require_once(__DIR__ . '/components/hooks.php'), |
74 | 39 | 'routes' => [ |
75 | 40 | [ |
76 | 41 | 'pattern' => 'komments/send', |
|
0 commit comments