You are here

function skinr_skin_info_status_default in Skinr 7.2

Prepare the default status for a skin.

Parameters

$skin_info: Information about a registered skin.

Return value

An array of default statuses for each enabled theme.

1 call to skinr_skin_info_status_default()
skinr_skin_info_process in ./skinr.module
Parse a skin_infos array as returned from a skins plugin.

File

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

Code

function skinr_skin_info_status_default($skin_info) {
  $status = array();

  // Retrieve the explicit default status of the registering theme for itself.
  $base_theme_status = NULL;
  if (isset($skin_info['status'][$skin_info['source']['name']])) {
    $base_theme_status = $skin_info['status'][$skin_info['source']['name']];
  }

  // Retrieve the sub themes of the base theme that registered the skin.
  $sub_themes = array();
  if (isset($skin_info['source']['sub themes'])) {
    $sub_themes = $skin_info['source']['sub themes'];
  }
  $themes = list_themes();
  foreach ($themes as $name => $theme) {
    if (!$theme->status) {
      continue;
    }

    // If this theme is a sub theme of the theme that registered the skin, check
    // whether we need to inherit the status of the base theme to the sub theme.
    // This is the case when a skin of a base theme enables itself for the base
    // theme (not knowing about potential sub themes).
    if (isset($base_theme_status) && isset($sub_themes[$name])) {
      $status[$name] = $base_theme_status;
    }

    // Apply global default.
    $status += array(
      $name => $skin_info['default status'],
    );
  }

  // Lastly, apply all explicit defaults.
  $status = array_merge($status, $skin_info['status']);
  return $status;
}