You are here

function libraries_sort_themes in Libraries API 7.3

Same name and namespace in other branches
  1. 7.2 libraries.module \libraries_sort_themes()

Sort a themes array.

Parameters

array $themes: Array of themes as objects, keyed by theme name.

string $base: A base theme (internal use only).

Return value

array A similar array to $themes, but sorted in such a way that subthemes are always located after its base theme.

1 call to libraries_sort_themes()
libraries_get_enabled_themes in ./libraries.module
Returns all enabled themes.

File

./libraries.module, line 90
External library handling for Drupal modules.

Code

function libraries_sort_themes($themes, $base = '') {
  $output = array();
  foreach ($themes as $name => $theme) {
    if (!isset($theme->base_theme) || $theme->base_theme == $base) {
      $output[$name] = $theme;
      unset($themes[$name]);
      $subthemes = libraries_sort_themes($themes, $name);
      foreach ($subthemes as $sub_name => $subtheme) {
        $output[$sub_name] = $subtheme;
      }
    }
  }
  return $output;
}