forked from hasan-ozbey/flarum-flamoji
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextend.php
69 lines (59 loc) · 2.93 KB
/
extend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* This file is part of the-turk/flarum-flamoji.
*
* Copyright (c) 2021 Hasan Özbey
*
* LICENSE: For the full copyright and license information,
* please view the LICENSE file that was distributed
* with this source code.
*/
namespace TheTurk\Flamoji;
use Flarum\Extend;
use s9e\TextFormatter\Configurator;
use TheTurk\Flamoji\Api\Controllers;
use TheTurk\Flamoji\Listener;
return [
(new Extend\Frontend('forum'))
->css(__DIR__.'/less/forum.less')
->js(__DIR__.'/js/dist/forum.js'),
(new Extend\Frontend('admin'))
->css(__DIR__.'/less/admin.less')
->js(__DIR__.'/js/dist/admin.js'),
new Extend\Locales(__DIR__.'/locale'),
(new Extend\Event())
->subscribe(Listener\SaveEmoji::class),
(new Extend\Formatter)
->configure(ConfigureTextFormatter::class),
(new Extend\Routes('api'))
->get('/the-turk/emojis', 'emojis.list', Controllers\ListEmojisController::class)
->post('/the-turk/emojis', 'emojis.create', Controllers\CreateEmojiController::class)
->post('/the-turk/import-emojis', 'emojis.import', Controllers\ImportEmojiController::class)
->patch('/the-turk/emojis/{id}', 'emojis.update', Controllers\UpdateEmojiController::class)
->delete('/the-turk/emojis/{id}', 'emojis.delete', Controllers\DeleteEmojiController::class),
(new Extend\Settings())
->serializeToForum('flamoji.auto_hide', 'the-turk-flamoji.auto_hide', 'boolVal')
->serializeToForum('flamoji.show_preview', 'the-turk-flamoji.show_preview', 'boolVal')
->serializeToForum('flamoji.show_search', 'the-turk-flamoji.show_search', 'boolVal')
->serializeToForum('flamoji.show_variants', 'the-turk-flamoji.show_variants', 'boolVal')
->serializeToForum('flamoji.emoji_style', 'the-turk-flamoji.emoji_style')
->serializeToForum('flamoji.emoji_data', 'the-turk-flamoji.emoji_data')
->serializeToForum('flamoji.emoji_version', 'the-turk-flamoji.emoji_version')
->serializeToForum('flamoji.initial_category', 'the-turk-flamoji.initial_category')
->serializeToForum('flamoji.show_category_buttons', 'the-turk-flamoji.show_category_buttons', 'boolVal')
->serializeToForum('flamoji.show_recents', 'the-turk-flamoji.show_recents', 'boolVal')
->serializeToForum('flamoji.recents_count', 'the-turk-flamoji.recents_count', 'intVal')
->serializeToForum('flamoji.specify_categories', 'the-turk-flamoji.specify_categories')
->serializeToForum('flamoji.custom_categories', 'the-turk-flamoji.custom_categories', function ($retrievedValue) {
$categories = json_decode($retrievedValue) ?? [];
$res = [];
foreach($categories as $key => $value){
if($value->is_enabled == 1){
$res[$key] = [
'path' => $value->path
];
}
}
return json_encode($res);
}),
];