Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
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 = (array) elgg_extract("class", $vars);
62 $class[] = "elgg-icon";
63 $class[] = "fa";
64 
65 foreach ($class as $index => $c) {
66  if (preg_match_all('/^elgg-icon-(.+)-hover$/i', $c)) {
67  // add hover class
68  $class[] = 'elgg-icon-hover';
69  $c = preg_replace('/(.+)-hover$/i', '$1', $c);
70  }
71 
72  if (preg_match_all('/^elgg-icon-(.+)/i', $c)) {
73  // convert
74  $base_icon = preg_replace('/^elgg-icon-(.+)/i', '$1', $c);
75  if ($convert) {
76  $base_icon = elgg_extract($base_icon, $translated_icons, $base_icon);
77  }
78  $class[] = "fa-{$base_icon}";
79  }
80 }
81 
82 $vars["class"] = array_unique($class);
83 
84 echo elgg_format_element('span', $vars, '');
$translated_icons
Definition: icon.php:13
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:218
foreach($class as $index=> $c) $vars["class"]
Definition: icon.php:82
$class
Definition: icon.php:61
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:1310
$convert
Definition: icon.php:58