|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package sitemaker |
|
5
|
|
|
* @copyright (c) 2020 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\controller; |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
13
|
|
|
|
|
14
|
|
|
class navbar |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var \phpbb\auth\auth */ |
|
17
|
|
|
protected $auth; |
|
18
|
|
|
|
|
19
|
|
|
/** @var \phpbb\config\config */ |
|
20
|
|
|
protected $config; |
|
21
|
|
|
|
|
22
|
|
|
/** @var \phpbb\config\db_text */ |
|
23
|
|
|
protected $config_text; |
|
24
|
|
|
|
|
25
|
|
|
/** @var \phpbb\request\request_interface */ |
|
26
|
|
|
protected $request; |
|
27
|
|
|
|
|
28
|
|
|
/* @var symfony_request */ |
|
|
|
|
|
|
29
|
|
|
protected $symfony_request; |
|
30
|
|
|
|
|
31
|
|
|
/** @var \phpbb\language\language */ |
|
32
|
|
|
protected $translator; |
|
33
|
|
|
|
|
34
|
|
|
/** @var \phpbb\user */ |
|
35
|
|
|
protected $user; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Constructor |
|
39
|
|
|
* |
|
40
|
|
|
* @param \phpbb\auth\auth $auth Auth object |
|
41
|
|
|
* @param \phpbb\config\config $config Config object |
|
42
|
|
|
* @param \phpbb\config\db_text $config_text Config text object |
|
43
|
|
|
* @param \phpbb\request\request_interface $request Request object |
|
44
|
|
|
* @param \phpbb\symfony_request $symfony_request Symfony Request object |
|
45
|
|
|
* @param \phpbb\language\language $translator Language object |
|
46
|
|
|
* @param \phpbb\user $user User object |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\request\request_interface $request, \phpbb\symfony_request $symfony_request, \phpbb\language\language $translator, \phpbb\user $user) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->auth = $auth; |
|
51
|
|
|
$this->config = $config; |
|
52
|
|
|
$this->config_text = $config_text; |
|
53
|
|
|
$this->request = $request; |
|
54
|
|
|
$this->symfony_request = $symfony_request; |
|
|
|
|
|
|
55
|
|
|
$this->translator = $translator; |
|
56
|
|
|
$this->user = $user; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
61
|
|
|
*/ |
|
62
|
|
|
public function css($style) |
|
63
|
|
|
{ |
|
64
|
|
|
$css = html_entity_decode($this->config_text->get('sitemaker_navbar_' . $style)); |
|
65
|
|
|
|
|
66
|
|
|
$response = new Response($css); |
|
67
|
|
|
$response->headers->set('Content-Type', 'text/css'); |
|
68
|
|
|
|
|
69
|
|
|
$response->setPublic(); |
|
70
|
|
|
$response->setSharedMaxAge(3600); |
|
71
|
|
|
$response->setETag(md5($response->getContent())); |
|
72
|
|
|
$response->setLastModified(new \DateTime($this->config['sitemaker_nav_last_modified'])); |
|
73
|
|
|
|
|
74
|
|
|
if ($response->isNotModified($this->symfony_request)) |
|
75
|
|
|
{ |
|
76
|
|
|
return $response; |
|
77
|
|
|
}; |
|
78
|
|
|
|
|
79
|
|
|
return $response; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
84
|
|
|
*/ |
|
85
|
|
|
public function save($style) |
|
86
|
|
|
{ |
|
87
|
|
|
$data = array('message' => ''); |
|
88
|
|
|
|
|
89
|
|
|
if (!$this->request->is_ajax() || !$this->auth->acl_get('a_sm_manage_blocks')) |
|
90
|
|
|
{ |
|
91
|
|
|
$data['message'] = $this->translator->lang('NOT_AUTHORISED'); |
|
92
|
|
|
$status = 401; |
|
93
|
|
|
} |
|
94
|
|
|
else |
|
95
|
|
|
{ |
|
96
|
|
|
$css = $this->request->variable('css', ''); |
|
97
|
|
|
$location = $this->request->variable('location', ''); |
|
98
|
|
|
|
|
99
|
|
|
$locations = (array) json_decode($this->config['sitemaker_nav_locations'], true); |
|
100
|
|
|
|
|
101
|
|
|
$this->config_text->set('sitemaker_navbar_' . $style, $css); |
|
102
|
|
|
|
|
103
|
|
|
$this->config->set('sitemaker_nav_last_modified', new \phpbb\datetime($this->user)); |
|
104
|
|
|
$this->config->set('sitemaker_nav_locations', json_encode(array_filter(array_merge($locations, [$style => $location])))); |
|
105
|
|
|
|
|
106
|
|
|
$data['message'] = ''; |
|
107
|
|
|
$data['location'] = $locations[$style] ?? ''; |
|
108
|
|
|
$status = 200; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$response = new Response(json_encode($data), $status); |
|
112
|
|
|
$response->headers->set('Content-Type', 'application/json'); |
|
113
|
|
|
|
|
114
|
|
|
return $response; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
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