You are here

function _skinr_skins_data in Skinr 6.2

Helper function to scan and collect skin .info data.

Return value

An associative array of skins information.

1 call to _skinr_skins_data()
skinr_rebuild_skinset_data in ./skinr.module
Rebuild, save, and return data about all currently available skinsets.

File

./skinr.module, line 670

Code

function _skinr_skins_data() {
  static $skins_info = array();
  if (empty($skins_info)) {

    // Find skins.
    $mask = '\\.info$';
    $directory = 'skins';
    $skinsets = drupal_system_listing($mask, $directory);

    // Find skins in theme folders.
    $themes = system_theme_data();
    foreach ($themes as $theme) {
      $dir = dirname($theme->filename) . '/' . $directory;
      $skinsets = array_merge($skinsets, file_scan_directory($dir, $mask, array(
        '.',
        '..',
        'CVS',
      ), 0, TRUE, 'name', 1));
    }

    // Find skins in module folders.
    foreach (skinr_get_module_apis() as $module => $info) {
      if (isset($info['skins']) && $info['skins'] == TRUE) {
        $dir = dirname($info['path'] . '/' . $directory);
        $skinsets = array_merge($skinsets, file_scan_directory($dir, $mask, array(
          '.',
          '..',
          'CVS',
        ), 0, TRUE, 'name', 1));
      }
    }
    $defaults = skinr_skins_default();
    foreach ($skinsets as $key => $skinset) {
      $skinsets[$key]->info = drupal_parse_info_file($skinset->filename) + $defaults;

      // Give the screenshot proper path information.
      if (!empty($skinsets[$key]->info['screenshot'])) {
        $skinsets[$key]->info['screenshot'] = dirname($skinsets[$key]->filename) . '/' . $skinsets[$key]->info['screenshot'];
      }

      // Invoke hook_skinr_info_alter() to give installed modules a chance to
      // modify the data in the .info files if necessary.
      drupal_alter('skinr_info', $skinsets[$key]->info, $skinsets[$key]);
    }
    $skins_info = $skinsets;
  }
  return $skins_info;
}