function fontawesome_extract_icons in Font Awesome Icons 7.2
Same name and namespace in other branches
- 8 fontawesome.module \fontawesome_extract_icons()
- 7.3 fontawesome.module \fontawesome_extract_icons()
Extracts all icons from the CSS file.
Return value
array
1 call to fontawesome_extract_icons()
- fontawesome_icon_bundles in ./
fontawesome.module - Implements hook_icon_bundles().
File
- ./
fontawesome.module, line 160 - fontawesome.module Drupal integration with Font Awesome, the iconic font for use with Bootstrap.
Code
function fontawesome_extract_icons() {
// If CDN is enabled, get CSS content from the CDN URL
if (variable_get('fontawesome_use_cdn', FALSE)) {
$url = FONTAWESOME_CDN_URL;
// The URL needs to have a schema to work with drupal_http_request
if (strpos($url, '//') === 0) {
$url = 'http:' . $url;
}
$request = drupal_http_request($url);
$content = !empty($request->data) ? $request->data : '';
}
else {
$library = libraries_load(FONTAWESOME_LIBRARY);
$filepath = DRUPAL_ROOT . '/' . $library['library path'] . '/css/font-awesome.css';
$content = file_exists($filepath) ? file_get_contents($filepath) : '';
}
// Parse the CSS content
if (preg_match_all('@\\.fa-([a-zA-Z0-9-]*?):before@m', $content, $matches)) {
$icons = $matches[1];
asort($icons);
return drupal_map_assoc($icons);
}
return array();
}