1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
3
|
|
|
/** |
4
|
|
|
* Holds the PhpMyAdmin\Controllers\TransformationOverviewController |
5
|
|
|
* |
6
|
|
|
* @package PhpMyAdmin\Controllers |
7
|
|
|
*/ |
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace PhpMyAdmin\Controllers; |
11
|
|
|
|
12
|
|
|
use PhpMyAdmin\DatabaseInterface; |
13
|
|
|
use PhpMyAdmin\Response; |
14
|
|
|
use PhpMyAdmin\Transformations; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Lists available transformation plugins |
18
|
|
|
* |
19
|
|
|
* @package PhpMyAdmin\Controllers |
20
|
|
|
*/ |
21
|
|
|
class TransformationOverviewController extends Controller |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var Transformations |
25
|
|
|
*/ |
26
|
|
|
private $transformations; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* TransformationOverviewController constructor. |
30
|
|
|
* |
31
|
|
|
* @param Response $response Response object |
32
|
|
|
* @param DatabaseInterface $dbi DatabaseInterface object |
33
|
|
|
* @param Transformations $transformations Transformations object |
34
|
|
|
*/ |
35
|
|
|
public function __construct($response, $dbi, $transformations) |
36
|
|
|
{ |
37
|
|
|
parent::__construct($response, $dbi); |
38
|
|
|
|
39
|
|
|
$this->transformations = $transformations; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return string HTML |
44
|
|
|
*/ |
45
|
|
|
public function indexAction(): string |
46
|
|
|
{ |
47
|
|
|
$types = $this->transformations->getAvailableMimeTypes(); |
48
|
|
|
|
49
|
|
|
$mimeTypes = []; |
50
|
|
|
foreach ($types['mimetype'] as $mimeType) { |
51
|
|
|
$mimeTypes[] = [ |
52
|
|
|
'name' => $mimeType, |
53
|
|
|
'is_empty' => isset($types['empty_mimetype'][$mimeType]), |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$transformations = [ |
58
|
|
|
'transformation' => [], |
59
|
|
|
'input_transformation' => [], |
60
|
|
|
]; |
61
|
|
|
|
62
|
|
|
foreach (array_keys($transformations) as $type) { |
63
|
|
|
foreach ($types[$type] as $key => $transformation) { |
64
|
|
|
$transformations[$type][] = [ |
65
|
|
|
'name' => $transformation, |
66
|
|
|
'description' => $this->transformations->getDescription( |
67
|
|
|
$types[$type . '_file'][$key] |
68
|
|
|
), |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
return $this->template->render('transformation_overview', [ |
74
|
|
|
'mime_types' => $mimeTypes, |
75
|
|
|
'transformations' => $transformations, |
76
|
|
|
]); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|