This repository was archived by the owner on Aug 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.php
More file actions
133 lines (118 loc) · 4.09 KB
/
Copy pathPlugin.php
File metadata and controls
133 lines (118 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php namespace Bronx\Project;
use Backend\Facades\Backend;
use Bronx\Project\Components\CategoryListWidget;
use Bronx\Project\Components\Catalog;
use Bronx\Project\Components\ProjectListWidget;
use Bronx\Project\FormWidgets\AddressFinder;
use Bronx\Project\Models\Category;
use Bronx\Project\Models\Project;
use Bronx\Project\Models\Settings;
use Illuminate\Support\Facades\Event;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
'name' => 'Проекты',
'description' => '...',
'author' => 'Alexander Shapoval',
'icon' => 'icon-leaf',
];
}
public function register()
{
}
public function boot()
{
Event::listen('pages.menuitem.listTypes', function () {
return [
'projectCatalogCategory' => 'Проекты: категории',
'projectCatalogProject' => 'Проекты: проекты',
];
});
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
if ($type == 'projectCatalogCategory') {
return Category::getMenuTypeInfo($type);
} else if ($type == 'projectCatalogProject') {
return Project::getMenuTypeInfo($type);
}
});
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
if ($type == 'projectCatalogCategory') {
return Category::resolveMenuItem($item, $url, $theme);
} else if ($type == 'projectCatalogProject') {
return Project::resolveMenuItem($item, $url, $theme);
}
});
}
public function registerComponents()
{
return [
Catalog::class => 'bronxProjectCatalog',
CategoryListWidget::class => 'bronxProjectCategoryListWidget',
ProjectListWidget::class => 'bronxProjectProjectListWidget',
];
}
public function registerNavigation()
{
return [
'project' => [
'label' => 'Проекты',
'url' => Backend::url('bronx/project/projects'),
'icon' => 'icon-leaf',
'iconSvg' => 'plugins/bronx/project/assets/icon.svg',
'order' => 50,
'sideMenu' => [
'projects' => [
'label' => 'Проекты',
'url' => Backend::url('bronx/project/projects'),
'icon' => 'icon-leaf',
],
'categories' => [
'label' => 'Категории',
'url' => Backend::url('bronx/project/categories'),
'icon' => 'icon-leaf',
],
],
],
];
}
public function registerSettings()
{
return [
'settings' => [
'label' => 'Проекты',
'description' => 'Управление настройками проектов',
'category' => 'Bronx',
'icon' => 'icon-cog',
'class' => Settings::class,
'order' => 70,
],
];
}
public function registerFormWidgets()
{
return [
AddressFinder::class => [
'label' => 'Address Finder',
'code' => 'addressfinder',
],
];
}
public function registerMarkupTags()
{
return [
'filters' => [
'filesize' => function ($size) {
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$precision = 2;
$bytes = max($size, 0);
$pow = min(floor(($bytes ? log($bytes) : 0) / log(1024)), count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
},
],
];
}
}