You are here

function icon_find_theme_include in Icon API 8

Same name and namespace in other branches
  1. 7 includes/utilities.inc \icon_find_theme_include()

Find a specific theme icon include file.

Parameters

string $theme: The name of the theme to find an include file for.

Return value

string|false The include path or FALSE if not found.

2 calls to icon_find_theme_include()
icon_extension_hook in includes/utilities.inc
Determines whether an extension implements a hook.
icon_extension_implements in includes/utilities.inc
Determines which extensions are implementing a hook.
1 string reference to 'icon_find_theme_include'
icon_reset_static_cache in includes/cache.inc
Clears all static caches used by the icon module.

File

includes/utilities.inc, line 359
utilities.inc Provides useful functions and common tasks.

Code

function icon_find_theme_include($theme) {
  static $includes;
  $themes =& drupal_static(__FUNCTION__, array());
  if (!isset($themes[$theme])) {
    $themes[$theme] = FALSE;
    if (!isset($includes)) {
      $includes = array();
      $listing = new ExtensionDiscovery(\Drupal::root());
      $available_themes = $listing
        ->scan('themes');
      foreach ($listing
        ->scan('themes') as $theme) {
        if (file_exists($filepath = $theme
          ->getPath() . '/icons.inc')) {
          $includes[$theme
            ->getName()] = $filepath;
        }
        else {
          if (file_exists($filepath = $theme
            ->getPath() . '/icon.inc')) {
            $includes[$theme
              ->getName()] = $filepath;
          }
        }
      }

      //$includes = array_keys(drupal_system_listing('/icon.inc|icons.inc$/', 'themes', 'uri', 0));
    }
    foreach ($includes as $uri) {
      $theme_path = drupal_get_path('theme', $theme);
      if (!empty($theme_path) && strpos($uri, $theme_path) !== FALSE) {
        $themes[$theme] = $uri;
        break;
      }
    }
  }
  return $themes[$theme];
}