1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Library more info view file. |
5
|
|
|
* |
6
|
|
|
* @package View |
7
|
|
|
* |
8
|
|
|
* @copyright YetiForce Sp. z o.o |
9
|
|
|
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) |
10
|
|
|
* @author Arkadiusz Sołek <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace YF\Modules\YetiForce\View; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Library more info view class. |
17
|
|
|
*/ |
18
|
|
|
class LibraryMoreInfo extends \App\Controller\Modal |
19
|
|
|
{ |
20
|
|
|
/** @var array Public libraries package files. */ |
21
|
|
|
public $packageFiles = ['package.json', 'composer.json', 'bower.json']; |
22
|
|
|
|
23
|
|
|
/** {@inheritdoc} */ |
24
|
|
|
public function checkPermission(): bool |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
return true; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** {@inheritdoc} */ |
30
|
|
|
public function getTitle(): string |
31
|
|
|
{ |
32
|
|
|
return \App\Language::translate('LBL_MORE_LIBRARY_INFO', $this->moduleName); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** {@inheritdoc} */ |
36
|
|
|
public function validateRequest(): void |
37
|
|
|
{ |
38
|
|
|
$this->request->validateWriteAccess(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** {@inheritdoc} */ |
42
|
|
|
public function process(): void |
43
|
|
|
{ |
44
|
|
|
$result = false; |
45
|
|
|
$fileContent = ''; |
46
|
|
|
if ($this->request->isEmpty('type') || $this->request->isEmpty('libraryName')) { |
47
|
|
|
$result = false; |
48
|
|
|
} else { |
49
|
|
|
if ('public' === $this->request->get('type')) { |
50
|
|
|
$dir = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'public_html' . \DIRECTORY_SEPARATOR . 'libraries' . \DIRECTORY_SEPARATOR; |
51
|
|
|
$libraryName = $this->request->get('libraryName'); |
52
|
|
|
foreach ($this->packageFiles as $file) { |
53
|
|
|
$packageFile = $dir . $libraryName . \DIRECTORY_SEPARATOR . $file; |
54
|
|
|
if ($fileContent) { |
55
|
|
|
continue; |
56
|
|
|
} |
57
|
|
View Code Duplication |
if (file_exists($packageFile)) { |
|
|
|
|
58
|
|
|
$fileContent = file_get_contents($packageFile); |
59
|
|
|
$result = true; |
60
|
|
|
} else { |
61
|
|
|
$result = false; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} elseif ('vendor' === $this->request->get('type')) { |
65
|
|
|
$filePath = 'vendor' . \DIRECTORY_SEPARATOR . $this->request->get('libraryName') . \DIRECTORY_SEPARATOR . 'composer.json'; |
66
|
|
|
|
67
|
|
View Code Duplication |
if (file_exists($filePath)) { |
|
|
|
|
68
|
|
|
$fileContent = file_get_contents($filePath); |
69
|
|
|
$result = true; |
70
|
|
|
} else { |
71
|
|
|
$result = false; |
72
|
|
|
} |
73
|
|
|
} else { |
74
|
|
|
$result = false; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
$moduleName = $this->request->getModule(false); |
|
|
|
|
78
|
|
|
$this->viewer->assign('QUALIFIED_MODULE', $moduleName); |
79
|
|
|
$this->viewer->assign('RESULT', $result); |
80
|
|
|
$this->viewer->assign('FILE_CONTENT', $fileContent); |
81
|
|
|
$this->viewer->view('LibraryMoreInfo.tpl', $moduleName); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.