[TASK] Add SVG Icons for document paste actions
[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 'apps-toolbar-menu-shortcut' => array(
50 'provider' => FontawesomeIconProvider::class,
51 'options' => array(
52 'name' => 'star',
53 )
54 ),
55 'actions-document-close' => array(
56 'provider' => FontawesomeIconProvider::class,
57 'options' => array(
58 'name' => 'close',
59 )
60 ),
61 'actions-actions-document-duplicates-select' => array(
62 'provider' => BitmapIconProvider::class,
63 'options' => array(
64 'source' => 'EXT:t3skin/images/icons/actions/document-duplicates-select.png',
65 )
66 ),
67 'actions-document-edit-access' => array(
68 'provider' => FontawesomeIconProvider::class,
69 'options' => array(
70 'name' => 'clock-o',
71 )
72 ),
73 'actions-document-export-t3d' => array(
74 'provider' => FontawesomeIconProvider::class,
75 'options' => array(
76 'name' => 'download',
77 )
78 ),
79 'actions-document-history-open' => array(
80 'provider' => FontawesomeIconProvider::class,
81 'options' => array(
82 'name' => 'history',
83 )
84 ),
85 'actions-document-info' => array(
86 'provider' => FontawesomeIconProvider::class,
87 'options' => array(
88 'name' => 'info-circle',
89 )
90 ),
91 'actions-document-import-t3d' => array(
92 'provider' => FontawesomeIconProvider::class,
93 'options' => array(
94 'name' => 'upload',
95 )
96 ),
97 'actions-document-localize' => array(
98 'provider' => BitmapIconProvider::class,
99 'options' => array(
100 'source' => 'EXT:t3skin/images/icons/actions/document-localize.png',
101 )
102 ),
103 'actions-document-move' => array(
104 'provider' => FontawesomeIconProvider::class,
105 'options' => array(
106 'name' => 'arrows',
107 )
108 ),
109 'actions-document-new' => array(
110 'provider' => FontawesomeIconProvider::class,
111 'options' => array(
112 'name' => 'plus-square',
113 )
114 ),
115 'actions-document-open' => array(
116 'provider' => FontawesomeIconProvider::class,
117 'options' => array(
118 'name' => 'pencil',
119 )
120 ),
121 'actions-document-paste' => array(
122 'provider' => SvgIconProvider::class,
123 'options' => array(
124 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-paste.svg',
125 )
126 ),
127 'actions-document-paste-after' => array(
128 'provider' => SvgIconProvider::class,
129 'options' => array(
130 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-paste-after.svg',
131 )
132 ),
133 'actions-document-paste-before' => array(
134 'provider' => SvgIconProvider::class,
135 'options' => array(
136 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-paste-before.svg',
137 )
138 ),
139 'actions-document-paste-into' => array(
140 'provider' => SvgIconProvider::class,
141 'options' => array(
142 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-paste-into.svg',
143 )
144 ),
145 'actions-document-select' => array(
146 'provider' => FontawesomeIconProvider::class,
147 'options' => array(
148 'name' => 'check-square-o',
149 )
150 ),
151 'actions-document-save' => array(
152 'provider' => SvgIconProvider::class,
153 'options' => array(
154 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-save.svg',
155 )
156 ),
157 'actions-document-save-cleartranslationcache' => array(
158 'provider' => SvgIconProvider::class,
159 'options' => array(
160 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-save-cleartranslationcache.svg',
161 )
162 ),
163 'actions-document-save-close' => array(
164 'provider' => SvgIconProvider::class,
165 'options' => array(
166 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-save-close.svg',
167 )
168 ),
169 'actions-document-save-new' => array(
170 'provider' => SvgIconProvider::class,
171 'options' => array(
172 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-save-new.svg',
173 )
174 ),
175 'actions-document-save-translation' => array(
176 'provider' => SvgIconProvider::class,
177 'options' => array(
178 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-save-translation.svg',
179 )
180 ),
181 'actions-document-save-view' => array(
182 'provider' => SvgIconProvider::class,
183 'options' => array(
184 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-document-save-view.svg',
185 )
186 ),
187 'actions-document-synchronize' => array(
188 'provider' => BitmapIconProvider::class,
189 'options' => array(
190 'source' => 'EXT:t3skin/images/icons/actions/document-synchronize.png'
191 )
192 ),
193 'actions-document-view' => array(
194 'provider' => FontawesomeIconProvider::class,
195 'options' => array(
196 'name' => 'desktop',
197 )
198 ),
199 'actions-edit-copy' => array(
200 'provider' => FontawesomeIconProvider::class,
201 'options' => array(
202 'name' => 'copy',
203 )
204 ),
205 'actions-edit-copy-release' => array(
206 'provider' => FontawesomeIconProvider::class,
207 'options' => array(
208 'name' => 'copy',
209 )
210 ),
211 'actions-edit-cut' => array(
212 'provider' => FontawesomeIconProvider::class,
213 'options' => array(
214 'name' => 'scissors',
215 )
216 ),
217 'actions-edit-cut-release' => array(
218 'provider' => FontawesomeIconProvider::class,
219 'options' => array(
220 'name' => 'scissors',
221 )
222 ),
223 'actions-edit-download' => array(
224 'provider' => FontawesomeIconProvider::class,
225 'options' => array(
226 'name' => 'download',
227 )
228 ),
229 'actions-edit-delete' => array(
230 'provider' => FontawesomeIconProvider::class,
231 'options' => array(
232 'name' => 'trash',
233 )
234 ),
235 'actions-edit-localize-status-low' => array(
236 'provider' => BitmapIconProvider::class,
237 'options' => array(
238 'source' => 'EXT:t3skin/images/icons/actions/edit-localize-status-low.png',
239 )
240 ),
241 'actions-edit-localize-status-high' => array(
242 'provider' => BitmapIconProvider::class,
243 'options' => array(
244 'source' => 'EXT:t3skin/images/icons/actions/edit-localize-status-high.png',
245 )
246 ),
247 'actions-edit-merge-localization' => array(
248 'provider' => BitmapIconProvider::class,
249 'options' => array(
250 'source' => 'EXT:t3skin/images/icons/actions/edit-merge-localization.png',
251 )
252 ),
253 'actions-edit-pick-date' => array(
254 'provider' => FontawesomeIconProvider::class,
255 'options' => array(
256 'name' => 'calendar',
257 )
258 ),
259 'actions-edit-rename' => array(
260 'provider' => FontawesomeIconProvider::class,
261 'options' => array(
262 'name' => 'quote-right',
263 )
264 ),
265 'actions-edit-hide' => array(
266 'provider' => FontawesomeIconProvider::class,
267 'options' => array(
268 'name' => 'toggle-on',
269 )
270 ),
271 'actions-edit-replace' => array(
272 'provider' => FontawesomeIconProvider::class,
273 'options' => array(
274 'name' => 'retweet',
275 )
276 ),
277 'actions-edit-restore' => array(
278 'provider' => BitmapIconProvider::class,
279 'options' => array(
280 'source' => 'EXT:t3skin/images/icons/actions/edit-restore.png',
281 )
282 ),
283 'actions-edit-undo' => array(
284 'provider' => FontawesomeIconProvider::class,
285 'options' => array(
286 'name' => 'undo',
287 )
288 ),
289 'actions-edit-unhide' => array(
290 'provider' => FontawesomeIconProvider::class,
291 'options' => array(
292 'name' => 'toggle-off',
293 )
294 ),
295 'actions-edit-upload' => array(
296 'provider' => FontawesomeIconProvider::class,
297 'options' => array(
298 'name' => 'upload',
299 )
300 ),
301 'actions-insert-record' => array(
302 'provider' => BitmapIconProvider::class,
303 'options' => array(
304 'source' => 'EXT:t3skin/images/icons/actions/insert-record.png',
305 )
306 ),
307 'actions-insert-reference' => array(
308 'provider' => BitmapIconProvider::class,
309 'options' => array(
310 'source' => 'EXT:t3skin/images/icons/actions/insert-reference.png',
311 )
312 ),
313 'actions-markstate' => array(
314 'provider' => FontawesomeIconProvider::class,
315 'options' => array(
316 'name' => 'square-o',
317 )
318 ),
319 'actions-page-open' => array(
320 'provider' => SvgIconProvider::class,
321 'options' => array(
322 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-page-open.svg',
323 )
324 ),
325 'actions-system-cache-clear-impact-low' => array(
326 'provider' => SvgIconProvider::class,
327 'options' => array(
328 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-low.svg',
329 )
330 ),
331 'actions-system-cache-clear-impact-medium' => array(
332 'provider' => SvgIconProvider::class,
333 'options' => array(
334 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-medium.svg',
335 )
336 ),
337 'actions-system-cache-clear-impact-high' => array(
338 'provider' => SvgIconProvider::class,
339 'options' => array(
340 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-cache-clear-impact-high.svg',
341 )
342 ),
343 'actions-system-help-open' => array(
344 'provider' => SvgIconProvider::class,
345 'options' => array(
346 'source' => 'EXT:backend/Resources/Public/Icons/Action/actions-system-help-open.svg',
347 )
348 ),
349 'actions-system-extension-configure' => array(
350 'provider' => FontawesomeIconProvider::class,
351 'options' => array(
352 'name' => 'gear',
353 )
354 ),
355 'actions-system-extension-download' => array(
356 'provider' => FontawesomeIconProvider::class,
357 'options' => array(
358 'name' => 'download',
359 )
360 ),
361 'actions-system-extension-install' => array(
362 'provider' => FontawesomeIconProvider::class,
363 'options' => array(
364 'name' => 'plus-circle',
365 )
366 ),
367 'actions-system-extension-import' => array(
368 'provider' => FontawesomeIconProvider::class,
369 'options' => array(
370 'name' => 'cloud-download',
371 )
372 ),
373 'actions-system-extension-uninstall' => array(
374 'provider' => FontawesomeIconProvider::class,
375 'options' => array(
376 'name' => 'minus-square',
377 )
378 ),
379 'actions-system-extension-sqldump' => array(
380 'provider' => FontawesomeIconProvider::class,
381 'options' => array(
382 'name' => 'database',
383 )
384 ),
385 'actions-system-extension-update' => array(
386 'provider' => FontawesomeIconProvider::class,
387 'options' => array(
388 'name' => 'refresh',
389 )
390 ),
391 'actions-system-list-open' => array(
392 'provider' => FontawesomeIconProvider::class,
393 'options' => array(
394 'name' => 'list-alt',
395 )
396 ),
397 'actions-version-open' => array(
398 'provider' => FontawesomeIconProvider::class,
399 'options' => array(
400 'name' => 'refresh',
401 )
402 ),
403 'actions-system-refresh' => array(
404 'provider' => FontawesomeIconProvider::class,
405 'options' => array(
406 'name' => 'refresh',
407 )
408 ),
409 'actions-version-swap-version' => array(
410 'provider' => FontawesomeIconProvider::class,
411 'options' => array(
412 'name' => 'exchange',
413 )
414 ),
415 'actions-unmarkstate' => array(
416 'provider' => FontawesomeIconProvider::class,
417 'options' => array(
418 'name' => 'check-square-o',
419 )
420 ),
421 'actions-view-go-back' => array(
422 'provider' => FontawesomeIconProvider::class,
423 'options' => array(
424 'name' => 'angle-double-left',
425 )
426 ),
427 'actions-view-go-up' => array(
428 'provider' => FontawesomeIconProvider::class,
429 'options' => array(
430 'name' => 'level-up',
431 )
432 ),
433 'actions-view-paging-first' => array(
434 'provider' => FontawesomeIconProvider::class,
435 'options' => array(
436 'name' => 'step-backward',
437 )
438 ),
439 'actions-view-paging-last' => array(
440 'provider' => FontawesomeIconProvider::class,
441 'options' => array(
442 'name' => 'step-forward',
443 )
444 ),
445 'actions-view-paging-previous' => array(
446 'provider' => FontawesomeIconProvider::class,
447 'options' => array(
448 'name' => 'arrow-left',
449 )
450 ),
451 'actions-view-paging-next' => array(
452 'provider' => FontawesomeIconProvider::class,
453 'options' => array(
454 'name' => 'arrow-right',
455 )
456 ),
457
458 'mimetypes-word' => array(
459 'provider' => FontawesomeIconProvider::class,
460 'options' => array(
461 'name' => 'file-word-o',
462 )
463 ),
464
465 // Status
466 'status-status-current' => array(
467 'provider' => FontawesomeIconProvider::class,
468 'options' => array(
469 'name' => 'caret-right',
470 )
471 ),
472
473 // Mimetypes
474 'mimetypes-text-html' => array(
475 'provider' => FontawesomeIconProvider::class,
476 'options' => array(
477 'name' => 'file-text-o',
478 )
479 ),
480
481 // Overlays
482 'overlay-read-only' => array(
483 'provider' => FontawesomeIconProvider::class,
484 'options' => array(
485 'name' => 'times-circle',
486 )
487 ),
488 );
489
490 /**
491 * @var string
492 */
493 protected $defaultIconIdentifier = 'default-not-found';
494
495 /**
496 * @param string $identifier
497 *
498 * @return bool
499 */
500 public function isRegistered($identifier) {
501 return !empty($this->icons[$identifier]);
502 }
503
504 /**
505 * @return string
506 */
507 public function getDefaultIconIdentifier() {
508 return $this->defaultIconIdentifier;
509 }
510
511 /**
512 * Registers an icon to be available inside the Icon Factory
513 *
514 * @param string $identifier
515 * @param string $iconProviderClassName
516 * @param array $options
517 *
518 * @throws \InvalidArgumentException
519 */
520 public function registerIcon($identifier, $iconProviderClassName, array $options = array()) {
521 if (!in_array(IconProviderInterface::class, class_implements($iconProviderClassName), TRUE)) {
522 throw new \InvalidArgumentException('An IconProvider must implement ' . IconProviderInterface::class, 1437425803);
523 }
524 $this->icons[$identifier] = array(
525 'provider' => $iconProviderClassName,
526 'options' => $options
527 );
528 }
529
530 /**
531 * Fetches the configuration provided by registerIcon()
532 *
533 * @param string $identifier the icon identifier
534 * @return mixed
535 * @throws Exception
536 */
537 public function getIconConfigurationByIdentifier($identifier) {
538 if (!$this->isRegistered($identifier)) {
539 throw new Exception('Icon with identifier "' . $identifier . '" is not registered"', 1437425804);
540 }
541 return $this->icons[$identifier];
542 }
543
544 /**
545 * @return array
546 * @internal
547 */
548 public function getAllRegisteredIconIdentifiers() {
549 return array_keys($this->icons);
550 }
551 }