3 final class PhabricatorFilesComposeIconBuiltinFile
4 extends PhabricatorFilesBuiltinFile
{
9 public function setIcon($icon) {
14 public function getIcon() {
18 public function setColor($color) {
19 $this->color
= $color;
23 public function getColor() {
27 public function getBuiltinFileKey() {
28 $icon = $this->getIcon();
29 $color = $this->getColor();
30 $desc = "compose(icon={$icon}, color={$color})";
31 $hash = PhabricatorHash
::digestToLength($desc, 40);
32 return "builtin:{$hash}";
35 public function getBuiltinDisplayName() {
36 $icon = $this->getIcon();
37 $color = $this->getColor();
38 return "{$icon}-{$color}.png";
41 public function loadBuiltinFileData() {
42 return $this->composeImage($this->getColor(), $this->getIcon());
45 public static function getAllIcons() {
46 $root = dirname(phutil_get_library_root('phabricator'));
47 $root = $root.'/resources/builtin/projects/';
49 $quips = self
::getIconQuips();
52 $list = Filesystem
::listDirectory($root, $include_hidden = false);
53 foreach ($list as $file) {
54 $short = preg_replace('/\.png$/', '', $file);
57 'path' => $root.$file,
58 'quip' => idx($quips, $short, $short),
65 public static function getAllColors() {
66 $colors = id(new CelerityResourceTransformer())
67 ->getCSSVariableMap();
69 $colors = array_select_keys(
85 $quips = self
::getColorQuips();
88 foreach ($colors as $name => $color) {
91 'quip' => idx($quips, $name, $name),
98 private function composeImage($color, $icon) {
99 $color_map = self
::getAllColors();
100 $color = idx($color_map, $color);
102 $fallback = 'backdrop';
103 $color = idx($color_map, $fallback);
107 'Fallback compose color ("%s") does not exist!',
112 $color_hex = idx($color, 'color');
113 $color_const = hexdec(trim($color_hex, '#'));
115 $icon_map = self
::getAllIcons();
116 $icon = idx($icon_map, $icon);
118 $fallback = 'fa-umbrella';
119 $icon = idx($icon_map, $fallback);
123 'Fallback compose icon ("%s") does not exist!',
128 $path = idx($icon, 'path');
129 $data = Filesystem
::readFile($path);
131 $icon_img = imagecreatefromstring($data);
133 $canvas = imagecreatetruecolor(200, 200);
134 imagefill($canvas, 0, 0, $color_const);
135 imagecopy($canvas, $icon_img, 0, 0, 0, 0, 200, 200);
137 return PhabricatorImageTransformer
::saveImageDataInAnyFormat(
142 private static function getIconQuips() {
144 'fa-android' => pht('Friendly Robot'),
145 'fa-apple' => pht('Friendly Fruit'),
146 'fa-beer' => pht('Liquid Carbs'),
147 'fa-bomb' => pht('Boom!'),
148 'fa-book' => pht('Read Me'),
149 'fa-briefcase' => pht('Briefcase'),
150 'fa-bug' => pht('Bug'),
151 'fa-building' => pht('Company'),
152 'fa-calendar' => pht('Deadline'),
153 'fa-camera-retro' => pht('Leica Enthusiast'),
154 'fa-chrome' => pht('Shiny'),
155 'fa-cloud' => pht('The Cloud'),
156 'fa-coffee' => pht('Go Juice'),
157 'fa-comments' => pht('Cartoon Captions'),
158 'fa-credit-card' => pht('Accounting'),
159 'fa-database' => pht('Stack of Pancakes'),
160 'fa-desktop' => pht('Cardboard Box'),
161 'fa-diamond' => pht('Isometric-Hexoctahedral'),
162 'fa-empire' => pht('Bad Guys'),
163 'fa-envelope' => pht('Communication'),
164 'fa-facebook' => pht('College Site'),
165 'fa-fax' => pht('Communication Device'),
166 'fa-film' => pht('Physical Film'),
167 'fa-firefox' => pht('Blake Ross'),
168 'fa-flag-checkered' => pht('Goal'),
169 'fa-flask' => pht('Experimental'),
170 'fa-folder' => pht('Folder'),
171 'fa-gamepad' => pht('Half-Life 3 Confirmed'),
172 'fa-gears' => pht('Mechanical'),
173 'fa-google' => pht('Car Company'),
174 'fa-hand-peace-o' => pht('Peace'),
175 'fa-hashtag' => pht('Not Slack'),
176 'fa-heart' => pht('Myocardial Infarction'),
177 'fa-internet-explorer' => pht('Now Just Edge'),
178 'fa-key' => pht('Primitive Security'),
179 'fa-legal' => pht('Hired Protection'),
180 'fa-linux' => pht('M\'Lady'),
181 'fa-lock' => pht('Policy'),
182 'fa-map-marker' => pht('Destination Beacon'),
183 'fa-microphone' => pht('Podcasting'),
184 'fa-mobile' => pht('Tiny Pocket Cat Meme Machine'),
185 'fa-money' => pht('1 of 99 Problems'),
186 'fa-phone' => pht('Grandma Uses This'),
187 'fa-pie-chart' => pht('Not Actually Edible'),
188 'fa-rebel' => pht('Good Guys'),
189 'fa-reddit-alien' => pht('Updoot In 5 Seconds'),
190 'fa-safari' => pht('Fruit Exploration'),
191 'fa-search' => pht('Dust Detector'),
192 'fa-server' => pht('Heating Units'),
193 'fa-shopping-cart' => pht('Buy Stuff'),
194 'fa-sitemap' => pht('Sitemap'),
195 'fa-star' => pht('The More You Know'),
196 'fa-tablet' => pht('Cellular Telephone For Giants'),
197 'fa-tag' => pht('You\'re It'),
198 'fa-tags' => pht('Tags'),
199 'fa-trash-o' => pht('Garbage'),
200 'fa-truck' => pht('Release'),
201 'fa-twitter' => pht('Bird Stencil'),
202 'fa-umbrella' => pht('An Umbrella'),
203 'fa-university' => pht('School'),
204 'fa-user-secret' => pht('Shhh'),
205 'fa-user' => pht('Individual'),
206 'fa-users' => pht('Team'),
207 'fa-warning' => pht('No Caution Required, Everything Looks Safe'),
208 'fa-wheelchair' => pht('Accessibility'),
209 'fa-windows' => pht('Windows'),
213 private static function getColorQuips() {
215 'red' => pht('Verbillion'),
216 'orange' => pht('Navel Orange'),
217 'yellow' => pht('Prim Goldenrod'),
218 'green' => pht('Lustrous Verdant'),
219 'blue' => pht('Tropical Deep'),
220 'sky' => pht('Wide Open Sky'),
221 'indigo' => pht('Pleated Khaki'),
222 'violet' => pht('Aged Merlot'),
223 'pink' => pht('Easter Bunny'),
224 'charcoal' => pht('Gemstone'),
225 'backdrop' => pht('Driven Snow'),