[TASK] Replace icon by the IconFactory actions-document-open-read-only
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Imaging / IconRegistry.php
1 <?php
2 namespace TYPO3\CMS\Core\Imaging;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Exception;
18 use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
19 use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider;
20 use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
21
22 /**
23 * Class IconRegistry, which makes it possible to register custom icons
24 * from within an extension.
25 */
26 class IconRegistry implements \TYPO3\CMS\Core\SingletonInterface {
27
28 /**
29 * Registered icons
30 *
31 * @var array
32 */
33 protected $icons = array(
34 // Default icon, fallback
35 'default-not-found' => array(
36 'provider' => FontawesomeIconProvider::class,
37 'options' => array(
38 'name' => 'times-circle',
39 )
40 ),
41
42 // Action icons
43 'apps-toolbar-menu-cache' => array(
44 'provider' => FontawesomeIconProvider::class,
45 'options' => array(
46 'name' => 'bolt',
47 )
48 ),
49 'actions-document-close' => array(
50 'provider' => FontawesomeIconProvider::class,
51 'options' => array(
52 'name' => 'close',
53 )
54 ),
55 'actions-actions-document-duplicates-select' => array(
56 'provider' => BitmapIconProvider::class,
57 'options' => array(
58 'source' => 'EXT:t3skin/images/icons/actions/document-duplicates-select.png',
59 )
60 ),
61 'actions-document-edit-access' => array(
62 'provider' => FontawesomeIconProvider::class,
63 'options' => array(
64 'name' => 'clock-o',
65 )
66 ),
67 'actions-document-export-t3d' => array(
68 'provider' => FontawesomeIconProvider::class,
69 'options' => array(
70 'name' => 'download',
71 )
72 ),
73 'actions-document-history-open' => array(
74 'provider' => FontawesomeIconProvider::class,
75 'options' => array(
76 'name' => 'history',
77 )
78 ),
79 'actions-document-info' => array(
80 'provider' => FontawesomeIconProvider::class,
81 'options' => array(
82 'name' => 'info-circle',
83 )
84 ),
85 'actions-document-import-t3d' => array(
86 'provider' => FontawesomeIconProvider::class,
87 'options' => array(
88 'name' => 'upload',
89 )
90 ),
91 'actions-document-localize' => array(
92 'provider' => BitmapIconProvider::class,
93 'options' => array(
94 'source' => 'EXT:t3skin/images/icons/actions/document-localize.png',
95 )
96 ),
97 'actions-document-move' => array(
98 'provider' => FontawesomeIconProvider::class,
99 'options' => array(
100 'name' => 'arrows',
101 )
102 ),
103 'actions-document-new' => array(
104 'provider' => FontawesomeIconProvider::class,
105 'options' => array(
106 'name' => 'plus-square',
107 )
108 ),
109 'actions-document-open' => array(
110 'provider' => FontawesomeIconProvider::class,
111 'options' => array(
112 'name' => 'pencil',
113 )
114 ),
115 'actions-document-paste-after' => array(
116 'provider' => FontawesomeIconProvider::class,
117 'options' => array(
118 'name' => 'clipboard',
119 )
120 ),
121 'actions-document-select' => array(
122 'provider' => FontawesomeIconProvider::class,
123 'options' => array(
124 'name' => 'check-square-o',
125 )
126 ),
127 'actions-document-paste-into' => array(
128 'provider' => FontawesomeIconProvider::class,
129 'options' => array(
130 'name' => 'clipboard',
131 )
132 ),
133 'actions-document-save' => array(
134 'provider' => BitmapIconProvider::class,
135 'options' => array(
136 'source' => 'EXT:t3skin/images/icons/actions/document-save.png'
137 )
138 ),
139 'actions-document-save-close' => array(
140 'provider' => BitmapIconProvider::class,
141 'options' => array(
142 'source' => 'EXT:t3skin/images/icons/actions/document-save-close.png'
143 )
144 ),
145 'actions-document-synchronize' => array(
146 'provider' => BitmapIconProvider::class,
147 'options' => array(
148 'source' => 'EXT:t3skin/images/icons/actions/document-synchronize.png'
149 )
150 ),
151 'actions-document-view' => array(
152 'provider' => FontawesomeIconProvider::class,
153 'options' => array(
154 'name' => 'desktop',
155 )
156 ),
157 'actions-edit-copy' => array(
158 'provider' => FontawesomeIconProvider::class,
159 'options' => array(
160 'name' => 'copy',
161 )
162 ),
163 'actions-edit-copy-release' => array(
164 'provider' => FontawesomeIconProvider::class,
165 'options' => array(
166 'name' => 'copy',
167 )
168 ),
169 'actions-edit-cut' => array(
170 'provider' => FontawesomeIconProvider::class,
171 'options' => array(
172 'name' => 'scissors',
173 )
174 ),
175 'actions-edit-cut-release' => array(
176 'provider' => FontawesomeIconProvider::class,
177 'options' => array(
178 'name' => 'scissors',
179 )
180 ),
181 'actions-edit-download' => array(
182 'provider' => FontawesomeIconProvider::class,
183 'options' => array(
184 'name' => 'download',
185 )
186 ),
187 'actions-edit-delete' => array(
188 'provider' => FontawesomeIconProvider::class,
189 'options' => array(
190 'name' => 'trash',
191 )
192 ),
193 'actions-edit-localize-status-low' => array(
194 'provider' => BitmapIconProvider::class,
195 'options' => array(
196 'source' => 'EXT:t3skin/images/icons/actions/edit-localize-status-low.png',
197 )
198 ),
199 'actions-edit-localize-status-high' => array(
200 'provider' => BitmapIconProvider::class,
201 'options' => array(
202 'source' => 'EXT:t3skin/images/icons/actions/edit-localize-status-high.png',
203 )
204 ),
205 'actions-edit-merge-localization' => array(
206 'provider' => BitmapIconProvider::class,
207 'options' => array(
208 'source' => 'EXT:t3skin/images/icons/actions/edit-merge-localization.png',
209 )
210 ),
211 'actions-edit-pick-date' => array(
212 'provider' => FontawesomeIconProvider::class,
213 'options' => array(
214 'name' => 'calendar',
215 )
216 ),
217 'actions-edit-rename' => array(
218 'provider' => FontawesomeIconProvider::class,
219 'options' => array(
220 'name' => 'quote-right',
221 )
222 ),
223 'actions-edit-hide' => array(
224 'provider' => FontawesomeIconProvider::class,
225 'options' => array(
226 'name' => 'toggle-on',
227 )
228 ),
229 'actions-edit-replace' => array(
230 'provider' => FontawesomeIconProvider::class,
231 'options' => array(
232 'name' => 'retweet',
233 )
234 ),
235 'actions-edit-restore' => array(
236 'provider' => BitmapIconProvider::class,
237 'options' => array(
238 'source' => 'EXT:t3skin/images/icons/actions/edit-restore.png',
239 )
240 ),
241 'actions-edit-undo' => array(
242 'provider' => FontawesomeIconProvider::class,
243 'options' => array(
244 'name' => 'undo',
245 )
246 ),
247 'actions-edit-unhide' => array(
248 'provider' => FontawesomeIconProvider::class,
249 'options' => array(
250 'name' => 'toggle-off',
251 )
252 ),
253 'actions-edit-upload' => array(
254 'provider' => FontawesomeIconProvider::class,
255 'options' => array(
256 'name' => 'upload',
257 )
258 ),
259 'actions-insert-record' => array(
260 'provider' => BitmapIconProvider::class,
261 'options' => array(
262 'source' => 'EXT:t3skin/images/icons/actions/insert-record.png',
263 )
264 ),
265 'actions-insert-reference' => array(
266 'provider' => BitmapIconProvider::class,
267 'options' => array(
268 'source' => 'EXT:t3skin/images/icons/actions/insert-reference.png',
269 )
270 ),
271 'actions-markstate' => array(
272 'provider' => FontawesomeIconProvider::class,
273 'options' => array(
274 'name' => 'square-o',
275 )
276 ),
277 'actions-page-open' => array(
278 'provider' => FontawesomeIconProvider::class,
279 'options' => array(
280 'name' => 'pencil-square-o',
281 )
282 ),
283 'actions-system-cache-clear-impact-low' => array(
284 'provider' => SvgIconProvider::class,
285 'options' => array(
286 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-low.svg',
287 )
288 ),
289 'actions-system-cache-clear-impact-medium' => array(
290 'provider' => SvgIconProvider::class,
291 'options' => array(
292 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-medium.svg',
293 )
294 ),
295 'actions-system-cache-clear-impact-high' => array(
296 'provider' => SvgIconProvider::class,
297 'options' => array(
298 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-high.svg',
299 )
300 ),
301 'actions-system-extension-configure' => array(
302 'provider' => FontawesomeIconProvider::class,
303 'options' => array(
304 'name' => 'gear',
305 )
306 ),
307 'actions-system-extension-download' => array(
308 'provider' => FontawesomeIconProvider::class,
309 'options' => array(
310 'name' => 'download',
311 )
312 ),
313 'actions-system-extension-install' => array(
314 'provider' => FontawesomeIconProvider::class,
315 'options' => array(
316 'name' => 'plus-circle',
317 )
318 ),
319 'actions-system-extension-import' => array(
320 'provider' => FontawesomeIconProvider::class,
321 'options' => array(
322 'name' => 'cloud-download',
323 )
324 ),
325 'actions-system-extension-uninstall' => array(
326 'provider' => FontawesomeIconProvider::class,
327 'options' => array(
328 'name' => 'minus-square',
329 )
330 ),
331 'actions-system-extension-sqldump' => array(
332 'provider' => FontawesomeIconProvider::class,
333 'options' => array(
334 'name' => 'database',
335 )
336 ),
337 'actions-system-extension-update' => array(
338 'provider' => FontawesomeIconProvider::class,
339 'options' => array(
340 'name' => 'refresh',
341 )
342 ),
343 'actions-system-list-open' => array(
344 'provider' => FontawesomeIconProvider::class,
345 'options' => array(
346 'name' => 'list-alt',
347 )
348 ),
349 'actions-version-open' => array(
350 'provider' => FontawesomeIconProvider::class,
351 'options' => array(
352 'name' => 'refresh',
353 )
354 ),
355 'actions-system-refresh' => array(
356 'provider' => FontawesomeIconProvider::class,
357 'options' => array(
358 'name' => 'refresh',
359 )
360 ),
361 'actions-version-swap-version' => array(
362 'provider' => FontawesomeIconProvider::class,
363 'options' => array(
364 'name' => 'exchange',
365 )
366 ),
367 'actions-unmarkstate' => array(
368 'provider' => FontawesomeIconProvider::class,
369 'options' => array(
370 'name' => 'check-square-o',
371 )
372 ),
373 'actions-view-go-back' => array(
374 'provider' => FontawesomeIconProvider::class,
375 'options' => array(
376 'name' => 'angle-double-left',
377 )
378 ),
379 'actions-view-go-up' => array(
380 'provider' => FontawesomeIconProvider::class,
381 'options' => array(
382 'name' => 'level-up',
383 )
384 ),
385 'actions-view-paging-first' => array(
386 'provider' => FontawesomeIconProvider::class,
387 'options' => array(
388 'name' => 'step-backward',
389 )
390 ),
391 'actions-view-paging-last' => array(
392 'provider' => FontawesomeIconProvider::class,
393 'options' => array(
394 'name' => 'step-forward',
395 )
396 ),
397 'actions-view-paging-previous' => array(
398 'provider' => FontawesomeIconProvider::class,
399 'options' => array(
400 'name' => 'arrow-left',
401 )
402 ),
403 'actions-view-paging-next' => array(
404 'provider' => FontawesomeIconProvider::class,
405 'options' => array(
406 'name' => 'arrow-right',
407 )
408 ),
409
410 // Status
411 'status-status-current' => array(
412 'provider' => FontawesomeIconProvider::class,
413 'options' => array(
414 'name' => 'caret-right',
415 )
416 ),
417
418 // Overlays
419 'overlay-read-only' => array(
420 'provider' => FontawesomeIconProvider::class,
421 'options' => array(
422 'name' => 'times-circle',
423 )
424 ),
425 );
426
427 /**
428 * @var string
429 */
430 protected $defaultIconIdentifier = 'default-not-found';
431
432 /**
433 * @param string $identifier
434 *
435 * @return bool
436 */
437 public function isRegistered($identifier) {
438 return !empty($this->icons[$identifier]);
439 }
440
441 /**
442 * @return string
443 */
444 public function getDefaultIconIdentifier() {
445 return $this->defaultIconIdentifier;
446 }
447
448 /**
449 * Registers an icon to be available inside the Icon Factory
450 *
451 * @param string $identifier
452 * @param string $iconProviderClassName
453 * @param array $options
454 *
455 * @throws \InvalidArgumentException
456 */
457 public function registerIcon($identifier, $iconProviderClassName, array $options = array()) {
458 if (!in_array(IconProviderInterface::class, class_implements($iconProviderClassName), TRUE)) {
459 throw new \InvalidArgumentException('An IconProvider must implement ' . IconProviderInterface::class, 1437425803);
460 }
461 $this->icons[$identifier] = array(
462 'provider' => $iconProviderClassName,
463 'options' => $options
464 );
465 }
466
467 /**
468 * Fetches the configuration provided by registerIcon()
469 *
470 * @param string $identifier the icon identifier
471 * @return mixed
472 * @throws Exception
473 */
474 public function getIconConfigurationByIdentifier($identifier) {
475 if (!$this->isRegistered($identifier)) {
476 throw new Exception('Icon with identifier "' . $identifier . '" is not registered"', 1437425804);
477 }
478 return $this->icons[$identifier];
479 }
480
481 /**
482 * @return array
483 * @internal
484 */
485 public function getAllRegisteredIconIdentifiers() {
486 return array_keys($this->icons);
487 }
488 }