|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Allows for the modifying of the forum layout settings. |
|
5
|
|
|
* |
|
6
|
|
|
* @package ElkArte Forum |
|
7
|
|
|
* @copyright ElkArte Forum contributors |
|
8
|
|
|
* @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file) |
|
9
|
|
|
* |
|
10
|
|
|
* This file contains code covered by: |
|
11
|
|
|
* copyright: 2011 Simple Machines (http://www.simplemachines.org) |
|
12
|
|
|
* |
|
13
|
|
|
* @version 2.0 Beta 1 |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace ElkArte\AdminController; |
|
17
|
|
|
|
|
18
|
|
|
use ElkArte\AbstractController; |
|
19
|
|
|
use ElkArte\Action; |
|
20
|
|
|
use ElkArte\Languages\Txt; |
|
21
|
|
|
use ElkArte\SettingsForm\SettingsForm; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Layout administration controller. |
|
25
|
|
|
* This class allows modifying admin layout settings for the forum. |
|
26
|
|
|
*/ |
|
27
|
|
|
class ManageLayout extends AbstractController |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Pre-dispatch, called before other methods. |
|
31
|
|
|
*/ |
|
32
|
|
|
public function pre_dispatch() |
|
33
|
|
|
{ |
|
34
|
|
|
// We need this in a few places, so it's easier to have it loaded here |
|
35
|
|
|
require_once(SUBSDIR . '/ManageFeatures.subs.php'); |
|
36
|
|
|
|
|
37
|
|
|
Txt::load('Help+ManageSettings'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* This function passes control through to the relevant tab. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function action_index() |
|
44
|
|
|
{ |
|
45
|
|
|
$subActions = [ |
|
46
|
|
|
'layout' => [$this, 'action_layoutSettings_display', 'permission' => 'admin_forum'], |
|
47
|
|
|
]; |
|
48
|
|
|
|
|
49
|
|
|
// Set up the action control |
|
50
|
|
|
$action = new Action('modify_layout'); |
|
51
|
|
|
|
|
52
|
|
|
// By default, do the layout settings |
|
53
|
|
|
$subAction = $action->initialize($subActions, 'layout'); |
|
54
|
|
|
|
|
55
|
|
|
// Call the right function for this sub-action. |
|
56
|
|
|
$action->dispatch($subAction); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Allows modifying the global layout settings in the forum |
|
61
|
|
|
* |
|
62
|
|
|
* - Accessed through ?action=admin;area=featuresettings;sa=layout; |
|
63
|
|
|
* |
|
64
|
|
|
* @event integrate_save_layout_settings |
|
65
|
|
|
*/ |
|
66
|
|
|
public function action_layoutSettings_display(): void |
|
67
|
|
|
{ |
|
68
|
|
|
global $txt, $context, $modSettings; |
|
69
|
|
|
|
|
70
|
|
|
// Initialize the form |
|
71
|
|
|
$settingsForm = new SettingsForm(SettingsForm::DB_ADAPTER); |
|
72
|
|
|
|
|
73
|
|
|
// Initialize it with our settings |
|
74
|
|
|
$settingsForm->setConfigVars($this->_layoutSettings()); |
|
75
|
|
|
|
|
76
|
|
|
// Saving? |
|
77
|
|
|
if ($this->_req->hasQuery('save')) |
|
78
|
|
|
{ |
|
79
|
|
|
// Setting a custom frontpage, set the hook to the FrontpageInterface of the controller |
|
80
|
|
|
if (!empty($this->_req->post->front_page)) |
|
81
|
|
|
{ |
|
82
|
|
|
// Addons may have left this blank |
|
83
|
|
|
$modSettings['front_page'] = empty($modSettings['front_page']) ? 'MessageIndex_Controller' : $modSettings['front_page']; |
|
84
|
|
|
|
|
85
|
|
|
$front_page = (string) $this->_req->getPost('front_page', 'trim', ''); |
|
86
|
|
|
if ( |
|
87
|
|
|
class_exists($modSettings['front_page']) |
|
88
|
|
|
&& in_array('validateFrontPageOptions', get_class_methods($modSettings['front_page'])) |
|
89
|
|
|
&& !$front_page::validateFrontPageOptions($this->_req->post) |
|
90
|
|
|
) |
|
91
|
|
|
{ |
|
92
|
|
|
$this->_req->post->front_page = ''; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
checkSession(); |
|
97
|
|
|
|
|
98
|
|
|
call_integration_hook('integrate_save_layout_settings'); |
|
99
|
|
|
|
|
100
|
|
|
$settingsForm->setConfigValues((array) $this->_req->post); |
|
101
|
|
|
$settingsForm->save(); |
|
102
|
|
|
writeLog(); |
|
103
|
|
|
|
|
104
|
|
|
redirectexit('action=admin;area=featuresettings;sa=layout'); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$context['post_url'] = getUrl('admin', ['action' => 'admin', 'area' => 'featuresettings', 'sa' => 'layout', 'save']); |
|
108
|
|
|
$context['settings_title'] = $txt['mods_cat_layout']; |
|
109
|
|
|
$context['sub_template'] = 'show_settings'; |
|
110
|
|
|
$context['page_title'] = $txt['modSettings_title']; |
|
111
|
|
|
|
|
112
|
|
|
$settingsForm->prepare(); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Return layout settings. |
|
117
|
|
|
* |
|
118
|
|
|
* @event integrate_modify_layout_settings Adds options to Configuration->Layout |
|
119
|
|
|
*/ |
|
120
|
|
|
private function _layoutSettings() |
|
121
|
|
|
{ |
|
122
|
|
|
global $txt; |
|
123
|
|
|
|
|
124
|
|
|
$config_vars = array_merge(getFrontPageControllers(), [ |
|
125
|
|
|
'', |
|
126
|
|
|
// Pagination stuff. |
|
127
|
|
|
['check', 'compactTopicPagesEnable'], |
|
128
|
|
|
['int', 'compactTopicPagesContiguous', 'subtext' => str_replace(' ', ' ', '"3" ' . $txt['to_display'] . ': <strong>1 ... 4 [5] 6 ... 9</strong>') . '<br />' . str_replace(' ', ' ', '"5" ' . $txt['to_display'] . ': <strong>1 ... 3 4 [5] 6 7 ... 9</strong>')], |
|
129
|
|
|
['int', 'defaultMaxMembers'], |
|
130
|
|
|
['check', 'displayMemberNames'], |
|
131
|
|
|
'', |
|
132
|
|
|
// Stuff that just is everywhere - today, search, online, etc. |
|
133
|
|
|
['select', 'todayMod', [$txt['today_disabled'], $txt['today_only'], $txt['yesterday_today'], $txt['relative_time']]], |
|
134
|
|
|
['check', 'onlineEnable'], |
|
135
|
|
|
['check', 'enableVBStyleLogin'], |
|
136
|
|
|
'', |
|
137
|
|
|
// Automagic image resizing. |
|
138
|
|
|
['int', 'max_image_width', 'subtext' => $txt['zero_for_no_limit']], |
|
139
|
|
|
['int', 'max_image_height', 'subtext' => $txt['zero_for_no_limit']], |
|
140
|
|
|
'', |
|
141
|
|
|
// This is like debugging sorta. |
|
142
|
|
|
['check', 'timeLoadPageEnable'], |
|
143
|
|
|
]); |
|
144
|
|
|
|
|
145
|
|
|
call_integration_hook('integrate_modify_layout_settings', [&$config_vars]); |
|
146
|
|
|
|
|
147
|
|
|
return $config_vars; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Public method to return the layout settings, used for admin search |
|
152
|
|
|
*/ |
|
153
|
|
|
public function layoutSettings_search() |
|
154
|
|
|
{ |
|
155
|
|
|
return $this->_layoutSettings(); |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|