Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/files/iconset/PhabricatorIconSet.php
12241 views
1
<?php
2
3
abstract class PhabricatorIconSet
4
extends Phobject {
5
6
final public function getIconSetKey() {
7
return $this->getPhobjectClassConstant('ICONSETKEY');
8
}
9
10
public function getChooseButtonText() {
11
return pht('Choose Icon...');
12
}
13
14
public function getSelectIconTitleText() {
15
return pht('Choose Icon');
16
}
17
18
public function getSelectURI() {
19
$key = $this->getIconSetKey();
20
return "/file/iconset/{$key}/select/";
21
}
22
23
final public function getIcons() {
24
$icons = $this->newIcons();
25
26
// TODO: Validate icons.
27
$icons = mpull($icons, null, 'getKey');
28
29
return $icons;
30
}
31
32
final public function getIcon($key) {
33
$icons = $this->getIcons();
34
return idx($icons, $key);
35
}
36
37
final public function getIconLabel($key) {
38
$icon = $this->getIcon($key);
39
40
if ($icon) {
41
return $icon->getLabel();
42
}
43
44
return $key;
45
}
46
47
final public function renderIconForControl(PhabricatorIconSetIcon $icon) {
48
return phutil_tag(
49
'span',
50
array(),
51
array(
52
id(new PHUIIconView())->setIcon($icon->getIcon()),
53
' ',
54
$icon->getLabel(),
55
));
56
}
57
58
final public static function getIconSetByKey($key) {
59
$sets = self::getAllIconSets();
60
return idx($sets, $key);
61
}
62
63
final public static function getAllIconSets() {
64
return id(new PhutilClassMapQuery())
65
->setAncestorClass(__CLASS__)
66
->setUniqueMethod('getIconSetKey')
67
->execute();
68
}
69
70
}
71
72