-
Notifications
You must be signed in to change notification settings - Fork 4
/
Plugin.php
88 lines (74 loc) · 2.29 KB
/
Plugin.php
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
<?php namespace Chkilel\Icones;
use ApplicationException;
use Backend;
use System\Classes\PluginBase;
use Chkilel\Icones\Classes\JsonIcon;
use Chkilel\Icones\FormWidgets\IconesFinder;
use Chkilel\Icones\Models\Settings;
class Plugin extends PluginBase
{
public function registerComponents()
{
}
public function registerSettings()
{
return [
'settings' => [
'label' => 'chkilel.icones::lang.settings.label',
'description' => 'chkilel.icones::lang.settings.description',
'icon' => 'icon-bomb',
'url' => Backend::url('chkilel/icones/settings'),
'category' => 'system::lang.system.categories.cms',
'order' => 500,
'permissions' => ['chkilel.icones.access_settings'],
'keywords' => 'svg icones icon iconify'
],
];
}
public function registerFormWidgets()
{
return [
IconesFinder::class => 'iconesfinder'
];
}
public function registerMarkupTags()
{
return [
'filters' => [
'iconify' => [$this, 'iconify']
],
];
}
public function registerListColumnTypes()
{
return [
'iconesthumb' => [$this, 'iconThumbListColumn'],
];
}
/**
* @param $value the Array value on which the filter is applied
* @param $props associative array with the folowing possible keys (see REEDME.md):
* 'class','width', 'height', 'inline', 'hFlip', 'vFlip', 'flip', 'rotate', 'align', 'color', 'box'
* @return string SVG icon
* @throws ApplicationException
*/
public function iconify($iconArray, $props = [])
{
$icon = new JsonIcon($iconArray);
return $icon->iconify($props);
}
/**
* @param $value the Array representation of the icon
* @param $column column definition object
* @param $record model record object.
* @return string SVG icon
* @throws ApplicationException
*/
public function iconThumbListColumn($value, $column, $record)
{
$props = ['inline' => true];
$props['height'] = $column->config['height'] ?? 24;
$icon = new JsonIcon($value);
return $icon->iconify($props);
}
}