1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jidaikobo\Kontiki\Controllers\FileControllerTraits; |
4
|
|
|
|
5
|
|
|
use Psr\Http\Message\ResponseInterface as Response; |
6
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request; |
7
|
|
|
|
8
|
|
|
trait AssetTrait |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Serve the requested JavaScript file. |
12
|
|
|
* |
13
|
|
|
* @return Response |
14
|
|
|
*/ |
15
|
|
|
public function serveJs(Request $request, Response $response): Response |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
$content = $this->view->fetch( |
18
|
|
|
'js/kontiki-file.js.php', |
19
|
|
|
[ |
20
|
|
|
'basepath' => env('BASEPATH', '') |
21
|
|
|
] |
22
|
|
|
); |
23
|
|
|
$response->getBody()->write($content); |
24
|
|
|
return $response |
25
|
|
|
->withHeader('Content-Type', 'application/javascript; charset=utf-8') |
26
|
|
|
->withStatus(200); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Serve the requested JavaScript file. |
31
|
|
|
* |
32
|
|
|
* @return Response |
33
|
|
|
*/ |
34
|
|
|
public function serveIndexJs(Request $request, Response $response): Response |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
$content = $this->view->fetch( |
37
|
|
|
'js/kontiki-file-index.js.php', |
38
|
|
|
[ |
39
|
|
|
'get_file_list' => __('get_file_list'), |
40
|
|
|
'confirm_delete_message' => __('confirm_delete_message', 'The item will be permanently deleted. Are you sure you want to delete this item?'), |
41
|
|
|
'couldnt_find_file' => __('couldnt_find_file'), |
42
|
|
|
'couldnt_get_file_list' => __('couldnt_get_file_list'), |
43
|
|
|
'copied' => __('copied'), |
44
|
|
|
'copy_failed' => __('copy_failed'), |
45
|
|
|
'close' => __('close'), |
46
|
|
|
'edit' => __('edit'), |
47
|
|
|
'couldnt_delete_file' => __('couldnt_delete_file'), |
48
|
|
|
'insert_success' => __('insert_success'), |
49
|
|
|
] |
50
|
|
|
); |
51
|
|
|
$response->getBody()->write($content); |
52
|
|
|
|
53
|
|
|
return $response |
54
|
|
|
->withHeader('Content-Type', 'application/javascript; charset=utf-8') |
55
|
|
|
->withStatus(200); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Serve the requested JavaScript file. |
60
|
|
|
* |
61
|
|
|
* @return Response |
62
|
|
|
*/ |
63
|
|
|
public function serveCsrfJs(Request $request, Response $response): Response |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
$content = $this->view->fetch('js/kontiki-file-csrf.js.php'); |
66
|
|
|
$response->getBody()->write($content); |
67
|
|
|
return $response |
68
|
|
|
->withHeader('Content-Type', 'application/javascript; charset=utf-8') |
69
|
|
|
->withStatus(200); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Serve the requested JavaScript file. |
74
|
|
|
* |
75
|
|
|
* @return Response |
76
|
|
|
*/ |
77
|
|
|
public function serveLightboxJs(Request $request, Response $response): Response |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
$content = $this->view->fetch('js/kontiki-file-lightbox.js.php'); |
80
|
|
|
$response->getBody()->write($content); |
81
|
|
|
return $response |
82
|
|
|
->withHeader('Content-Type', 'application/javascript; charset=utf-8') |
83
|
|
|
->withStatus(200); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Serve the requested JavaScript file. |
88
|
|
|
* |
89
|
|
|
* @return Response |
90
|
|
|
*/ |
91
|
|
|
public function serveUtilsJs(Request $request, Response $response): Response |
|
|
|
|
92
|
|
|
{ |
93
|
|
|
$content = $this->view->fetch('js/kontiki-file-utils.js.php'); |
94
|
|
|
$response->getBody()->write($content); |
95
|
|
|
return $response |
96
|
|
|
->withHeader('Content-Type', 'application/javascript; charset=utf-8') |
97
|
|
|
->withStatus(200); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Serve the requested JavaScript file. |
102
|
|
|
* |
103
|
|
|
* @return Response |
104
|
|
|
*/ |
105
|
|
|
public function serveUploaderJs(Request $request, Response $response): Response |
|
|
|
|
106
|
|
|
{ |
107
|
|
|
$content = $this->view->fetch( |
108
|
|
|
'js/kontiki-file-uploader.js.php', |
109
|
|
|
[ |
110
|
|
|
'uploading' => __('uploading'), |
111
|
|
|
'couldnt_upload' => __('couldnt_upload', "Could not upload"), |
112
|
|
|
] |
113
|
|
|
); |
114
|
|
|
$response->getBody()->write($content); |
115
|
|
|
return $response |
116
|
|
|
->withHeader('Content-Type', 'application/javascript; charset=utf-8') |
117
|
|
|
->withStatus(200); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Serve the requested Css file. |
122
|
|
|
* |
123
|
|
|
* @return Response |
124
|
|
|
*/ |
125
|
|
|
public function serveCss(Request $request, Response $response): Response |
|
|
|
|
126
|
|
|
{ |
127
|
|
|
$content = $this->view->fetch('css/kontiki-file.css'); |
128
|
|
|
$response->getBody()->write($content); |
129
|
|
|
return $response->withHeader( |
130
|
|
|
'Content-Type', |
131
|
|
|
'text/css; charset=utf-8' |
132
|
|
|
)->withStatus(200); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.