You are here

function skinr_get_group_info in Skinr 7.2

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

Retrieves all skin groups registered by modules and themes.

Return value

An array of groups.

4 calls to skinr_get_group_info()
SkinrApiTestCase::testSkinrGroupInfo in tests/skinr.test
Tests hook_skinr_group_info().
skinr_ui_admin_library_form in ./skinr_ui.admin.inc
Menu callback: skins administration.
skinr_ui_form in ./skinr_ui.edit.inc
Form builder for the skins configuration form.
skinr_ui_form_validate in ./skinr_ui.edit.inc
Form validation handler for skinr_ui_form_alter().

File

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

Code

function skinr_get_group_info() {
  $group_info =& drupal_static(__FUNCTION__);
  if (!isset($group_info)) {
    if ($cached = cache_get('skinr_group_info')) {
      $group_info = $cached->data;
      return $group_info;
    }
    $group_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_group_info')) {
        $hooks["{$name}_skinr_group_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_group_{$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 group information.
            foreach ($extension_info as &$group) {
              $group += array(
                'title' => '',
                'description' => '',
                'weight' => 0,
              );
            }
            $group_info += $extension_info;
          }
        }
      }
    }

    // Allow modules to alter groups through hook_skinr_group_info_alter().
    drupal_alter('skinr_group_info', $group_info);
    cache_set('skinr_group_info', $group_info);
  }
  return $group_info;
}