You are here

function skinr_skin_data in Skinr 6.2

Themes are allowed to set Skinr skins in their .info files.

@todo Use DB caching. No need to keep processing things every page load.

Return value

An array of skinsets keyed by themename.

4 calls to skinr_skin_data()
skinr_skin_extract in ./skinr.module
skinr_skin_get_files in ./skinr.module
Helper function to fetch all css or js files from an array of skins.
skinr_ui_form_alter in ./skinr_ui.module
Implementation of hook_form_alter().
skinr_ui_form_validate in ./skinr_ui.module
Validation handler.

File

./skinr.module, line 1014

Code

function skinr_skin_data() {
  static $cache = NULL;
  if (is_null($cache)) {
    $skins_skinsets = skinr_skinsets('skinset');
    $themes_skinsets = skinr_skinsets('theme');

    // Need to merge all skins skinsets into a single list of skins.
    // Also merge in the groups information.
    $additional_skins = array();
    $groups = array();
    foreach ($skins_skinsets as $key => $skinset) {
      if (!empty($skinset->skins) && $skinset->status == 1) {
        $additional_skins += $skinset->skins;
      }
      if (!empty($skinset->options['groups'])) {
        $groups += $skinset->options['groups'];
      }
    }

    // Merge the additional skins into each theme, even if that theme has no
    // skinr data.
    $themes = list_themes();
    foreach ($themes as $theme) {
      if ($theme->status != 1) {
        continue;
      }
      if (isset($themes_skinsets[$theme->name])) {
        $cache[$theme->name] = $themes_skinsets[$theme->name];
        $cache[$theme->name]->skins += $additional_skins;
        $cache[$theme->name]->options['groups'] += $groups;
      }
      else {
        $cache[$theme->name] = array(
          'options' => array(
            'groups' => $groups,
          ),
          'skins' => $additional_skins,
        );
      }
    }
  }
  return $cache;
}