1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* phpBB Directory extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2014 ErnadoO <http://www.phpbb-services.com> |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace ernadoo\phpbbdirectory\acp; |
12
|
|
|
|
13
|
|
|
class phpbbdirectory_module |
14
|
|
|
{ |
15
|
|
|
public $page_title; |
16
|
|
|
|
17
|
|
|
public $tpl_name; |
18
|
|
|
|
19
|
|
|
public $u_action; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* |
23
|
|
|
* @param int $id |
24
|
|
|
* @param string $mode |
25
|
|
|
*/ |
26
|
|
|
public function main($id, $mode) |
27
|
|
|
{ |
28
|
|
|
global $request, $phpbb_container; |
29
|
|
|
|
30
|
|
|
$action = $request->variable('action', ''); |
31
|
|
|
$update = ($request->is_set_post('update')) ? true : false; |
32
|
|
|
|
33
|
|
|
switch ($mode) |
34
|
|
|
{ |
35
|
|
|
case 'main': |
36
|
|
|
|
37
|
|
|
// Set the page title for our ACP page |
38
|
|
|
$this->page_title = 'ACP_DIRECTORY'; |
39
|
|
|
|
40
|
|
|
// Load a template from adm/style for our ACP page |
41
|
|
|
$this->tpl_name = 'acp_dir_main'; |
42
|
|
|
|
43
|
|
|
// Get an instance of the acp_main controller |
44
|
|
|
$main_controller = $phpbb_container->get('ernadoo.phpbbdirectory.controller.acp.main'); |
45
|
|
|
|
46
|
|
|
// Make the $u_action url available in the acp_main controller |
47
|
|
|
$main_controller->set_page_url($this->u_action); |
48
|
|
|
|
49
|
|
|
if ($action) |
50
|
|
|
{ |
51
|
|
|
if (!confirm_box(true)) |
52
|
|
|
{ |
53
|
|
|
$main_controller->display_confirm($action); |
54
|
|
|
} |
55
|
|
|
else |
56
|
|
|
{ |
57
|
|
|
$main_controller->exec_action($action); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
// Display main page |
62
|
|
|
$main_controller->display_stats(); |
63
|
|
|
|
64
|
|
|
break; |
65
|
|
|
|
66
|
|
|
case 'settings': |
67
|
|
|
|
68
|
|
|
// Get an instance of the acp_settings controller |
69
|
|
|
$settings_controller = $phpbb_container->get('ernadoo.phpbbdirectory.controller.acp.settings'); |
70
|
|
|
|
71
|
|
|
// Set the page title for our ACP page |
72
|
|
|
$this->page_title = 'ACP_DIRECTORY_SETTINGS'; |
73
|
|
|
|
74
|
|
|
// Load a template from adm/style for our ACP page |
75
|
|
|
$this->tpl_name = 'acp_board'; |
76
|
|
|
|
77
|
|
|
// Make the $u_action url available in the acp_settings controller |
78
|
|
|
$settings_controller->set_page_url($this->u_action); |
79
|
|
|
|
80
|
|
|
$settings_controller->process(); |
81
|
|
|
|
82
|
|
|
// Display config |
83
|
|
|
$settings_controller->display_config(); |
84
|
|
|
|
85
|
|
|
break; |
86
|
|
|
|
87
|
|
|
case 'cat': |
88
|
|
|
|
89
|
|
|
// Set the page title for our ACP page |
90
|
|
|
$this->page_title = 'ACP_DIRECTORY'; |
91
|
|
|
|
92
|
|
|
// Load a template from adm/style for our ACP page |
93
|
|
|
$this->tpl_name = 'acp_dir_cat'; |
94
|
|
|
|
95
|
|
|
// Get an instance of the acp_cat controller |
96
|
|
|
$cat_controller = $phpbb_container->get('ernadoo.phpbbdirectory.controller.acp.cat'); |
97
|
|
|
|
98
|
|
|
// Make the $u_action url available in the acp_cat controller |
99
|
|
|
$cat_controller->set_page_url($this->u_action); |
100
|
|
|
|
101
|
|
|
// Major routines |
102
|
|
|
if ($update) |
103
|
|
|
{ |
104
|
|
|
$cat_controller->update(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
switch ($action) |
108
|
|
|
{ |
109
|
|
|
case 'progress_bar': |
110
|
|
|
$cat_controller->action_progress_bar(); |
111
|
|
|
return; |
112
|
|
|
break; |
113
|
|
|
|
114
|
|
|
case 'sync': |
115
|
|
|
$cat_controller->action_sync(); |
116
|
|
|
break; |
117
|
|
|
|
118
|
|
|
case 'sync_cat': |
119
|
|
|
$cat_controller->action_sync_cat(); |
120
|
|
|
break; |
121
|
|
|
|
122
|
|
|
case 'move_up': |
123
|
|
|
case 'move_down': |
124
|
|
|
$cat_controller->action_move(); |
125
|
|
|
break; |
126
|
|
|
|
127
|
|
|
case 'edit': |
128
|
|
|
$this->page_title = 'DIR_EDIT_CAT'; |
129
|
|
|
|
130
|
|
|
$cat_controller->action_edit(); |
131
|
|
|
return; |
132
|
|
|
break; |
133
|
|
|
|
134
|
|
|
case 'add': |
135
|
|
|
$this->page_title = 'DIR_ADD_CAT'; |
136
|
|
|
|
137
|
|
|
$cat_controller->action_add(); |
138
|
|
|
return; |
139
|
|
|
break; |
140
|
|
|
|
141
|
|
|
case 'delete': |
142
|
|
|
$cat_controller->action_delete(); |
143
|
|
|
return; |
144
|
|
|
break; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
// Display categories |
148
|
|
|
$cat_controller->display_cats(); |
149
|
|
|
|
150
|
|
|
break; |
151
|
|
|
|
152
|
|
|
case 'val': |
153
|
|
|
|
154
|
|
|
// Set the page title for our ACP page |
155
|
|
|
$this->page_title = 'ACP_DIRECTORY'; |
156
|
|
|
|
157
|
|
|
// Load a template from adm/style for our ACP page |
158
|
|
|
$this->tpl_name = 'acp_dir_val'; |
159
|
|
|
|
160
|
|
|
// Get an instance of the acp_validation controller |
161
|
|
|
$validation_controller = $phpbb_container->get('ernadoo.phpbbdirectory.controller.acp.validation'); |
162
|
|
|
|
163
|
|
|
// Make the $u_action url available in the acp_validation controller |
164
|
|
|
$validation_controller->set_page_url($this->u_action); |
165
|
|
|
|
166
|
|
|
$mark = ($request->is_set_post('link_id')) ? $request->variable('link_id', array(0)) : array(); |
167
|
|
|
|
168
|
|
|
if ($action && count($mark)) |
169
|
|
|
{ |
170
|
|
|
if (!confirm_box(true) && $action != 'approved') |
171
|
|
|
{ |
172
|
|
|
$validation_controller->display_confirm($mark); |
173
|
|
|
} |
174
|
|
|
else |
175
|
|
|
{ |
176
|
|
|
$validation_controller->exec_action($mark); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
$validation_controller->notifiy_submiters(); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
// Display websites pending validation |
183
|
|
|
$validation_controller->display_websites(); |
184
|
|
|
|
185
|
|
|
break; |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Display thumb services available |
191
|
|
|
* |
192
|
|
|
* @param string $url_selected |
193
|
|
|
* @return string |
194
|
|
|
*/ |
195
|
|
|
public function get_thumb_service_list($url_selected) |
196
|
|
|
{ |
197
|
|
|
$thumbshot = array( |
198
|
|
|
'http://www.apercite.fr/apercite/120x90/oui/oui/', |
199
|
|
|
'http://www.easy-thumb.net/min.html?url=', |
200
|
|
|
); |
201
|
|
|
|
202
|
|
|
$select_options = ''; |
203
|
|
|
foreach ($thumbshot as $url) |
204
|
|
|
{ |
205
|
|
|
$selected = ($url == $url_selected) ? 'selected="selected"' : ''; |
206
|
|
|
|
207
|
|
|
$select_options .= '<option value="' . $url . '" ' . $selected . '>' . parse_url($url, PHP_URL_HOST) . '</option>'; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
return $select_options; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Display order drop-down list |
215
|
|
|
* |
216
|
|
|
* @param string $order_selected |
217
|
|
|
* @return string |
218
|
|
|
*/ |
219
|
|
|
public function get_order_list($order_selected) |
220
|
|
|
{ |
221
|
|
|
global $user; |
222
|
|
|
|
223
|
|
|
$order_array = array( |
224
|
|
|
'a a', |
225
|
|
|
'a d', |
226
|
|
|
't a', |
227
|
|
|
't d', |
228
|
|
|
'r a', |
229
|
|
|
'r d', |
230
|
|
|
's a', |
231
|
|
|
's d', |
232
|
|
|
'v a', |
233
|
|
|
'v d' |
234
|
|
|
); |
235
|
|
|
$tpl = ''; |
236
|
|
|
foreach ($order_array as $i) |
237
|
|
|
{ |
238
|
|
|
$selected = ($i == $order_selected) ? 'selected="selected"' : ''; |
239
|
|
|
$order_substr = trim(str_replace(' ', '_', $i)); |
240
|
|
|
$tpl .= '<option value="' . $i . '" ' . $selected . '>' . $user->lang['DIR_ORDER_' . strtoupper($order_substr)] . '</option>'; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
return ($tpl); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Adjust all three max_filesize config vars for display |
248
|
|
|
*/ |
249
|
|
|
public function max_filesize($value, $key = '') |
250
|
|
|
{ |
251
|
|
|
// Determine size var and adjust the value accordingly |
252
|
|
|
$filesize = get_formatted_filesize($value, false, array('mb', 'kb', 'b')); |
253
|
|
|
$size_var = $filesize['si_identifier']; |
254
|
|
|
$value = $filesize['value']; |
255
|
|
|
|
256
|
|
|
// size and maxlength must not be specified for input of type number |
257
|
|
|
return '<input type="number" id="' . $key . '" min="0" max="999999999999999" step="any" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>'; |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
|