|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Advanced BBCode Box |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2013 Matt Friedman |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace vse\abbc3\event; |
|
12
|
|
|
|
|
13
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
|
|
|
|
|
14
|
|
|
use vse\abbc3\core\acp_manager; |
|
15
|
|
|
use vse\abbc3\ext; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Event listener |
|
19
|
|
|
*/ |
|
20
|
|
|
class acp_listener implements EventSubscriberInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** @var acp_manager */ |
|
23
|
|
|
protected $acp_manager; |
|
24
|
|
|
|
|
25
|
|
|
/** @var string */ |
|
26
|
|
|
protected $root_path; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Constructor |
|
30
|
|
|
* |
|
31
|
|
|
* @param acp_manager $acp_manager |
|
32
|
|
|
* @param string $root_path |
|
33
|
|
|
* @access public |
|
34
|
|
|
*/ |
|
35
|
21 |
|
public function __construct(acp_manager $acp_manager, $root_path) |
|
36
|
|
|
{ |
|
37
|
21 |
|
$this->acp_manager = $acp_manager; |
|
38
|
21 |
|
$this->root_path = $root_path; |
|
39
|
21 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Assign functions defined in this class to event listeners in the core |
|
43
|
|
|
* |
|
44
|
|
|
* @return array |
|
45
|
|
|
* @static |
|
46
|
|
|
* @access public |
|
47
|
|
|
*/ |
|
48
|
1 |
|
public static function getSubscribedEvents() |
|
49
|
|
|
{ |
|
50
|
|
|
return [ |
|
51
|
1 |
|
'core.acp_bbcodes_display_form' => 'acp_bbcodes_custom_sorting', |
|
52
|
1 |
|
'core.acp_bbcodes_display_bbcodes' => 'acp_bbcodes_custom_sorting_buttons', |
|
53
|
1 |
|
'core.acp_bbcodes_modify_create' => 'acp_bbcodes_modify_create', |
|
54
|
1 |
|
'core.acp_bbcodes_edit_add' => 'acp_bbcodes_group_select_box', |
|
55
|
|
|
|
|
56
|
|
|
// text_formatter events (for phpBB 3.2.x) |
|
57
|
1 |
|
'core.text_formatter_s9e_configure_after' => 's9e_store_bbcode_groups', |
|
58
|
1 |
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Add some additional elements to the BBCodes template |
|
63
|
|
|
* |
|
64
|
|
|
* @param \phpbb\event\data $event The event object |
|
|
|
|
|
|
65
|
|
|
* @access public |
|
66
|
|
|
*/ |
|
67
|
3 |
|
public function acp_bbcodes_custom_sorting_buttons($event) |
|
68
|
|
|
{ |
|
69
|
3 |
|
$bbcode_id = $event['row']['bbcode_id']; |
|
70
|
3 |
|
$event->update_subarray('bbcodes_array', 'U_MOVE_UP', $event['u_action'] . '&action=' . ext::MOVE_UP . '&id=' . $bbcode_id . '&hash=' . generate_link_hash(ext::MOVE_UP . $bbcode_id)); |
|
|
|
|
|
|
71
|
3 |
|
$event->update_subarray('bbcodes_array', 'U_MOVE_DOWN', $event['u_action'] . '&action=' . ext::MOVE_DOWN . '&id=' . $bbcode_id . '&hash=' . generate_link_hash(ext::MOVE_DOWN . $bbcode_id)); |
|
72
|
3 |
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Add the Group select form field on BBCode edit page |
|
76
|
|
|
* |
|
77
|
|
|
* @param \phpbb\event\data $event The event object |
|
78
|
|
|
* @access public |
|
79
|
|
|
*/ |
|
80
|
4 |
|
public function acp_bbcodes_group_select_box($event) |
|
81
|
|
|
{ |
|
82
|
4 |
|
$bbcode_group = ($event['action'] === 'edit') ? $this->acp_manager->get_bbcode_group_data($event['bbcode_id']) : []; |
|
83
|
|
|
|
|
84
|
4 |
|
$event->update_subarray('tpl_ary', 'S_GROUP_OPTIONS', $this->acp_manager->bbcode_group_select_options($bbcode_group)); |
|
85
|
4 |
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Handle BBCode order changes when moving them up/down |
|
89
|
|
|
* |
|
90
|
|
|
* @param \phpbb\event\data $event The event object |
|
91
|
|
|
* @access public |
|
92
|
|
|
*/ |
|
93
|
9 |
|
public function acp_bbcodes_custom_sorting($event) |
|
94
|
|
|
{ |
|
95
|
|
|
// Move up/down actions |
|
96
|
9 |
|
switch ($event['action']) |
|
97
|
|
|
{ |
|
98
|
9 |
|
case ext::MOVE_UP: |
|
99
|
9 |
|
case ext::MOVE_DOWN: |
|
100
|
2 |
|
$this->acp_manager->move($event['action']); |
|
101
|
2 |
|
break; |
|
102
|
|
|
|
|
103
|
7 |
|
case ext::MOVE_DRAG: |
|
104
|
1 |
|
$this->acp_manager->move_drag(); |
|
105
|
1 |
|
break; |
|
106
|
9 |
|
} |
|
107
|
|
|
|
|
108
|
|
|
// Add some additional template variables |
|
109
|
9 |
|
$event->update_subarray('template_data', 'UA_DRAG_DROP', str_replace('&', '&', $event['u_action'] . '&action=' . ext::MOVE_DRAG)); |
|
110
|
|
|
|
|
111
|
|
|
// Change SQL so that it orders by bbcode_order |
|
112
|
9 |
|
$event->update_subarray('sql_ary', 'ORDER_BY', 'b.bbcode_order, b.bbcode_id'); |
|
113
|
9 |
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Handle BBCode order and group data during modify/create routines |
|
117
|
|
|
* |
|
118
|
|
|
* @param \phpbb\event\data $event The event object |
|
119
|
|
|
* @access public |
|
120
|
|
|
*/ |
|
121
|
3 |
|
public function acp_bbcodes_modify_create($event) |
|
122
|
|
|
{ |
|
123
|
|
|
// Set a new BBCode order value on create |
|
124
|
3 |
|
if ($event['action'] === 'create') |
|
125
|
3 |
|
{ |
|
126
|
2 |
|
$event->update_subarray('sql_ary', 'bbcode_order', $this->acp_manager->get_max_bbcode_order() + 1); |
|
127
|
2 |
|
} |
|
128
|
|
|
|
|
129
|
|
|
// Get the BBCode groups from the form |
|
130
|
3 |
|
$bbcode_group = $this->acp_manager->get_bbcode_group_form_data(); |
|
131
|
3 |
|
$event->update_subarray('sql_ary', 'bbcode_group', $bbcode_group); |
|
132
|
|
|
|
|
133
|
|
|
// Supply BBCode groups to hidden form fields |
|
134
|
3 |
|
$event->update_subarray('hidden_fields', 'bbcode_group', $bbcode_group); |
|
135
|
3 |
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Store BBCode groups in a s9e\TextFormatter variable |
|
139
|
|
|
* |
|
140
|
|
|
* @param \phpbb\event\data $event The event object |
|
141
|
|
|
* @access public |
|
142
|
|
|
*/ |
|
143
|
1 |
|
public function s9e_store_bbcode_groups($event) |
|
144
|
|
|
{ |
|
145
|
|
|
/** @var \s9e\TextFormatter\Configurator $configurator */ |
|
146
|
1 |
|
$configurator = $event['configurator']; |
|
147
|
1 |
|
$bbcode_groups = $this->acp_manager->get_bbcode_groups_data(); |
|
148
|
|
|
|
|
149
|
|
|
// Save BBCode groups in a registered variable in the configurator. That variable will be |
|
150
|
|
|
// copied in the parser's configuration and be available during parser setup. |
|
151
|
1 |
|
$configurator->registeredVars['abbc3.bbcode_groups'] = $bbcode_groups; |
|
152
|
1 |
|
} |
|
153
|
|
|
} |
|
154
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths