MDL-69109 core: use different cache keys for FA icon maps
[moodle.git] / lib / classes / output / icon_system_fontawesome.php
CommitLineData
95b06c13
DW
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Contains class \core\output\icon_system
19 *
20 * @package core
21 * @category output
22 * @copyright 2016 Damyon Wiese
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26namespace core\output;
27
e330b1c2
DW
28use renderer_base;
29use pix_icon;
30
b9b409cf
DW
31defined('MOODLE_INTERNAL') || die();
32
95b06c13
DW
33/**
34 * Class allowing different systems for mapping and rendering icons.
35 *
36 * Possible icon styles are:
37 * 1. standard - image tags are generated which point to pix icons stored in a plugin pix folder.
38 * 2. fontawesome - font awesome markup is generated with the name of the icon mapped from the moodle icon name.
39 * 3. inline - inline tags are used for svg and png so no separate page requests are made (at the expense of page size).
40 *
41 * @package core
42 * @category output
43 * @copyright 2016 Damyon Wiese
44 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
45 */
46class icon_system_fontawesome extends icon_system_font {
47
b9b409cf
DW
48 /**
49 * @var array $map Cached map of moodle icon names to font awesome icon names.
50 */
51 private $map = [];
52
95b06c13
DW
53 public function get_core_icon_map() {
54 return [
55 'core:docs' => 'fa-info-circle',
ad056aa2
DW
56 'core:help' => 'fa-question-circle text-info',
57 'core:req' => 'fa-exclamation-circle text-danger',
95b06c13
DW
58 'core:a/add_file' => 'fa-file-o',
59 'core:a/create_folder' => 'fa-folder-o',
60 'core:a/download_all' => 'fa-download',
ad056aa2 61 'core:a/help' => 'fa-question-circle text-info',
95b06c13
DW
62 'core:a/logout' => 'fa-sign-out',
63 'core:a/refresh' => 'fa-refresh',
64 'core:a/search' => 'fa-search',
65 'core:a/setting' => 'fa-cog',
66 'core:a/view_icon_active' => 'fa-th',
67 'core:a/view_list_active' => 'fa-list',
68 'core:a/view_tree_active' => 'fa-folder',
69 'core:b/bookmark-new' => 'fa-bookmark',
70 'core:b/document-edit' => 'fa-pencil',
71 'core:b/document-new' => 'fa-file-o',
72 'core:b/document-properties' => 'fa-info',
73 'core:b/edit-copy' => 'fa-files-o',
74 'core:b/edit-delete' => 'fa-trash',
75 'core:e/abbr' => 'fa-comment',
76 'core:e/absolute' => 'fa-crosshairs',
77 'core:e/accessibility_checker' => 'fa-universal-access',
78 'core:e/acronym' => 'fa-comment',
79 'core:e/advance_hr' => 'fa-arrows-h',
80 'core:e/align_center' => 'fa-align-center',
81 'core:e/align_left' => 'fa-align-left',
82 'core:e/align_right' => 'fa-align-right',
83 'core:e/anchor' => 'fa-chain',
84 'core:e/backward' => 'fa-undo',
85 'core:e/bold' => 'fa-bold',
86 'core:e/bullet_list' => 'fa-list-ul',
5a90a7ca 87 'core:e/cancel' => 'fa-times',
f152b71d 88 'core:e/cancel_solid_circle' => 'fas fa-times-circle',
95b06c13
DW
89 'core:e/cell_props' => 'fa-info',
90 'core:e/cite' => 'fa-quote-right',
91 'core:e/cleanup_messy_code' => 'fa-eraser',
ad056aa2 92 'core:e/clear_formatting' => 'fa-i-cursor',
95b06c13
DW
93 'core:e/copy' => 'fa-clone',
94 'core:e/cut' => 'fa-scissors',
95 'core:e/decrease_indent' => 'fa-outdent',
96 'core:e/delete_col' => 'fa-minus',
97 'core:e/delete_row' => 'fa-minus',
98 'core:e/delete' => 'fa-minus',
99 'core:e/delete_table' => 'fa-minus',
100 'core:e/document_properties' => 'fa-info',
b9b409cf 101 'core:e/emoticons' => 'fa-smile-o',
95b06c13 102 'core:e/find_replace' => 'fa-search-plus',
251ee97c 103 'core:e/file-text' => 'fa-file-text',
95b06c13
DW
104 'core:e/forward' => 'fa-arrow-right',
105 'core:e/fullpage' => 'fa-arrows-alt',
106 'core:e/fullscreen' => 'fa-arrows-alt',
107 'core:e/help' => 'fa-question-circle',
108 'core:e/increase_indent' => 'fa-indent',
109 'core:e/insert_col_after' => 'fa-columns',
110 'core:e/insert_col_before' => 'fa-columns',
111 'core:e/insert_date' => 'fa-calendar',
112 'core:e/insert_edit_image' => 'fa-picture-o',
113 'core:e/insert_edit_link' => 'fa-link',
910b62a3 114 'core:e/insert_edit_video' => 'fa-file-video-o',
95b06c13
DW
115 'core:e/insert_file' => 'fa-file',
116 'core:e/insert_horizontal_ruler' => 'fa-arrows-h',
117 'core:e/insert_nonbreaking_space' => 'fa-square-o',
118 'core:e/insert_page_break' => 'fa-level-down',
119 'core:e/insert_row_after' => 'fa-plus',
120 'core:e/insert_row_before' => 'fa-plus',
121 'core:e/insert' => 'fa-plus',
122 'core:e/insert_time' => 'fa-clock-o',
123 'core:e/italic' => 'fa-italic',
124 'core:e/justify' => 'fa-align-justify',
125 'core:e/layers_over' => 'fa-level-up',
126 'core:e/layers' => 'fa-window-restore',
127 'core:e/layers_under' => 'fa-level-down',
128 'core:e/left_to_right' => 'fa-chevron-right',
129 'core:e/manage_files' => 'fa-files-o',
130 'core:e/math' => 'fa-calculator',
131 'core:e/merge_cells' => 'fa-compress',
132 'core:e/new_document' => 'fa-file-o',
133 'core:e/numbered_list' => 'fa-list-ol',
134 'core:e/page_break' => 'fa-level-down',
135 'core:e/paste' => 'fa-clipboard',
136 'core:e/paste_text' => 'fa-clipboard',
137 'core:e/paste_word' => 'fa-clipboard',
138 'core:e/prevent_autolink' => 'fa-exclamation',
139 'core:e/preview' => 'fa-search-plus',
140 'core:e/print' => 'fa-print',
141 'core:e/question' => 'fa-question',
142 'core:e/redo' => 'fa-repeat',
ad056aa2 143 'core:e/remove_link' => 'fa-chain-broken',
95b06c13
DW
144 'core:e/remove_page_break' => 'fa-remove',
145 'core:e/resize' => 'fa-expand',
146 'core:e/restore_draft' => 'fa-undo',
147 'core:e/restore_last_draft' => 'fa-undo',
148 'core:e/right_to_left' => 'fa-chevron-left',
149 'core:e/row_props' => 'fa-info',
150 'core:e/save' => 'fa-floppy-o',
151 'core:e/screenreader_helper' => 'fa-braille',
152 'core:e/search' => 'fa-search',
153 'core:e/select_all' => 'fa-arrows-h',
ad056aa2 154 'core:e/show_invisible_characters' => 'fa-eye-slash',
95b06c13 155 'core:e/source_code' => 'fa-code',
ad056aa2 156 'core:e/special_character' => 'fa-pencil-square-o',
95b06c13
DW
157 'core:e/spellcheck' => 'fa-check',
158 'core:e/split_cells' => 'fa-columns',
159 'core:e/strikethrough' => 'fa-strikethrough',
5530d873 160 'core:e/styleparagraph' => 'fa-font',
95b06c13
DW
161 'core:e/subscript' => 'fa-subscript',
162 'core:e/superscript' => 'fa-superscript',
163 'core:e/table_props' => 'fa-table',
164 'core:e/table' => 'fa-table',
165 'core:e/template' => 'fa-sticky-note',
166 'core:e/text_color_picker' => 'fa-paint-brush',
167 'core:e/text_color' => 'fa-paint-brush',
168 'core:e/text_highlight_picker' => 'fa-lightbulb-o',
169 'core:e/text_highlight' => 'fa-lightbulb-o',
170 'core:e/tick' => 'fa-check',
171 'core:e/toggle_blockquote' => 'fa-quote-left',
172 'core:e/underline' => 'fa-underline',
173 'core:e/undo' => 'fa-undo',
174 'core:e/visual_aid' => 'fa-universal-access',
175 'core:e/visual_blocks' => 'fa-audio-description',
95b06c13 176 'theme:fp/add_file' => 'fa-file-o',
85594276
MG
177 'theme:fp/alias' => 'fa-share',
178 'theme:fp/alias_sm' => 'fa-share',
95b06c13 179 'theme:fp/check' => 'fa-check',
3c885071 180 'theme:fp/create_folder' => 'fa-folder-o',
95b06c13
DW
181 'theme:fp/cross' => 'fa-remove',
182 'theme:fp/download_all' => 'fa-download',
183 'theme:fp/help' => 'fa-question-circle',
184 'theme:fp/link' => 'fa-link',
185 'theme:fp/link_sm' => 'fa-link',
186 'theme:fp/logout' => 'fa-sign-out',
187 'theme:fp/path_folder' => 'fa-folder',
188 'theme:fp/path_folder_rtl' => 'fa-folder',
189 'theme:fp/refresh' => 'fa-refresh',
190 'theme:fp/search' => 'fa-search',
191 'theme:fp/setting' => 'fa-cog',
192 'theme:fp/view_icon_active' => 'fa-th',
193 'theme:fp/view_list_active' => 'fa-list',
194 'theme:fp/view_tree_active' => 'fa-folder',
45ae297f 195 'core:i/addblock' => 'fa-plus-square',
95b06c13
DW
196 'core:i/assignroles' => 'fa-user-plus',
197 'core:i/backup' => 'fa-file-zip-o',
198 'core:i/badge' => 'fa-shield',
4c98e56c 199 'core:i/breadcrumbdivider' => 'fa-angle-right',
d21ae8c2 200 'core:i/bullhorn' => 'fa-bullhorn',
95b06c13
DW
201 'core:i/calc' => 'fa-calculator',
202 'core:i/calendar' => 'fa-calendar',
4febb36e
RW
203 'core:i/calendareventdescription' => 'fa-align-left',
204 'core:i/calendareventtime' => 'fa-clock-o',
ad056aa2 205 'core:i/caution' => 'fa-exclamation text-warning',
95b06c13 206 'core:i/checked' => 'fa-check',
302586a5 207 'core:i/checkedcircle' => 'fa-check-circle',
95b06c13
DW
208 'core:i/checkpermissions' => 'fa-unlock-alt',
209 'core:i/cohort' => 'fa-users',
210 'core:i/competencies' => 'fa-check-square-o',
b9b409cf 211 'core:i/completion_self' => 'fa-user-o',
33b8ca26 212 'core:i/contentbank' => 'fa-paint-brush',
f3dacc38 213 'core:i/dashboard' => 'fa-tachometer',
95b06c13 214 'core:i/lock' => 'fa-lock',
cbc6794d 215 'core:i/categoryevent' => 'fa-cubes',
64448e1e 216 'core:i/course' => 'fa-graduation-cap',
e75b4e41 217 'core:i/courseevent' => 'fa-graduation-cap',
d1fc4bdc 218 'core:i/customfield' => 'fa-hand-o-right',
95b06c13
DW
219 'core:i/db' => 'fa-database',
220 'core:i/delete' => 'fa-trash',
221 'core:i/down' => 'fa-arrow-down',
222 'core:i/dragdrop' => 'fa-arrows',
ad056aa2 223 'core:i/duration' => 'fa-clock-o',
db65ba45
RW
224 'core:i/emojicategoryactivities' => 'fa-futbol-o',
225 'core:i/emojicategoryanimalsnature' => 'fa-leaf',
226 'core:i/emojicategoryflags' => 'fa-flag',
227 'core:i/emojicategoryfooddrink' => 'fa-cutlery',
228 'core:i/emojicategoryobjects' => 'fa-lightbulb-o',
229 'core:i/emojicategoryrecent' => 'fa-clock-o',
230 'core:i/emojicategorysmileyspeople' => 'fa-smile-o',
231 'core:i/emojicategorysymbols' => 'fa-heart',
232 'core:i/emojicategorytravelplaces' => 'fa-plane',
95b06c13
DW
233 'core:i/edit' => 'fa-pencil',
234 'core:i/email' => 'fa-envelope',
45ae297f 235 'core:i/empty' => 'fa-fw',
b9b409cf 236 'core:i/enrolmentsuspended' => 'fa-pause',
95b06c13 237 'core:i/enrolusers' => 'fa-user-plus',
ad056aa2 238 'core:i/expired' => 'fa-exclamation text-warning',
b9b409cf 239 'core:i/export' => 'fa-download',
95b06c13
DW
240 'core:i/files' => 'fa-file',
241 'core:i/filter' => 'fa-filter',
242 'core:i/flagged' => 'fa-flag',
243 'core:i/folder' => 'fa-folder',
ad056aa2
DW
244 'core:i/grade_correct' => 'fa-check text-success',
245 'core:i/grade_incorrect' => 'fa-remove text-danger',
95b06c13 246 'core:i/grade_partiallycorrect' => 'fa-check-square',
0ac1dcd8 247 'core:i/grades' => 'fa-table',
46d51c8c 248 'core:i/grading' => 'fa-magic',
6b55b28e 249 'core:i/gradingnotifications' => 'fa-bell-o',
95b06c13 250 'core:i/groupevent' => 'fa-group',
8857c715 251 'core:i/groupn' => 'fa-user',
95b06c13 252 'core:i/group' => 'fa-users',
8857c715
DW
253 'core:i/groups' => 'fa-user-circle',
254 'core:i/groupv' => 'fa-user-circle-o',
64448e1e 255 'core:i/home' => 'fa-home',
95b06c13 256 'core:i/hide' => 'fa-eye',
b9b409cf 257 'core:i/hierarchylock' => 'fa-lock',
95b06c13 258 'core:i/import' => 'fa-level-up',
386d1091 259 'core:i/incorrect' => 'fa-exclamation',
95b06c13 260 'core:i/info' => 'fa-info',
4413b466 261 'core:i/invalid' => 'fa-times text-danger',
95b06c13
DW
262 'core:i/item' => 'fa-circle',
263 'core:i/loading' => 'fa-circle-o-notch fa-spin',
264 'core:i/loading_small' => 'fa-circle-o-notch fa-spin',
ef4e04ee 265 'core:i/location' => 'fa-map-marker',
95b06c13
DW
266 'core:i/lock' => 'fa-lock',
267 'core:i/log' => 'fa-list-alt',
268 'core:i/mahara_host' => 'fa-id-badge',
269 'core:i/manual_item' => 'fa-square-o',
f7cfa26e
DM
270 'core:i/marked' => 'fa-circle',
271 'core:i/marker' => 'fa-circle-o',
95b06c13
DW
272 'core:i/mean' => 'fa-calculator',
273 'core:i/menu' => 'fa-ellipsis-v',
0cd6e1bf 274 'core:i/menubars' => 'fa-bars',
545e8988
JD
275 'core:i/messagecontentaudio' => 'fa-headphones',
276 'core:i/messagecontentimage' => 'fa-image',
277 'core:i/messagecontentvideo' => 'fa-film',
278 'core:i/messagecontentmultimediageneral' => 'fa-file-video-o',
95b06c13
DW
279 'core:i/mnethost' => 'fa-external-link',
280 'core:i/moodle_host' => 'fa-graduation-cap',
3cfff885 281 'core:i/moremenu' => 'fa-ellipsis-h',
95b06c13 282 'core:i/move_2d' => 'fa-arrows',
bd038cc1 283 'core:i/muted' => 'fa-microphone-slash',
04b1bea1 284 'core:i/navigationitem' => 'fa-fw',
b9b409cf 285 'core:i/ne_red_mark' => 'fa-remove',
eca7e529 286 'core:i/new' => 'fa-bolt',
ad056aa2 287 'core:i/news' => 'fa-newspaper-o',
40a14ef3 288 'core:i/next' => 'fa-chevron-right',
95b06c13
DW
289 'core:i/nosubcat' => 'fa-plus-square-o',
290 'core:i/notifications' => 'fa-bell',
291 'core:i/open' => 'fa-folder-open',
d268c5ba 292 'core:i/otherevent' => 'fa-calendar',
95b06c13
DW
293 'core:i/outcomes' => 'fa-tasks',
294 'core:i/payment' => 'fa-money',
295 'core:i/permissionlock' => 'fa-lock',
296 'core:i/permissions' => 'fa-pencil-square-o',
297 'core:i/persona_sign_in_black' => 'fa-male',
298 'core:i/portfolio' => 'fa-id-badge',
299 'core:i/preview' => 'fa-search-plus',
40a14ef3 300 'core:i/previous' => 'fa-chevron-left',
64448e1e 301 'core:i/privatefiles' => 'fa-file-o',
95b06c13
DW
302 'core:i/progressbar' => 'fa-spinner fa-spin',
303 'core:i/publish' => 'fa-share',
304 'core:i/questions' => 'fa-question',
305 'core:i/reload' => 'fa-refresh',
306 'core:i/report' => 'fa-area-chart',
307 'core:i/repository' => 'fa-hdd-o',
308 'core:i/restore' => 'fa-level-up',
309 'core:i/return' => 'fa-arrow-left',
ad056aa2
DW
310 'core:i/risk_config' => 'fa-exclamation text-muted',
311 'core:i/risk_managetrust' => 'fa-exclamation-triangle text-warning',
312 'core:i/risk_personal' => 'fa-exclamation-circle text-info',
313 'core:i/risk_spam' => 'fa-exclamation text-primary',
314 'core:i/risk_xss' => 'fa-exclamation-triangle text-danger',
95b06c13
DW
315 'core:i/role' => 'fa-user-md',
316 'core:i/rss' => 'fa-rss',
24a6b594 317 'core:i/rsssitelogo' => 'fa-graduation-cap',
95b06c13
DW
318 'core:i/scales' => 'fa-balance-scale',
319 'core:i/scheduled' => 'fa-calendar-check-o',
320 'core:i/search' => 'fa-search',
64448e1e 321 'core:i/section' => 'fa-folder-o',
7b91dcf2 322 'core:i/sendmessage' => 'fa-paper-plane',
57ea73d0 323 'core:i/settings' => 'fa-cog',
95b06c13 324 'core:i/show' => 'fa-eye-slash',
cbc6794d 325 'core:i/siteevent' => 'fa-globe',
3cfff885 326 'core:i/star' => 'fa-star',
6e1a4477 327 'core:i/star-o' => 'fa-star-o',
b9b409cf 328 'core:i/star-rating' => 'fa-star',
95b06c13
DW
329 'core:i/stats' => 'fa-line-chart',
330 'core:i/switch' => 'fa-exchange',
331 'core:i/switchrole' => 'fa-user-secret',
a111ab44 332 'core:i/trash' => 'fa-trash',
95b06c13
DW
333 'core:i/twoway' => 'fa-arrows-h',
334 'core:i/unchecked' => 'fa-square-o',
302586a5 335 'core:i/uncheckedcircle' => 'fa-circle-o',
95b06c13
DW
336 'core:i/unflagged' => 'fa-flag-o',
337 'core:i/unlock' => 'fa-unlock',
338 'core:i/up' => 'fa-arrow-up',
33b8ca26 339 'core:i/upload' => 'fa-upload',
95b06c13
DW
340 'core:i/userevent' => 'fa-user',
341 'core:i/user' => 'fa-user',
342 'core:i/users' => 'fa-users',
4413b466 343 'core:i/valid' => 'fa-check text-success',
ad056aa2 344 'core:i/warning' => 'fa-exclamation text-warning',
a111ab44 345 'core:i/window_close' => 'fa-window-close',
95b06c13
DW
346 'core:i/withsubcat' => 'fa-plus-square',
347 'core:m/USD' => 'fa-usd',
348 'core:t/addcontact' => 'fa-address-card',
349 'core:t/add' => 'fa-plus',
350 'core:t/approve' => 'fa-thumbs-up',
351 'core:t/assignroles' => 'fa-user-circle',
352 'core:t/award' => 'fa-trophy',
353 'core:t/backpack' => 'fa-shopping-bag',
354 'core:t/backup' => 'fa-arrow-circle-down',
ad056aa2 355 'core:t/block' => 'fa-ban',
95b06c13
DW
356 'core:t/block_to_dock_rtl' => 'fa-chevron-right',
357 'core:t/block_to_dock' => 'fa-chevron-left',
76b5fe86 358 'core:t/calc_off' => 'fa-calculator', // TODO: Change to better icon once we have stacked icon support or more icons.
95b06c13
DW
359 'core:t/calc' => 'fa-calculator',
360 'core:t/check' => 'fa-check',
361 'core:t/cohort' => 'fa-users',
f4967f18
LB
362 'core:t/collapsed_empty_rtl' => 'fa-caret-square-o-left',
363 'core:t/collapsed_empty' => 'fa-caret-square-o-right',
364 'core:t/collapsed_rtl' => 'fa-caret-left',
365 'core:t/collapsed' => 'fa-caret-right',
7b91dcf2 366 'core:t/collapsedcaret' => 'fa-caret-right',
95b06c13
DW
367 'core:t/contextmenu' => 'fa-cog',
368 'core:t/copy' => 'fa-copy',
369 'core:t/delete' => 'fa-trash',
370 'core:t/dockclose' => 'fa-window-close',
371 'core:t/dock_to_block_rtl' => 'fa-chevron-right',
372 'core:t/dock_to_block' => 'fa-chevron-left',
373 'core:t/download' => 'fa-download',
374 'core:t/down' => 'fa-arrow-down',
1a9c60e9 375 'core:t/downlong' => 'fa-long-arrow-down',
95b06c13
DW
376 'core:t/dropdown' => 'fa-cog',
377 'core:t/editinline' => 'fa-pencil',
378 'core:t/edit_menu' => 'fa-cog',
379 'core:t/editstring' => 'fa-pencil',
380 'core:t/edit' => 'fa-cog',
ad056aa2
DW
381 'core:t/emailno' => 'fa-ban',
382 'core:t/email' => 'fa-envelope-o',
13cd05ac 383 'core:t/emptystar' => 'fa-star-o',
95b06c13
DW
384 'core:t/enrolusers' => 'fa-user-plus',
385 'core:t/expanded' => 'fa-caret-down',
ad056aa2 386 'core:t/go' => 'fa-play',
cf7ac868 387 'core:t/grades' => 'fa-table',
8857c715
DW
388 'core:t/groupn' => 'fa-user',
389 'core:t/groups' => 'fa-user-circle',
390 'core:t/groupv' => 'fa-user-circle-o',
95b06c13
DW
391 'core:t/hide' => 'fa-eye',
392 'core:t/left' => 'fa-arrow-left',
393 'core:t/less' => 'fa-caret-up',
394 'core:t/locked' => 'fa-lock',
ad056aa2 395 'core:t/lock' => 'fa-unlock',
95b06c13
DW
396 'core:t/locktime' => 'fa-lock',
397 'core:t/markasread' => 'fa-check',
398 'core:t/messages' => 'fa-comments',
399 'core:t/message' => 'fa-comment',
400 'core:t/more' => 'fa-caret-down',
c698b85a 401 'core:t/move' => 'fa-arrows-v',
d0f3b5f0 402 'core:t/online' => 'fa-circle',
95b06c13
DW
403 'core:t/passwordunmask-edit' => 'fa-pencil',
404 'core:t/passwordunmask-reveal' => 'fa-eye',
405 'core:t/portfolioadd' => 'fa-plus',
406 'core:t/preferences' => 'fa-wrench',
407 'core:t/preview' => 'fa-search-plus',
408 'core:t/print' => 'fa-print',
409 'core:t/removecontact' => 'fa-user-times',
f4967f18 410 'core:t/reload' => 'fa-refresh',
95b06c13
DW
411 'core:t/reset' => 'fa-repeat',
412 'core:t/restore' => 'fa-arrow-circle-up',
413 'core:t/right' => 'fa-arrow-right',
a111ab44 414 'core:t/sendmessage' => 'fa-paper-plane',
95b06c13 415 'core:t/show' => 'fa-eye-slash',
eb6a339f 416 'core:t/sort_by' => 'fa-sort-amount-asc',
95b06c13
DW
417 'core:t/sort_asc' => 'fa-sort-asc',
418 'core:t/sort_desc' => 'fa-sort-desc',
419 'core:t/sort' => 'fa-sort',
420 'core:t/stop' => 'fa-stop',
421 'core:t/switch_minus' => 'fa-minus',
422 'core:t/switch_plus' => 'fa-plus',
423 'core:t/switch_whole' => 'fa-square-o',
f31804c0 424 'core:t/tags' => 'fa-tags',
95b06c13
DW
425 'core:t/unblock' => 'fa-commenting',
426 'core:t/unlocked' => 'fa-unlock-alt',
79349862 427 'core:t/unlock' => 'fa-lock',
95b06c13 428 'core:t/up' => 'fa-arrow-up',
1a9c60e9 429 'core:t/uplong' => 'fa-long-arrow-up',
95b06c13
DW
430 'core:t/user' => 'fa-user',
431 'core:t/viewdetails' => 'fa-list',
432 ];
433 }
e330b1c2 434
e330b1c2
DW
435 /**
436 * Overridable function to get a mapping of all icons.
437 * Default is to do no mapping.
438 */
439 public function get_icon_name_map() {
440 if ($this->map === []) {
7e8940b5 441 $cache = \cache::make('core', 'fontawesomeiconmapping');
e330b1c2 442
17ab4fb2
MG
443 // Create different mapping keys for different icon system classes, there may be several different
444 // themes on the same site.
445 $mapkey = 'mapping_'.preg_replace('/[^a-zA-Z0-9_]/', '_', get_class($this));
446 $this->map = $cache->get($mapkey);
7e8940b5
DW
447
448 if (empty($this->map)) {
449 $this->map = $this->get_core_icon_map();
450 $callback = 'get_fontawesome_icon_map';
451
452 if ($pluginsfunction = get_plugins_with_function($callback)) {
453 foreach ($pluginsfunction as $plugintype => $plugins) {
454 foreach ($plugins as $pluginfunction) {
455 $pluginmap = $pluginfunction();
456 $this->map += $pluginmap;
457 }
e330b1c2
DW
458 }
459 }
17ab4fb2 460 $cache->set($mapkey, $this->map);
e330b1c2
DW
461 }
462
463 }
464 return $this->map;
465 }
466
467
468 public function get_amd_name() {
469 return 'core/icon_system_fontawesome';
470 }
471
472 public function render_pix_icon(renderer_base $output, pix_icon $icon) {
473 $subtype = 'pix_icon_fontawesome';
474 $subpix = new $subtype($icon);
8626dc99 475
e330b1c2
DW
476 $data = $subpix->export_for_template($output);
477
8626dc99
DW
478 if (!$subpix->is_mapped()) {
479 $data['unmappedIcon'] = $icon->export_for_template($output);
480 }
ef96eb02
DW
481 if (isset($icon->attributes['aria-hidden'])) {
482 $data['aria-hidden'] = $icon->attributes['aria-hidden'];
483 }
e330b1c2
DW
484 return $output->render_from_template('core/pix_icon_fontawesome', $data);
485 }
486
95b06c13
DW
487}
488