1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package Breizh Smilies Categories Extension |
5
|
|
|
* @copyright (c) 2020-2024 Sylver35 https://breizhcode.com |
6
|
|
|
* @license https://opensource.org/licenses/gpl-license.php GNU Public License |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace sylver35\smiliescat\event; |
11
|
|
|
|
12
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
13
|
|
|
use sylver35\smiliescat\core\diffusion; |
14
|
|
|
use phpbb\config\config; |
15
|
|
|
use phpbb\controller\helper; |
16
|
|
|
use phpbb\template\template; |
17
|
|
|
use phpbb\language\language; |
18
|
|
|
|
19
|
|
|
class listener implements EventSubscriberInterface |
20
|
|
|
{ |
21
|
|
|
/* @var \sylver35\smiliescat\core\diffusion */ |
22
|
|
|
protected $diffusion; |
23
|
|
|
|
24
|
|
|
/** @var \phpbb\config\config */ |
25
|
|
|
protected $config; |
26
|
|
|
|
27
|
|
|
/* @var \phpbb\controller\helper */ |
28
|
|
|
protected $helper; |
29
|
|
|
|
30
|
|
|
/** @var \phpbb\template\template */ |
31
|
|
|
protected $template; |
32
|
|
|
|
33
|
|
|
/** @var \phpbb\language\language */ |
34
|
|
|
protected $language; |
35
|
|
|
|
36
|
|
|
/** @var string phpBB root path */ |
37
|
|
|
protected $root_path; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Constructor |
41
|
|
|
*/ |
42
|
|
|
public function __construct(diffusion $diffusion, config $config, helper $helper, template $template, language $language, $root_path) |
43
|
|
|
{ |
44
|
|
|
$this->diffusion = $diffusion; |
45
|
|
|
$this->config = $config; |
46
|
|
|
$this->helper = $helper; |
47
|
|
|
$this->template = $template; |
48
|
|
|
$this->language = $language; |
49
|
|
|
$this->root_path = $root_path; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
static public function getSubscribedEvents() |
53
|
|
|
{ |
54
|
|
|
return [ |
55
|
|
|
'core.user_setup' => 'load_language_on_setup', |
56
|
|
|
'core.page_header' => 'add_page_header', |
57
|
|
|
'core.posting_modify_template_vars' => 'add_categories', |
58
|
|
|
'core.acp_language_after_delete' => 'language_after_delete', |
59
|
|
|
'breizhshoutbox.smilies' => 'smilies', |
60
|
|
|
'breizhshoutbox.smilies_popup' => 'smilies_popup', |
61
|
|
|
'breizhshoutbox.shoutbox_smilies_after' => 'category_smilies', |
62
|
|
|
'breizhshoutbox.shoutbox_rules_after' => 'add_page_header', |
63
|
|
|
]; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Load language files during user setup |
68
|
|
|
* |
69
|
|
|
* @param array $event |
70
|
|
|
* |
71
|
|
|
* @return void |
72
|
|
|
* @access public |
73
|
|
|
*/ |
74
|
|
|
public function load_language_on_setup($event) |
75
|
|
|
{ |
76
|
|
|
$lang_set_ext = $event['lang_set_ext']; |
77
|
|
|
$lang_set_ext[] = [ |
78
|
|
|
'ext_name' => 'sylver35/smiliescat', |
79
|
|
|
'lang_set' => ['smilies_category'], |
80
|
|
|
]; |
81
|
|
|
$event['lang_set_ext'] = $lang_set_ext; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Add the category popup link |
86
|
|
|
* |
87
|
|
|
* @return void |
88
|
|
|
* @access public |
89
|
|
|
*/ |
90
|
|
|
public function add_page_header() |
91
|
|
|
{ |
92
|
|
|
$this->diffusion->url_to_page(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Add the Smilies Categories on posting form |
97
|
|
|
* |
98
|
|
|
* @return void |
99
|
|
|
* @access public |
100
|
|
|
*/ |
101
|
|
|
public function add_categories($event) |
102
|
|
|
{ |
103
|
|
|
$this->diffusion->cats_to_posting_form($event); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param array $event |
108
|
|
|
* |
109
|
|
|
* @return void |
110
|
|
|
* @access public |
111
|
|
|
*/ |
112
|
|
|
public function smilies($event) |
113
|
|
|
{ |
114
|
|
|
$list_cats = $this->diffusion->list_cats(false); |
115
|
|
|
$event['content'] = array_merge($event['content'], [ |
116
|
|
|
'title_cat' => $this->language->lang('ACP_SC_SMILIES'), |
117
|
|
|
'categories' => $list_cats['list_cat'], |
118
|
|
|
]); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param array $event |
123
|
|
|
* |
124
|
|
|
* @return void |
125
|
|
|
* @access public |
126
|
|
|
*/ |
127
|
|
|
public function smilies_popup($event) |
128
|
|
|
{ |
129
|
|
|
$list_cats = $this->diffusion->list_cats($event['cat']); |
130
|
|
|
$event['content'] = array_merge($event['content'], [ |
131
|
|
|
'title_cat' => $this->language->lang('ACP_SC_SMILIES'), |
132
|
|
|
'categories' => $list_cats['list_cat'], |
133
|
|
|
]); |
134
|
|
|
|
135
|
|
|
$list = $this->diffusion->smilies_popup($event['cat'], $event['start']); |
136
|
|
|
if ($list['in_cat'] !== false) |
137
|
|
|
{ |
138
|
|
|
$event['content'] = array_merge($event['content'], [ |
139
|
|
|
'in_cat' => $list['in_cat'], |
140
|
|
|
'total' => $list['total'], |
141
|
|
|
'cat' => $list['cat'], |
142
|
|
|
'smilies' => $list['smilies'], |
143
|
|
|
'emptyRow' => $list['emptyRow'], |
144
|
|
|
'title' => $list['title'], |
145
|
|
|
'start' => $list['start'], |
146
|
|
|
'pagination' => $list['pagination'], |
147
|
|
|
]); |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param array $event |
153
|
|
|
* |
154
|
|
|
* @return void |
155
|
|
|
* @access public |
156
|
|
|
*/ |
157
|
|
|
public function language_after_delete($event) |
158
|
|
|
{ |
159
|
|
|
$this->diffusion->delete_categories_lang($event['lang_iso']); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param array $event |
164
|
|
|
* |
165
|
|
|
* @return void |
166
|
|
|
* @access public |
167
|
|
|
*/ |
168
|
|
|
public function category_smilies($event) |
169
|
|
|
{ |
170
|
|
|
$this->diffusion->category_smilies(); |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|