|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Reduce Search Index [RSI]. An extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2020-forever, Dark❶, https://dark1.tech |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace dark1\reducesearchindex\controller; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @ignore |
|
15
|
|
|
*/ |
|
16
|
|
|
use dark1\reducesearchindex\core\consts; |
|
17
|
|
|
use phpbb\language\language; |
|
18
|
|
|
use phpbb\log\log; |
|
19
|
|
|
use phpbb\request\request; |
|
20
|
|
|
use phpbb\template\template; |
|
21
|
|
|
use phpbb\user; |
|
22
|
|
|
use phpbb\config\config; |
|
23
|
|
|
use phpbb\config\db_text as config_text; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Reduce Search Index [RSI] ACP controller Main. |
|
27
|
|
|
*/ |
|
28
|
|
|
class acp_main extends acp_base |
|
29
|
|
|
{ |
|
30
|
|
|
/** @var config */ |
|
31
|
|
|
protected $config; |
|
32
|
|
|
|
|
33
|
|
|
/** @var config_text */ |
|
34
|
|
|
protected $config_text; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Constructor. |
|
38
|
|
|
* |
|
39
|
|
|
* @param language $language Language object |
|
40
|
|
|
* @param log $log Log object |
|
41
|
|
|
* @param request $request Request object |
|
42
|
|
|
* @param template $template Template object |
|
43
|
|
|
* @param user $user User object |
|
44
|
|
|
* @param config $config Config object |
|
45
|
|
|
* @param config_text $config_text Config text object |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct(language $language, log $log, request $request, template $template, user $user, config $config, config_text $config_text) |
|
48
|
|
|
{ |
|
49
|
|
|
parent::__construct($language, $log, $request, $template, $user); |
|
50
|
|
|
|
|
51
|
|
|
$this->config = $config; |
|
52
|
|
|
$this->config_text = $config_text; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Display the options a user can configure for Main Mode. |
|
57
|
|
|
* |
|
58
|
|
|
* @return void |
|
59
|
|
|
* @access public |
|
60
|
|
|
*/ |
|
61
|
|
|
public function handle() |
|
62
|
|
|
{ |
|
63
|
|
|
// Is the form being submitted to us? |
|
64
|
|
|
if ($this->request->is_set_post('submit')) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->check_form_on_submit(); |
|
67
|
|
|
|
|
68
|
|
|
// Set the options the user configured |
|
69
|
|
|
$this->config->set('dark1_rsi_enable', $this->request->variable('dark1_rsi_enable', 0)); |
|
70
|
|
|
$this->config->set('dark1_rsi_ign_com_enable', $this->request->variable('dark1_rsi_ign_com_enable', 0)); |
|
71
|
|
|
$this->config->set('dark1_rsi_time', strtotime($this->request->variable('dark1_rsi_time', '0', true))); |
|
72
|
|
|
$this->config->set('dark1_rsi_interval', $this->request->variable('dark1_rsi_interval', 0) * 86400); |
|
73
|
|
|
|
|
74
|
|
|
$unq_com_words = explode("\n", $this->request->variable('dark1_rsi_ign_com_words', '', true)); |
|
75
|
|
|
$unq_com_words = array_unique(array_map('strtolower', $unq_com_words)); |
|
76
|
|
|
natsort($unq_com_words); |
|
77
|
|
|
$this->config_text->set('dark1_rsi_ign_com_words', implode("\n", $unq_com_words)); |
|
78
|
|
|
|
|
79
|
|
|
$this->success_form_on_submit(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
// Set output variables for display in the template |
|
83
|
|
|
$this->template->assign_vars([ |
|
84
|
|
|
'RSI_ENABLE' => $this->config['dark1_rsi_enable'], |
|
85
|
|
|
'RSI_IGN_COM_ENABLE' => $this->config['dark1_rsi_ign_com_enable'], |
|
86
|
|
|
'RSI_INTERVAL' => $this->config['dark1_rsi_interval'] / 86400, |
|
87
|
|
|
'RSI_TIME' => $this->user->format_date($this->config['dark1_rsi_time'], consts::TIME_FORMAT, true), |
|
88
|
|
|
'RSI_CURR_TIME' => $this->user->format_date(time(), consts::TIME_FORMAT, true), |
|
89
|
|
|
'RSI_IGN_COM_WORDS' => $this->config_text->get('dark1_rsi_ign_com_words'), |
|
90
|
|
|
]); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|