|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package Board3 Portal v2.1 |
|
5
|
|
|
* @copyright (c) 2013 Board3 Group ( www.board3.de ) |
|
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace board3\portal\modules; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @package Stylechanger |
|
14
|
|
|
*/ |
|
15
|
|
|
class stylechanger extends module_base |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Allowed columns: Just sum up your options (Exp: left + right = 10) |
|
19
|
|
|
* top 1 |
|
20
|
|
|
* left 2 |
|
21
|
|
|
* center 4 |
|
22
|
|
|
* right 8 |
|
23
|
|
|
* bottom 16 |
|
24
|
|
|
*/ |
|
25
|
|
|
public $columns = 10; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Default modulename |
|
29
|
|
|
*/ |
|
30
|
|
|
public $name = 'BOARD_STYLE'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Default module-image: |
|
34
|
|
|
* file must be in "{T_THEME_PATH}/images/portal/" |
|
35
|
|
|
*/ |
|
36
|
|
|
public $image_src = 'portal_style.png'; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* module-language file |
|
40
|
|
|
* file must be in "language/{$user->lang}/mods/portal/" |
|
41
|
|
|
*/ |
|
42
|
|
|
public $language = 'portal_stylechanger_module'; |
|
43
|
|
|
|
|
44
|
|
|
/** @var \phpbb\config\config */ |
|
45
|
|
|
protected $config; |
|
46
|
|
|
|
|
47
|
|
|
/** @var \board3\portal\includes\modules_helper */ |
|
48
|
|
|
protected $modules_helper; |
|
49
|
|
|
|
|
50
|
|
|
/** @var \phpbb\template\template */ |
|
51
|
|
|
protected $template; |
|
52
|
|
|
|
|
53
|
|
|
/** @var \phpbb\db\driver\driver_interface */ |
|
54
|
|
|
protected $db; |
|
55
|
|
|
|
|
56
|
|
|
/** @var \phpbb\request\request_interface */ |
|
57
|
|
|
protected $request; |
|
58
|
|
|
|
|
59
|
|
|
/** @var \phpbb\user */ |
|
60
|
|
|
protected $user; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Construct a stylechanger object |
|
64
|
|
|
* |
|
65
|
|
|
* @param \phpbb\config\config $config phpBB config |
|
66
|
|
|
* @param \board3\portal\includes\modules_helper $modules_helper Modules helper |
|
67
|
|
|
* @param \phpbb\template\template $template phpBB template |
|
68
|
|
|
* @param \phpbb\db\driver\driver_interface $db Database driver |
|
69
|
|
|
* @param \phpbb\request\request_interface $request phpBB request |
|
70
|
|
|
* @param \phpbb\user $user phpBB user object |
|
71
|
|
|
*/ |
|
72
|
|
View Code Duplication |
public function __construct($config, $modules_helper, $template, $db, $request, $user) |
|
73
|
|
|
{ |
|
74
|
|
|
$this->config = $config; |
|
75
|
|
|
$this->modules_helper = $modules_helper; |
|
76
|
|
|
$this->template = $template; |
|
77
|
|
|
$this->db = $db; |
|
78
|
|
|
$this->request = $request; |
|
79
|
|
|
$this->user = $user; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* {@inheritdoc} |
|
84
|
|
|
*/ |
|
85
|
|
|
public function get_template_side($module_id) |
|
86
|
|
|
{ |
|
87
|
|
|
$style_count = 0; |
|
88
|
|
|
$style_select = ''; |
|
89
|
|
|
$sql = 'SELECT style_id, style_name |
|
90
|
|
|
FROM ' . STYLES_TABLE . ' |
|
91
|
|
|
WHERE style_active = 1 |
|
92
|
|
|
ORDER BY LOWER(style_name) ASC'; |
|
93
|
|
|
$result = $this->db->sql_query($sql, 3600); |
|
94
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
|
95
|
|
|
{ |
|
96
|
|
|
$style = $this->request->variable('style', 0); |
|
97
|
|
|
if (!empty($style)) |
|
98
|
|
|
{ |
|
99
|
|
|
$url = str_replace('style=' . $style, 'style=' . $row['style_id'], $this->modules_helper->route('board3_portal_controller')); |
|
100
|
|
|
} |
|
101
|
|
|
else |
|
102
|
|
|
{ |
|
103
|
|
|
$url = $this->modules_helper->route('board3_portal_controller') . '?style=' . $row['style_id']; |
|
104
|
|
|
} |
|
105
|
|
|
++$style_count; |
|
106
|
|
|
$style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $this->user->style['style_id'] ? ' selected="selected"' : '') . '>' . utf8_htmlspecialchars($row['style_name']) . '</option>'; |
|
107
|
|
|
} |
|
108
|
|
|
$this->db->sql_freeresult($result); |
|
109
|
|
|
if (strlen($style_select)) |
|
110
|
|
|
{ |
|
111
|
|
|
$this->template->assign_var('STYLE_SELECT', $style_select); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
// Assign specific vars |
|
115
|
|
|
$this->template->assign_vars(array( |
|
116
|
|
|
'S_STYLE_OPTIONS' => ($this->config['override_user_style'] || $style_count < 2) ? '' : $style_select, |
|
117
|
|
|
)); |
|
118
|
|
|
|
|
119
|
|
|
return 'stylechanger_side.html'; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* {@inheritdoc} |
|
124
|
|
|
*/ |
|
125
|
|
|
public function get_template_acp($module_id) |
|
126
|
|
|
{ |
|
127
|
|
|
return array( |
|
128
|
|
|
'title' => 'BOARD_STYLE', |
|
129
|
|
|
'vars' => array(), |
|
130
|
|
|
); |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|