You are here

function skinr_get_skin_info in Skinr 7.2

Same name and namespace in other branches
  1. 8.2 skinr.module \skinr_get_skin_info()

Retrieves all skins registered by modules and themes.

Return value

An array of skins.

10 calls to skinr_get_skin_info()
SkinrApiTestCase::testSkinrSkinInfo in tests/skinr.test
Tests hook_skinr_skin_info().
skinr_flatten_skins_array in ./skinr.module
Returns an array of classes.
skinr_preprocess in ./skinr.module
Implements hook_preprocess().
skinr_skin_features_export_options in ./skinr.features.inc
Implements hook_features_export_options().
skinr_ui_admin_library_form in ./skinr_ui.admin.inc
Menu callback: skins administration.

... See full list

File

./skinr.module, line 1469
Handles core Skinr functionality.

Code

function skinr_get_skin_info() {
  $skin_info =& drupal_static(__FUNCTION__);
  if (!isset($skin_info)) {
    if ($cached = cache_get('skinr_skin_info')) {
      $skin_info = $cached->data;
      return $skin_info;
    }
    $skin_info = array();
    foreach (skinr_implements_api() as $name => $extension) {
      $hooks = array();

      // Run through skinr_hook to ensure the required include gets loaded.
      if (skinr_hook($name, 'skinr_skin_info')) {
        $hooks["{$name}_skinr_skin_info"] = $extension;
      }

      // Load the extension's plugins, if any.
      if ($files = skinr_load_plugins($extension)) {

        // The base path for plugins is the directory defined by the extension.
        $dir = $extension['path'] . '/' . $extension['directory'];
        foreach ($files as $plugin => $file) {
          $path = $dir . '/' . basename(dirname($file->uri));
          $hooks["{$name}_skinr_skin_{$plugin}_info"] = array(
            // The source path for a plugin is the plugin directory.
            'path' => $path,
            'include file' => $path . '/' . $file->filename,
          ) + $extension;
        }
      }
      foreach ($hooks as $function => $source) {
        if (function_exists($function)) {
          $extension_info = $function();
          if (isset($extension_info) && is_array($extension_info)) {

            // Prepare the skin information.
            skinr_skin_info_process($extension_info, $source);
            $skin_info += $extension_info;
          }
        }
      }
    }

    // Allow modules to alter registered skin information.
    drupal_alter('skinr_skin_info', $skin_info);
    cache_set('skinr_skin_info', $skin_info);
  }
  return $skin_info;
}