1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package sitemaker |
5
|
|
|
* @copyright (c) 2013 Daniel A. (blitze) |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace blitze\sitemaker\acp; |
11
|
|
|
|
12
|
|
|
use blitze\sitemaker\services\menus\nestedset; |
13
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @package acp |
17
|
|
|
*/ |
18
|
|
|
class menu_module |
19
|
|
|
{ |
20
|
|
|
/** @var \phpbb\controller\helper */ |
|
|
|
|
21
|
|
|
protected $controller_helper; |
22
|
|
|
|
23
|
|
|
/** @var \phpbb\event\dispatcher_interface */ |
|
|
|
|
24
|
|
|
protected $phpbb_dispatcher; |
25
|
|
|
|
26
|
|
|
/** @var \phpbb\request\request_interface */ |
|
|
|
|
27
|
|
|
protected $request; |
28
|
|
|
|
29
|
|
|
/** @var \phpbb\template\template */ |
|
|
|
|
30
|
|
|
protected $template; |
31
|
|
|
|
32
|
|
|
/** @var \blitze\sitemaker\services\icon_picker */ |
33
|
|
|
protected $icon; |
34
|
|
|
|
35
|
|
|
/** @var \phpbb\language\language */ |
|
|
|
|
36
|
|
|
protected $language; |
37
|
|
|
|
38
|
|
|
/** @var \blitze\sitemaker\model\mapper_factory */ |
39
|
|
|
protected $mapper_factory; |
40
|
|
|
|
41
|
|
|
/** @var \blitze\sitemaker\services\util */ |
42
|
|
|
protected $util; |
43
|
|
|
|
44
|
|
|
/** @var string phpBB root path */ |
45
|
|
|
protected $phpbb_root_path; |
46
|
|
|
|
47
|
|
|
/** @var string phpEx */ |
48
|
|
|
protected $php_ext; |
49
|
|
|
|
50
|
|
|
/** @var string */ |
51
|
|
|
public $tpl_name; |
52
|
|
|
|
53
|
|
|
/** @var string */ |
54
|
|
|
public $page_title; |
55
|
|
|
|
56
|
|
|
/** @var string */ |
57
|
|
|
public $u_action; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* menu_module constructor. |
61
|
|
|
*/ |
62
|
2 |
|
public function __construct() |
63
|
|
|
{ |
64
|
2 |
|
global $phpbb_container, $phpbb_dispatcher, $request, $template, $user, $phpbb_root_path, $phpEx; |
65
|
|
|
|
66
|
2 |
|
$this->phpbb_dispatcher = $phpbb_dispatcher; |
67
|
2 |
|
$this->request = $request; |
68
|
2 |
|
$this->template = $template; |
69
|
2 |
|
$this->phpbb_root_path = $phpbb_root_path; |
70
|
2 |
|
$this->php_ext = $phpEx; |
71
|
|
|
|
72
|
2 |
|
$this->controller_helper = $phpbb_container->get('controller.helper'); |
73
|
2 |
|
$this->language = $phpbb_container->get('language'); |
74
|
2 |
|
$this->mapper_factory = $phpbb_container->get('blitze.sitemaker.mapper.factory'); |
75
|
2 |
|
$this->icon = $phpbb_container->get('blitze.sitemaker.icon_picker'); |
76
|
2 |
|
$this->util = $phpbb_container->get('blitze.sitemaker.util'); |
77
|
2 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return void |
81
|
|
|
*/ |
82
|
2 |
|
public function main() |
83
|
|
|
{ |
84
|
2 |
|
$menu_id = $this->request->variable('menu_id', 0); |
85
|
|
|
|
86
|
2 |
|
nestedset::load_scripts($this->util); |
87
|
2 |
|
$this->util->add_assets(array( |
88
|
2 |
|
'js' => array('@blitze_sitemaker/assets/menu/admin.min.js'), |
89
|
2 |
|
'css' => array('@blitze_sitemaker/assets/menu/admin.min.css') |
90
|
2 |
|
)); |
91
|
|
|
|
92
|
2 |
|
$this->list_menus($menu_id); |
93
|
2 |
|
$this->build_bulk_options(); |
94
|
|
|
|
95
|
2 |
|
$this->template->assign_vars(array( |
96
|
2 |
|
'S_MENU' => true, |
97
|
2 |
|
'MENU_ID' => $menu_id, |
98
|
2 |
|
'ICON_PICKER' => $this->icon->picker(), |
99
|
2 |
|
'T_PATH' => $this->phpbb_root_path, |
100
|
2 |
|
'UA_AJAX_URL' => $this->controller_helper->route('blitze_sitemaker_menus_admin', array(), true, '') . '/', |
101
|
2 |
|
)); |
102
|
|
|
|
103
|
2 |
|
$this->tpl_name = 'acp_menu'; |
104
|
2 |
|
$this->page_title = 'ACP_MENU'; |
105
|
2 |
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param int $menu_id |
109
|
|
|
* @return void |
110
|
|
|
*/ |
111
|
2 |
|
protected function list_menus(&$menu_id) |
112
|
|
|
{ |
113
|
2 |
|
$menu_mapper = $this->mapper_factory->create('menus'); |
114
|
|
|
|
115
|
|
|
// Get all menus |
116
|
2 |
|
$collection = $menu_mapper->find(); |
117
|
|
|
|
118
|
2 |
|
if ($collection->valid()) |
119
|
2 |
|
{ |
120
|
2 |
|
$menu = (isset($collection[$menu_id])) ? $collection[$menu_id] : $collection->current(); |
121
|
2 |
|
$menu_id = $menu->get_menu_id(); |
|
|
|
|
122
|
|
|
|
123
|
2 |
|
foreach ($collection as $entity) |
124
|
|
|
{ |
125
|
2 |
|
$id = $entity->get_menu_id(); |
126
|
2 |
|
$this->template->assign_block_vars('menu', array( |
127
|
2 |
|
'ID' => $id, |
128
|
2 |
|
'NAME' => $entity->get_menu_name(), |
129
|
2 |
|
'S_ACTIVE' => ($id == $menu_id) ? true : false, |
130
|
2 |
|
)); |
131
|
2 |
|
} |
132
|
2 |
|
} |
133
|
2 |
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return void |
137
|
|
|
*/ |
138
|
2 |
|
protected function build_bulk_options() |
139
|
|
|
{ |
140
|
2 |
|
$bulk_options = array(); |
141
|
2 |
|
$forumslist = make_forum_select(false, false, true, false, false, false, true); |
|
|
|
|
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Event to add bulk menu options |
145
|
|
|
* |
146
|
|
|
* @event blitze.sitemaker.acp_add_bulk_menu_options |
147
|
|
|
* @var array bulk_options Array of bulk menu options |
148
|
|
|
* @var array forumslist Array of phpBB forums |
149
|
|
|
* @since 3.1.0 |
150
|
|
|
*/ |
151
|
2 |
|
$vars = array('bulk_options', 'forumslist'); |
152
|
2 |
|
extract($this->phpbb_dispatcher->trigger_event('blitze.sitemaker.acp_add_bulk_menu_options', compact($vars))); |
153
|
|
|
|
154
|
2 |
|
$bulk_options['FORUMS'] = $this->get_forums_string($forumslist); |
155
|
|
|
|
156
|
2 |
|
$this->template->assign_var('bulk_options', $bulk_options); |
157
|
2 |
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param array $forumslist |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
2 |
|
protected function get_forums_string(array $forumslist) |
164
|
|
|
{ |
165
|
2 |
|
$forum_url = $this->controller_helper->route('blitze_sitemaker_forum', array(), true, '', UrlGeneratorInterface::RELATIVE_PATH); |
166
|
2 |
|
$text = $this->language->lang('FORUM') . '|' . $forum_url . "\n"; |
167
|
2 |
|
foreach ($forumslist as $forum_id => $row) |
168
|
|
|
{ |
169
|
2 |
|
$text .= "\t" . str_replace(' ', "\t", $row['padding']); |
170
|
2 |
|
$text .= $row['forum_name'] . '|'; |
171
|
2 |
|
$text .= "viewforum.{$this->php_ext}?f=$forum_id\n"; |
172
|
2 |
|
} |
173
|
|
|
|
174
|
2 |
|
return trim($text); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
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