Elgg  Version 2.3
icon.php
Go to the documentation of this file.
1 <?php
12 // these 'old' Elgg 1.x sprite icons will be converted to the FontAwesome version
14  "arrow-two-head" => "arrows-h",
15  "attention" => "exclamation-triangle",
16  "cell-phone" => "mobile",
17  "checkmark" => "check",
18  "clip" => "paperclip",
19  "cursor-drag-arrow" => "arrows",
20  "drag-arrow" => "arrows", // 'old' admin sprite
21  "delete-alt" => "times-circle",
22  "delete" => "times",
23  "facebook" => "facebook-square",
24  "grid" => "th",
25  "hover-menu" => "caret-down",
26  "info" => "info-circle",
27  "lock-closed" => "lock",
28  "lock-open" => "unlock",
29  "mail" => "envelope-o",
30  "mail-alt" => "envelope",
31  "print-alt" => "print elgg-icon-hover",
32  "push-pin" => "thumb-tack",
33  "push-pin-alt" => "thumb-tack elgg-icon-hover",
34  "redo" => "share",
35  "round-arrow-left" => "arrow-circle-left",
36  "round-arrow-right" => "arrow-circle-right",
37  "round-checkmark" => "check-circle",
38  "round-minus" => "minus-circle",
39  "round-plus" => "plus-circle",
40  "rss" => "rss-square",
41  "search-focus" => "search elgg-icon-hover",
42  "settings" => "wrench",
43  "settings-alt" => "cog",
44  "share" => "share-alt-square",
45  "shop-cart" => "shopping-cart",
46  "speech-bubble" => "comment",
47  "speech-bubble-alt" => "comments",
48  "star-alt" => "star elgg-icon-hover",
49  "star-empty" => "star-o",
50  "thumbs-down-alt" => "thumbs-down elgg-icon-hover",
51  "thumbs-up-alt" => "thumbs-up elgg-icon-hover",
52  "trash" => "trash-o",
53  "twitter" => "twitter-square",
54  "undo" => "reply",
55  "video" => "film"
56 );
57 
58 $convert = (bool) elgg_extract('convert', $vars, true);
59 unset($vars['convert']);
60 
61 $class = elgg_extract_class($vars, ["elgg-icon", "fa"]);
62 
63 foreach ($class as $index => $c) {
64  if (preg_match_all('/^elgg-icon-(.+)-hover$/i', $c)) {
65  // add hover class
66  $class[] = 'elgg-icon-hover';
67  $c = preg_replace('/(.+)-hover$/i', '$1', $c);
68  }
69 
70  if (preg_match_all('/^elgg-icon-(.+)/i', $c)) {
71  // convert
72  $base_icon = preg_replace('/^elgg-icon-(.+)/i', '$1', $c);
73  if ($convert) {
74  $base_icon = elgg_extract($base_icon, $translated_icons, $base_icon);
75  }
76  $class[] = "fa-{$base_icon}";
77  }
78 }
79 
80 $vars["class"] = array_unique($class);
81 
82 echo elgg_format_element('span', $vars, '');
foreach($class as $index=> $c) $vars["class"]
Definition: icon.php:80
$class
Definition: icon.php:61
elgg_extract_class(array $array, $existing=[])
Extract class names from an array with key "class", optionally merging into a preexisting set...
Definition: elgglib.php:1396
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
$convert
Definition: icon.php:58
elgg echo
Translates a string.
Definition: languages.js:48
$translated_icons
Definition: icon.php:13
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
$index
Definition: gallery.php:49